fix: gracefully escalate process supervisor cancellations#85865
Conversation
|
Codex review: needs maintainer review before merge. Latest ClawSweeper review: 2026-05-24 01:07 UTC / May 23, 2026, 9:07 PM ET. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
PR Surface View PR surface stats
Summary Reproducibility: yes. by source and supplied live proof, though I did not rerun it in this read-only review. Current PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the narrow tree-aware SIGTERM grace fix after maintainer review and checks, while leaving the broader drain-timeout and pipe-close follow-up in the linked issue. Do we have a high-confidence way to reproduce the issue? Yes by source and supplied live proof, though I did not rerun it in this read-only review. Current Is this the best way to solve the issue? Yes. Threading a bounded grace option through the existing supervisor adapter contract is the narrow maintainable fix; the broader drain-timeout and pipe-close ideas should stay in the linked follow-up issue. Label justifications:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against acf265d4d51d. |
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Clockwork Signal Puff Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper hatch |
|
🦞👀 I queued a comment sync for this PR. If the egg is hatchable, ClawSweeper will generate the image once and update the existing review comment. |
|
ClawSweeper could not hatch this PR egg yet. Reason: there is no current durable ClawSweeper review record for this PR, so there is no PR egg state record to update. |
c90757c to
8470ec5
Compare
|
Verification for Behavior addressed: process supervisor cancellation now owns the bounded
|
…5865) * fix: gracefully escalate supervisor cancellations * fix: preserve process-tree cancellation during grace * fix: satisfy signal monitor allSettled lint * fix(process): split graceful cancel signal escalation --------- Co-authored-by: JARVIS-Glasses <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…5865) * fix: gracefully escalate supervisor cancellations * fix: preserve process-tree cancellation during grace * fix: satisfy signal monitor allSettled lint * fix(process): split graceful cancel signal escalation --------- Co-authored-by: JARVIS-Glasses <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…5865) * fix: gracefully escalate supervisor cancellations * fix: preserve process-tree cancellation during grace * fix: satisfy signal monitor allSettled lint * fix(process): split graceful cancel signal escalation --------- Co-authored-by: JARVIS-Glasses <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…5865) * fix: gracefully escalate supervisor cancellations * fix: preserve process-tree cancellation during grace * fix: satisfy signal monitor allSettled lint * fix(process): split graceful cancel signal escalation --------- Co-authored-by: JARVIS-Glasses <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…5865) * fix: gracefully escalate supervisor cancellations * fix: preserve process-tree cancellation during grace * fix: satisfy signal monitor allSettled lint * fix(process): split graceful cancel signal escalation --------- Co-authored-by: JARVIS-Glasses <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…5865) * fix: gracefully escalate supervisor cancellations * fix: preserve process-tree cancellation during grace * fix: satisfy signal monitor allSettled lint * fix(process): split graceful cancel signal escalation --------- Co-authored-by: JARVIS-Glasses <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…5865) * fix: gracefully escalate supervisor cancellations * fix: preserve process-tree cancellation during grace * fix: satisfy signal monitor allSettled lint * fix(process): split graceful cancel signal escalation --------- Co-authored-by: JARVIS-Glasses <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…5865) * fix: gracefully escalate supervisor cancellations * fix: preserve process-tree cancellation during grace * fix: satisfy signal monitor allSettled lint * fix(process): split graceful cancel signal escalation --------- Co-authored-by: JARVIS-Glasses <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
Summary
adapter.kill("SIGTERM", { graceMs: 5000 }); child and PTY adapters route SIGTERM throughkillProcessTree; tests cover tree-aware SIGTERM and no-detach safeguards.Motivation
Timeouts can happen while tool subprocesses are writing session state, cleaning temp files, or closing resources. This PR gives subprocesses a bounded graceful shutdown window while preserving the existing process-tree stop guarantee for descendants.
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Real behavior proof (required for external PRs)
corepack pnpm install --frozen-lockfile. The descendant regression was run against old PR heade7ed7242ceb18783de1559d6dd700c973d2b726c, then after applying the tree-aware patch that produced head720a57df0358976503d2ec501fb68e32d8ecb910.{ "proof": "process-supervisor-graceful-cancel-66399", "cleanupCase": { "name": "cleanup", "exitReason": "overall-timeout", "exitCode": 0, "exitSignal": null, "timedOut": true, "stdout": [ "child_ready=true", "child_observed_sigterm=true", "child_finished_async_cleanup=true" ], "markerWritten": true }, "fallbackCase": { "name": "fallback", "exitReason": "overall-timeout", "exitCode": null, "exitSignal": "SIGKILL", "timedOut": true, "stdout": [ "child_ready=true", "child_observed_sigterm=true", "child_ignores_sigterm=true" ], "markerWritten": false }, "descendantCase": { "name": "descendant", "exitReason": "overall-timeout", "exitCode": 0, "exitSignal": null, "timedOut": true, "stdout": [ "parent_ready=true", "descendant_pid=43906" ], "parentMarkerWritten": true, "descendantMarkerWritten": true, "descendantPid": 43906, "descendantAliveAfterWait": false } }{ "proof": "process-supervisor-graceful-cancel-66399", "descendantCase": { "name": "descendant", "exitReason": "overall-timeout", "exitCode": 0, "exitSignal": null, "timedOut": true, "stdout": [ "parent_ready=true", "descendant_pid=43701" ], "parentMarkerWritten": true, "descendantMarkerWritten": false, "descendantPid": 43701, "descendantAliveAfterWait": true } }Root Cause (if applicable)
adapter.kill("SIGTERM"), but the child adapter treated non-SIGKILL signals as direct child-only signals instead of using the process-tree path.Regression Test Plan (if applicable)
src/process/supervisor/supervisor.test.ts,src/process/supervisor/adapters/child.test.ts,src/process/supervisor/adapters/pty.test.tskill-tree.test.tsalready covers the underlying process-group/direct-pid behavior; this PR adds adapter-level coverage for SIGTERM using that path.User-visible / Behavior Changes
Timed-out or cancelled exec/tool subprocesses now get a bounded 5s tree-aware SIGTERM cleanup window before SIGKILL. Processes or descendants that ignore SIGTERM are still force-killed by the existing process-tree path.
Diagram (if applicable)
Security Impact (required)
Yes/No): NoYes/No): NoYes/No): NoYes/No): YesYes/No): NoYes, explain risk + mitigation: cancellation behavior changed in the command execution boundary. The mitigation is that SIGTERM now uses the existing process-tree kill helper and preserves detached:false safeguards before the bounded SIGKILL fallback.Repro + Verification
Environment
Steps
e7ed7242ceb18783de1559d6dd700c973d2b726cto reproduce direct-child-only SIGTERM leaving a descendant alive.Expected
Actual
Evidence
Attach at least one:
Additional verification run on the same throwaway checkout after applying the patch:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
No inline review threads exist. The top-level ClawSweeper finding about process-tree cancellation is addressed by the latest commit.
Compatibility / Migration
Yes/No): YesYes/No): NoYes/No): NoRisks and Mitigations
{ detached: false }when spawn falls back to no-detach or service-managed mode disables detachment.