Skip to content

refactor(build): one shared tools-hatch layering for every synthesized bundler config (xref row 13) - #495

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
feat/xref-single-build-instance
Sep 4, 2026
Merged

refactor(build): one shared tools-hatch layering for every synthesized bundler config (xref row 13)#495
ScriptedAlchemy merged 1 commit into
mainfrom
feat/xref-single-build-instance

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Summary

Cross-reference learning A (TanStack Start / React Router rsbuild-plugin matrix row 13, suggestion 6): run every environment through one composition path.

composeEntryLibConfig (Rslib: scripts, hooks, MCP entries, routed CLI bin, package build) and composeMcpAppsRsbuildConfig (Rsbuild: MCP App views) each applied the profile → tools.rsbuild → tools.rspack → invariants layering separately, and the MCP Apps layering had no unit coverage. This PR extracts the shared order into packages/agent-bundle/src/build/compose-layers.ts (composeToolsLayers, frameworkInvariantLayer) and has both callers lift the same layers into their engine's merge (mergeRslibConfig keyed by lib id / mergeRsbuildConfig).

agent-bundle stays Rspack/Rsbuild/Rslib-only; no new abstraction over other bundlers.

Behavior preservation

  • tests/compose-layers.test.ts pins: a tools.rsbuild fragment reaches the MCP Apps config exactly as it reaches an entry lib; the tools.rspack hatch (fragment + mutator) runs before the framework enforceInvariants mutator on both paths; output.cleanDistPath stays false on both paths; without a hatch only profile + invariants compose.
  • Artifact and package-build trees of examples/audiobook-curator and examples/host-test rebuilt on this branch are byte-identical to origin/main (c6db0ffe1) — modulo the pre-existing, per-build staged-directory token (.artifact.stage-XXXXXX) Rspack writes into a // NAMESPACE OBJECT comment of MCP entries, which already makes the manifest sha256 of those two files differ between two consecutive runs of main (noted for a follow-up; not introduced here).
  • inspect --bundler output is unchanged (cli.test.ts "dumps the synthesized bundler configuration" passes; tools.rspack still renders [hatch, "[function enforceInvariants]"]).
  • Integration suites run locally on this branch: build.test.ts, hooks.test.ts, mcp.test.ts, cli.test.ts (86/86 passing).

Docs

No user-facing behavior change; the existing tools prose (docs/entry-conventions.md, website/docs/{en,zh}/reference/configuration.mdx) already describes the layering generically and stays accurate.

Review status

  • Codex reviewed 2c6a527 (PR opened): completed, no findings, no review threads.
  • Current head 8353a2f differs from 2c6a527 only in the changeset's PR reference ((#492)(#495)); no code changed. Per the maintainer's instruction this PR carries no comments, so the re-review request is recorded here rather than posted.
  • Merge gate: all checks green on 8353a2f.

@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8353a2f

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

… shared layering

Extract compose-layers.ts: the profile -> tools.rsbuild -> tools.rspack -> framework
invariants order that composeEntryLibConfig (Rslib) and composeMcpAppsRsbuildConfig
(Rsbuild) each applied separately. Both now lift the same layers into their engine's
merge. A unit test pins that a hatch reaches the MCP Apps config the same way it
reaches an entry lib and that the invariants win on both paths.

Behavior-preserving: artifact and package-build trees of examples/audiobook-curator
and examples/host-test are byte-identical before and after (modulo the pre-existing
staged-directory token Rspack writes into a NAMESPACE OBJECT comment).
@ScriptedAlchemy
ScriptedAlchemy force-pushed the feat/xref-single-build-instance branch from 2c6a527 to 8353a2f Compare September 4, 2026 00:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 4, 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-04T00:58:31.766770Z 2c6a527 PR opened
ℹ️ 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.

@pkg-pr-new

pkg-pr-new Bot commented Sep 4, 2026

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

commit: 8353a2f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant