Skip to content

fix: avoid false update cleanup failures when the host is busy - #150392

Merged
steipete merged 1 commit into
mainfrom
upd/flake-managed-handoff-validate
Sep 17, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/flake-managed-handoff-validate

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #150244, #149005

What Problem This Solves

Fixes managed update repair reporting failed process cleanup after its child processes have already stopped while the host event loop is busy.

User Impact

Repairs can finish when native process-group and output completion are confirmed. Missing authority, live descendants, and unfinished output retain their existing failures.

Why This Change Was Made

The deadline introduced in #149005 could reject cleanup before Node delivered queued native exit and pipe events. The relay owner now lets one I/O poll deliver those facts before final timeout rejection and starts its existing extinction join at control EOF. The five-second budget is unchanged, and repeated cancellation cannot renew it.

This changes the loaded runtime's cleanup owner. It adds no protocol, configuration, schema, or dependency changes; installed updater code and the existing backup/rollback paths retain their behavior.

Evidence

  • Original hosted failure: https://github.com/openclaw/openclaw/actions/runs/35138469387/job/104937134432
  • Attribution: faad1d457de (fix: wait for owned stdio cleanup without premature timeout #149005), the direct setTimeout(expireCleanup, ...) call at line 316. A real-process probe passes with its parent host, fails on main, and passes with this fix. The relevant host/relay/anchor sources are unchanged between the failing branch's eb8bca1326c base and tested main 387da5edaa9.
  • The new regression independently confirms process-group disappearance before the original deadline, then holds the host past that deadline. Before this fix it fails with the exact hosted pending vector: closing receipt, lineage EOF, and output EOF observed; relay exit/control closure still queued. No original handoff assertion was changed. The original hosted process was not instrumented, so the exact synchronous work that delayed its callbacks remains unknown.
  • Main baseline: 10/10 complete lifecycle-file runs passed, 181 cases per run. Ten exact hosted-shard selections produced six passes and four separate failures. The reported repair case passed 9/9 times reached; one config failure prevented it from running.
  • Post-fix full handoff/canary and process-lifecycle proof: 261 cases passed, including all four repair-authority variants and all 50 existing relay-owner negative cases. The canary uses published-driver markers and verifies candidate cleanup; this is boundary proof, not an executed published-package upgrade.
  • Final integrated source: the original repair case passed 20/20 executions, the native retirement regression passed 20/20, and all 92 relay-owner/caller/readiness/real child-lifecycle cases passed. Vitest repeats ran with retries disabled; any failed repetition fails the run.
  • The complete changed gate passed on both the initial and refreshed bases. Fresh Codex branch review (--mode branch --base origin/main --max-priority P1) is scoped-clean, with no accepted/actionable P0/P1 findings.

The other baseline failures were the native-control interval case (attempts 1 and 10), a config.set request timeout (attempt 3), and a launchd command-order assertion (attempt 5). The config-reread warning in the original hosted log belongs to a passing neighboring config test.

An initial filtered proof timed out while parallel proof commands rebuilt shared dist; the exact stall was not captured. An observed cold run then passed every gate in 27.5 seconds, and further runtime proof uses one build owner at a time. The new observer also exposed Darwin's transient EPERM for an unreaped group; it now keeps that state unconfirmed and still requires ESRCH before the unchanged deadline.

A later main landing (#147903) split this factory into { adapter, ready }. The task branch was refreshed to 307255794c4, and the new regression consumes that contract. The unfixed owner reproduced the same hosted pending vector on this refreshed base before the patch was reapplied. Local proof ran on macOS with Node 26.8.2; hosted Linux CI supplies the platform check.

Production: +14/-2 lines (net +12). Tests: +203 lines. Docs: +2 lines. No baseline, timeout, or dependency changes.

Let queued native exit and EOF events settle before final cleanup timeout
rejection, and begin the existing authority join at control EOF. Preserve
the deadline and all native cleanup checks.

Cover the busy-host race with an independent native retirement observer.
Related: #149005, #150244
@clawsweeper

clawsweeper Bot commented Sep 16, 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 docs Improvements or additions to documentation gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Sep 16, 2026
@steipete
steipete marked this pull request as ready for review September 16, 2026 23:59
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 8:06 PM ET / September 17, 2026, 00:06 UTC.

ClawSweeper review

What this changes

The PR lets queued process-exit and pipe events settle before reporting cleanup timeout, with a real-process regression and updated documentation.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main retains the timeout race, and the related PRs do not replace this work. No blocking correctness defect was found.

Priority: P2
Reviewed head: 4f7b1869aae45555de5be8bbe6549b93f046bd98

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful native-process regression coverage and no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this member-authored PR. Its captured evidence reports real macOS relay/anchor retirement under an injected host stall and successful after-fix joins; the inspected regression matches that scenario, while published-package upgrade execution is explicitly unclaimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this member-authored PR. Its captured evidence reports real macOS relay/anchor retirement under an injected host stall and successful after-fix joins; the inspected regression matches that scenario, while published-package upgrade execution is explicitly unclaimed.
Evidence reviewed 7 items Introduced scope and current-main necessity: The host-verified introduced delta contains only the relay owner, its new regression, and background-process documentation. Comparing the merge base with fetched main produces no change to the relay owner, so main still has the original direct timeout callback. The verified test merge preserves that same three-file scope.
Cleanup invariants remain intact: The complete owner still requires a matching closing receipt, relay exit, lineage EOF, and an ESRCH process-group observation. Output completion remains independently required. Earlier control EOF starts the existing join; it does not itself certify extinction, renew the deadline, or restore lost authority.
Regression exercises actual native retirement: The new test wraps actual spawn calls, uses the production relay and anchor, blocks the host after acknowledgment delivery, and independently observes process-group disappearance. It asserts successful result and extinction joins after queued callbacks arrive. The captured PR body reports 20/20 executions on macOS with Node 26.8.2; these runs were not independently executed during this read-only review.
Findings None None.
Security None None.

How this fits together

OpenClaw’s process supervisor manages child commands used by tools and managed update repair. Its relay combines native process termination and output completion into the cleanup result consumed by callers.

flowchart TD
  A[Command or update repair] --> B[Process supervisor]
  B --> C[Relay and process-group anchor]
  C --> D[Exit and pipe events]
  D --> E[Cleanup owner]
  F[Cleanup deadline] --> E
  E --> G[Confirmed completion or cleanup error]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +12, Tests +203, Docs +2. Total +217 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 14 2 +12
Tests 1 203 0 +203
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 219 2 +217

Review metrics

None.

Technical review

Best possible solution:

Keep cleanup decisions in the existing relay owner, allowing queued completion facts to settle while preserving native extinction checks and bounded failure.

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

Yes, source establishes a concrete path: block the host after closing acknowledgment while native retirement finishes, then deliver queued exit and pipe events after the deadline. The supplied regression targets that path; this review did not execute it or establish the original hosted stall’s exact cause.

Is this the best way to solve the issue?

Yes. The patch repairs event-delivery ordering within the existing owner without extending the configured deadline or accepting root exit alone as cleanup proof.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4428de2785a2.

Labels

Label changes:

  • add P2: This addresses a bounded process-cleanup race affecting managed repair, without evidence of a widespread user-facing outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this member-authored PR. Its captured evidence reports real macOS relay/anchor retirement under an injected host stall and successful after-fix joins; the inspected regression matches that scenario, while published-package upgrade execution is explicitly unclaimed.

Label justifications:

  • P2: This addresses a bounded process-cleanup race affecting managed repair, without evidence of a widespread user-facing outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this member-authored PR. Its captured evidence reports real macOS relay/anchor retirement under an injected host stall and successful after-fix joins; the inspected regression matches that scenario, while published-package upgrade execution is explicitly unclaimed.

Evidence

What I checked:

  • Introduced scope and current-main necessity: The host-verified introduced delta contains only the relay owner, its new regression, and background-process documentation. Comparing the merge base with fetched main produces no change to the relay owner, so main still has the original direct timeout callback. The verified test merge preserves that same three-file scope. (src/process/supervisor/service-child-relay-host.ts:289, 4428de2785a2)
  • Cleanup invariants remain intact: The complete owner still requires a matching closing receipt, relay exit, lineage EOF, and an ESRCH process-group observation. Output completion remains independently required. Earlier control EOF starts the existing join; it does not itself certify extinction, renew the deadline, or restore lost authority. (src/process/supervisor/service-child-relay-host.ts:382, 4f7b1869aae4)
  • Regression exercises actual native retirement: The new test wraps actual spawn calls, uses the production relay and anchor, blocks the host after acknowledgment delivery, and independently observes process-group disappearance. It asserts successful result and extinction joins after queued callbacks arrive. The captured PR body reports 20/20 executions on macOS with Node 26.8.2; these runs were not independently executed during this read-only review. (src/process/supervisor/service-child-relay-host.retirement.test.ts:164, 4f7b1869aae4)
  • Negative cleanup coverage is retained: Existing tests retain explicit failures for missing receipts, unconfirmed group disappearance, missing lineage EOF, unfinished output, and repeated cancellation without deadline renewal. The proposed patch does not weaken these assertions. (src/process/supervisor/service-child-relay-host.test.ts:813, 4f7b1869aae4)
  • Production boundary and upgrade scope: The child adapter selects this owner for POSIX process-tree ownership and managed-service markers. The PR changes no persisted state, launch authorization, protocol, configuration, installed updater, or backup/rollback implementation. Its captured evidence expressly describes published-driver-marker canary coverage as boundary proof, not an executed published-package upgrade. The changed behavior does not depend on the Codex runtime contract. (src/process/supervisor/adapters/child.ts:167, 4f7b1869aae4)
  • Area history and routing: Current-main history records recent cleanup work by Peter Steinberger, Vincent Koc, and Jason (Json). The supplied GitHub context verifies fix: wait for owned stdio cleanup without premature timeout #149005 and fix(codex): recover admitted native completions after restart #147903 as merged. Some historical objects prevented full blame/parent-patch inspection, so this review makes no verified introduction or causal attribution claim. (src/process/supervisor/service-child-relay-host.ts, 4428de2785a2)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 7b6094e into main Sep 17, 2026
284 checks passed
@steipete
steipete deleted the upd/flake-managed-handoff-validate branch September 17, 2026 00:23
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 17, 2026
Merge current main while retaining #150392 control-EOF joining and deferred expiry. Route extinction wait failures through the retained finalization outcome, and revalidate authority after both observational joins before probing the process group. The PR adds no dependency or protocol changes.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 17, 2026
…claw#150392)

Fix managed update repair reporting failed process cleanup after its child processes have already stopped while the host event loop is busy.

The deadline introduced by openclaw#149005 could reject before Node delivered queued native exit and pipe events, producing the update-managed-service handoff lifecycle failure. The existing relay cleanup owner now lets one I/O poll deliver those facts before final timeout rejection and starts its existing extinction join at control EOF. The five-second budget is unchanged, and repeated cancellation cannot renew it. Missing authority, live descendants, and unfinished output still fail.

The regression reproduces the original pending-completion vector on the unfixed owner. The candidate native-retirement case and original repair case each passed 20 executions; integrated relay-owner/caller/readiness/child lifecycle proof passed 92 cases. Changed gates and the scoped P0/P1 review passed. Published-driver markers have boundary coverage; this does not claim an executed published-package upgrade. Installed updater code and existing backup/rollback paths retain their behavior.

Related: openclaw#150244, openclaw#149005
steipete added a commit that referenced this pull request Sep 17, 2026
Merge current main while retaining #150392 control-EOF joining and deferred expiry. Route extinction wait failures through the retained finalization outcome, and revalidate authority after both observational joins before probing the process group. The PR adds no dependency or protocol changes.
steipete added a commit that referenced this pull request Sep 17, 2026
Merge current main while retaining #150392 control-EOF joining and deferred expiry. Route extinction wait failures through the retained finalization outcome, and revalidate authority after both observational joins before probing the process group. The PR adds no dependency or protocol changes.
steipete added a commit that referenced this pull request Sep 17, 2026
Merge current main while retaining #150392 control-EOF joining and deferred expiry. Route extinction wait failures through the retained finalization outcome, and revalidate authority after both observational joins before probing the process group. The PR adds no dependency or protocol changes.
steipete added a commit that referenced this pull request Sep 17, 2026
Keep child cleanup and eager supervised-process failures visible to callers without letting unobserved rejections crash the Gateway. Publish the retained cleanup promise at the sole spawnServiceChildRelay creation site, join authority finalization and admitted tree signaling, and preserve retained-handle escalation, forced-exit diagnostics, output drainage, and cleanup deadlines. Uncertain extinction remains a failure.

Include redacted error stacks in Gateway stability bundles, bounded to 8,000 UTF-16 code units; older bundles without stacks remain readable. No configuration, CLI option, dependency, schema version, or installed update-driver behavior changes. The runtime repair takes effect when the candidate Gateway starts.

Related: #144911, #144941. Preserve integration with #150306, #150392, and #150564. The earlier MCP field-crash path is separately contained by #144941; this change closes remaining unobserved-promise paths.

Thanks to @itanyplus, @waynegault, @chachi-max, and @kip-claw for the reports and field evidence.

Validation: exact-head CI run 35208176360 is green. Recorded focused proof: 395 tests passed and 6 skipped, followed by 64 passing spawn-broker tests; check:changed passed. Codex review is scoped-clean through P1 on a patch-identical revision, and ClawSweeper reports no findings on the landed head. Prior macOS Gateway probes predate final broker integration and do not claim a Linux/systemd field-crash reproduction.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
…150427)

Keep child cleanup and eager supervised-process failures visible to callers without letting unobserved rejections crash the Gateway. Publish the retained cleanup promise at the sole spawnServiceChildRelay creation site, join authority finalization and admitted tree signaling, and preserve retained-handle escalation, forced-exit diagnostics, output drainage, and cleanup deadlines. Uncertain extinction remains a failure.

Include redacted error stacks in Gateway stability bundles, bounded to 8,000 UTF-16 code units; older bundles without stacks remain readable. No configuration, CLI option, dependency, schema version, or installed update-driver behavior changes. The runtime repair takes effect when the candidate Gateway starts.

Related: openclaw#144911, openclaw#144941. Preserve integration with openclaw#150306, openclaw#150392, and openclaw#150564. The earlier MCP field-crash path is separately contained by openclaw#144941; this change closes remaining unobserved-promise paths.

Thanks to @itanyplus, @waynegault, @chachi-max, and @kip-claw for the reports and field evidence.

Validation: exact-head CI run 35208176360 is green. Recorded focused proof: 395 tests passed and 6 skipped, followed by 64 passing spawn-broker tests; check:changed passed. Codex review is scoped-clean through P1 on a patch-identical revision, and ClawSweeper reports no findings on the landed head. Prior macOS Gateway probes predate final broker integration and do not claim a Linux/systemd field-crash reproduction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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