Skip to content

fix(rstest): alias agent-bundle/meta in the Rstest presets and raise AB4760 outside the compiler (#386) - #416

Merged
ScriptedAlchemy merged 6 commits into
mainfrom
fix/386-meta-rstest-alias
Sep 3, 2026
Merged

ScriptedAlchemy merged 6 commits into
mainfrom
fix/386-meta-rstest-alias

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 3, 2026 •

Copy link
Copy Markdown
Owner

Closes #386.

Summary

  • agentBundleRstest() and agentBundleBrowserRstest() (agent-bundle/rstest) now write .agent-bundle/test/meta.mjs and alias agent-bundle/meta$ (resolve.alias, exact match) to it. The module is generated by the very same generatedMetaModuleSource(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's manifest.plugin identity, so a source module importing { name, version, packageName, packageVersion } loads under plain unit tests, the route-unit level, renderRoute, and invokeCli with exactly the identity package.json + agent-bundle.config.ts declare. projectMeta accepts a narrow ProjectMetaSource so the build and the presets share one function — no duplicated identity logic.
  • The published agent-bundle/meta (dist/meta.js) reached outside the compiler now throws the new structured AB4760 diagnostic instead of a bare Error: AgentBundleMetaUnavailableError extends CodedError with code, recovery, and a Diagnostic-shaped diagnostic field; the message carries [AB4760] … plus the recovery inline so a bare node process and any test runner print the exact fix. Throwing stays per-binding through the hoisted function (no TDZ ReferenceError). The importing module is not observable from a module evaluated through ESM linking, so the message names the situation rather than a file.
  • AB4760 verified unused in origin/main docs/diagnostics.md and in all 16 open PR diffs; documented in docs/diagnostics.md (family row + section with the exact recovery), docs/entry-conventions.md, a new docs/framework-mode.md "Release identity in source" section, and packages/agent-bundle/README.md (Testing routes).
  • Changeset .changeset/386-meta-rstest-alias.md (patch, agent-bundle).

Evidence

  • New fixture project packages/agent-bundle/fixtures/meta-consumer (package.json meta-consumer-fixture@3.4.5, plugin.name: 'meta-consumer', no plugin.version): src/lib/identity.ts imports agent-bundle/meta; a tool route and a CLI route import it transitively. It carries its own preset-built pools (rstest.config.ts for tests/unit/**, rstest.route-unit.config.ts) plus rstest.no-preset.config.ts reproducing the issue.
  • tests/rstest-meta-alias.test.ts (unit pool): the preset config carries resolve.alias['agent-bundle/meta$'] = <root>/.agent-bundle/test/meta.mjs; the written file is byte-identical to generatedMetaModuleSource(projectMeta(prepared.model.metadata)) from ProjectService.prepare; importing it yields name: 'meta-consumer', packageName/packageVersion/version from package.json, frozen meta === default; import('../src/meta.ts') rejects with AB4760, the recovery text, and an isDiagnostic-valid diagnostic.
  • tests/rstest-meta-consumer.test.ts (integration pool; spawns rstest): 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 no ReferenceError.
  • tests/mcp.test.ts: the existing dist proof now asserts [AB4760], the recovery line, and code: 'AB4760' in a bare node stderr. tests/test-browser-rstest.test.ts: browser preset carries the alias and the route-harness identity (route-harness/1.0.0/packageName = undefined).
  • Fixture pools are excluded from the workspace pools (fixtureProjectTestFiles in rstest.integration-tests.ts).

Gates run from the worktree (logs under /tmp/lane-386/):

gate result
pnpm build pass; dist/meta.js throws MetaUnavailableError with code: 'AB4760' and the recovery (verified with node --input-type=module -e "await import('./dist/meta.js')")
pnpm typecheck pass
pnpm lint pass (0 errors, 0 warnings)
pnpm test:unit 2731 passed; 2 failures unrelated: mcp-probe-service teardown timing (passes in isolation) and native-claude-contract 5 s timeout (fails identically on a clean origin/main stash in this loaded environment, load avg > 60)
pnpm test:route-unit 37 passed (one 5 s timeout flake in lifecycle-replay during a concurrent build; clean on rerun)
pnpm test:projection 66 passed
integration (targeted) rstest-meta-consumer.test.ts 4 passed; mcp.test.ts "rejects the built identity module" passed

Test plan

  • pnpm typecheck, pnpm lint
  • pnpm test:unit, pnpm test:route-unit, pnpm test:projection
  • pnpm 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"
  • CI green

@changeset-bot

changeset-bot Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 61c7fdb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-bundle Patch

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T09:46:05.456732Z 61c7fdb Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread .changeset/386-meta-rstest-alias.md Outdated
@pkg-pr-new

pkg-pr-new Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@416
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@416
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@416

commit: 61c7fdb

@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: c0e028fab3

ℹ️ 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".

@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/agent-bundle/src/rstest/index.ts Outdated
@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/agent-bundle/src/test/manifest.ts Outdated
@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/agent-bundle/src/meta-diagnostic.ts Outdated
@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 61c7fdbbdb

ℹ️ 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".

…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.
@ScriptedAlchemy
ScriptedAlchemy force-pushed the fix/386-meta-rstest-alias branch from 61c7fdb to 746939e Compare September 3, 2026 10:22
@ScriptedAlchemy
ScriptedAlchemy merged commit 926b035 into main Sep 3, 2026
5 checks passed
ScriptedAlchemy added a commit that referenced this pull request Sep 3, 2026
…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).
ScriptedAlchemy added a commit that referenced this pull request Sep 3, 2026
…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).
@ScriptedAlchemy
ScriptedAlchemy deleted the fix/386-meta-rstest-alias branch September 14, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant