feat(routes): conventional shared layout module for rendered routes (#312) - #396
Conversation
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. |
🦋 Changeset detectedLatest commit: 0087552 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d61864efa
ℹ️ 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".
7d61864 to
affbd94
Compare
commit: |
…ll container metadata Address Codex review on #396: - generated MCP and rendered-route workers now import only the layouts some route of that worker composes through, so a server-scoped layout for one server can no longer be evaluated (or fail) inside an unrelated CLI, script, or server process - decodeAgentDocument treats an explicit metadata={null} on a layout container as authored metadata that wins over the inner result, matching the non-object-container-wins contract; only undefined adopts the inner metadata
|
@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 |
…ll container metadata Address Codex review on #396: - generated MCP and rendered-route workers now import only the layouts some route of that worker composes through, so a server-scoped layout for one server can no longer be evaluated (or fail) inside an unrelated CLI, script, or server process - decodeAgentDocument treats an explicit metadata={null} on a layout container as authored metadata that wins over the inner result, matching the non-object-container-wins contract; only undefined adopts the inner metadata
43e202c to
a4658c1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4658c1210
ℹ️ 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".
…et per convention Address Codex review on #396 (rebased head a4658c1): - a src/mcp/<server>/layout.* under a server pinned to custom, command, or remote via routes.servers is skipped entirely — not validated (AB4830), not retained, and never AB4832 — matching the documented opt-out and the way that server's route modules are dropped; the AB4832 recovery names the override - the changeset is one imperative, user-facing summary naming the exports and AB4830-AB4832, ends with the PR reference, and uses patch per the pre-1.0 rule (minor is reserved for breaking changes)
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d33030e7b
ℹ️ 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: eb7a916821
ℹ️ 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 |
…ll container metadata Address Codex review on #396: - generated MCP and rendered-route workers now import only the layouts some route of that worker composes through, so a server-scoped layout for one server can no longer be evaluated (or fail) inside an unrelated CLI, script, or server process - decodeAgentDocument treats an explicit metadata={null} on a layout container as authored metadata that wins over the inner result, matching the non-object-container-wins contract; only undefined adopts the inner metadata
…et per convention Address Codex review on #396 (rebased head a4658c1): - a src/mcp/<server>/layout.* under a server pinned to custom, command, or remote via routes.servers is skipped entirely — not validated (AB4830), not retained, and never AB4832 — matching the documented opt-out and the way that server's route modules are dropped; the AB4832 recovery names the override - the changeset is one imperative, user-facing summary naming the exports and AB4830-AB4832, ends with the PR reference, and uses patch per the pre-1.0 rule (minor is reserved for breaking changes)
eb7a916 to
f3b5601
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3b560195f
ℹ️ 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".
…r layouts, version as minor Address Codex review on #396 (heads eb7a916 and f3b5601): - decodeAgentDocument snapshots both metadata operands through the document's JSON wire boundary before merging a layout container with its valued child, so a Date, class instance, accessor, or cyclic value fails closed exactly as it does without a layout instead of being flattened into {} - AB4832 now also fires for a server layout whose server declares only apps/ routes, which never take a layout, so an accepted layout is always composed - the changeset returns to minor for both packages: AgentBundleTestManifest gains a required layouts field and the decoder changes the output of previously valid valueless-root documents, both breaking under the pre-1.0 policy; the summary names both - docs record the deliberate route-first composition trade-off (no Suspense fallback around children) and the sharpened AB4832 scope
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 06de53338c
ℹ️ 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: c7de7465cb
ℹ️ 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8efaed59b8
ℹ️ 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".
8efaed5 to
bb9001a
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb9001a47d
ℹ️ 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: 888a941f1a
ℹ️ 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".
888a941 to
397c29c
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 397c29c543
ℹ️ 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".
397c29c to
cdf4582
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cdf458254e
ℹ️ 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".
…splicing; README states the CLI artifact default
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: daffae1431
ℹ️ 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".
… list them as source inputs
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3bc0e09442
ℹ️ 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".
…luded, with the finished document bytes
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
main (#396) adds src/layout.tsx and src/mcp/<server>/layout.tsx. The conventions table and source tree list both, MCP servers and Apps gains a Shared layouts section covering composition order, container merging, route identity, failure semantics, and AB4830-AB4832, and the reference code-family table names the layout codes.
Summary
Implements #312: a
layout.tsx-style convention for the shell around every rendered route.src/layout.{ts,tsx}default-exports one component receiving{ children, route, signal }(AgentLayoutPropsfrom@agent-bundle/runtime) and wraps every rendered route: generated MCP tools/resources/prompts, renderedsrc/cli/**commands, projected MCP commands, and renderedsrc/scripts/*.tsx.src/mcp/<server>/layout.{ts,tsx}nests inside it for one generated server (root → server → route). Event routes and browser App routes are never wrapped._layout.tsxopts out.CompiledRouteGraph.layouts, only present when declared so pre-layout graph digests are unchanged), validates them statically —AB4830contract (non-function default, route-onlyconfig/inputSchema/resultSchema,execute/render),AB4831duplicate scope,AB4832orphaned server layout — and threads them through the normalized model, project identity, and every worker source input.id,kind,name,serverId). With layouts, one root component awaits the route element and then wraps it, so a throwing route still rejects the Flight root and fails closed exactly as before (no degradation into a represented boundary error under the shell). Without layouts the emitted worker is the same shape as today (composeLayoutsiscreateElement(route.module.default, props)).decodeAgentDocumenttreats anAgent.Resultwithout avalueas a container; a directly nested valued result merges into it (value adopted, children spliced in place, object metadata merged key-by-key with the container winning). A layout shell therefore never changes a route's result value, MCP content/structuredContent, or CLI Markdown. ExportsAgentLayoutProps/AgentLayoutRoute/AgentLayoutRouteKind;agent-bundleroot exports the React-free identity types only (root declarations stay React-free for config-only consumers — pinned bypublic-api.test.ts).agent-bundle/testcomposes the same chain at route-unit (renderRoute), cli-dispatch (invokeCli), and mcp-in-memory (invokeMcpTool) levels via manifestlayouts+ generatedlayoutLoaders(registry version 4). A module passed directly torenderRoute()composes no layout.examples/audiobook-curatoradoptssrc/layout.tsxas the document shell (rootAgent.Result+ route provenance metadata) and drops the per-routeCuratorDocumentwrapper from 21 routes; MCP and CLI output are byte-identical (the Refactor audiobook audit route composition #336 pins pass unchanged).examples/rsc-agent-runtimeis a custom-server/prebuilt-payload example with no generated routes, so the convention does not apply there.docs/entry-conventions.md(table rows + “Shared layouts”),docs/framework-mode.md,docs/diagnostics.md(AB4830–AB4832), README note foroutput.distPath(Configurable artifact output path (output.distPath) landed in #296 #297 verification), changeset (agent-bundleminor,@agent-bundle/runtimeminor).Evidence
packages/agent-bundle/tests/route-graph.test.ts(discovery, digest stability, opt-out, AB4830/AB4831/AB4832),tests/entry-shell.test.ts(chain baking, root/server/none, identity fields, root-await composition),tests/test-harness-manifest.test.ts(manifestlayouts,layoutLoaders),packages/rsc-runtime/tests/dispatcher.test.ts(container merge, nested merge, metadata rules, valued root unchanged).tests/route-unit/render-route.test.ts— root+server layouts aroundtool:harness/echokeep node kinds and value; probe route shows server-layout content + merged metadata; CLI route takes only the root layout; direct module render composes nothing.tests/projection/mcp-in-memory.test.ts(layout-probecontent + structuredContent),tests/projection/cli-dispatch-mcp.test.ts(projected tool keeps its server layout), contract matrix green with the new fixture route.packages/agent-bundle/tests/layout-build.test.ts— one build ships the layouts around the generated MCP server (stdio client), the routed CLI bin (piped Markdown,--json,--ndjsonmetadata + value), a projected MCP command, and a rendered script; a throwing route under a layout fails closed on both MCP and CLI; a layout-free build ships byte-identical surfaces; an invalid layout fails the build withAB4830.examples/audiobook-curatorpnpm typecheck,pnpm test(40),pnpm test:routes(31, incl. new layout-metadata assertions and the unchanged byte-identical CLI pins).Test plan
pnpm typecheck,pnpm lintpnpm test:unit(2 pre-existing environmental failures reproduce on cleanorigin/main:mcp-probe-serviceteardown timing,native-claude-contract5 s timeout)pnpm test:route-unit,pnpm test:projectionpnpm build && pnpm test:integration:run(rerunning after rebase; pre-rebase run: 938 passed, 2 failed —host-install-proofCodexlogofield fixed on main by test(install): expect the Codex interface.logo field in the packed host-install proof #367, andpublic-apiroot-declaration React leak fixed in the second commit)Closes #312.