Skip to content

fix(doctor): wait for hosted child cleanup before settling cancellation - #204750

Draft
vincentkoc wants to merge 9 commits into
mainfrom
fix/doctor-pending-cleanup-20261124
Draft

vincentkoc wants to merge 9 commits into
mainfrom
fix/doctor-pending-cleanup-20261124

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Join the process runner's attached cleanup owner before Doctor classifies a provisional result or releases its caller, command scope, async-work scope and signal-exit registrations. Genuine cleanup uncertainty and original rejection causes remain visible.

The real-child regression returns its outer command callback while nested Doctor cleanup is held, verifies that the outer scope stays pending, then releases the child and joins both outcomes. The existing fixture corrections retain canonical attribution, original behavior assertions and timeouts.

This successor adds fixed labels and monotonic elapsed time to the two existing chat-delivery observer rejections, retaining the original error as the cause. It adds no timer, request, payload or assertion and preserves observer order and cleanup. This is diagnostic only: the observed delivery failure remains unresolved; an unlabelled earlier failure remains unlocalized.

Current evidence and limits

  • Signed candidate ee8ad4087cfdb9cf58eda5b6bfbb2965f2e86e53, tree 600ac3121b53390173a167e4c856357db43cdff5, source base 115e7114dea5c58669b78c3c405c191e085d5874. Eight files: Doctor production +40/-21, tests +270/-6, tooling +6/-0. The 19 net production lines implement one shared cleanup-lifetime boundary.
  • Native source coverage is two reviewed ranges: six complete views from the source base through 6ab055fc, then one complete whole-session view from 6ab055fc through ee8ad408. Both completed with zero findings; unchanged earlier views retain their historical attribution.
  • Current CI run 45471813462 supplies ten of eleven required whole files under both Node and Bun, including all nine Doctor cases, the session fixture, and the RPC helper's ten cases in attempt 2. Attempt 3 ended before the final Git owner began, so its Git Node/Bun results are UNRUN.
  • Separate current-source Darwin arm64 whole-file Git proof completed 21 passed and six Linux-only skipped cases under each Node 26.7.0 and pinned Bun 1.4.4. Both owning invocations and their child/output custody closed successfully. The six held-birth permutations still require Linux evidence; this is not eleven-of-eleven Linux completion.
  • Current owning type/lint, guards and Knip components passed; the CI-artifact build completed with nonfatal CSS/chat budget reports. Current latest-stable updater/Doctor, PostgreSQL 2026.11.5 and native-systemd 2026.10.9 upgrade components passed. The step-11 synthetic version relabel is distinct from the original candidate archive used by PostgreSQL/systemd; these results do not establish universal child extinction.
  • Attempt 3 terminal reconciliation found 163 completed jobs: 130 successful, seven failed, ten skipped and sixteen cancelled. Retained executions, projected skips and new cancelled rows remain distinct. The original observer's pagination inconsistency remains recorded as UNKNOWN; separate reconciliation and all owned processes closed before the original deadline.
  • Baseline sensitivity at the exact source base plus current fixture remains unrun: native source admission and capacity qualification are still missing. No concrete extra physical-disk requirement has been established. Actual hosted Doctor startup cancellation on Linux/Android with verified inference also remains unproven; deterministic process fixtures do not substitute for it.

Earlier-head failures and measurements remain historical. Current source review and component results do not waive broader CI failures, Linux-only gaps, baseline sensitivity, actual-product cancellation, or protected investigation stops. The native assessment remains NEEDS WORK; this PR remains a draft.

Join the retained cleanup owner before Doctor classifies startup cancellation or releases async, command, and signal-exit lifetimes. Preserve genuine cleanup uncertainty and rejection.

Add a held-birth real-child regression and cleanup failure controls. Runtime validation is pending; this does not attribute the observed CI cleanup failure to a proven execution branch.
@vincentkoc vincentkoc self-assigned this Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 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. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M labels Nov 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes hosted Doctor await attached process cleanup and improves supporting test fixtures and failure diagnostics.

Example: On Linux, hosted Doctor is cancelled while process-start identity collection is still pending.

  • Before: Doctor treats the provisional uncertain result as final and releases its lifetime registrations before attached cleanup settles.
  • After: Doctor awaits the existing cleanup promise before reporting cancellation or genuine cleanup uncertainty.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Source review is clean, but the explicitly unfinished behavioral and validation evidence does not support a merge-ready rating.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cancelling hosted Doctor during child startup can report cleanup uncertainty and release lifetime registrations before cleanup finishes.
Reason: The maintainer-authored direction restores the existing cleanup contract with a focused change and no new public behavior or configuration.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored draft open: the cleanup fix addresses a current source-level lifetime gap, and review found no introduced defect, including in the observer diagnostics.

Priority: P2
Reviewed head: ee8ad4087cfdb9cf58eda5b6bfbb2965f2e86e53

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The author should provide redacted shipped-entry-point startup-cancellation evidence showing cleanup completes before caller and shutdown settlement, plus the missing base-red/head-green sensitivity result.
Agent review details

How this fits together

The System agent launches hosted Doctor through the process runner; child output returns to the caller while command, asynchronous-work, and signal-exit owners retain its cleanup lifetime.

flowchart TD
  A[System agent request] --> B[Hosted Doctor owner]
  B --> C[Process runner]
  C --> D[Doctor child]
  C --> E[Attached cleanup promise]
  E --> B
  B --> F[Caller and lifetime settlement]
Loading

Technical review

Best possible solution:

Keep the existing Doctor owner responsible for joining the runner's attached cleanup before any dependent lifetime settles.

Do we have a high-confidence way to reproduce the issue?

Source establishes the Linux startup-cancellation path: the runner can return before attached cleanup settles, while current main immediately classifies that provisional result; no target code was executed during this review.

Is this the best way to solve the issue?

The patch repairs the existing lifetime owner with a direct cleanup join, preserves rejection causes and genuine uncertainty, and adds no competing state or cleanup mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5e5ecba4ed8c.

Provenance checked

  • Hosted Doctor lifetime settlement keeps the original intent (6ae7b96: Keep synchronous Doctor work outside the Gateway while retaining admitted work and cleanup through cancellation.)
  • Hosted cancellation and deadline keeps the original intent (9a1a754: Bound read-only hosted diagnosis and join process-tree cleanup without changing standalone Doctor behavior.)
  • Gateway delivery observer diagnostics keeps the original intent (2d39f43: Consolidate fixture plumbing while retaining owner-boundary delivery assertions.)
  • Manual-check discovery and catalog expectations keeps the original intent (fix(ci): register manual fast-track checks with Knip #204640: Model existing manual consumers in Knip; the separate catalog repair preserves receiver-added export policy and existing latency assertions.)

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:19 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 +19, Tests +264, Other +6. Total +289 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 40 21 +19
Tests 5 270 6 +264
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 6 0 +6
Total 8 316 27 +289

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.

Review metrics

Metric Value Why it matters
Production versus test changes Production +40/-21; tests +270/-6 Production growth joins an existing cleanup owner; test growth covers held startup cleanup and distinct uncertain, rejected, and missing-cleanup outcomes.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The source shows a bounded hosted Doctor cancellation-lifetime defect without evidence of a broad current outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • 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 (2 earlier review cycles)
  • reviewed 2026-11-24T16:29:06.518Z sha cc9fac7 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-24T18:55:56.679Z sha 6ab055f :: needs maintainer review before merge. :: none

Reviewed November 24, 2026, 2:50 PM ET / 19:50 UTC (Revision 3).

Keep the real source driver and foreign command directory while
resolving this checkout's TypeScript package aliases. This fixes the
raw tsx bootstrap failing before launch with normalization-core missing;
argv, private output, descriptor lineage and both runtimes stay covered.

(cherry picked from commit 63d1647)
The receiver adds federated export provenance to shared catalog rows. Include it in the existing exact row assertion while retaining the unchanged peer fixture and latency, coalescing, and failure checks.

Related: #204558

Validated: original focused case reproduces the scheduled CI failure; all 15 catalog Gateway tests pass with the updated expectation. Targeted lint, format, and Gateway-method test typecheck pass.
(cherry picked from commit 4c68c0b)
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling labels Nov 24, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review current head 6ab055fc3dccb68aa66c2ee2617d6c858b70c7e1 and the updated PR body. Read-only focus: the complete changed owner and fixture boundaries, preserved assertions and cleanup, and the recorded source-review and CI evidence with its remaining gaps. This requests review only, with no repair or merge action.

@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please perform a read-only review of exact current head ee8ad40.

Review the diagnostic-only labeling of the two existing chat-event waits. Original rejection causes, timeout budgets, ordering, payloads and cleanup are preserved. Current-head ordinary CI is pending; prior session failure, missing RPC coverage and baseline-red gap remain explicit.

This requests review only; do not repair, merge, change labels or gates, deploy, or reinterpret protected findings as waived.

@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui commands Command implementations gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M 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.

1 participant