Repository navigation
fix(identity): give every managed Crew MCP server the session token - #12564
iamwhatever wants to merge 1 commit into
Conversation
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify kirocrew-panel and kirocrew-crew-log actually post back to the gateway — the derivation now hands every managed server a session bearer token. [DESIGN-REVIEWED] fdecf39 |
Opus 4.8 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Verify the widened bearer-token grant: the old ratchet capped recipients at {core, cron, dashboard}; seven managed servers now qualify — confirm I checked the load-bearing premise myself: every managed server module ( What this change shipsInventory (7 items) — 7 justifiedIntent: FIX — managed Crew tools like
[FIRST-PRINCIPLES-REVIEWED] fdecf39 |
0a3731c to
7f9a82a
Compare
7f9a82a to
b62108c
Compare
|
Both CONCERNS are addressed in the amended commit. The duplicated subtraction is gone: The Addressed in |
GPT 5.6 Review —
|
|
Fixed. In |
b62108c to
9eb66d8
Compare
|
Addressed. The invariant — a managed Crew server posts back to the gateway for the session it acts for, so it needs that session's identity — is now stated at the registry definition ( In |
9eb66d8 to
6485514
Compare
|
The resolver strip closes the blocker: In |
6485514 to
fdecf39
Compare
|
The loader pair is removed from this PR — the identity fix now ships alone (gatewayd.py only adds the registry-derived |
|
Agreed, and split out: the |
|
Done — the pair is deferred to its own change per your recommendation. Removed here: |
GPT 5.6 Review —
|
|
Closing: superseded by #12476, merged to main at 20:50 UTC. #12476 lands the same design this PR converged on -- token recipients derive from the managed registry ( Thanks to the reviewers whose rounds shaped the shared design. |
Problem / Motivation
With the MCP gateway stubs off (the default install), a
kirocrew-workorkirocrew-dashboardtool call failed with:On the shared ACP runtime the session identity token rides on the injected
mcpServerselement, not the process environment. That token was only ever puton the always-on control plane (
kirocrew-core,kirocrew-cron), so any othermanaged Crew server launched from the agent spec came up with an empty env and
could not prove which session it was acting for.
Why it matters
A conductor whose spec grants
kirocrew-work, or an agent grantedkirocrew-dashboard, could not use those tools at all — every call answeredidentity_unattested. The same gap applies to every other managed Crew server(
kirocrew-computer,kirocrew-crew-log,kirocrew-panel), each of which alsoposts back to the gateway for its session.
What changed (motivation → approach → change)
Managed Crew servers post back to the gateway to prove their session, but only
the always-on control plane was handed the per-session token, and the recipients
were hand-maintained name lists in two places — so a managed server missing from
either silently got no identity.
Both lists now derive from one source: the managed registry
(
mcp_cleanup.KIROCREW_BIN_MCP_SERVERS, the ratchet-pinned mirror ofagent._MANAGED_MCP_SERVERS). Insrc/kiro_crew/acp/session_mcp.pythe KIROdirect-path identity (
IDENTITY_BOUND_OPT_IN_SERVERS) is now every managedserver minus the always-on control plane; in
src/kiro_crew/mcp_gateway/gatewayd.pythe stub path (CONTROL_PLANE_BACKENDS)is the whole registry. The codex/opencode withhold path reads that same site:
src/kiro_crew/providers/mirrors/identity.pyidentity_bound_crew_servers()returns
frozenset(IDENTITY_BOUND_OPT_IN_SERVERS)rather than recomputing thesubtraction. A new managed server gets identity on every path for free, and none
can drift.
The recipient set is DERIVED at runtime, and a test-side NAME PIN in
test/test_session_token_identity.pyfixes the reviewed membership beside thederivation: a managed server joining or leaving the recipients now needs a
same-commit, reviewed edit to that literal.
src/kiro_crew/mcp_cleanup.pyKIROCREW_BIN_MCP_SERVERSnow states itsinvariant at the definition — membership is what grants the token on both launch
paths, so a server that does not post back must not be listed there. The
architecture doc
docs/architecture/mcp.mdis updated to describe the derivedrecipients (every declared, granted managed server,
opt_inandspec_gatealike) on both paths, replacing the passage pinning the extras to exactly
kirocrew-dashboard.Invariants unchanged:
CONTROL_PLANE_SERVERSstays(core, cron); identity iscarried only when the spec declares the server and
toolsgrants it, neverauto-mounted; and
_spawns_own_control_planestill verifies each spawn byrealpath, argv and env, so a gated server resolves to no managed entry and is
denied the token.
Verification: with the stubs off,
/proc/<pid>/environon each managed backendnow carries
KIROCREW_STUB_SESSION_TOKEN, where only mcp-core did before.Backwards compatibility
Compatible: identity is still gated on spec declaration +
toolsgrant + thebyte-exact
_spawns_own_control_planeprovenance check, so no session gains atoken it was not already entitled to; the always-on mount set and the
codex/opencode withhold set are unchanged.
Tests
test/test_session_token_identity.py— pinsIDENTITY_BOUND_OPT_IN_SERVERSas the derivation (managed registry minus the control plane), that it stays
disjoint from
CONTROL_PLANE_SERVERS, and thatidentity_bound_crew_serversreturns that single source verbatim so the direct path and the codex/opencode
mirror cannot diverge. A test-side NAME PIN asserts the recipient set equals
{kirocrew-computer, kirocrew-dashboard, kirocrew-work, kirocrew-crew-log, kirocrew-panel}and thatCONTROL_PLANE_BACKENDS == frozenset(KIROCREW_BIN_MCP_SERVERS),so a new managed server that posts back must be added in the same reviewed
commit while the runtime stays derived.
test/test_mcp_gateway_stub_session_token.py— pinsCONTROL_PLANE_BACKENDSequal to the whole managed registry(
= _MANAGED_MCP_SERVERS), containment ofCONTROL_PLANE_SERVERS, and thateach token-only server is
opt_inor gated (so it correctly stays out of thealways-on mount set). The parametrized token-carriage tests now cover every
managed backend.
A new managed server automatically gets identity; a spec that does not declare a
server still gets nothing.
Follow-up
The dynamic-loader env hardening for token-bearing control planes (fencing
LD_*/DYLD_*overlays a spec adds relative to the gateway's own inheritedenvironment) is tracked separately in #12615.
Manual verification
N/A — unit coverage sufficient. The identity carriage, the never-auto-mount and
foreign-command guards, and the codex/opencode withhold parity are all asserted
in the two test files above;
_spawns_own_control_plane's realpath/argv/envfences are pinned in the existing gateway suite.
Related Issues
no linked issue: internal identity-plumbing fix surfaced during drive-to-green.
Pattern harvest
Rule candidate: review-prompt
Pattern: any managed Crew server that posts back to the gateway must obtain its
identity from the same registry the launcher uses (
KIROCREW_BIN_MCP_SERVERS/_MANAGED_MCP_SERVERS), never from a hand-maintained name list — two lists oftoken recipients drift, and a server missing from one silently loses identity.