Skip to content

fix(mcp-gateway): hand the dashboard control plane its per-session token - #12459

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/dashboard-control-plane-token
Sep 21, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/dashboard-control-plane-token

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

#12445 (the fix for issue #12441) classifies a 409 from the gateway as identity_unattested and refuses the call. The refusal rests on a stated premise (mcp_shared.py, beside the branch): a legitimate pooled backend never lands there, because the gateway daemon hands it the token per frame and the resolver sends it. The same block records that a legitimate call still reaches the neighbouring resolution_failed arm in this deployment, keeps that arm permissive until the reason is understood, and calls that reason a gateway-side question.

kirocrew-dashboard is where the premise breaks. It posts back to the control plane for the calling session, and it is not in CONTROL_PLANE_BACKENDS in mcp_gateway/gatewayd.py. So the daemon never hands a gateway-pooled dashboard backend the token, every one of its control-plane calls answers 409, lands in the identity_unattested branch, and is refused: session_create, session_send, session_read_message, the chat_folder_* and chat_tag_* tools all fail, on every call, and restarting the session does not help.

Why it matters

Any agent that coordinates other sessions -- a conductor standing up workers, a session filing itself into a folder -- loses its whole control surface. This change is the gateway-side answer the mcp_shared.py block asks for: with the dashboard in the set, the premise holds for every backend the set names, so the refuse verdict of #12445 hits only the callers it means to hit. The other conceivable remedy, letting identity_unattested through, was rejected on main and becomes unnecessary once no legitimate call lands in that branch.

What changed (motivation -> approach -> change)

Piece Before After
mcp_gateway/gatewayd.py CONTROL_PLANE_BACKENDS kirocrew-core, kirocrew-cron plus kirocrew-dashboard
agent.py managed_mcp_spec_entry(name) None for every opt_in entry include_opt_in=True resolves an opt_in invocation; a closed spec_gate still yields None; the default is unchanged
not-in-set exit of _spawns_own_control_plane silent False False plus one DEBUG line naming the backend
_deny_control_plane warning names kirocrew-core/kirocrew-cron names no server
ratchet in test/test_mcp_gateway_stub_session_token.py the two constants are equal CONTROL_PLANE_SERVERS is contained in CONTROL_PLANE_BACKENDS; the token-only extras are pinned to exactly kirocrew-dashboard; every extra must be a managed opt_in server
docs/architecture/mcp.md, token forwarding describes the set as a mirror of CONTROL_PLANE_SERVERS names the three members, the superset relationship and why, the ratchet's three checks, and the include_opt_in resolution

A backend that posts back to the gateway for the calling session must prove which session it acts for. The gateway accepts two proofs: the process ancestry of a Unix socket peer, or the per-session attestation token. A dashboard backend spawned by kiro-cli has kiro-cli in its ancestry, so it passes. A dashboard backend spawned by the gateway daemon has systemd in its ancestry, so only the token can name its session, and the daemon hands the token only to backends named in CONTROL_PLANE_BACKENDS.

That set named two backends. kirocrew-dashboard also posts back for the calling session, and it was not in the set. Two gates hid this. The membership test returns False without logging, so the missing name left no trace. And managed_mcp_spec_entry returned None for every opt_in entry, which the dashboard is, so adding the name alone turns the silent refusal into a logged one (no managed spec entry resolves for this name).

The fix adds the name and lets the control-plane check resolve an opt_in invocation. The check still compares the spawned binary by realpath and the argv exactly against that invocation, refuses any non-empty PYTHON* variable in the child environment, and refuses an import root that shadows kiro_crew. Membership is a necessary condition; none of those fences moved. The include_opt_in flag skips exactly one of the two emission disqualifiers: an opt_in server that is running was granted per agent, so its invocation is still the one to compare against; a closed spec_gate still yields None, because the gate exists to keep that backend unspawned and a spawn under its name must not be handed a token. Neither spec writer passes the flag, so no opt_in entry is emitted that the base does not emit.

acp.session_mcp.CONTROL_PLANE_SERVERS is deliberately unchanged. It decides which servers every session mounts and which survive a disabledTools entry (session_mcp subtracts it from the disabled set). Naming the dashboard there would mount it in every session and make an operator's decision to switch its tools off unenforceable. The two constants answer different questions, so the ratchet that pinned them equal now pins containment, the exact token-only set (kirocrew-dashboard), and the opt_in property of every extra. The token-forwarding section of docs/architecture/mcp.md describes that relationship instead of the mirror it described before.

Backwards compatibility

Compatible: the only backend whose behavior changes is a gateway-pooled kirocrew-dashboard, which now receives the token it needs. A kiro-cli-spawned dashboard, every third-party backend, both spec writers and the disabledTools handling are unchanged. managed_mcp_spec_entry gains a keyword-only flag with the old default, and every existing caller passes no flag.

Tests

test/test_mcp_gateway_stub_session_token.py, run with -n0: 95 passed, 1 skipped.

  • The ratchet replaces the equality pin with three checks: CONTROL_PLANE_SERVERS is contained in CONTROL_PLANE_BACKENDS, the token-only extras equal exactly kirocrew-dashboard, and every extra is a managed opt_in server. A new token recipient has to update the pin in the same commit that adds it; a typo'd or third-party name fails the property check even if someone edits the pin.
  • The check is pinned to call managed_mcp_spec_entry with include_opt_in=True. Every test double in the file swallows keywords, so dropping the argument at the call site would otherwise leave the dashboard unverifiable with the whole file still green.
  • TestTokenOnlyControlPlane: the real dashboard invocation matches itself; the same invocation with a foreign binary, different argv or a non-empty PYTHONPATH is denied and each denial names its reason; managed_mcp_spec_entry("kirocrew-dashboard") without the flag is still None; the flag keeps a closed or raising spec_gate closed on a synthetic entry, and the real dashboard is denied the token under a closed gate through the production path; a name outside the set logs one DEBUG line and no WARNING, while a reserved name that fails logs the WARNING and never the DEBUG line.

Mutation check on the new tests: removing kirocrew-dashboard from the set reddens 4; dropping include_opt_in=True at the call site reddens 3; making the flag skip the spec_gate check reddens 2; raising the DEBUG line to WARNING reddens 1; widening the exact pin by a second name reddens 1 (the ratchet, with its message).

Manual verification

On a gateway restarted with this change, session_create from a pooled dashboard backend succeeded 3 of 3 times where every call failed before, and the gateway log recorded 0 token rejections and 0 resolver refusals for that backend.

Related Issues

Related: #12445 (the resolver now sends the caller token and refuses identity_unattested on the premise that a legitimate pooled backend is always handed the token; this PR makes that premise hold for the dashboard) and #12441 (the report that #12445 addressed; the dashboard half of the same symptom is handled here).

no linked issue: the dashboard case was reproduced on a live gateway and has no issue of its own; this PR carries the analysis.

Pattern harvest

Rule candidate: review-prompt
Pattern: a membership test that returns False without logging makes a member missing from the set indistinguishable from an ordinary non-member, so an allowlist of trusted names should log its rejections at least at DEBUG.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@chenmingwei23
chenmingwei23 requested review from a team and hoang-phan98 September 21, 2026 05:33
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 21, 2026
@chenmingwei23

chenmingwei23 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Intent: Hand the gateway-pooled kirocrew-dashboard backend the per-session attestation token, so its session-posting tools (session_create, session_send, the folder and tag tools) can prove which session they act for, without loosening any of the binary, argv or environment fences that guard the token. This is the gateway-side answer to the question mcp_shared.py leaves open in #12445: it makes the premise behind the identity_unattested refusal (a legitimate pooled backend is always handed the token) hold for all three control-plane backends.
Not a goal: Changing acp.session_mcp.CONTROL_PLANE_SERVERS (which servers every session mounts, and disabledTools handling); granting the token to any other opt_in server (kirocrew-work, kirocrew-crew-log, kirocrew-computer); or changing how mcp_shared.py classifies or refuses a 409 identity failure (#12445 settled that, and refusing is right once the premise holds).

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of e158a115d466e262c34fe5d22e96ca580db7b22a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Fix is name-scoped but the failure class is property-scoped: a pooled kirocrew-work shares the dashboard's 409 shape and stays refused.

Watch

kirocrew-work is the other opt_in managed server that posts back for the calling session over the same loopback client (mcp_work.py imports _get/_post/_resolve_session_key from mcp_core, "same cross-module reuse as mcp_dashboard"), and gatewayd pooling is not name-restricted — so a gateway-pooled work-ledger backend lands in the same identity_unattested refusal, and the new ratchet (token_only == frozenset({"kirocrew-dashboard"})) deliberately excludes it without the PR saying whether that case can occur. The conductor scenario the description motivates ("a conductor standing up workers") uses the work ledger too, so the fix may half-restore its own headline use case.
Clears when: the author states (or tests) that a gateway-pooled kirocrew-work cannot occur, or adds it to the set and the ratchet pin in a follow-up.

[DESIGN-REVIEWED] e158a11

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of e158a115d466e262c34fe5d22e96ca580db7b22a and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e158a11

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e158a115d466e262c34fe5d22e96ca580db7b22a: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 21, 2026
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed e158a115d466e262c34fe5d22e96ca580db7b22a — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] e158a11

Verdict parsed from the review's SHA-scoped output markers for commit e158a115d466e262c34fe5d22e96ca580db7b22a.

False positive or not applicable? A repository writer can comment:
/ai-review override fable e158a115d466e262c34fe5d22e96ca580db7b22a: <one-sentence reason>

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 21, 2026
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of e158a115d466e262c34fe5d22e96ca580db7b22a — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The fix is real but point-patched: kirocrew-work and kirocrew-crew-log post back for the calling session the same way and stay broken when pooled.

Not justified as shipped

  • Item 1 — symptom-level (point patch): the root cause is "a backend that posts back for the calling session is missing from CONTROL_PLANE_BACKENDS", and the premise this PR restores (mcp_shared.py:918: "A legitimate pooled backend never lands here") is stated for every pooled backend, not the dashboard. Grepping session_key=caller_key post-backs: 2 unfixed siblings — kirocrew-work (mcp_work.py:344-373, /api/work-ledger/*) and kirocrew-crew-log (mcp_crew_log.py:374,524,579) — both opt_in bin servers (mcp_cleanup.py:58) stub-wrapped by the same rewriter.py:929 pooling path, both running the same mcp_shared resolver that refuses on identity_unattested; the description's own motivating caller, a conductor, carries kirocrew-work. The new ratchet pins extras to exactly kirocrew-dashboard and the description never says what is left.
    Clears when: the two siblings are shown never gateway-pooled (or their calls attested another way), or the same membership fix lands for them with the pin updated.

What this change ships

Inventory (7 items) — 6 justified

Intent: FIX — a gateway-pooled dashboard backend's control-plane tools all answer 409 and refuse; hand it the per-session token so they work.

  1. Pooled dashboard tools (session_create, session_send, folder/tag) now succeed instead of always refusing — symptom-level (point patch: 2 counted siblings, above)
  2. managed_mcp_spec_entry gains keyword-only include_opt_in (default unchanged; spec_gate still closes it) — justified
  3. A backend outside the set now leaves one DEBUG log line — rides along (declared; the silence is how this bug hid)
  4. _deny_control_plane warning no longer names kirocrew-core/kirocrew-cron — rides along (declared; old text wrong for dashboard denials)
  5. Equality ratchet replaced by containment + exact-extras pin + opt_in property — justified
  6. docs/architecture/mcp.md token-forwarding section describes the superset — justified
  7. New tests pinning the dashboard grant and its fences, failing on base — justified

[FIRST-PRINCIPLES-REVIEWED] e158a11

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 21, 2026
@chenmingwei23

chenmingwei23 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

span=e39d4f07c17b (First Principles Review, head 98b10e67).

  • rebutted -- Item 1: kirocrew-work and kirocrew-crew-log are outside CONTROL_PLANE_BACKENDS on purpose, not by omission.

Membership in CONTROL_PLANE_BACKENDS hands a process a per-session bearer token. That grant is decided one backend at a time, on evidence for that backend: that the gateway daemon pools it, that its posts for the calling session need the token, and that the binary, argv and environment fences hold for its exact invocation. kirocrew-dashboard is the backend reproduced and verified on a live gateway (every control-plane call refused before, 3 of 3 session_create after). Neither sibling has that evidence yet. Adding them on the strength of a grep would grant a credential without verification, which is the over-provisioning the GPT lane blocks on in this very round, and the exact-set pin landing in the next head exists so that every addition is a separate, reviewed acknowledgment.
Scope was declared before review: the intent comment lists both siblings under Not a goal. This PR restores the one pooled control plane that session orchestration (conductors, workers, folders, tags) depends on; it does not claim to be the general fix, and the body wording that called the dashboard the third such backend is corrected in the next head.
Nothing needs re-deriving for them later. The ratchet is written by property so that a verified sibling is one name plus one pin update under the same test; that follow-up is a separate PR with its own live verification, and no issue is filed here because nothing is being deferred from this change's intent.

@chenmingwei23
chenmingwei23 force-pushed the fix/dashboard-control-plane-token branch from 98b10e6 to 6bc8daf Compare September 21, 2026 08:35
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 21, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Rebased onto main 3017e6a2 (27 commits; none touch agent.py, gatewayd.py or the test file, main's mcp.md edits are in a different section). New head 6bc8daff, still one commit.

This head also carries the two round-1 repairs: the ratchet now pins the token-only set to exactly kirocrew-dashboard (widening it by one name reddens the test with a message naming the required action), and the token-forwarding section of docs/architecture/mcp.md describes the superset relationship and the three checks instead of a mirror. test/test_mcp_gateway_stub_session_token.py with -n0: 95 passed, 1 skipped. The body no longer carries a closing reference to #12441.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 21, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

span=e249a2d196db (First Principles Review, head 6bc8daff).

  • rebutted -- Item 1: the mechanism is read correctly; widening this PR to kirocrew-work and kirocrew-crew-log is the disproportional step, and the scope was set on purpose.

The mechanism holds as stated: _resolve_tool_policy declares X-Session-Key for every pooled caller-aware backend, the only token a daemon-spawned backend can attach is the per-frame sessionToken that gatewayd hands to CONTROL_PLANE_BACKENDS, and without it the read is answered member_identity_unavailable and every tool call is refused. So a kirocrew-work or kirocrew-crew-log backend that gatewayd pools would refuse every call the same way the dashboard did. Nothing here disputes that.
What this PR decides is one grant, not the class. Membership in CONTROL_PLANE_BACKENDS hands a process a per-session bearer token, and each grant is made on evidence for that backend: that the daemon pools it, that its exact invocation is the one _spawns_own_control_plane compares realpath, argv and environment against, and that the fences hold for it. The dashboard has that evidence (reproduced on a live gateway: every control-plane call refused before, 3 of 3 session_create after; seven positive and negative invocation cases in the tests). Neither sibling has been reproduced or fenced yet, and the two grants would ride into a security change on a code read alone. The intent comment declared both as non-goals before review for that reason.
The same one-name-plus-pin change fixes each sibling when its evidence exists, and the ratchet now makes that an explicit, reviewed step rather than a silent widening: the token-only set is pinned to exactly kirocrew-dashboard, so adding a name fails the test until the pin is updated in the same commit. The residual is disclosed here rather than hidden: until that follow-up, a pooled kirocrew-work or kirocrew-crew-log backend still lands in the identity_unattested arm, which is the pre-existing behavior on main, not a regression introduced by this head.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 21, 2026
gatewayd forwards the per-session attestation token only to backends named
in CONTROL_PLANE_BACKENDS, and that set named kirocrew-core and kirocrew-cron.
kirocrew-dashboard is the third backend that posts back to the gateway for
the calling session (session_create, session_send, the folder and tag tools),
so a gatewayd-spawned dashboard backend, whose process ancestry ends at
systemd instead of kiro-cli, had neither identity channel and every one of
its tools answered "execution identity is unavailable".

Two gates stood in the way. The set membership test returned False silently,
so the missing name never produced a log line. And managed_mcp_spec_entry
answered None for any opt_in entry, which the dashboard is, so adding the
name alone only turned the silent refusal into a logged one.

- add kirocrew-dashboard to CONTROL_PLANE_BACKENDS
- managed_mcp_spec_entry(name, include_opt_in=True) resolves an opt_in
  entry's invocation for the control-plane check only; a closed spec_gate
  still yields None, and neither spec writer passes the flag
- log the not-in-set exit at DEBUG so the two False exits are distinguishable
- the denial warning no longer names two specific servers

acp.session_mcp.CONTROL_PLANE_SERVERS is deliberately unchanged: it decides
which servers every session mounts and which survive a disabledTools entry,
so naming the dashboard there would make an operator's decision to switch
its tools off unenforceable. The ratchet now pins containment instead of
equality and requires every token-only extra to be a managed opt_in server.
@chenmingwei23
chenmingwei23 force-pushed the fix/dashboard-control-plane-token branch from 6bc8daf to e158a11 Compare September 21, 2026 09:19
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Sep 21, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Rebased onto main 1fa7f5ba (4 commits; none touch agent.py, gatewayd.py, the test file or mcp.md). New head e158a115, still one commit, diff unchanged from 6bc8daff. test/test_mcp_gateway_stub_session_token.py with -n0 on the rebased tree: 95 passed, 1 skipped.

On 6bc8daff every lane had finished: Backend Tests (Windows) (8) failed once on test/test_decisions_tool_risk.py::TestTheRecord::test_a_risky_answer_returns_the_row_that_was_written (nothing in this diff touches kiro_crew.decisions; the same shape is reported in #12376) and passed on a single re-run, so that was a flake.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 21, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

span=2ae75641d45a (Design Review, head e158a115).

  • rebutted -- Watch: a gateway-pooled kirocrew-work CAN occur, and it is left outside CONTROL_PLANE_BACKENDS here on purpose; the grant is deferred to its own verified change, not denied.

The observation is accurate. mcp_work.py reuses the same loopback client as mcp_dashboard, kirocrew-work is classified caller-aware (so shareable and therefore poolable), and gatewayd's pooling is not name-gated. A pooled kirocrew-work backend would declare its session key without a token, be answered member_identity_unavailable, and have its calls refused -- the arm this PR takes the dashboard out of. That is main's behavior today, unchanged by this head.
This PR grants one token, to the backend that was reproduced and verified: every control-plane call refused before the change, 3 of 3 session_create after, seven positive and negative invocation cases pinned in TestTokenOnlyControlPlane. kirocrew-work has no reproduction and no fenced invocation case yet, and a bearer-token grant added on a code read alone is the widening the review lanes exist to catch. The intent comment listed kirocrew-work and kirocrew-crew-log as non-goals before review for that reason.
The follow-up is mechanical and deliberately made visible: the ratchet pins the token-only set to exactly kirocrew-dashboard, so adding kirocrew-work fails the test until the pin is updated in the same commit, and the invocation cases in TestTokenOnlyControlPlane are the template for its verification. Until that lands, the residual is as stated above and is disclosed here rather than in the body, so the body describes what this head does.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

span=5009e862a0f4 (First Principles Review, head e158a115).

  • rebutted -- Item 1: the mechanism is read correctly for the class; granting kirocrew-work and kirocrew-crew-log a bearer token in the same change, without their own verification, is the disproportional step, and the scope was set on purpose before review.

Agreed on the mechanism: _resolve_tool_policy declares X-Session-Key for every pooled caller-aware backend, the only token a daemon-spawned backend can attach is the per-frame sessionToken gatewayd hands to CONTROL_PLANE_BACKENDS, and without it every tool call is refused as identity_unattested. Both siblings are caller-aware and therefore poolable, so a pooled kirocrew-work or kirocrew-crew-log lands in that arm exactly as the dashboard did. That is the pre-existing state of main, and this head does not change it for them.
What this PR decides is one grant on one backend's evidence: the dashboard was reproduced on a live gateway (every control-plane call refused before, 3 of 3 session_create after) and its exact invocation is what _spawns_own_control_plane compares realpath, argv and environment against, with the negative cases pinned. Neither sibling has been reproduced or had its invocation fenced, and a security change should not carry two unverified token grants on a grep. The intent comment declared both as non-goals for that reason.
The class fix is the same one-name-plus-pin change per sibling, and the ratchet now makes each one an explicit reviewed step: the token-only set is pinned to exactly kirocrew-dashboard, so a new recipient fails the test until the pin moves in the same commit. The residual -- pooled siblings still refused until their own change lands -- is stated here so the disclosure travels with the decision.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Tracking issue for the residual disclosed in the two dispositions above: #12464.

That issue covers the class rather than the two siblings alone, and it is wider than this PR in two ways. It also names kirocrew-computer, and it covers acp/session_mcp.kiro_control_plane_servers as well as gatewayd.CONTROL_PLANE_BACKENDS. This PR touches only the second, for only kirocrew-dashboard, on that backend's own reproduced evidence.

So this head is the pooled-path half of #12464 for one recipient. The ratchet added here pins the token-only set to exactly kirocrew-dashboard, which makes every further recipient an explicit reviewed step in whichever change adds it.

Posted as a comment rather than a body edit: editing the body would re-run the review lanes that list edited, and this head is settled.

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified at e158a115. Note for anyone reading the PR comments: one of them claims a rebase to 6bc8daff, but gh reports head e158a115 and 6bc8daff does not exist in the repo, so every bot verdict and this review are scoped to e158a115.

The membership gate runs first and reads nothing before it: if server_name not in CONTROL_PLANE_BACKENDS at gatewayd.py:222, ahead of the lazy managed_mcp_spec_entry import at :237. The set is now frozenset({"kirocrew-core", "kirocrew-cron", "kirocrew-dashboard"}) (:169).

Membership is necessary and not sufficient — none of the real fences moved. After the set check, _spawns_own_control_plane still requires realpath(binary) == spec, argv == expected_argv exactly, an empty child PYTHON* env, and no import root shadowing kiro_crew (:241-:270), each denying to False.

include_opt_in skips only the opt_in disqualifier and keeps the spec gate: _mcp_server_emission_eligible has exactly two disqualifiers, and _mcp_spec_gate_open is still consulted, with a raising gate reading CLOSED. No third fence is bypassed.

The token cannot ride to a foreign child. backend.control_plane is assigned at :4412 from the _spawns_own_control_plane verdict computed at :4355, i.e. from the resolved command, not from the name the stub registered; _caller_for_backend attaches the token only when that flag is true (:307), never mutates caller, and each call site re-derives from the tokenless base.

Scoping holds: the attached value is conn.stub_session_token, bound to the calling stub connection rather than to caller-supplied input, so a frame carries only its own connection's token. Adding one name does not widen that path.

Nothing leaks: the new DEBUG line logs server_name only, the reworded WARNING logs server_name + reason, and the deny reasons log command/argv/paths but never the token. When conn.stub_session_token is falsy the tokenless base caller is returned and the post-back 409s rather than falling back to an ambient credential.

One correction to my own review premise — I went in looking for a token file write and owner-only permissions. There is none: this change forwards the token in-memory per frame via dataclasses.replace(caller, session_token=...) and adds no file I/O at all, so the at-rest questions belong to the pre-existing machinery, untouched here.

The Design and First Principles CONCERNS are both real: kirocrew-work is opt_in, posts back for the calling session, shares the same 409 shape, and stays excluded. But the consequence is a fail-closed functionality gap, not a security regression, and granting one backend at a time on live evidence is the conservative direction — the ratchet is by-property so a verified sibling costs one name plus one pin.

No vacuous guards found. Each of the four new tests reddens on a real mutation, and the log assertions use single-tuple unpacking so an empty log fails rather than passes — which is the trap this shape usually falls into.

@chenmingwei23
chenmingwei23 merged commit 2d14b26 into main Sep 21, 2026
93 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/dashboard-control-plane-token branch September 21, 2026 15:15
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 21, 2026
NicholasRBowers added a commit that referenced this pull request Sep 21, 2026
An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since #12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes #12464
NicholasRBowers added a commit that referenced this pull request Sep 21, 2026
An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since #12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes #12464
NicholasRBowers added a commit that referenced this pull request Sep 21, 2026
An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since #12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes #12464
NicholasRBowers added a commit that referenced this pull request Sep 21, 2026
An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since #12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes #12464
NicholasRBowers added a commit that referenced this pull request Sep 21, 2026
#12476)

An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since #12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes #12464

Co-authored-by: Nicholas Bowers <NicholasRBowers@users.noreply.github.com>
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…ken (kirodotdev#12459)

gatewayd forwards the per-session attestation token only to backends named
in CONTROL_PLANE_BACKENDS, and that set named kirocrew-core and kirocrew-cron.
kirocrew-dashboard is the third backend that posts back to the gateway for
the calling session (session_create, session_send, the folder and tag tools),
so a gatewayd-spawned dashboard backend, whose process ancestry ends at
systemd instead of kiro-cli, had neither identity channel and every one of
its tools answered "execution identity is unavailable".

Two gates stood in the way. The set membership test returned False silently,
so the missing name never produced a log line. And managed_mcp_spec_entry
answered None for any opt_in entry, which the dashboard is, so adding the
name alone only turned the silent refusal into a logged one.

- add kirocrew-dashboard to CONTROL_PLANE_BACKENDS
- managed_mcp_spec_entry(name, include_opt_in=True) resolves an opt_in
  entry's invocation for the control-plane check only; a closed spec_gate
  still yields None, and neither spec writer passes the flag
- log the not-in-set exit at DEBUG so the two False exits are distinguishable
- the denial warning no longer names two specific servers

acp.session_mcp.CONTROL_PLANE_SERVERS is deliberately unchanged: it decides
which servers every session mounts and which survive a disabledTools entry,
so naming the dashboard there would make an operator's decision to switch
its tools off unenforceable. The ratchet now pins containment instead of
equality and requires every token-only extra to be a managed opt_in server.
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
kirodotdev#12476)

An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since kirodotdev#12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
kirodotdev#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes kirodotdev#12464

Co-authored-by: Nicholas Bowers <NicholasRBowers@users.noreply.github.com>
wknight1 pushed a commit to wknight1/KiroCrew that referenced this pull request Oct 5, 2026
kirodotdev#12476)

An opt-in Crew server (kirocrew-dashboard, kirocrew-work, kirocrew-crew-log,
kirocrew-panel) granted by a spec on the kiro backend was mounted straight from
the spec with no session-valued environment, and gatewayd handed the per-frame
token only to kirocrew-core, kirocrew-cron and (since kirodotdev#12459) kirocrew-dashboard.
Since the tool-policy read requires an attestation, every call on any other
such server refused as identity_unattested, and on the kiro backend the
dashboard itself still did.

kiro_control_plane_servers now re-emits every IDENTITY_BOUND_SERVERS element
the spec grants, so the token attach reaches them; CONTROL_PLANE_BACKENDS is
the same set, read from the mcp_cleanup leaf. Both paths resolve a granted
opt-in name with managed_mcp_spec_entry(name, include_opt_in=True), the form
kirodotdev#12459 introduced for the pooled check. The grant itself is unchanged: the
spec's tools allowlist still decides what is mounted.

Fixes kirodotdev#12464

Co-authored-by: Nicholas Bowers <NicholasRBowers@users.noreply.github.com>
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.

2 participants