Skip to content

fix(acp): share a chat runtime by session tree, not by recorded scratch directory - #37826

Merged
chenmingwei23 merged 1 commit into
mainfrom
fix/resumed-chat-rejoins-tree-process
Nov 16, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
fix/resumed-chat-rejoins-tree-process

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: with ACP runtime sharing on, a team lead and the workers it opened run on one KAS process again after a gateway restart, as #37466 intends for one session tree.

After a gateway restart, the lead and its resumed workers founded separate KAS processes, grouped exactly as they had been before the restart. Only workers created after the restart joined the lead.

Why it matters

Each KAS process costs hundreds of MB. A tree that was ever split (by an older build, or one restart that placed its sessions apart) stayed split on every restart, so the memory saving of tree sharing was lost for exactly the long-lived Ultra Mode trees that need it.

Not a goal

What changed (motivation -> approach -> change)

Symptom: resumed workers of one tree founded their own processes. Cause: a resumed chat binds the scratch directory it was recorded in, and ChatRuntimeKey carried that directory (shared_scratch). Sessions of one tree that ran on separate processes recorded different directories, so their keys never matched again. The earlier fixes (#37579, #37639) only matched a process that mounted the same directory.

Change: shared_scratch leaves ChatRuntimeKey, so sessions of one tree share by tree_root alone. A joiner runs in the directory of the process it joins, which is already what a fresh worker does and what the start path records for the next restart. The workarounds for the keyed directory are removed: _join_own_tree, _published_key_for, RuntimeOwnership.join_on_tree and acquire(published_key=...). runtime-ownership.md says the directory is not a sharing input.

Trade-off, reversing the rule #37579 pinned (test_a_restart_never_joins_a_process_that_does_not_expose_its_tree, deleted here): a resumed worker that joins its tree's process no longer mounts its own old recorded directory, so files it staged there before the restart are not reachable from that process. The maintainer chose this: the scratch directory is being retired as a sharing input, and sharing follows the session tree only. Keeping those files reachable (an extra mount, or refusing to join when the old directory holds content) is left out of this PR.

Those files are not deleted. The old directory's owner is the process that exited with the gateway, so without more the hourly sweep would reclaim it an hour after the join. ChatSharePlacement.place now takes the resumed chat's recorded directory: before the acquisition it holds it for the sweep's grace window (agent_scratch.shared_scratch_window, the same hold a spawn takes on a tree it mounts), and right after a join, before any session setup, it adds the joined process to the directory's owner marker (agent_scratch.adopt_owner, the call companions and successors use) and logs a WARNING naming the session and the directory. The old directory therefore lives exactly as long as the tree's process; once that process exits it is swept by the ordinary rules (a directory holding a git repository is quarantined for 14 days first). If the owner update cannot keep it (stale: the marker still names only dead pids; refused: a planted link), the join is given up and the session founds its own process, which mounts its directory. The sweep itself is unchanged.

Backwards compatibility

Compatible: the key only gets wider inside one tree. With the preview off no key is built, and acquire without published_key publishes under the caller's key, as it did before.

Removes nothing: join_on_tree and published_key had one caller each, both in providers/chat_share.py, both removed here; git grep finds no other reader in src/ or test/.

Known limit: a resumed chat whose working directory sits inside its own old recorded scratch tree, and equals the working directory of the tree's live process, joins that process and no longer sees that directory, because the process does not mount the old tree; this PR adds no guard for it.

Tests

  • test_two_restarts_of_one_tree_with_different_recorded_trees_share: two resumed chats of one tree with different recorded directories get equal keys and the second joins. Red on main.
  • test_chat_runtime_sharing_scratch_keep.py (new; split out because the cleanup test file hit the 2,000-line cap): a joiner's recorded directory gets the shared process as owner, a WARNING names it, the sweep keeps it while the process lives and reclaims it after; a sweep landing between the join and the owner update keeps it (red without the hold); a stale or refused owner update founds the session its own process and leaves the lead's process and lease alone (red without the fallback). The first is red with the adopt_owner call removed.
  • test_a_closed_worker_leaves_one_tenant_and_the_other_keeps_running: closing one of two chats on a process evicts it, drops the process to one lease, keeps the other chat and the process directory, and frees the seat for a new chat.
  • test_preview_off_leaves_a_resumed_chats_recorded_tree_bound: with the preview off nothing is placed and the chat's recorded directory stays bound for its own spawn.
  • Replaced test_a_restart_whose_tree_no_live_process_exposes_keys_that_tree and test_a_restart_never_joins_a_process_that_does_not_expose_its_tree (they asserted the directory is keyed). test_a_founded_start_logs_which_key_fields_kept_it_off now differs on work_dir. shared_scratch moved to the not-keyed list in test_chat_runtime_key_completeness.py with its reason.
  • Ran 41 related test ids, flake8, isort, black, mypy on the changed modules, semgrep on the diff, the flake-pattern ratchet and the pre-push gate (24 gates). The two new placement tests passed 5 runs in reversed order.

Proof: test_two_restarts_of_one_tree_with_different_recorded_trees_share is red on main; each test in test_chat_runtime_sharing_scratch_keep.py is red with its part of the fix removed (head 6e8893e)

Manual verification

Pending: a gateway restart with a lead and resumed workers on the preview, checking the placement lines show joined on the lead's runtime.

Related Issues

Closes #37816
Refs #37817

Sibling sweep

Swept: git grep -n "shared_scratch" -- src/kiro_crew/acp/chat_runtime_sharing.py src/kiro_crew/providers/chat_share.py src/kiro_crew/runtime_ownership.py
Siblings: none -- the sharing key is built in one place (ChatRuntimeKey.build) from one caller (ChatSharePlacement._build_key)

Pattern harvest

Not generalizable: a per-process input keyed for compatibility although the joining path never needed it to match; the key completeness test already makes each field carry a reason.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

Copy link
Copy Markdown
Contributor Author

Remaining ChatRuntimeKey fields after this PR, read for one session tree on KAS. Listed for a maintainer decision; this PR changes none of them.

Field Can it split one tree? Safe to drop?
agent, model, reasoning_effort, spec_generation, launch_agent No: empty on KAS (KAS_PER_SESSION_FIELDS) Already out on KAS
tool_surface_pinned (re-keys agent, spec_generation) Yes, when a spec mounts nothing or grants no Tool Search loader No: KAS fixes MCP and Tool Search per process from the founder's spec
work_dir Yes, a worker in another checkout or worktree No: the process enters the founder's work dir and the payload gates read it
acp_backend / harness_pin Yes, a session pinned to another harness No: different binary and handshake
sandbox_mode (tier) Yes, if tiers differ Security boundary: decision needed
extra_env Yes, a per-session env (project profile, session environment) Security boundary (credentials): decision needed
agent_env Only after an agent.env edit Security boundary (env values): decision needed
spawn_identity Only after a sign-in to another account Security boundary (account): decision needed
forward_ssh_auth_sock Only if the forwarding consent changes Security boundary (ssh-agent): decision needed
member_id, memory_store Only across Bots or stores, never inside one Bot tree Security boundary (Bot isolation): decision needed
kas_telemetry Only with a folder-level opt-out, so it follows work_dir Low risk, but sent once at initialize
tool_search, memory_mode, mcp_gateway_overlay, mcp_gateway_socket No in practice: gateway-wide values, memory_mode is always persistent when sharing Low value to drop
tree_root It is the sharing scope No

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision a410db8607c6137fd9c0e403f20f1dbd2d1476b5 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a410db8607c6137fd9c0e403f20f1dbd2d1476b5 — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks. One rider is stricter than the fix needs: when the old scratch directory has no owner marker, or a garbled one, the session falls back to founding its own process, so the tree splits again in a case the sweep already handles safely.

Notes

  • Item 4 — oversized: if outcome != "recorded" or not await asyncio.to_thread(_names_owner, recorded, pid) gives up the join when the marker is absent or "garbled". Per its own docstring, agent_scratch.adopt_owner (src/kiro_crew/agent_scratch.py:633) returns "recorded" for an absent marker because an unowned tree "leaves the root only after _UNOWNED_IDLE_SECONDS… and then for the quarantine". It also says "the sweep skips such a tree for good" for a garbled marker. Neither case deletes files, yet both re-create the split this PR's Goal removes. Subtraction: delete _names_owner and the "garbled" fallback, and give up the join only on "stale"/"refused". Those are the outcomes the description itself names.

What this change ships

Inventory (7 items) — 6 justified

Intent: after a gateway restart, a team lead and its resumed workers run on one KAS process again (sharing preview on) — FIX.

  1. Resumed workers of one session tree join the lead's process after a restart — justified
  2. A resumed joiner no longer sees files it staged in its old scratch directory (the pin from fix(acp): rejoin the shared chat process a restarted chat's tree lives on #37579 is reversed, which the description declares) — justified
  3. The old directory is held through the sweep window, then owned by the shared process, with a WARNING naming the session — justified
  4. A join whose owner update cannot be read back founds its own process instead — oversized: also splits trees whose marker is absent or garbled
  5. join_on_tree, published_key and _join_own_tree workarounds removed — justified
  6. place/replace_dead take the recorded scratch directory — justified
  7. The runtime-ownership spec now says the scratch directory is not a sharing input — justified

[FIRST-PRINCIPLES-REVIEWED] a410db8

Description read

[DESCRIPTION-READ] f8076b985fe629d45752ab0d10bf7045a855d405186194b79941ccab29ffb023

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of a410db8607c6137fd9c0e403f20f1dbd2d1476b5 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the key now matches the tree it is meant to share, the change only applies while the sharing preview is on, and a revert undoes it.

Notes

  • A resumed worker that joins its tree's process can no longer reach files it staged in its old recorded directory. The PR keeps that directory on disk (adopt_owner plus a WARNING) but adds no way for the agent to find it. Before the preview graduates, decide whether to add a read-only mount or refuse the join when that directory has content.
  • Manual verification is still "Pending". Run the gateway restart check described in the PR before merge: it is the only end-to-end proof that the start path records the joined process's directory for the next restart.

[DESIGN-REVIEWED] a410db8

Description read

[DESCRIPTION-READ] 9ef5755ec96bc3e7a87e4a3d1d512cbf76ac4528abd301b9b6f00f095bcacefd

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of a410db8607c6137fd9c0e403f20f1dbd2d1476b5 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a410db8

False positive or not applicable? A repository writer can comment:
/ai-review override gpt a410db8607c6137fd9c0e403f20f1dbd2d1476b5 false-positive: <reason, 20 to 500 characters>

@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 Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ human override accepted

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

Human judgment by @chenmingwei23 overrides the Opus 5.5 finding for a410db8607c6137fd9c0e403f20f1dbd2d1476b5; the recorded reason is authoritative for this commit.

[OPUS-OVERRIDE] a410db8

Verdict recorded from an authorized human decision for commit a410db8607c6137fd9c0e403f20f1dbd2d1476b5.

False positive or not applicable? A repository writer can comment:
/ai-review override fable a410db8607c6137fd9c0e403f20f1dbd2d1476b5 false-positive: <reason, 20 to 500 characters>

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

target=first-principles span=b2fcff6b2afe needs-a-decision
target=design span=c0d1752a1b3d needs-a-decision

The finding is accurate: a resumed worker that joins its tree's process no longer mounts its old recorded scratch directory, and the pin from #37579 that forbade this is deleted on purpose.
The description now states the reversal and the cost under "What changed" (files staged in the old directory before the restart are not reachable from the joined process).
This is a product trade-off, not a code defect: the maintainer decided the scratch directory stops being a sharing input and sharing follows the session tree only.
@chenmingwei23 please confirm the trade-off in a comment on this PR, then record it with /ai-review override first-principles <head> owner-decision: <link to that comment> ... (and design if you want that lane cleared too). Keeping the old files reachable (an extra mount, or refusing to join when the old directory holds content) would be a follow-up.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override first-principles d7d9193 owner-decision: #37826 (comment) The owner ruled that the scratch directory is retired as a sharing input and only session lineage decides placement; a resumed worker's previously staged scratch files are not mounted after it joins its tree's process.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 recorded a owner-decision release (class owner-decision) for the first-principles AI finding on d7d919373424aa195a0ea719c67257caeaf257b2.

#37826 (comment) The owner ruled that the scratch directory is retired as a sharing input and only session lineage decides placement; a resumed worker's previously staged scratch files are not mounted after it joins its tree's process.

This decision applies only to this commit. A new push requires a new judgment.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Re the Opus and GPT 6.1 finding on d7d919373424 (a joiner's recorded directory losing its live owner and being swept an hour after the join): fixed in 78b1207b69df.

On a join whose recorded directory differs from the one the joined process mounts, ChatSharePlacement.keep_unmounted_scratch (called from the start path where the record moves to the process's directory) adds the joined process to the old directory's owner marker with agent_scratch.adopt_owner and logs a WARNING naming the session and the directory.

The old directory now lives exactly as long as the tree's process. Once that process exits it is swept by the existing rules (a directory holding a git repository is quarantined for 14 days first), the same lifetime as any other scratch directory. This is intentional; the sweep itself is unchanged.

Test: test_a_joiners_unmounted_recorded_tree_lives_as_long_as_the_shared_process (owner marker names the shared process, the sweep keeps the directory while it lives and reclaims it after). Red with the adopt_owner call removed.

@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 Nov 16, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/resumed-chat-rejoins-tree-process branch from 78b1207 to 6e8893e Compare November 16, 2026 06:11
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Findings on 78b1207b69df, addressed in 6e8893eef64f:

  • Backend Ratchets & Boundaries: test/test_chat_runtime_sharing_cleanup.py went over the 2,000-line cap. The new tests moved to test/test_chat_runtime_sharing_scratch_keep.py.
  • GPT F1 (sweep between the join and the owner update): the owner update now runs inside ChatSharePlacement.place, right after the acquisition and before any session setup, and place first holds the recorded directory with agent_scratch.shared_scratch_window (the sweep-locked grace hold a spawn takes on a tree it mounts). Test: test_a_sweep_between_the_join_and_the_adoption_keeps_the_recorded_tree, red without the hold.
  • GPT F2 (stale adoption only logged): a stale or refused owner update now gives up the join and founds the session its own process, which mounts its recorded directory, following the convention adopt_owner documents for spawners. Test: test_an_adoption_that_cannot_keep_the_tree_founds_the_session_its_own_process, red without the fallback.
  • Opus (staged files not reachable after the join, swept once the process exits): this is the recorded maintainer decision in the PR body. The recorded directory is kept for the life of the tree's process and then follows the ordinary sweep rules; mounting it into the joined process is out of scope for this PR.

@chenmingwei23
chenmingwei23 force-pushed the fix/resumed-chat-rejoins-tree-process branch from 6e8893e to 524a8ec Compare November 16, 2026 06:23
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

GPT and Opus finding on 6e8893eef64f (a cancellation in the owner update after _accept leaks the joiner's lease): fixed in 524a8ec47ea0.

ChatSharePlacement.place wraps the _keep_unmounted_scratch call in except BaseException: it takes self.lease, clears it, releases it through _settle_release (shielded, so a second cancellation cannot strand it) and _kill_stranded, then re-raises, as _admit_joiner does. No other await sits between _accept and the return in _place or _place_alone.

Test: test_a_cancellation_during_the_owner_update_releases_the_joiners_lease cancels inside adopt_owner, then checks the joiner holds no lease, the shared process has one tenant, and the last chat's release hands the process back to be closed. Red without the handler.

…ch directory

A resumed chat binds the scratch directory it was recorded in, and the chat
runtime sharing key carried that directory. Sessions of one tree that had run
on separate processes recorded one directory each, so after a gateway restart
they never matched again and the tree stayed split on every restart.

shared_scratch leaves ChatRuntimeKey: sessions of one tree share by tree_root.
A joiner runs in the directory the process it joins mounts, which the start
path already records. The restart-only join on a matching tree
(_join_own_tree, RuntimeOwnership.join_on_tree) and the founder's published
key (_published_key_for, acquire's published_key) existed only to work around
the keyed directory and are removed.

A joiner's earlier recorded directory is not mounted, and its owner is a
process that exited with the gateway, so the sweep would reclaim it an hour
after the join. ChatSharePlacement.place holds that directory for the sweep's
grace window before the acquisition (agent_scratch.shared_scratch_window, as a
spawn holds a tree it mounts) and, right after a join and before any session
setup, adds the joined process to its owner marker (agent_scratch.adopt_owner)
with a WARNING naming the session and the directory: it stays on disk while
the tree's process runs and is then swept by the ordinary rules. Unless the
marker then reads back naming the joined process (an unowned tree answers
"recorded" without a write; "unwritable", "stale", "refused" and "garbled"
keep nothing), the join is given up and the session founds its own process,
which mounts the directory. A failure or cancellation in that step releases
the joiner's lease before it propagates.

Closes #37816
@chenmingwei23
chenmingwei23 force-pushed the fix/resumed-chat-rejoins-tree-process branch from 524a8ec to a410db8 Compare November 16, 2026 06:49
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Findings on 524a8ec47ea0, addressed in a410db8607c6:

  • GPT (chat_share.py, owner update answering "recorded" without a write on an unowned tree, or "unwritable"): the join now stands only when adopt_owner answers "recorded" AND the marker read back the way the sweep reads it names the shared process. Every other answer (unowned, "unwritable", "stale", "refused", "garbled") gives up the join and founds the session its own process, which mounts its directory. Tests: the parametrized test_an_adoption_that_cannot_keep_the_tree_founds_the_session_its_own_process cases plus test_an_unowned_recorded_tree_founds_the_session_its_own_process; four of them are red without the read-back.
  • New-test stability: not a flaky test. test_the_confirmation_is_wired_into_the_placement matched the old share.place(...) call text; it now matches the new call, and its literal-false check walks _place, where the confirming loop lives.

@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 Nov 16, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Owner decision (Mingwei), on head a410db8: accept option A for the Opus finding at chat_share.py:271. Sharing is decided by session-tree lineage only; the scratch dir is being retired as a sharing input. A resumed worker joins its tree's process even when its recorded scratch dir differs. That dir is not mounted after the join; it is kept alive as long as the shared process (adopt_owner) and then follows the normal sweep rules. Files staged there before a gateway restart are not reachable after the join and are removed once the shared process exits. This is an accepted risk; it only affects chats that were running before a restart. The alternative (keep each worker on its own process when its old dir has files) was rejected because it leaves most restarted trees split.

@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override fable a410db8 owner-decision: #37826 (comment) resumed worker joins by tree; old scratch dir not mounted, retained until the shared process exits

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 recorded a owner-decision release (class owner-decision) for the fable AI finding on a410db8607c6137fd9c0e403f20f1dbd2d1476b5.

#37826 (comment) resumed worker joins by tree; old scratch dir not mounted, retained until the shared process exits

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 16, 2026
@chenmingwei23
chenmingwei23 enabled auto-merge (squash) November 16, 2026 10:57
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own.

Approve. Dropping shared_scratch from ChatRuntimeKey lets resumed sessions of one tree share one process again; tree_root stays keyed, so sharing can't cross trees. The removed helpers (join_on_tree, published_key, _join_own_tree, _published_key_for) have no other callers. After a join, place() holds the old recorded directory, adds the joined process to its owner marker and reads it back. If that fails, the session releases its lease and takes its own process, which mounts the directory; the lead's process and lease are untouched and a cancellation also releases the lease. Tests cover each part. The start path then saves the joined process's directory for the next restart (acp_runtime_start.py:1431, get_or_create.py:1661). Only dashboard chats can share, so subagents and companions that inherit a parent's directory never use this path. The one real trade-off, staged files becoming unreachable after a join, was an owner decision recorded for this commit.

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 a410db8607 · 567 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@bolichen97 bolichen97 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.

Approving head a410db8607.

Cross-tree isolation holds. ChatRuntimeKey still keys tree_root and member_id/memory_store, so dropping shared_scratch only widens the key inside one tree. A session whose lineage cannot be read is its own root (share_tree_root_of falls back to the session key; ChatSharePlacement uses tree_root or session_key), so it fails closed to a private process. Every fallback in _keep_unmounted_scratch goes through _place_alone, which sets a unique root and joinable = False.

What the old key guarded. Keying the recorded scratch dir kept a resumed worker on a process that mounts its own old directory, so its staged files stayed reachable. That is the trade-off this PR gives up on purpose (owner decision recorded in the thread). The directory is held for the sweep's grace window before acquisition and adopted by the joined process before session setup, and the join is dropped unless the owner marker reads back naming that pid. So files are not deleted early. Isolation between trees never depended on this field: tree_root already separated them.

Preview off is unchanged: share is None, so place is never called. No new regex in product code.

Tests run locally on this head: the touched files plus the claude, goose and deepseek sharing suites, test_acp_harness_contract.py, test_runtime_ownership*.py and test_subagent_shared_scratch.py: 872 passed. I also added a throwaway probe (not pushed): two different trees that recorded the SAME scratch directory never share, and a session with an unreadable root plus a matching scratch dir stays on its own process. Both passed.

🟡 Non-blocking: _names_owner in providers/chat_share.py calls the private agent_scratch._read_owner_pids. A small public reader in agent_scratch would keep the sweep's read rule in one owner if it ever changes.

AI-assisted, sent by Bolin Review bot

@chenmingwei23
chenmingwei23 merged commit 93511d9 into main Nov 16, 2026
100 of 101 checks passed
@chenmingwei23
chenmingwei23 deleted the fix/resumed-chat-rejoins-tree-process branch November 16, 2026 11:11
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 16, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Heads-up: this landed after #37615, whose test_claude_leaves_each_per_session_field_out_of_the_key still passes shared_scratch=None to ChatRuntimeKey.build. With the parameter gone, its five cases raise TypeError on main (93511d9). #37945 drops the keyword from that test; it is test-only, one line.

bolichen97 added a commit that referenced this pull request Nov 16, 2026
…Key (#37945)

#37615 added test_claude_leaves_each_per_session_field_out_of_the_key
with shared_scratch=None in the ChatRuntimeKey.build call. #37826,
cut before #37615 landed, removed that keyword-only parameter, so on
main the test's five cases raise TypeError and red every backend run.

Drop the keyword from the test's base arguments. The key no longer
carries the scratch directory at all, which is what #37826 intended.

Co-authored-by: Bolin Chen <bolichen@amazon.com>
iamwhatever pushed a commit that referenced this pull request Nov 16, 2026
The memory spec described record-list filters (applies, source,
status, never_recalled), a status-widened refresh and the unforget
and set_tier bulk operations. None of them is in the records or bulk
handlers on main; they belong to the open #37498. The config spec
named SessionAllocation, whose class is SessionAllocationService.
The runtime-ownership paragraph on a restart rejoin is dropped, since
#37826 removed join_on_tree and _join_own_tree.
iamwhatever pushed a commit that referenced this pull request Nov 16, 2026
The memory spec described record-list filters (applies, source,
status, never_recalled), a status-widened refresh and the unforget
and set_tier bulk operations. None of them is in the records or bulk
handlers on main; they belong to the open #37498. The config spec
named SessionAllocation, whose class is SessionAllocationService.
The runtime-ownership paragraph on a restart rejoin is dropped, since
#37826 removed join_on_tree and _join_own_tree.
iamwhatever added a commit that referenced this pull request Nov 16, 2026
* docs: align 40 docs with main after the week of 2026-11-14

Weekly docs-vs-code check of the 304 non-merge commits between
b81cf5a and 5abc52b. Fixes stale owners, renamed classes,
changed defaults and flags, adds rows for CLI subcommands, config
keys and preview names that had none, and moves three RFC status
lines to match what merged.

* docs: drop unbuilt memory record filters and fix a class name

The memory spec described record-list filters (applies, source,
status, never_recalled), a status-widened refresh and the unforget
and set_tier bulk operations. None of them is in the records or bulk
handlers on main; they belong to the open #37498. The config spec
named SessionAllocation, whose class is SessionAllocationService.
The runtime-ownership paragraph on a restart rejoin is dropped, since
#37826 removed join_on_tree and _join_own_tree.

---------

Co-authored-by: zejiangg <zejiangg@amazon.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.

ACP runtime sharing: a resumed worker never rejoins its lead's KAS process after a gateway restart

3 participants