Skip to content

feat(runtime): thread transport-observed identity into generated MCP tool scopes (#223) - #276

Merged
ScriptedAlchemy merged 2 commits into
mainfrom
feat/223-tool-scope-axes
Sep 2, 2026
Merged

feat(runtime): thread transport-observed identity into generated MCP tool scopes (#223)#276
ScriptedAlchemy merged 2 commits into
mainfrom
feat/223-tool-scope-axes

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

Delivers the remaining #223 transport slice for the generated MCP server: tool, resource, and prompt request scopes now observe the transport-known identity axes and forward them into the Flight worker, so compiled bundles' handlers read (await agent()).host/.session/.actor/.workspace instead of typed-unavailable axes the transport actually knew. Mirrors the rsc-runtime wiring PR #273 landed:

  • host from the negotiated MCP client identity (server.server.getClientVersion()?.name, source native), resolved per request after the initialize handshake;
  • session from the transport's native sessionId where one exists (unchanged wiring — bare stdio supplies none, so it stays honestly unavailable('not-provided'));
  • actor from http.authInfo.clientId where present (unchanged — stdio has no authInfo, honestly unavailable);
  • workspace derived from the server process cwd (available({ root: process.cwd() }, 'derived')), the established CLI derivation.

No Flight-worker changes: createFlightWorkerHost already probes agent() and forwards all four axes; the generated worker template already re-installs them. The gap was purely the host-scope installation. The in-memory projection level (agent-bundle/test) now mirrors the worker boundary — its in-process stand-in forwards the host-scope axes into the render scope with the documented harness context seam still winning — so mcp-in-memory stays faithful to the artifact.

Observed axes per transport after this change

Transport host session actor workspace
packed stdio (generated artifact) available/native (client name) unavailable/not-provided unavailable/not-provided available/derived (spawn cwd)
generated stdio (integration fixture) available/native unavailable/not-provided unavailable/not-provided available/derived
mcp-in-memory projection available/native unavailable/not-provided unavailable/not-provided available/derived
generated event scopes native (unchanged) native (unchanged) unavailable (stays #233/#269 follow-up) native (unchanged)

Assertions flipped from honest absence to the positive contract at all three proof levels (generated-server integration inspect, mcp-in-memory tool:harness/context — now also proving lookalike host/session input fields cannot alter observed axes — and a new packed-journey context assertion inside the existing first session, no new spawns). Honest-absence assertions stay for the axes stdio genuinely lacks.

Also repairs two stale packed listTools expectations: #273 added tool:harness/context and #275 added tool:harness/mutation-probe to the shared route-harness fixture without updating the packed journey's strict list (the packed pool is not a per-PR gate, so main drifted red there).

Event scopes' actor mounting and Workbench provenance stay out per the recorded #269/#233 and Workbench deferrals on #223.

Changeset: minor for agent-bundle.

Gates (local, on the rebased branch at f06a91c)

  • pnpm build + pnpm typecheck — pass
  • pnpm lint — 0 errors / 0 warnings (939 files)
  • pnpm test:unit — 2454 passed / 0 failed (one pool-level flake observed and re-run green twice; isolated file runs green with and without this diff)
  • pnpm test:route-unit — 18/18
  • pnpm test:projection — 57/57 (includes feat(cli): project MCP tools into the routed CLI via routes.mcpCommands (#102 stage 4) #275's new cli-dispatch-mcp suite)
  • generated-route-server integration (scoped, prebuilt) — 9/9
  • packed journey (scoped run-packed-tests.mjs) — every assertion through both packed sessions passes including the new context axes proof; the suite then fails at the pre-existing requestEventRuntime IPC step, reproduced byte-identical on unchanged origin/main (A/B with only the stale listTools repair applied), unrelated to this change.

Refs #223, #273, #233, #269.

…opes (#223)

Generated MCP tool, resource, and prompt request scopes now observe the
negotiated client identity as a native host and derive workspace from the
server process cwd, alongside the existing native session and authInfo
actor, forwarding all four axes into the Flight worker. Typed
unavailability is preserved where a transport genuinely lacks an axis
(bare stdio supplies no sessionId or authInfo). The in-memory projection
level mirrors the worker boundary so mcp-in-memory stays faithful, with
the harness context seam still winning. Proof assertions flip from
honest absence to the positive contract at the generated-server
integration, mcp-in-memory, and packed journey levels; also repairs the
packed listTools assertion left stale when #273 added the context
fixture route.
@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2661ae8

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 Minor

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 2, 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-02T04:49:49.406604Z 2661ae8 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.

@ScriptedAlchemy
ScriptedAlchemy merged commit 69c20ab into main Sep 2, 2026
4 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the feat/223-tool-scope-axes branch September 2, 2026 04:47
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