Repository navigation
fix(runtime): workers fail silently after Node is upgraded under a running Gateway - #175206
Conversation
…ades Classify retained-runtime loader and exec failures at worker startup, report one actionable restart error, and mark Gateway readiness degraded. Preserve native error metadata and completion across process-worker owners, then reject further launches once runtime loss is confirmed. Keep ordinary worker crashes and supervisor exit/restart policy unchanged. Cover real native and brokered pre-handshake failures, removed or non-executable runtimes, addon-only loader errors, once-only logging, and cached readiness. Retain session-owned capture for delayed broker pipes. Move broker spawn-option translation to its existing pipe owner and cut over both callers.
…start Request one graceful fresh-process restart when the native service command's Node can start. Preserve admission, active-work drain, and supervisor handoff ownership; refuse in-process fallback when the retained runtime is unavailable. Keep unverifiable targets and recent runtime-recovery successors report-only. Verify launchd's loaded job corresponds to its definition before probing Node. Reuse the existing health fields and shutdown history without new config or persistent-state contracts. Prove decision cases, graceful drain ordering, failed-handoff exit, and retained degraded health. Document automatic recovery and operator repair behavior.
Require the existing bare-Node probe for missing-symbol diagnostics that native addons can also emit. Prepare compiled subprocesses before runtime-recovery test hooks.
Publish confirmed missing Node executable observations from health and readiness through the shared diagnosis owner. Service-managed Gateways can request guarded fresh-process lifecycle recovery even while resident workers continue serving reads. Exercise the real readiness boundary after deleting an executable, preserve one-shot publication, and correct fixture isolation and the deferred test type. Real isolated launchd proof verifies one successful restart with a viable service runtime and report-only behavior without a loop when that runtime is unusable.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesDiagnose unavailable child runtimes and request one graceful service restart when a working replacement Node is verified. Example: A Homebrew Node upgrade removes the executable retained by a running launchd Gateway.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-directed repair addresses a concrete runtime failure, and the final fixture correction introduces no actionable defect; current-head CI remains pending. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherWorker launchers publish startup failures to the shared runtime owner, which supplies health facts and delegates recovery to the existing Gateway lifecycle. flowchart TD
A[Worker startup failure] --> B[Child runtime owner]
C[Health and readiness observation] --> B
B --> D[Unavailable runtime diagnosis]
D --> E[Service runtime verification]
E --> F[Graceful lifecycle restart]
E --> G[Report only recovery guidance]
Technical reviewBest possible solution: Land the shared diagnosis and guarded lifecycle recovery after required current-head checks pass. Do we have a high-confidence way to reproduce the issue? Current-main launchers retain process.execPath, so removing that executable establishes the failing startup path; the PR also records real upgrade failures and isolated launchd reproduction, without this review executing target code. Is this the best way to solve the issue? The repair preserves exact-runtime requirements and uses existing diagnosis, admission, drain, and supervisor owners instead of substituting a potentially incompatible interpreter. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 85507ee9070b. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +415, Tests +823, Docs +40. Total +1278 across 33 files. Added test files: 4. View PR surface stats
Review metrics
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 (4 earlier review cycles)
Reviewed October 17, 2026, 5:39 AM ET / 09:39 UTC (Revision 5). |
Merge origin/main at 2044a2c. Keep the retired standalone verifier removed and retain the current bounded-diagnostic tests. Preserve runtime diagnosis and lifecycle recovery for the remaining worker owners.
|
@clawsweeper re-review Resolved the main conflict while preserving removal of the retired standalone verifier. The signed head is |
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
Emit native exit then close from the fake route owner for stop, kill, and explicit exits. Keep the launch assertion aligned with captured stderr. Production waits for close so runtime diagnosis sees all stderr. Before this correction, three denial cases time out locally and the prior CI shard repeatedly stalls in the claim fixture. Afterward all 31 tests pass under Node and Bun. Targeted lint, formatting, infra test types, and independent P0-P2 review pass.
|
@clawsweeper re-review Please review current head |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
The reason added by #175206 has always been consumed within process-respawn. Remove its unused export while retaining the recent-restart loop check, graceful lifecycle request and independent admission reason unchanged. Validation: both process-respawn suites pass, 37 tests in 84.13s wall time. The dependency scan no longer reports this export. Production and full-tree unused-file scans pass; the MCP v1 peer fixtures are live compatibility proof and their audit ownership was already repaired in 801d701. P2 review found no actionable findings.
The loader fixture added by ec23eef (#175206) can receive bootstrap EPIPE before native exit. Closing then records its intentional loader failure as a shutdown error. Awaiting that close before restoring process.execPath leaked the synthetic Node path into later process tests; removing the fixture left those tests spawning a nonexistent executable. Restore the original runtime before cleanup. Validate only the exact expected loader shutdown error, and prove a fresh broker starts afterward. Keep every readiness, stderr, descriptor, and lifecycle assertion. The runtime detector correctly diagnosed the broken fixture; production code is unchanged. Reproduced the original failure on Linux with host-stderr.test.ts under --maxWorkers=1 --repeats 30 (1 failed, 4 passed; 29.17s wrapper). After repair, seven selected files pass 40 tests on Linux (12.09s), and six process files pass with --maxWorkers=4 --repeats 10 (26.90s), including both real EMFILE cases. On macOS the same serial proof passes 38 tests with two Linux-only skips (46.22s wall), and parallel pressure passes 27 tests with those same skips (96.99s wall). Targeted services test types, normal/boundary lint, formatting and P2 review pass. No retries, timeout changes, or production recovery changes.
…nning Gateway (openclaw#175206) * fix(runtime): diagnose unavailable worker executables after Node upgrades Classify retained-runtime loader and exec failures at worker startup, report one actionable restart error, and mark Gateway readiness degraded. Preserve native error metadata and completion across process-worker owners, then reject further launches once runtime loss is confirmed. Keep ordinary worker crashes and supervisor exit/restart policy unchanged. Cover real native and brokered pre-handshake failures, removed or non-executable runtimes, addon-only loader errors, once-only logging, and cached readiness. Retain session-owned capture for delayed broker pipes. Move broker spawn-option translation to its existing pipe owner and cut over both callers. * fix(gateway): recover unavailable child runtimes through lifecycle restart Request one graceful fresh-process restart when the native service command's Node can start. Preserve admission, active-work drain, and supervisor handoff ownership; refuse in-process fallback when the retained runtime is unavailable. Keep unverifiable targets and recent runtime-recovery successors report-only. Verify launchd's loaded job corresponds to its definition before probing Node. Reuse the existing health fields and shutdown history without new config or persistent-state contracts. Prove decision cases, graceful drain ordering, failed-handoff exit, and retained degraded health. Document automatic recovery and operator repair behavior. * test(gateway): prepare lifecycle imports before case deadlines * fix(runtime): verify dyld symbol failures before recovery Require the existing bare-Node probe for missing-symbol diagnostics that native addons can also emit. Prepare compiled subprocesses before runtime-recovery test hooks. * fix(runtime): recover missing executables observed by readiness Publish confirmed missing Node executable observations from health and readiness through the shared diagnosis owner. Service-managed Gateways can request guarded fresh-process lifecycle recovery even while resident workers continue serving reads. Exercise the real readiness boundary after deleting an executable, preserve one-shot publication, and correct fixture isolation and the deferred test type. Real isolated launchd proof verifies one successful restart with a viable service runtime and report-only behavior without a loop when that runtime is unusable. * fix(runtime): confirm pre-handshake worker exit failures Probe the retained runtime after startup IPC errors or an observed read-only worker exit, including broker exits whose stderr arrives too late. A healthy bare-runtime probe still preserves ordinary worker and add-on failure behavior. Complete broker fixture disconnect receipts, admit the ordinary-crash fixture request before exit, type the restart request mock, and use a real Node service target when the lifecycle regression runs under Bun. * test(runtime): separate snapshot budgets from runtime probes Keep the exact snapshot launch and timeout assertions while excluding the diagnostic Node version probe after a pre-start timeout. Production behavior is unchanged. Validation: real sync and async timeout cases pass; targeted lint and format pass; infra test types pass. Full test types retain the already-attributed config health disposal errors. Independent P0-P2 review is scoped-clean. * test(runtime): complete Tailscale claim child lifecycle Emit native exit then close from the fake route owner for stop, kill, and explicit exits. Keep the launch assertion aligned with captured stderr. Production waits for close so runtime diagnosis sees all stderr. Before this correction, three denial cases time out locally and the prior CI shard repeatedly stalls in the claim fixture. Afterward all 31 tests pass under Node and Bun. Targeted lint, formatting, infra test types, and independent P0-P2 review pass.
The reason added by openclaw#175206 has always been consumed within process-respawn. Remove its unused export while retaining the recent-restart loop check, graceful lifecycle request and independent admission reason unchanged. Validation: both process-respawn suites pass, 37 tests in 84.13s wall time. The dependency scan no longer reports this export. Production and full-tree unused-file scans pass; the MCP v1 peer fixtures are live compatibility proof and their audit ownership was already repaired in b2f3d47. P2 review found no actionable findings.
The loader fixture added by dbcbf12 (openclaw#175206) can receive bootstrap EPIPE before native exit. Closing then records its intentional loader failure as a shutdown error. Awaiting that close before restoring process.execPath leaked the synthetic Node path into later process tests; removing the fixture left those tests spawning a nonexistent executable. Restore the original runtime before cleanup. Validate only the exact expected loader shutdown error, and prove a fresh broker starts afterward. Keep every readiness, stderr, descriptor, and lifecycle assertion. The runtime detector correctly diagnosed the broken fixture; production code is unchanged. Reproduced the original failure on Linux with host-stderr.test.ts under --maxWorkers=1 --repeats 30 (1 failed, 4 passed; 29.17s wrapper). After repair, seven selected files pass 40 tests on Linux (12.09s), and six process files pass with --maxWorkers=4 --repeats 10 (26.90s), including both real EMFILE cases. On macOS the same serial proof passes 38 tests with two Linux-only skips (46.22s wall), and parallel pressure passes 27 tests with those same skips (96.99s wall). Targeted services test types, normal/boundary lint, formatting and P2 review pass. No retries, timeout changes, or production recovery changes.
What Problem This Solves
Fixes: when Node is upgraded underneath a running Gateway (for example
brew upgrade noderemoving the Cellar path the Gateway was started from), every new worker process fails to start. Read-only SQLite sessions, schema inspection, vector, broker and other workers die with opaque errors such asSQLite read-only worker exited with signal SIGABRT(dyld cannot find the removed libraries) or ENOENT. The Gateway itself stays up with nothing that says what happened or what to do, and resident worker threads keep serving some reads, so health looks fine while new work fails.User Impact
User impact: after a Node upgrade, a service-managed Gateway restarts itself once into the new Node and keeps working. If the service's own Node is unusable, the Gateway stays up and clearly reports
NODE_RUNTIME_UNAVAILABLEwith "Restart the Gateway", health shows the runtime unavailable, and/readyzreturns 503 instead of failing silently.Why This Change Was Made
Maintainer decision (Peter): "Restart via lifecycle". When the service command's runtime resolves to a working Node, the Gateway asks its existing lifecycle owner for a graceful restart into a fresh process. Otherwise it stays up in report-only mode, which avoids restart loops when the pinned binary is gone.
src/infra/child-runtime-viability.ts) classifies confirmed startup failures of the retained executable. dyld symbol errors are confirmed with a bare-Node probe, so an add-on-only loader failure cannot disable the runtime. The owner logs the diagnosis once and rejects further launches immediately. Readiness observations publish to the same owner.childRuntime.availablebecomes false, and/readyzreturns 503 withfailing: ["child-runtime"].--version); on launchd it also checks the loaded job against its plist. It then requests a graceful restart through the existing lifecycle restart and supervisor handoff, with admission close, active-work drain and a fresh process. It never uses the in-process restart fallback, which cannot repair this condition.Evidence
chat.history, health andsessions.listsucceeded.childRuntime.available: false.SQLite read-only worker exited with signal SIGABRTon new worker spawns with no diagnosis. The regression reproduced the opaque exit 134 with dyld stderr before the fix.Main integration validation
Merged current main while preserving its retirement of the standalone database-verification subprocess and keeping the current bounded-diagnostic tests. The lifecycle recovery policy is unchanged.
The resolved candidate passed 19 focused tests: current verifier diagnostics (9), real read-only runtime failures/readiness (8), and lifecycle drain/failed-handoff behavior (2). Core types, targeted type-aware lint, formatting, and diff checks passed. A fresh independent review of the complete 30-file delta found no actionable P0–P2 or security findings; the signed merge commit has exactly the reviewed tree. The previously documented SIGINT timeout and one-off SIGTERM timeout remain attributed as above; this does not claim a fully green local run-loop suite.
Landing review correction
Exact-head CI and ClawSweeper exposed a pre-handshake diagnosis gap: a child can lose IPC, or exit before transferred stderr arrives. Those observed startup failures now reach the existing bounded bare-runtime probe. The probe still requires runtime failure evidence; ordinary worker crashes and add-on-only loader errors leave a usable Node available.
The correction also gives the ordinary-crash fixture an IPC admission barrier, completes fake broker disconnect receipts, types the restart-request mock from production, resolves a real Node service target when tests run under Bun, and documents the isolated logger mock. A new regression failed before the classifier correction because the broken executable remained present and the IPC error contained no executable path. The real broker regression also exposed the bare-exit shape before the session correction.
CI run 39011161425 on head 92efc80 found the task-owned defects above. Its separate session-accessor disposal and worker-placement failures match scheduled main run 39010956087 exactly (jobs 117333372934 and 117333373118). The older Bun stderr shutdown timeout remains unattributed: the untouched test passed on the baseline under pinned Bun, which is not a claim that the timeout was fixed. Local CLI test types additionally find two inherited stale
usingdeclarations in config health-state tests; main already fixes them in 7b727f0, and that fix was present in the original CI merge baseline.Final correction proof: Node classifier and real read-only runtime 19/19; Bun read-only session/runtime 19/19, broker stderr 5/5, recovery budget 2/2 and lifecycle drain/failed-handoff 2/2. Core types, targeted type-aware lint, formatting and mock-export ratchet pass. Local CLI test types retain only the inherited config-health
usingerror described above. Final product delta: production +515/−100, tests +826/−10, docs +40/−0 across 31 files.Final test-fixture corrections
The snapshot timeout expectation excludes the independent bare-Node diagnostic probe while still asserting exactly one snapshot launch and its timeout, kill signal, hidden-window and stdio options. The real sync and async timeout cases passed.
A later CI investigation found that the Tailscale claim fixture emitted
exitwithout nativeclose, leaving cleanup waiting now that the production owner correctly waits for stderr completion. The fixture now emitsexitfollowed byclosefor normal stop, kill and explicit exit scenarios, and expects piped stderr. Before the correction, all three selected denial cases timed out locally; afterward all 31 tests passed under both Node and Bun. Targeted type-aware lint, formatting, infra test types and diff checks passed. Production source is unchanged by these test corrections.Independent P0–P2 review of the final Tailscale fixture correction is scoped-clean. Fresh exact-head CI and ClawSweeper review are requested for
3e2ee6215109383194f2564b0a59119b30cc01e6; earlier CI is retained as historical failure evidence, not current-head success.Final CI attribution
CI run 39021553780, attempt 1 completed on final head
3e2ee6215109383194f2564b0a59119b30cc01e6. Both PostgreSQL conformance jobs, all production/test typecheck lanes, andsecurity-fastpassed. Independent Security Review 39021551842 passed. ClawSweeper revision 5 reviewed this exact head with no actionable or security findings and no remaining before-merge items.Five baseline-attributed root failures leave CI red; the failed
openclaw/ci-gateis their aggregate.The actual tested merge is
74e718f461ba350acb75d253090282c4caa3b8ac, with ordered parents baseline85507ee9070bb97345b7621440d683845dd64403and this PR head. Complete UI/package/test-fixture inputs and the directly imported contracts are identical between baseline and tested merge. For the catalog case, the complete agents/plugins trees and test/shared inputs are also identical; that healthy initial worker-thread load does not execute child-process runtime recovery. The native inherited-failure evidence retains the exact input objects, job logs, checkout, passing scoped checks, and complete failed-job accounting.