Skip to content

fix: report cancellation after hosted Doctor stops - #208096

Merged
daniel-lxs merged 6 commits into
mainfrom
openclaw/main-ci-failures-sweep-744e7f
Nov 29, 2026
Merged

daniel-lxs merged 6 commits into
mainfrom
openclaw/main-ci-failures-sweep-744e7f

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • On main 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.
  • The review of 27a4b1c found 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 repair 019d8786, whose tree matches published head ffb0057. Both the final line and the genuine cleanup error are preserved.
  • On matched AWS c7a.8xlarge machines, 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.
Stop to observed abort, median / p95 (ms), 25 samples per row per head This repair #204750 timing run
Real Doctor worker 26.5 / 32.0 26.4 / 31.5
Cooperative child 26.2 / 30.2 25.4 / 28.1
Cancellation before identification settles 27.0 / 29.1 25.4 / 28.2
Child ignores SIGTERM 328.0 / 333.5 327.2 / 332.0

No surviving PID or process group: both probes returned ESRCH in 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

roboclaw-bot and others added 3 commits November 29, 2026 06:04
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
@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S labels Nov 29, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 29, 2026
@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

Hosted 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.

  • Before: The caller can receive “Command cleanup could not confirm that owned work stopped” despite successful cleanup.
  • After: The caller receives an abort after cleanup confirms the worker stopped.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation and distinct regressions support correctness; inaccessible runtime captures limit independently inspected proof.
Proof confidence 🦐 gold shrimp (3/6) This PR is exempt from contributor proof requirements; its body reports actual Linux Doctor-worker cancellation with PID and process-group ESRCH observations, but the linked captures were inaccessible and no target code was executed during this review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cancelling hosted Doctor can report cleanup failure even though its worker stops successfully.
Reason: This maintainer-authored repair restores the established cancellation contract with a small change at the existing Doctor owner.

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: d63695af3b7fe0e97e4cc0a775a5a90cfc65d278

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Hosted Doctor subprocess and cleanup settlement keeps the original intent (6ae7b96: Keep Gateway requests responsive by moving synchronous Doctor work into a child while retaining cleanup settlement before releasing callers.)
  • Hosted Doctor cancellation and bounded lifetime keeps the original intent (9a1a754: Prevent hosted diagnosis from stalling live sessions by propagating cancellation, bounding execution, and joining process-tree cleanup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 6ae7b96 adds src/commands/doctor-process.ts:52 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6ae7b962344a; files: src/commands/doctor-process.ts)

PR surface

Source +7, Tests +31. Total +38 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 12 5 +7
Tests 2 34 3 +31
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 46 8 +38

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on maintainer: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-29T07:16:46.923Z sha 27a4b1c :: ready, awaiting a maintainer decision. :: none

Reviewed November 29, 2026, 3:47 AM ET / 08:47 UTC (Revision 2).

roboclaw-bot and others added 3 commits November 29, 2026 07:44
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
@daniel-lxs
daniel-lxs marked this pull request as ready for review November 29, 2026 08:42
@daniel-lxs

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 29, 2026
@daniel-lxs
daniel-lxs merged commit fba18be into main Nov 29, 2026
187 checks passed
@daniel-lxs
daniel-lxs deleted the openclaw/main-ci-failures-sweep-744e7f branch November 29, 2026 08:59
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 30, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants