Skip to content

Never kill a replacement Session from a stale Tool stop - #1286

Merged
nedtwigg merged 2 commits into
mainfrom
audit-tool-reap-race
Oct 21, 2026
Merged

nedtwigg merged 2 commits into
mainfrom
audit-tool-reap-race

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

A reap's stop writes Ctrl+C, waits for the prompt or a 3s grace, then kills the PTY. The "closed meanwhile" guard checked only registry.has(id), so a Session that reused the id during that wait would be killed by the old stop. The guard now compares the registry entry captured before the interrupt.

The stop is otherwise not cancellable, and docs/specs/dor-tool.md -> Reaping now says so. Once Ctrl+C is written the run has usually exited. Abandoning the kill at that point restores nothing: it lapses the host hold, turns the Tool into a plain terminal, and drops the payload the stop captured. Finishing the stop leaves a Tool that rehydrates from that payload. A Tool shown during the stop already rehydrates once the stop resolves.

Validation: the new test fails with the old guard and passes with the new one; all 992 tests in lib/src/components/wall/ pass; tsc -b, spec lint, and Markdown lint pass.

🤖 Generated with Claude Code

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: e2e4351
Status: ✅  Deploy successful!
Preview URL: https://5f16c1bf.mouseterm.pages.dev
Branch Preview URL: https://audit-tool-reap-race.mouseterm.pages.dev

View logs

…rupted

Abandoning the kill after Ctrl+C restored nothing: the run had already
exited, so it lapsed the host hold, turned the Tool into a plain
terminal, and dropped the captured payload. Keep only the identity
check, so a Session reusing the id mid-stop is never killed, and state
in the spec that a stop is never abandoned once interrupted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nedtwigg nedtwigg changed the title Keep new work alive when an idle Tool stop becomes stale Never kill a replacement Session from a stale Tool stop Oct 21, 2026
@nedtwigg
nedtwigg merged commit 01d59da into main Oct 21, 2026
15 checks passed
@nedtwigg
nedtwigg deleted the audit-tool-reap-race branch October 21, 2026 17:06
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.

2 participants