fix(rstest): alias agent-bundle/meta in the Rstest presets and raise AB4760 outside the compiler (#386) - #416
Conversation
🦋 Changeset detectedLatest commit: 61c7fdb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f12457f23d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
commit: |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15ff07a782
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3d847069f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 349da6458d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…AB4760 outside the compiler (#386) agentBundleRstest() and agentBundleBrowserRstest() write .agent-bundle/test/meta.mjs from the same generatedMetaModuleSource/projectMeta the build injects, fed from the compiler pass's plugin identity, and alias `agent-bundle/meta$` to it, so source importing the identity loads under unit, route-unit, renderRoute, and invokeCli tests without a build. The published dist/meta.js now throws the structured AB4760 diagnostic (code, recovery, diagnostic fields; recovery inline in the message) instead of a bare Error.
…-bundle/meta When preparation produced no plugin model the manifest carries the frozen FALLBACK_PLUGIN_IDENTITY placeholder; the presets now write a self-contained module whose bindings throw AB4760 naming the compiler diagnostics instead of stamping `unknown@0.0.0` as a real identity.
61c7fdb to
746939e
Compare
…en after rebase The script child resolves agent-bundle/meta to testMetaModuleSource: the build's generated identity when the manifest carries a plugin model, the AB4760 module when it carries the model-less sentinel (#416).
…en after rebase The script child resolves agent-bundle/meta to testMetaModuleSource: the build's generated identity when the manifest carries a plugin model, the AB4760 module when it carries the model-less sentinel (#416).
Closes #386.
Summary
agentBundleRstest()andagentBundleBrowserRstest()(agent-bundle/rstest) now write.agent-bundle/test/meta.mjsand aliasagent-bundle/meta$(resolve.alias, exact match) to it. The module is generated by the very samegeneratedMetaModuleSource(projectMeta(...))the build injects (src/build/meta.ts, Infer plugin version from package.json and expose a build-time version constant to plugin code #237), fed from the compiler pass'smanifest.pluginidentity, so a source module importing{ name, version, packageName, packageVersion }loads under plain unit tests, the route-unit level,renderRoute, andinvokeCliwith exactly the identitypackage.json+agent-bundle.config.tsdeclare.projectMetaaccepts a narrowProjectMetaSourceso the build and the presets share one function — no duplicated identity logic.agent-bundle/meta(dist/meta.js) reached outside the compiler now throws the new structuredAB4760diagnostic instead of a bareError:AgentBundleMetaUnavailableError extends CodedErrorwithcode,recovery, and aDiagnostic-shapeddiagnosticfield; the message carries[AB4760] …plus the recovery inline so a barenodeprocess and any test runner print the exact fix. Throwing stays per-binding through the hoisted function (no TDZReferenceError). The importing module is not observable from a module evaluated through ESM linking, so the message names the situation rather than a file.AB4760verified unused in origin/maindocs/diagnostics.mdand in all 16 open PR diffs; documented indocs/diagnostics.md(family row + section with the exact recovery),docs/entry-conventions.md, a newdocs/framework-mode.md"Release identity in source" section, andpackages/agent-bundle/README.md(Testing routes)..changeset/386-meta-rstest-alias.md(patch,agent-bundle).Evidence
packages/agent-bundle/fixtures/meta-consumer(package.jsonmeta-consumer-fixture@3.4.5,plugin.name: 'meta-consumer', noplugin.version):src/lib/identity.tsimportsagent-bundle/meta; a tool route and a CLI route import it transitively. It carries its own preset-built pools (rstest.config.tsfortests/unit/**,rstest.route-unit.config.ts) plusrstest.no-preset.config.tsreproducing the issue.tests/rstest-meta-alias.test.ts(unit pool): the preset config carriesresolve.alias['agent-bundle/meta$'] = <root>/.agent-bundle/test/meta.mjs; the written file is byte-identical togeneratedMetaModuleSource(projectMeta(prepared.model.metadata))fromProjectService.prepare; importing it yieldsname: 'meta-consumer',packageName/packageVersion/versionfrom package.json, frozenmeta=== default;import('../src/meta.ts')rejects withAB4760, the recovery text, and anisDiagnostic-validdiagnostic.tests/rstest-meta-consumer.test.ts(integration pool; spawnsrstest): the fixture's unit pool and route-unit pool (renderRoute('tool:consumer/identity'),invokeCli(['version'])) pass under the preset; the same unit tests without the preset fail with[AB4760] …+ recovery and noReferenceError.tests/mcp.test.ts: the existing dist proof now asserts[AB4760], the recovery line, andcode: 'AB4760'in a barenodestderr.tests/test-browser-rstest.test.ts: browser preset carries the alias and the route-harness identity (route-harness/1.0.0/packageName = undefined).fixtureProjectTestFilesinrstest.integration-tests.ts).Gates run from the worktree (logs under
/tmp/lane-386/):pnpm builddist/meta.jsthrowsMetaUnavailableErrorwithcode: 'AB4760'and the recovery (verified withnode --input-type=module -e "await import('./dist/meta.js')")pnpm typecheckpnpm lintpnpm test:unitmcp-probe-serviceteardown timing (passes in isolation) andnative-claude-contract5 s timeout (fails identically on a cleanorigin/mainstash in this loaded environment, load avg > 60)pnpm test:route-unitlifecycle-replayduring a concurrent build; clean on rerun)pnpm test:projectionrstest-meta-consumer.test.ts4 passed;mcp.test.ts"rejects the built identity module" passedTest plan
pnpm typecheck,pnpm lintpnpm test:unit,pnpm test:route-unit,pnpm test:projectionpnpm build+rstest --config rstest.integration.config.ts packages/agent-bundle/tests/rstest-meta-consumer.test.ts packages/agent-bundle/tests/mcp.test.ts -t "rejects the built identity module"