Repository navigation
fix(acp): share a KAS MCP server's launch reference (backport #34542) - #34610
Conversation
…34542) KAS keeps one MCP pool per engine process and restarts a server whose declaration changed. The env-relay launcher reference carried the session key and a random version, so every new session on a shared runtime killed the server mid-start for every session. The reference now names no session and its version is an HMAC of the snapshot under a per-process key; the gateway counts the projections holding each file and removes it with the last. Fixes #34382 Original author: @JLargent42 (#34542) (cherry picked from commit 337ad4f)
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a faithful backport of #34542, already decided on main, and the three hand-ported hunks only leave out the OAuth bridge that 0.12.x does not have. Notes
[DESIGN-REVIEWED] fa7cfe7 Description read[DESCRIPTION-READ] 7e9a6ab6b65e8c3113360b01c3f002d71a2924776cd3dd4fb1f33043a0b7d005 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) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This backports a fix whose defect is on record (#34382). The one leftover is a dead Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: on 0.12.x, keep a KAS local stdio MCP server running when a second session starts. FIX.
[FIRST-PRINCIPLES-REVIEWED] fa7cfe7 Description read[DESCRIPTION-READ] d604ed93567714a1e40cad40fdd93208bbd2ae02f024477db2ce40a3ce09a894 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. None of the three candidates holds up against the code. A provider's [OPUS-REVIEWED] fa7cfe7 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 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: |
Problem / Motivation
Goal: On 0.12.x, a KAS local stdio MCP server stays up when another session starts, instead of being restarted, timing out and losing its tools.
Backport of #34542 to
release/0.12.0. On 0.12.1, every new session on a shared KAS runtime declares the env-relay launcher with its own session key and a random version. KAS keeps one MCP pool per engine process and restarts a server whose declaration changed, so the server is killed mid-start, hits the 60 s timeout, and its tools vanish with no notice. A customer is hitting "MCP not loading" on 0.12.1.Why it matters
Any 0.12.x user with a local stdio MCP server whose env Crew relays (any non-boolean env value) loses that server's tools as soon as a second session starts on the same KAS runtime. Nothing in the UI says why.
Not a goal
governance_appplumbing (fix(kas): six KAS harness and mcp.json reach fixes #33510).What changed (motivation → approach → change)
One pick,
337ad4fcc7d6ab7e1deb15e6a688399ed7b04dcd(squash of #34542, original author @JLargent42), applied with-x. The commit's author is Ray because the leak guard refuses a noreply author email; the original author is credited in the commit message.Root cause → change: the launcher reference now names no session (
SHARED_SESSION = "shared"), and its version is an HMAC of the snapshot under a per-process in-memory key, so every session of the same agent sends the same declaration. The gateway counts the projections holding each shared file (_SHARED_HOLDS), anddiscard_batchremoves it with the last hold.Prerequisites: none picked. Hand-port of three conflicting hunks. The conflicting context on main comes from feature work that is not on 0.12.x. Pulling it in would add a whole feature, so it was left out:
src/kiro_crew/acp/kas_env_launch.py_write_snapshot: main has aleafparameter andsnapshot_dir(leaf), added by the Crew-owned OAuth bridge (feat(connections): Crew-owned GitHub OAuth on KAS behind connections.crew_oauth (default off) #29543 / feat(connections): bridge Crew-owned OAuth per session for claude #33597 / feat(connections): bridge Crew-owned OAuth for codex, copilot, pi and strands #33799). The port keeps release's singlesnapshot_dir(), adds onlyshared, and passesSNAPSHOT_LEAFto_shared_version.src/kiro_crew/acp/kas_env_launch.pydiscard_batch: main also unregisters Connection bridges (crew_oauth_proxy.unregister_snapshots) and walks(SNAPSHOT_LEAF, BRIDGE_LEAF). The port keeps only the hold-count release over release's one directory.src/kiro_crew/acp/kas_agents.py: main passesgovernance_app=(fix(kas): six KAS harness and mcp.json reach fixes #33510). The port takes only the comment change.Hunks git auto-merged, trimmed because they describe the bridge release does not have:
kas_env_launch.pymodule docstring: dropped the "A Crew-owned Connection bridge keeps a random version per write ..." sentence.src/kiro_crew/kas_env_shim.pysnapshot_namedocstring: dropped the Connection bridge sentence.docs/system-specs/modules/security.md: dropped "A Crew-owned Connection bridge keeps a random version per write, and its provider removes exactly the ones its batch names when it shuts down."Backwards compatibility
Compatible: the launcher still accepts any reference whose snapshot matches; old per-session snapshots are removed by the existing boot sweep.
Removes nothing: the shape of the launch reference changes, but no key, path or reader is removed; per-session files are replaced by shared ones read by the same launcher.
Tests
Test changes come from the pick (
test/test_kas_env_launch.py,test/test_kas_env_launch_resume.py,test/test_kas_mcp_not_run_notice.py).Run locally, single process (
-n0), on head fa7cfe7:test/test_kas_env_launch.py,test/test_kas_env_launch_resume.py,test/test_kas_mcp_not_run_notice.py,test/test_kas_header_bridge.py,test/test_kas_inherited_auth_env.py,test/test_kas_agents_mcp_env_relay.py: 184 passedtest/test_kas_env_shim.py: 16 passedcheck_comment_history.pyandcheck_brand_name.pyagainstorigin/release/0.12.0: cleanProof: not provable -- other: backport; the fix was proven on main in #34542 and this PR carries the same tests
Manual verification
N/A — unit coverage above; the same change is on main.
Related Issues
Backport of #34542. Fixes #34382 on 0.12.x.
Sibling sweep
Siblings: none -- the backport touches the same sites #34542 changed on main
Pattern harvest
Not generalizable: backport of an already-harvested fix (#34542)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.