Repository navigation
fix(acp): rejoin the shared chat process a restarted chat's tree lives on - #37579
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the restart joins only a live process that exposes its tree and matches every other key field, and otherwise falls back to the unchanged acquire path. Notes
[DESIGN-REVIEWED] f4aedcd Description read[DESCRIPTION-READ] c5005fd3997c8f1f2861ea4a78fccd60a7f7791b7d50252a6a5c33a14be30bae 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 Nothing blocks: the fix acts on the actual cause — the founder's key leaves the tree empty while a restart's key names it — and is gated on tree identity, so it reaches only a process already mounting that tree. What this change shipsInventory (3 items) — 3 justifiedIntent: when a dashboard chat restarts with ACP runtime sharing on, it should go back to the shared process its work already lives on, not start a second one. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] f4aedcd Description read[DESCRIPTION-READ] 39e908abdcfe03e0bf27ebd65140d66dc12695e02f68a79821c2a5a3859f4b51 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: |
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: |
a897fea to
57b24a1
Compare
|
Disposition for a897fea (First Principles BLOCK, Opus BLOCK, PR Hygiene): all three were real. The edit had dropped the |
57b24a1 to
bc8afca
Compare
|
Disposition for 57b24a1 (GPT BLOCK and Opus BLOCK, same finding): real. Swapping the founder's empty shared_scratch into the key let acquire() pick any same-key process with room, including one on another tree (founder full) or one whose key matched only after the swap. Head bc8afca drops the key swap. A restart now first tries RuntimeOwnership.join_on_tree, which takes only a live runtime that exposes the chat's tree AND equals its key read with shared_scratch="" (so effort, model, agent, account and folder are all still compared), and never spawns. Otherwise the normal acquire runs on the key that still names the tree, so the restart founds a process that mounts it. New test: test_a_restart_never_joins_a_process_that_does_not_expose_its_tree (cap 2, full founder plus a same-key process on another tree). |
bc8afca to
f4aedcd
Compare
|
Disposition for GPT on bc8afca (unbounded test waits): real. Head f4aedcd waits for the pre-warm's gate with async_wait_until on (gate set or task done) and surfaces a pre-warm that failed early via task.result(); the cancelled task is awaited with await_until. Both are bounded by kiro_crew.testing.wait; test_wait_discipline_ratchet.py passes. |
Code change approver recommendation: ApproveWhy: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. The fix targets the real asymmetry: a founder keys shared_scratch="" (provider has no tree when the placement is built) while a restart keys its recorded tree. join_on_tree takes a lease only on a live, open runtime whose key equals the restart's key with shared_scratch blanked and whose work_scratch_dir is the restart's tree. It applies the same admits rule (room, closed, one lease per session key) and never spawns. Any miss falls back to the unchanged acquire on the tree-bearing key, so the restart still starts a process that mounts its tree. The give-up path (unique key) skips the new step, and dead runtimes are dropped first. Only dashboard chats with the preview on are placed this way, and every session on a shared process already shares its tree, so a restart rejoining the process that mounts its own tree crosses no new trust boundary. Three tests cover the race (it would start a second process without the fix), the no-live-tree case and the full-process case. No regression found on main paths or the preview-off path. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
I checked head f4aedcd. join_on_tree uses the same room check, liveness check and lease mint as acquire, plus one test: the runtime's work_scratch_dir must equal the chat's tree. It never spawns. When nothing matches, placement falls back to the unchanged acquire, using the key that still names the tree. Only dashboard chats that are persistent and not members can reach this path, and it sits behind the chat_runtime_sharing preview. Reverting the place hunk fails test_a_chat_restarted_onto_its_shared_tree_rejoins_that_process. Removing the room check or the tree comparison fails the cap 2 negative test. The new tests wait on an Event with bounded timeouts and never sleep.
Done well: the fix stays narrow and fails safe, so a restarted chat can never land on a process that runs on another tree.
Optional:
- Add a short paragraph on the
join_on_treepre-step to the Leases section of docs/system-specs/modules/runtime-ownership.md. Today that section describes placement as key only. - Removing
entry.key == keyfromjoin_on_treeleaves every test green. One test with a live process on the same tree under a differentconfigured_modelorerawould pin the claim that a chat on another model or account does not join. - A founder keyed on a tree it later dropped is still missed by a restart that carries the founder's live tree. This already happens on main, so it can go to #37466 or a follow-up.
Problem / Motivation
Goal: a dashboard chat that restarts with ACP runtime sharing on goes back to the shared process its work already lives on, instead of starting a second one.
With the preview on, a chat that restarts keys its placement on the tree its session was recorded in (
recorded_treeon the resume path insession_allocation_parts/get_or_create.py, or the process it last ran on inproviders/acp_runtime_start.py). The process that founded the shared group allocated that same tree for itself and keyed no tree (shared_scratch=""). The two keys differ only in that field, so the restarted chat founds a second process mounting the same tree.The common way to hit it: a chat's first message arrives while its pre-warm (eager spawn) is still in its handshake. The message takes the start over, the pre-warm is dropped, and the chat restarts with a resume id and the recorded tree. A pod run with three chats on one project showed two processes where one was expected; the placement log reads
spawnedfor the restarted chat right afterleft to first turn (refused)for its pre-warm.KAS is hit on main. KAS is the only member of
ACP_BACKENDS_CHAT_RUNTIME_SHARINGon main, and the restart path is backend-agnostic, so KAS dashboard chats with the preview on lose sharing this way today. The codex and claude chat routes in review (#37472, #37540) and the goose one (#37567) reuse the same placement and would inherit it. #37466 (per-tree KAS sharing) keepsshared_scratchin the key, so the same rule should carry over when it rebases; not checked further here.Why it matters
Each extra process is the memory and start-up cost the preview exists to remove. A user who opens a chat and types at once gets no sharing for that chat, and the operator sees
spawnedwith no refusal line to explain it.Not a goal
ChatSharePlacement.What changed (motivation -> approach -> change)
A restarted chat keyed a path its group's founder never keyed -> let the restart join only the live process that exposes its tree and matches every other field of its key -> one registry join that never spawns, tried before the normal acquisition.
RuntimeOwnership.join_on_tree(key, tree, session_key, cap)(runtime_ownership.py): a lease on a live runtime whose key equalskeyAND whosework_scratch_diristree, with the same room and same-session rule asacquire. It never spawns; on no match it returns None.ChatSharePlacement._join_own_treeandplace(providers/chat_share.py): a chat carrying a tree first triesjoin_on_treewith its key read as the founder's (shared_scratch=""). Every other field is still compared, so a chat on another model, effort, agent, account or folder does not join. When no process on its tree can take it (none alive, or full), the normal acquisition runs on the key that still names the tree, so the restart founds a process that mounts it and never lands on a same-key process on another tree. The confirm-and-retry loop is unchanged.Backwards compatibility
Compatible: only placements with the preview on change, and only a restart whose tree a live shared process with an otherwise equal key exposes and has room for; such a chat now joins that process instead of founding a second one on the same tree.
Tests
test/test_chat_runtime_sharing_cleanup.py::TestChatSharePlacement::test_a_chat_restarted_onto_its_shared_tree_rejoins_that_process: chat A founds a process; chat B's pre-warm joins it and is held mid-handshake on anasyncio.Eventgate (waited on withkiro_crew.testing.waitbounds, so a pre-warm that fails early reports instead of hanging); the first message drops it (the task is cancelled); B restarts carrying A's process's tree and must join that process. No sleeps.test/test_chat_runtime_sharing_cleanup.py::TestChatSharePlacement::test_a_restart_whose_tree_no_live_process_exposes_keys_that_tree: with no live process on the tree, the restart founds its own process and a fresh chat does not land on it.test/test_chat_runtime_sharing_cleanup.py::TestChatSharePlacement::test_a_restart_never_joins_a_process_that_does_not_expose_its_tree: cap 2, the process on the chat's tree is full and a same-key process on another tree has room; the restart founds its own process instead of joining the other tree.test/test_chat_runtime_sharing.py,test/test_chat_runtime_sharing_cleanup.pyandtest/test_runtime_ownership.pypass; flake8, black and isort are clean on the changed files.Proof: PROVEN test/test_chat_runtime_sharing_cleanup.py::TestChatSharePlacement::test_a_chat_restarted_onto_its_shared_tree_rejoins_that_process (head f4aedcd)
Manual verification
Pod run with three goose dashboard chats on one project and the preview on (the #37567 stack, where this was found): without this change, the chat whose first message overtook its pre-warm founded a second process (two chat processes for three chats). The rerun with this change follows on #37567.
Screenshots / video
None: no user-visible surface changes.
Pattern harvest
Not generalizable: one key field that two start paths filled differently (a founder allocates its own tree and keys none; a restart keys the recorded tree). The restart now joins by tree identity (the process that exposes the tree) rather than by an equal spelling of the path.
Related Issues
Part of #5033
Based on main. Found while measuring #37567.
Checklist