Repository navigation
fix(update): bound finalization and diagnose stalled phases - #140648
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 7, 2026, 2:15 AM ET / 06:15 UTC. ClawSweeper reviewWhat this changesBounds update finalization and CLI cleanup, reports stalled phases, and terminates owned subprocesses so supervised upgrades receive a terminal result. Merge readiness⛔ Blocked before merge - 3 items remain The containment fix remains useful: current main still lacks these finalization deadlines. The prior findings are addressed, and no additional blocking defect was identified. The related macOS incident remains unresolved independently. Priority: P1 Review scores
Verification
How this fits togetherUpdate finalization repairs configuration and plugins after a core upgrade. A supervising updater waits for its JSON result and process exit before proceeding with activation or recovery. flowchart TD
A[Supervised upgrade or repair] --> B[Admission and configuration checks]
B --> C[Bounded finalization phases]
C --> D[Doctor and plugin subprocesses]
C --> E[Phase diagnostics and update ledger]
C --> F{Completed or timed out}
F --> G[Terminal result and owned process cleanup]
G --> H[Supervisor activation or recovery]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +343, Tests +493, Docs +21, Config 0, Other -1. Total +856 across 28 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain bounded finalization with the documented timeout override and demonstrated fresh-state/upgrade behavior, while preserving the separate investigation into the affected macOS stall. Do we have a high-confidence way to reproduce the issue? Yes for the unbounded-wait mechanism: current main awaits phase callbacks without an enclosing deadline, and the supplied before/after transcript exercises an injected stalled operation. The reporter's exact macOS trigger remains unknown; this review executed no tests. Is this the best way to solve the issue? Yes for bounded-outcome containment: deadlines belong to finalization, child cleanup follows process ownership, and borrowed callers retain their lifetime. This does not establish a root-cause fix for the separate macOS incident. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d8b597be60c4. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
Record phase progress as it happens, retain OCM-compatible terminal timings, and stop owned subprocess trees before a timed-out finalizer permits rollback. Bound shared CLI disposers and report resources that outlive terminal output. Force-kill the managed Codex version probe at its existing deadline. The missing deadline, child-custody, and diagnostic recovery paths require production growth; remove duplicated phase bookkeeping and the version probe's callback wrapper. Keep issue #139485 open for the affected macOS reproduction. Reported by @hannesrudolph.
f48bcd7 to
dc78b37
Compare
Detach the fixture grandchild from the launcher-owned libuv Job so only the finalizer Job can terminate it after the launcher exits. Keep borrowed and Gateway negative controls.
|
Merged via squash.
|
* fix(update): identify children in stalled finalization diagnostics Report bounded descendant identities in phase and cleanup diagnostics without argv or environment disclosure. Preserve terminal outcomes and fence children before releasing the supervisor result. Related: #139485; follows #140648. Reporter: @hannesrudolph. * fix(update): read Linux child executable identities Use bounded /proc executable lookups because Linux accounting names can contain mutable argument-derived titles. Preserve process IDs with null names when a process disappears. Keeps the native privacy regression that failed in CI.
…#140648) * fix(update): bound finalization and diagnose stalled phases Record phase progress as it happens, retain OCM-compatible terminal timings, and stop owned subprocess trees before a timed-out finalizer permits rollback. Bound shared CLI disposers and report resources that outlive terminal output. Force-kill the managed Codex version probe at its existing deadline. The missing deadline, child-custody, and diagnostic recovery paths require production growth; remove duplicated phase bookkeeping and the version probe's callback wrapper. Keep issue openclaw#139485 open for the affected macOS reproduction. Reported by @hannesrudolph. * test(update): complete stalled cleanup fixture * fix(update): keep completion refresh interruptible * test(update): use supported subprocess IPC option * fix(update): preserve triage after bounded preflight * fix(update): preserve recovery and optional completion outcomes * fix(update): retain process ownership through finalizer exit * test(update): keep process and budget checks type-safe * test(update): exercise Windows orphan cleanup ownership Detach the fixture grandchild from the launcher-owned libuv Job so only the finalizer Job can terminate it after the launcher exits. Keep borrowed and Gateway negative controls. * style(tests): use pinned planner formatting * fix(process): preserve live child custody after probe failure * fix(update): preserve borrowed CLI process lifetime * test(update): avoid returning the borrowed caller timer
) * fix(update): identify children in stalled finalization diagnostics Report bounded descendant identities in phase and cleanup diagnostics without argv or environment disclosure. Preserve terminal outcomes and fence children before releasing the supervisor result. Related: openclaw#139485; follows openclaw#140648. Reporter: @hannesrudolph. * fix(update): read Linux child executable identities Use bounded /proc executable lookups because Linux accounting names can contain mutable argument-derived titles. Preserve process IDs with null names when a process disappears. Keeps the native privacy regression that failed in CI.
Keep explicit Codex version checks bounded when descendants retain output pipes, preserve timeout failures, and carry nonfatal repair warnings through the existing Doctor result channel. Routine repair now shares lint default-check selection. Related: #139485; follow-up to #140648 and #141740. The daemonized-child experiment completed on official 2026.9.2 and main; this does not claim the original incident is resolved.
…w#141995) Keep explicit Codex version checks bounded when descendants retain output pipes, preserve timeout failures, and carry nonfatal repair warnings through the existing Doctor result channel. Routine repair now shares lint default-check selection. Related: openclaw#139485; follow-up to openclaw#140648 and openclaw#141740. The daemonized-child experiment completed on official 2026.9.2 and main; this does not claim the original incident is resolved.
Related: #139485
What Problem This Solves
Fixes an issue where externally supervised upgrades could wait indefinitely for
openclaw update finalize --json --yes --no-restartwhile the Gateway remained stopped. A pending phase produced neither a terminal result nor a phase-start receipt, and cleanup could continue waiting after a result had been printed. Reported by @hannesrudolph.This repairs the bounded-outcome and diagnostic guarantees. The exact operation in the reported macOS configuration remains unconfirmed; #139485 stays open for a reporter rerun.
Why This Change Was Made
Executable finalization now owns deadlines for preflight and the six existing OCM phases, including their config reads and plugin-lease acquisition. Phase starts and finishes stream immediately to stderr. The existing update ledger records them after write admission, including the original preflight start timestamp once the ledger is attached. A deadline fences owned command trees, records failure, synchronously emits one JSON result with
status: "failed",stuckPhase,elapsedMs,error, and compatiblephaseTimings, then exits nonzero without yielding to abandoned mutations during supervisor rollback.Unix command scopes stop retained process groups on normal return, rejection, and deadline. Windows executable finalizers retain a non-inheritable Job until OS process exit, which terminates descendants even after their launcher exits; borrowed calls and Gateway execution do not acquire that permanent process ownership. This replaces the weaker Windows taskkill path. A live native child retains PID ownership even if the optional start-time probe fails; after the root exits, the timestamp guard still protects against PID reuse. Phase exits and the post-output watchdog use the same executable ownership boundary. The exported CLI bridge continues awaiting phases and preserves its caller-owned process lifetime.
Shared CLI disposers have individual five-second deadlines and retain their unsettled names. Ten seconds after terminal JSON, a still-running finalizer records active resource types and unsettled disposers, then exits with the recorded outcome. The watchdog is unreferenced, so it does not delay healthy exit. Human-mode repair starts its exit grace only after interactive recovery finishes. The existing terminal ledger outcome remains immutable; exit diagnostics use a separate bounded step.
The existing
--timeoutoverrides each phase budget. OCM v0.2.38'sCommand::output()and phase parser remain compatible: stdout stays one JSON document, the six phase names and timing fields remain unchanged, the additive preflight timing is ignored by older OCM parsers, and the nonzero exit releases its failure/rollback path.The audit also found a concrete deadline defect in the managed Codex native
--versionprobe: Node's default timeout sends SIGTERM and can keep waiting for a child that ignores it. That probe now uses SIGKILL at its existing five-second deadline and removes its callback wrapper. This default-disabled candidate check precedes finalization in OCM, so it is not presented as Hannes's identified trigger.Completion refresh also used a synchronous child wait that could prevent any JavaScript phase timer from firing. It now uses the existing asynchronous command runner with process-tree cleanup and shutdown time reserved inside the unchanged overall phase budget. A child timeout that settles within that budget remains a nonfatal completion-cache failure; an actual phase overrun remains fatal. The manual-refresh hint is preserved.
User Impact
A stalled finalizer now produces a bounded failure naming its phase. A retained cleanup resource cannot turn a recorded result into an indefinite supervisor wait. Operators can preserve the stderr diagnostic and inspect the update ledger; unusually long legitimate phases can use the existing timeout override.
Production LOC: +600/-257 (net +343). Tests/support LOC: +580/-88 (net +492). Docs LOC: +22/-1 (net +21). Tooling/baseline LOC: +2/-2 (net 0). The positive production exception supplies missing deadline, subprocess-cancellation, and diagnostic recovery paths, including Windows kernel ownership that survives an exited launcher. The finalizer owner shrinks by 43 lines, the version probe by 9, and completion refresh by 9; the added ownership machinery is needed because exiting the parent alone does not stop detached package-manager descendants.
Evidence
Final head
72be047a9a57c074f75e9b85f6ab068509dc387chas green CI, a clean full branch review, passing selected checks, and an exact-commit build. Blacksmith Testbox leasetbx_01m1x6w973cm9dpszeh2x6j2m1, run 34088554369, verified all 38,907 tracked source files and the embedded build commit before/after live execution. The lease is stopped and cleanup verified.The OCM stand-in clears its environment, uses null stdin and piped stdout/stderr, and waits synchronously. All state is synthetic. Official 2026.9.1 runs as an owned Gateway on a free loopback port, then stops before the built 2026.9.2 finalizer runs. Every
--no-restartcase leaves the Gateway stopped. This proves the command/stdio contract; it does not claim an affected-macOS reproduction or a complete OCM rollback test.Compact live stand-in transcript (
processElapsedMsincludes CLI startup; the phase-failure JSON separately reportselapsedMs: 1233):Before-fix proof used official npm 2026.9.2 and source regressions. On stopped Testbox
tbx_01m1wqx05146v0en349a65tb6m, run 34073327915, an unresolved actual snapshot operation still produced no JSON after 15,015 ms. Both source phase/handle regressions reached their 100-second guards; the retained-handle case already had complete success JSON. Healthy official 9.1→9.2 took 4,269 ms. The final Testbox also confirmed that the official completion child ignored SIGTERM and left zero stdout after 45,054 ms before the harness stopped its owned process group.The PID comparison failed on the previous code because its owned descendant survived, then passed all eight cases after repair. The two borrowed-caller regressions also failed on the old owners (phase exit 1 and missing caller-completion marker after output). After repair, all 14 output-process cases, eight PID cases, and 411 update CLI tests passed on
f0d57bfee36511951c21fc6984add3ab9124477cin stopped Testboxtbx_01m1x64e60pbpfy4vyttd73s80, run 34087729930. The final run verified all 28 file hashes, permitting only the exact reviewed Promise-executor block-body correction in the fixture; production, delays, and assertions are unchanged. It reused those 433 passes and two intended failures, then ran the final selected checks, build, and live scenarios. CI caught that fixture lint error; the corrected head passes lint and CI.An earlier wider run passed 609 tests, full changed-file checks, and a build, with unchanged evidence retained by hashes: run 34082821509, stopped lease
tbx_01m1x1kw1jyrdbfvsgr5kecjga. Coverage includes named disposer deadlines, incremental ledger receipts, interactive recovery, completion siblings, and the managed Codex probe. That version probe stops at its five-second deadline (5,086 ms), versus 10,153 ms on the original code. The final selected checks passed core and core-test typechecks, changed-file lint, all three unused-export scans, and the unchanged schema-version guard.All five native Windows cases passed on final head
72be047ain 2.55 seconds: CI job 101637179316. They cover exit 0/1, inherited Job membership, already-exited launchers, and borrowed/Gateway exclusions on Node 22.23.2 Windows x64. An exact-predecessor native Windows rerun was unavailable; all positive cases and negative ownership controls ran on the final head.Rejected harness attempts are excluded from passing evidence. Live fault injection verifies the exact built module/function and an entry marker, so an unentered fault or a skipped regression cannot count as a pass.
Audit references:
src/cli/update-cli/update-command-finalize.ts:72,89,184,185,195,198,234: preflight, validation, backup, Doctor, plugin phase/lease, and convergence are inside phase ownership.src/cli/update-cli/update-finalization-lifecycle.ts:110,180: terminal deadline and post-output diagnostics.src/process/exec-spawn.ts:22,54: owned Unix command groups and live-child PID authority.src/cli/runtime-cleanup-scope.ts:22,27andsrc/process/supervisor/service-child-windows-job-native.ts:15: Windows executable ownership until OS exit.src/cli/runtime-cleanup.ts:12: named disposer bounds. Audited waits include harness disposal (src/agents/harness/registry.ts:153), Codex startup-producer drain (extensions/codex/src/app-server/shared-client.ts:1466), MCP HTTP close (src/gateway/mcp-http.ts:518), and memory idle/watcher/provider drains (extensions/memory-core/src/memory/manager.ts:650,671,682). They are audit candidates, not established incident causes.src/cli/update-cli/shared.ts:443: asynchronous completion refresh replaces the synchronous SIGTERM-only wait.extensions/codex/src/doctor.ts:69: repaired native-version timeout. Codex transport already ends/unreferences its pipes and has forced termination (extensions/codex/src/app-server/transport.ts:112).src/agents/provider-local-service.ts:493,553); transport dispatchers destroy after a bounded close (src/infra/net/ssrf.ts:770). Proxy stop delegates synchronously, and CLI ownership bounds its lazy cleanup (src/cli/run-main.ts:1692).src/skills/runtime/refresh.ts:500); no evidence establishes finalizer activation of that path. Retained watcher types will appear in the exit diagnostic.ClawSweeper follow-through: preserve interactive recovery and optional completion outcomes; repair initial-null PID custody; provide default-budget fresh/upgrade proof and native Windows controls. Both borrowed-call before/after regressions are proved in the linked functional run. The refusal helper now states its existing always-throwing contract with
Promise<never>, removing an unreachable branch rather than adding a fallback. The remaining ClawSweeper budget tradeoff is accepted within the requested per-phase deadline scope: defaults have fresh/upgrade proof and the existing timeout override is documented. There is no new data model; the existing-store upgrade path and schema guard pass. The original macOS trigger remains unknown. That uncertainty is the reason to keep #139485 open for @hannesrudolph's rerun, consistent with the requested containment-and-diagnostics scope. There are no schema, configuration, dependency, or protocol changes.NO-FOLLOW-UP: the useful owner refactors and dead-path removal are included here; no separate refactor is justified by the remaining evidence.