Repository navigation
fix: report cancellation after hosted Doctor stops - #208096
Conversation
Join the command runner’s retained cleanup before classifying an early cancellation. The caller, command scope and signal exit gate now use the same outcome without changing signal escalation or uncertainty handling. Co-authored-by: daniel-lxs <[email protected]>
Worked on by: - @daniel-lxs Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: 3073d9e5-710f-4bdb-b1e9-3f79a042ed65
Worked on by: - @daniel-lxs Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: b18f0032-f420-4994-824d-88e75b45b04e
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. |
|
Codex review: passed. What this changesHosted Doctor waits for retained process cleanup before classifying cancellation and preserves buffered diagnostics when cleanup remains uncertain. Example: Cancel hosted Doctor while Linux process identification is still pending and its worker honors SIGTERM.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a focused fix for a current-main cancellation bug; no actionable defects were found, and exact-head CI is still running. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe System agent invokes Doctor in a child process; the parent forwards diagnostics and joins the process runner’s cleanup before releasing its caller and lifecycle registrations. flowchart TD
A[System agent request] --> B[Hosted Doctor owner]
B --> C[Process runner]
C --> D[Doctor child]
D --> E[Diagnostic output]
C --> F[Retained cleanup]
F --> B
E --> B
B --> G[Caller outcome]
Technical reviewBest possible solution: Keep the existing runner cleanup owner and let Doctor join its final result before reporting cancellation or cleanup uncertainty. Do we have a high-confidence way to reproduce the issue? Source establishes the race: the runner can return provisional cleanup uncertainty before identification settles, while current-main Doctor immediately treats that result as final; the added Linux case forces this ordering without removing existing assertions. Is this the best way to solve the issue? The patch repairs the Doctor consumer of the existing provisional-result contract without changing generic runner deadlines, process ownership, configuration, or escalation policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 407b5233029c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +7, Tests +31. Total +38 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 29, 2026, 3:47 AM ET / 08:47 UTC (Revision 2). |
Join the retained cleanup result inside the tracked worker. Flush any pending output before the caller reports that result, while the scope and exit gate continue to observe the same cleanup failure. Co-authored-by: daniel-lxs <[email protected]>
Worked on by: - @daniel-lxs Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: 2d79060b-bc54-4428-9e3a-888aed99dec8
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Wait for the command runner to confirm that the hosted Doctor worker stopped before reporting cancellation. Flush the final diagnostic when cleanup remains uncertain. Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: 3073d9e5-710f-4bdb-b1e9-3f79a042ed65 OpenClaw-Publication: b18f0032-f420-4994-824d-88e75b45b04e OpenClaw-Publication: 2d79060b-bc54-4428-9e3a-888aed99dec8 (cherry picked from commit fba18be) Release adaptation: Preserve stable's existing provisional cleanup join and delayed Linux identity coverage from 7dcaef8. Flush buffered output when that worker settles, including rejection; keep the existing cancellation, scope and signal-exit gates. Companion audit: delayed-admission fixture and process owner are present-equivalent in 7dcaef8. No later same-path or SHA follow-ups. PR mentions 16a2d4b (log search), 21786f6 (localization), 9cec330 (workboard) and 34d4f8f (Doctor cron/sandbox inventory) are unrelated to hosted Doctor process settlement and are not applicable. Co-authored-by: RomneyDa <[email protected]>
Wait for the command runner to confirm that the hosted Doctor worker stopped before reporting cancellation. Flush the final diagnostic when cleanup remains uncertain. Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: 3073d9e5-710f-4bdb-b1e9-3f79a042ed65 OpenClaw-Publication: b18f0032-f420-4994-824d-88e75b45b04e OpenClaw-Publication: 2d79060b-bc54-4428-9e3a-888aed99dec8
What Problem This Solves
Cancelling hosted Doctor just as its worker starts can report “Command cleanup could not confirm that owned work stopped” instead of an abort. The main CI failure hit this with a worker that honored SIGTERM.
User Impact
The caller gets its abort after the worker’s process group is confirmed gone. If cleanup cannot be confirmed, the caller still gets the cleanup error and Doctor delivers any buffered final diagnostic, even without a trailing newline. No configuration, migration or timeout changes.
Why This Change Was Made
The runner can return before its Linux process-identity read finishes. It attaches the final cleanup promise to that provisional result. Doctor waits for that promise inside the tracked worker, so the caller, command scope and signal-exit gate observe one outcome. The caller flushes buffered output before reporting cleanup uncertainty. This preserves the bounded runner result and process-tree ownership decisions in #197510 and #191125.
Related: #204750 addresses the same race. These are alternatives. This PR changes the Doctor owner and two Doctor test files (+46/−8, production +12/−5). Vincent’s changes eight files (+316/−27, production +40/−21), with extra coverage of nested lifetimes and cleanup failures, as well as tooling and fixtures outside Doctor.
Evidence
a012e91c, the unchanged stress test reproduced the cleanup error with a SIGTERM-ignoring child. Delaying identification until readiness reproduced the exact CI assertion with a cooperative child. Neither original case lost an assertion.27a4b1cfound no actionable defects and favored the focused repair, but the reviewer could not inspect the CrabBox capture. Independently, a comparison showed that revision dropped the final stderr line without a trailing newline on uncertain cleanup. The new regression failed there (expected [] to include 'last diagnostic') and passed on repair019d8786, whose tree matches published headffb0057. Both the final line and the genuine cleanup error are preserved.c7a.8xlargemachines, eight CPU burners shared four CPUs with the tests. Identical fixture bytes, CI-pinned Bun, zero retries. This repair and Vincent’s matrix each passed 300/300 mixed cases, including 100 forced early cancellations, plus 300/300 additional cooperative cases. Native Doctor suites: 10/10 here, 12/12 there; the suites differ. Format, focused lint and both owning typechecks passed on the repair.No surviving PID or process group: both probes returned
ESRCHin 25/25 timed real-worker cancellations on each head. These timings are observations, not a speed advantage. The AWS leases were released. Not verified here: full updated-head GitHub CI, a live model-initiated session, or non-Linux behavior.Credit: @daniel-lxs for the CI report and reproduction request.
Work sessions
Linked for team reference; these sessions aren’t public.
Worked on by