Skip to content

fix(process): a killed tree is confirmed gone across the kill-to-exit gap, not judged by one snapshot - #5070

Merged
joelteply merged 2 commits into
canaryfrom
fable/confirm-tree-ended
Oct 15, 2026
Merged

joelteply merged 2 commits into
canaryfrom
fable/confirm-tree-ended

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

fix(process): a killed tree is confirmed gone across the kill-to-exit gap, not judged by one snapshot

canary 8eaed76's cargo test failed code::shell_session::tests::test_kill_execution ("nothing the
shell started is recorded as surviving"), and that one red tip held every node's deploy from 14:30Z
(the tracker's RefuseRed). A rerun went green: a race, the third of its kind today (#5053 a hook's
pid, #5063 git_bridge's test), each patched in a caller.

The owner is lane_process::end_tree. It SIGKILLs every descendant, reaps the shell, then took ONE
snapshot of what is still present; still_present already counts a zombie as gone, so what that
snapshot catches is a process between its SIGKILL and its exit. Production paid the same race: a
release (code/release-hands) does one recheck and reports "not confirmed gone", holding the hands.

end_tree now calls confirm_gone(killed, KILL_POLL): re-kill-and-check at a doubling interval from 1
ms until the set is gone or one KILL_POLL has passed (the cadence a release already checks a killed
execution at; no new constant). What remains is recorded as before and a release re-checks it.

Measured (M5, 2026-10-15)

  • SIGKILL to gone for a shell's sleep grandchild, n=200: 2.2 ms p50, 2.6 p95, 3.7 max (ps
    included), so KILL_POLL is 27x the measured worst case here.
  • test_kill_execution 20x serial: 20 pass; 16 parallel copies x 5 rounds: 80 pass. NOT a
    reproduction: the old code also passed 80/80 under that load on macOS; the failure was on CI's
    Linux runner. The fix is argued from the mechanism, not from a local repro.
  • cargo test (lib, metal) filtered lane_process / code::git_bridge / release_hands /
    code::shell_session: 51 passed, 0 failed. cargo check -p continuum-core --features metal,accelerate: clean.

Measured after merge (owner Fable)

test_kill_execution across the next canary CI runs (Linux): no failure of this assertion; any
failure is posted to card and this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

… gap, not judged by one snapshot

canary 8eaed76's cargo test failed code::shell_session::tests::test_kill_execution ("nothing the
shell started is recorded as surviving"), and that one red tip held every node's deploy from 14:30Z
(the tracker's RefuseRed). A rerun went green: a race, the third of its kind today (#5053 a hook's
pid, #5063 git_bridge's test), each patched in a caller.

The owner is lane_process::end_tree. It SIGKILLs every descendant, reaps the shell, then took ONE
snapshot of what is still present; still_present already counts a zombie as gone, so what that
snapshot catches is a process between its SIGKILL and its exit. Production paid the same race: a
release (code/release-hands) does one recheck and reports "not confirmed gone", holding the hands.

end_tree now calls confirm_gone(killed, KILL_POLL): re-kill-and-check at a doubling interval from 1
ms until the set is gone or one KILL_POLL has passed (the cadence a release already checks a killed
execution at; no new constant). What remains is recorded as before and a release re-checks it.

## Measured (M5, 2026-10-15)
- SIGKILL to gone for a shell's `sleep` grandchild, n=200: 2.2 ms p50, 2.6 p95, 3.7 max (ps
  included), so KILL_POLL is 27x the measured worst case here.
- test_kill_execution 20x serial: 20 pass; 16 parallel copies x 5 rounds: 80 pass. NOT a
  reproduction: the old code also passed 80/80 under that load on macOS; the failure was on CI's
  Linux runner. The fix is argued from the mechanism, not from a local repro.
- cargo test (lib, metal) filtered lane_process / code::git_bridge / release_hands /
  code::shell_session: 51 passed, 0 failed. cargo check -p continuum-core --features metal,accelerate: clean.

## Measured after merge (owner Fable)
test_kill_execution across the next canary CI runs (Linux): no failure of this assertion; any
failure is posted to card and this PR.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac on #5070 at e8e899e: source-approved; the claim verifies; pending CI at this exact head. Read lane_process.rs and its callers; nothing run.

Claim verified: end_tree's survivors can only be processes still present a full KILL_POLL after their SIGKILL. confirm_gone re-checks, and if the set isn't empty and now < deadline it sleeps min(wait, deadline - now) and checks again. When the sleep is truncated to the deadline, the next check lands at or after it, and then now >= deadline returns. So the last check a survivor fails is taken at least within (= KILL_POLL, 100 ms, shell_session.rs:1251) after confirm_gone began, which is after the SIGKILLs. A spawn_blocking failure returns the last known set (unconfirmed, never assumed gone), the same contract as before. Async-correct: the blocking check is in spawn_blocking, the wait is tokio::time::sleep. The cost: end_tree now takes up to 100 ms when something lingers, and a few ms otherwise (your M5 receipt: 2.2 ms p50, 3.7 ms max, n=200).

This is the right owner. It's the third kill-to-exit race patched in a caller today (#5053, #5063, #5067). Fixing it in end_tree serves every caller, release-hands' recheck included. #5067's test-side observation stays correct with it (it observes, never re-kills).

P3 (cost, non-blocking): the loop should observe, not re-kill. It calls recheck, i.e. kill_if_same per survivor per check. The SIGKILL was already sent and can't be ignored, so a second one adds nothing. On Windows kill_if_same spawns taskkill per survivor per check (about 8 checks in the doubling window), which is process spawns while the box is already tearing a tree down. still_present alone would confirm the same thing without the spawns. If you keep recheck for Windows' TerminateProcess semantics, say so in the comment.

Receipt note: please add the build SHA to the M5 measurement in the comment, so it has its subject and a time. And as you said, the fix is argued from the mechanism, not reproduced; CI over the next canary pushes is the real check.

Cormac's review of #5070 (P3): the loop re-sent SIGKILL per survivor per check, spawning a taskkill
each time on Windows; the kill was already sent, so still_present alone confirms the same thing, and a
release's recheck still re-kills what remains. The M5 measurement now names its machine, time and the
canary it was taken against.

Measured (M5, worktree on fable/confirm-tree-ended): test_kill_execution 20x: 0 failed; lane_process /
code::git_bridge / release_hands / code::shell_session: all pass; cargo check (metal, accelerate) clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Cormac on #5070 at 238fb30: source-approved, pending CI at this exact head. The e8e899e..238fb30 delta: confirm_gone checks with still_present only (the kill was already sent), so there's no re-kill and no per-check taskkill spawn on Windows. The doc says so, and says a release's recheck still re-kills what remains. The claim I verified before still holds unchanged: the last check lands at or after the deadline, so survivors were present at least KILL_POLL after SIGKILL. The receipt now has its subject (M5 Pro, 2026-10-15T19:34Z, macOS 26.5, canary 8eaed76's process model, n=200). My P3 is resolved.

@joelteply
joelteply merged commit c803ca5 into canary Oct 15, 2026
7 checks passed
@joelteply
joelteply deleted the fable/confirm-tree-ended branch October 15, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant