Repository navigation
fix(identity): name recovery paths, reset refused flag, drop dead wrappers (#17612) - #19939
Conversation
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS The wrong recovery-path claim this PR fixes in code still sits in the design note, and deleting the wrapper also deleted the only written rationale for the unsigned read. Watch
[DESIGN-REVIEWED] a25a5b9 Description read[DESCRIPTION-READ] 077d358b62a52b804339b30c0babe2e73855397eae2b3c58e75557ce4449b641 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The Not justified as shipped
What this change shipsInventory (5 items) — 4 justifiedIntent: give whoever audits the cleared-stub identity path accurate comments and less dead code (FIX of the advisory items in #17612).
[FIRST-PRINCIPLES-REVIEWED] a25a5b9 Description read[DESCRIPTION-READ] 2b34948d5cebdd3ffc604ebf0b78af9590d35e2c281932a59c33a854251d14f0 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 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: |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
4cc1297 to
e6230b5
Compare
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsFINDING -- src/kiro_crew/mcp_gateway/daemon/identity.py:101 -- “naming this connection's own token” misdocuments recovery: False positive or not applicable? A repository writer can comment: |
8d3c659 to
a64edeb
Compare
|
Rebased: main moved in src/kiro_crew/agent_capabilities.py (same-dir), src/kiro_crew/cli_doctor.py (same-dir), src/kiro_crew/kiro_prerequisite.py (same-dir), src/kiro_crew/mcp_tools/apps.py (import), src/kiro_crew/session.py (same-dir), src/kiro_crew/session_background.py (same-dir) since this head went green (aaffa10 -> 3791b79); CI re-running. |
bf447b1 to
38c385d
Compare
8f9d77a to
11ea502
Compare
11ea502 to
b5b647e
Compare
b5b647e to
a25a5b9
Compare
|
HOLD at a25a5b9. This changes caller identity and session-token attribution, so approval remains with a human maintainer. Please also answer the current-head Design and First Principles items. They cover the old recovery story still in the design note, the unsigned deny-only read rationale lost with the wrapper, and the reachable effect of the new identity_refused reset. A fix or evidence-backed rebuttal should address each item. This is not an approval of the identity changes. Tests were inspected, not run locally. — crew-pr-reviewer (r99) |
mbriones98
left a comment
There was a problem hiding this comment.
Checks green and PR Readiness passed at a25a5b9; non-feature change.
bolichen97
left a comment
There was a problem hiding this comment.
Readiness sweep review: read the full diff (merge-base) and the PR thread. PR Readiness is success on this head, mergeable, no effective CHANGES_REQUESTED, no unresolved blocking thread. Comments and dead-code removal only; merged-tree tests 358 passed. No regression to normal use found.
Problem / Motivation
Goal: clear the four advisory items from #17612 that are within this PR's reach.
Five items were listed in #17612. Four are addressed here (items 1, 2, 4, 5a, 5b). Item 3 (the
## Testsoffset in the merged PR #17524 body) requires the original PR author (chenmingwei23) or a maintainer to edit, as this PR should not modify another contributor's text.Why it matters
The wrong comment about how a cleared stub regains its identity leaves operators without an accurate mental model of the recovery paths, and makes the code harder to audit. The stale
identity_refusedflag is harmless today but becomes a defect if a third guard is ever added. The missing reader makes the security argument incomplete. The wrapper and re-export are dead code.Not a goal
What changed
Item 1 — comment corrected. The
session_token and not conn.stub_session_token and shared_pidbranch in_apply_claimhad a comment claiming "a claim carrying ITS token repairs it through the branch above." That is wrong: a cleared stub is tokenless by definition, so the branch above (conn.stub_session_token != session_token) can never match it. The two real recovery paths are (1) a tokenless claim, which keeps its PID-wide reach unconditionally, and (2) a tokened claim arriving after_pid_live_tenantsdrops below two because the co-tenant's connections have disconnected. Both are now named in the comment. The reason string is also fixed: "cleared until a claim carrying its own token names it" → "cleared until a tokenless claim retargets it or the co-tenant disconnects".Item 2 —
identity_refusedreset on re-attribution. The flag was set when a connection was cleared and never cleared. It is harmless while a caller is present (theexisting_keyguard in the recaller already rejects it), but the flag outliving the condition that set it is the kind of state that becomes a defect.conn.identity_refused = Falseis now set whenconn.caller = updated_calleris set in the retarget path.Item 4 —
_policy_session_keynamed as a reader of the env rung.mcp_shared._policy_session_keycallsresolve_own_identity(), which reads theKIROCREW_SESSION_KEYrung guarded by #17524. The backwards-compatibility argument in that PR named the lenient resolver and audit callers but not this one. A docstring note is added: on a shared pid the rung resolves no key,identity.failedis set,Noneis returned, and_resolve_tool_policyraises intoresolution_failed, which is in_UNRESOLVED_REFUSES_CALL— sotools/callis refused rather than proceeding under a co-tenant's exclusion set.Item 5a —
_host_pid_hosts_several_sessionsremoved. The wrapper's body wasreturn host_pid_is_shared(host_pid). The one call site in_resolve_session_key_strictnow callshost_pid_is_shareddirectly. The docstring reference is updated.Item 5b —
_pid_live_tenantsre-export kept. The composition-contract test (test_every_owner_name_is_bound_on_the_facade_to_the_owners_object) requires every name defined in adaemon/*.pymodule to be bound ongatewayd.py; since_pid_live_tenantsis still defined and used indaemon/identity.py, the facade re-export must stay. The second OR condition in the issue's clears-when is met:control.pyreads it directly fromdaemon.identity, not throughgatewayd.Backwards compatibility
Compatible. No change to runtime behavior.
Items 5a and 5b drop two names from the public surface of these modules.
Reader sweep on
origin/mainataaffa10318:_host_pid_hosts_several_sessions: no external callers (onlymcp_core._resolve_session_key_strict, now callshost_pid_is_shareddirectly)._pid_live_tenantsthroughgatewayd: re-export kept; the composition-contract test requires it (everydaemon/*.pyname must be on the facade).control.pyreads it fromdaemon.identitydirectly.Tests
One new test:
test_a_cleared_stub_regains_identity_after_co_tenant_disconnectsintest_mcp_gateway_stub_session_token.py.It pins the second recovery path (item 1): a cleared tokenless stub is retargeted when the co-tenant disconnects and
_pid_live_tenantsdrops below two. It also pins item 2:identity_refusedis False after retargeting.Determinism to be proven by CI (no local test runner on this host per worker policy).
Manual verification
Static gates only:
isort,flake8,mypy— all clean.Pattern harvest
Not generalizable: the wrong comment and the stale flag are one-offs in this file. The reader-list gap is a documentation discipline; the two subtractions are cleanup.
Intended? / Repro
Verified per item:
fix/claim-per-sessionmerge commit, a cleared stub hasstub_session_token = None; the branch above checksconn.stub_session_token, so it can never match. The comment was wrong. The two real paths are confirmed by code inspection.grep -n identity_refused src/kiro_crew/mcp_gateway/daemon/control.pyon main shows the flag is set but never cleared in the retarget path. No test verifies the flag is cleared after retargeting._policy_session_key):grep -n "resolve_own_identity" src/kiro_crew/mcp_shared.pyon main confirms_policy_session_keycalls it. Not named in fix(mcp): stop answering MCP identity per process on a runtime hosting several sessions #17524's backwards-compatibility section.grep -n "_host_pid_hosts_several_sessions" src/kiro_crew/mcp_core.pyon main shows the function body isreturn host_pid_is_shared(host_pid).grep -n "_pid_live_tenants" src/kiro_crew/mcp_gateway/gatewayd.pyon main shows the re-export. Removal breakstest_every_owner_name_is_bound_on_the_facade_to_the_owners_object— the composition-contract test mandates every daemon module name be on the facade. Re-export kept.Related Issues
Fixes #17612