Skip to content

fix(gateway): detect Node runtimes that cannot launch children - #200038

Merged
obviyus merged 4 commits into
mainfrom
fix/child-runtime-viability
Nov 16, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/child-runtime-viability

Conversation

@obviyus

@obviyus obviyus commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #199762

What Problem This Solves

After a shared-library upgrade leaves the running Gateway's Node binary unlaunchable, status still reports its child runtime as available and relay startup can hide the loader error behind an IPC failure.

User Impact

Health and status now recognize this runtime failure, and failed relay startup preserves the loader's diagnostic. No configuration, update, or Doctor behavior changes.

Why This Change Was Made

Reuse the existing native runtime probe and unavailable state, rather than treating executable access as proof that Node can start. Keep the loader's own error text and remove the redundant probe path from failure diagnosis.

Evidence

  • Secretless Linux node:24.22.1, isolated HOME/state, real Gateway and cron command. After startup, move its actual libstdc++.so.6 out of the loader's search path; no mocked launches or injected failures.
  • Main twice: Node children exit 127 while childRuntime.available remains true. Candidate twice: false, with the loader's missing-library diagnostic logged.
  • Real relay source integration twice per side: main returns write EPIPE; candidate returns the child's missing-library diagnostic.
  • Healthy Node remains available. Thirty /readyz requests per run: main median 1.016/0.744 ms; final candidate 8.408/8.459 ms. The added check remains below 10 ms median in these runs.
  • Caller audit: one probe per health RPC (including cached responses), status RPC, and each /readyz HTTP hit after startup. Restart reacquisition attempts and failed pre-handshake launch diagnosis also probe; healthy child launches do not. There is no internal high-frequency polling loop. An orchestrator polling every few seconds pays the measured approximately 8 ms per request. No cache: binary identity cannot reveal a removed shared library.
  • Focused runtime, SQLite, spawn-broker, relay, and Gateway health suites: 99 tests pass. Changed-file formatting and lint pass. Both hosted findings are addressed: loader details supplement the existing restart instruction, and cleanup/cancellation fixtures hold the remaining asynchronous diagnosis boundary. Cached health still shares one observation with readiness.
  • Full declaration build and packed-artifact integrity pass; extracted package CLI version and Gateway help smoke pass at final head 163ea84. This last commit only updates the cached-health observation fixture; production is identical to the twice-proven bc25065 build.
  • Production +6 lines; tests 0. Existing cleanup/cancellation cases are retained and now hold the native asynchronous diagnosis boundary. The async filesystem guard still covers healthy availability without incidental access/stat call counts.

Reversible code-only change. Blast radius: child-runtime health/readiness and relay startup diagnostics; no persisted state or public API changes.

Probe child startup before publishing runtime availability, retain the loader diagnostic, and surface it when relay startup loses its transport.

Fixes #199762
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Natural Linux reproduction on Node 24.22.1, with isolated HOME/config/state and no credentials. Start the real Gateway, create a cron command running its Node binary, then move the actual libstdc++.so.6 symlink out of the loader's search path while the Gateway stays running. Restore it before shutdown. No mocked processes, held replies, or injected faults.

Run Healthy available After library removal Gateway-launched Node child
main 1 true true exit 127
main 2 true true exit 127
candidate 1 true false exit 127
candidate 2 true false exit 127

Main: bef242d04174a93645ac026656f355de1caa12b3. Main used dist-nodts; candidate used the full declaration build. Both candidates also logged the loader's reason:

[runtime] /usr/local/bin/node: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

A separate real relay source integration loaded the relay owner before removing the same library. Two runs per side:

main:      relay rejected: write EPIPE
candidate: relay rejected: /usr/local/bin/node: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

Healthy /readyz timing, 30 sequential requests per run (milliseconds):

Run Median Mean p95
main 1 1.016 3.841 3.392
main 2 0.744 0.846 1.588
candidate 1 8.059 11.562 30.631
candidate 2 9.591 15.918 62.681

The added startup check costs approximately 7–9 ms at the median in these runs; it does not block the Gateway thread. Healthy availability stays true.

Focused vitest-source: 56 tests pass. The strengthened existing loader-message assertion fails on main and passes on the candidate. Formatting and focused lint pass. No test cases removed: the async filesystem guard remains, also covers healthy availability, and no longer asserts incidental access/stat call counts. Net production +4 lines; tests -1.

Host execution safety: only the two runtime/relay source files and their two tests changed; no package manifests, lockfiles, scripts, hooks, patches, or install lifecycle inputs changed. All product reproduction ran in the secretless Linux container through ocx.

Full tier at 3c192e3f90f37465bbdde9a239e56ea0046213f6: declaration build passed; package tarball integrity passed, including the dist import graph. Extracted package CLI reports OpenClaw 2026.11.4 (3c192e3) and gateway call --help succeeds. This smoke reused the checkout's dependency resolution; it was not a fresh install.

@clawsweeper

clawsweeper Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR probes whether the retained Node runtime can launch and includes loader diagnostics alongside restart guidance.

Example: Remove libstdc++.so.6 after starting a Gateway on Linux with Node 24.22.1.

  • Before: Node children exit 127 while childRuntime.available remains true, and relay startup reports write EPIPE.
  • After: childRuntime.available becomes false, and relay startup reports the missing-library diagnostic with instructions to restart the Gateway.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with real Gateway proof, preserved cleanup contracts, explicit probe-cost measurements, and no remaining findings; CI completion remains separate.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied secretless Linux Node 24.22.1 runs exercise the real Gateway and cron child after actual libstdc++.so.6 removal, showing availability change from true to false; repeated real relay-owner runs replace EPIPE with restart guidance and loader diagnostics, and production is unchanged at the reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A running Gateway can report healthy child-runtime availability after a library upgrade prevents all new Node children from starting, while relay errors hide the recovery cause.
Reason: The repair restores the documented health contract, has a natural production-boundary reproduction, and records the per-request probe cost under maintainer-authored direction.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a confirmed runtime-health false positive and misleading relay startup errors; no actionable findings remain, and exact-head CI is still running.

Priority: P1
Reviewed head: 163ea849be075d26dbcdd26d8502c031d0c50406

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared child-runtime owner receives health observations and child-startup failures, classifies runtime availability, and supplies health/readiness results, actionable errors, and lifecycle recovery signals.

flowchart TD
  A[Health status and readiness] --> B[Child runtime owner]
  C[Relay startup failure] --> B
  B --> D[Native Node version probe]
  D --> E[Existing failure classifier]
  E --> F[Availability and restart diagnostic]
  E --> G[Lifecycle recovery owner]
Loading

Technical review

Best possible solution:

Use the existing asynchronous probe and shared failure classifier for availability and early relay diagnosis while retaining lifecycle recovery and independent cleanup ownership.

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

Current-main source confirms the access-only false positive, and supplied repeated real Gateway/library-removal runs demonstrate it; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch is the smallest complete repair: it reuses the bounded native probe and existing failure owner, removes redundant diagnosis probing, and preserves ordinary-worker-crash handling.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 82974f3026e8.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Olli: Raw commit 92c86fe adds src/infra/child-runtime-viability.ts:29 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 92c86fefcd44; files: src/infra/child-runtime-viability.ts)

PR surface

Source +6, Tests 0. Total +6 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 15 9 +6
Tests 5 26 26 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 41 35 +6

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 change Production +15/−9; tests +26/−26 Net production growth of six lines reuses existing diagnosis machinery; test changes preserve distinct cleanup, cancellation, diagnostic, and shared-observation contracts.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: The affected-release report describes broken heartbeat and model-backed cron workflows until restart while runtime health incorrectly remains available.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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-16T08:48:52.007Z sha 3c192e3 :: needs changes before merge. :: [P2] Retain restart guidance alongside the loader diagnostic | [P2] Retarget cleanup regressions after removing the access check
  • reviewed 2026-11-16T09:24:57.417Z sha bc25065 :: needs maintainer review before merge. :: none

Reviewed November 16, 2026, 4:53 AM ET / 09:53 UTC (Revision 3).

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Final head: bc25065bef4722e560dda38da9131524e2638e90.

Both review findings are addressed. Existing restart guidance is retained before the loader detail; SQLite and spawn-broker cleanup fixtures now hold fs.stat, the remaining asynchronous diagnosis boundary. No cases or cleanup/cancellation assertions were removed. Net production +6 lines, tests 0.

Repeated the real secretless Linux Node 24.22.1 Gateway/library-removal scenario twice on this full build, using the same fixture as the two failing main runs. Both final runs report healthy availability before removal, then childRuntime.available: false while Gateway-launched Node children exit 127. Both log:

[runtime] The Node.js runtime this Gateway started with (/usr/local/bin/node) can no longer start worker processes, likely because it was upgraded or removed. Restart the Gateway.
/usr/local/bin/node: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

Repeated the real relay-source integration twice too: its rejected startup now carries both those existing messages, rather than write EPIPE.

Final healthy readiness timings, 30 requests per run: medians 8.408/8.459 ms; means 16.037/11.374 ms; p95 62.767/15.323 ms. Main medians were 1.016/0.744 ms. The caller audit and per-hit cost are explicit in the PR body. There is no positive cache, because unchanged Node file identity cannot detect a removed library.

Final gates run locally: 83 focused runtime/SQLite/broker/relay tests pass; changed-file formatting and lint pass; full declaration build passes; package tarball inventory/import-graph integrity passes; extracted packed CLI version and Gateway help pass at bc25065. Packed smoke reuses checkout dependency resolution rather than a fresh install. The source diff changes only two production files and four test files, with no install/lifecycle inputs.

The initial unrelated UI shard passed its one authorized retry: https://github.com/openclaw/openclaw/actions/runs/43833582376/job/133195424009 . The exact CI main parent also exhibits the two-rounds=true reader failure: https://github.com/openclaw/openclaw/actions/runs/43833245027/job/133184117656 . The two-rounds=false case passed on that parent, so it is not claimed as inherited. No UI code was changed.

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 16, 2026
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Final head: 163ea849be075d26dbcdd26d8502c031d0c50406.

The last change only migrates the cached-health observation regression from the removed access check to asynchronous stat. It still verifies exactly one shared observation and no synchronous runtime filesystem work; its module filter no longer mistakes a worktree directory named fix-child-runtime-viability for a runtime module frame. All 16 Gateway health owner-routing cases pass. Together with the 83 previously passing runtime/SQLite/broker/relay cases, 99 focused cases pass, with no removed cases and net test lines 0.

Full declaration build, package tarball inventory/import-graph integrity, and extracted packed CLI version plus Gateway help smoke passed on this exact head. The packed CLI reports OpenClaw 2026.11.4 (163ea84); its smoke reuses checkout dependency resolution.

Production is unchanged from bc25065bef4722e560dda38da9131524e2638e90, so the two final natural Linux Gateway/library-removal runs, two real relay-source runs, and measured healthy controls remain applicable. Both existing restart guidance and loader text are preserved. The PR body explicitly records every probe caller and the approximately 8.4 ms median cost per /readyz hit. No cache was added.

@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Nov 16, 2026
@clawsweeper

clawsweeper Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Nov 16, 2026
@obviyus
obviyus merged commit 5bd858c into main Nov 16, 2026
128 of 129 checks passed
@obviyus
obviyus deleted the fix/child-runtime-viability branch November 16, 2026 10:04
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @goldmar for the report. This is fixed on main: the Gateway now reports a Node runtime that cannot start child processes as unavailable, with the loader error, instead of claiming it is available.

steipete added a commit to steipete/openclaw that referenced this pull request Nov 16, 2026
Declare the two live spawned test fixtures introduced by openclaw#199560 as exact Knip roots. Hold the current asynchronous executable stat in the HTTP readiness test after openclaw#200038 retired its access call. Preserve all readiness assertions and production behavior.
steipete added a commit that referenced this pull request Nov 16, 2026
* fix(ci): restore worker fixture and readiness checks

Declare the two live spawned test fixtures introduced by #199560 as exact Knip roots. Hold the current asynchronous executable stat in the HTTP readiness test after #200038 retired its access call. Preserve all readiness assertions and production behavior.

* fix(test): hold current runtime preparation during startup readiness

* fix(ci): complete live workflow consumer graph after consolidation
steipete added a commit that referenced this pull request Nov 17, 2026
…200370)

* fix(gateway): keep runtime probes off the main spawn thread

Route asynchronous runtime viability probes through the existing broker host without re-entering command diagnosis. Keep broker state separate from startup and detect removed runtimes even while the transport is unavailable. Preserve the detection introduced by @obviyus in #200038 and the spawn ownership established by #150564.

* refactor(process): separate the spawn broker host contract

Remove the type dependency cycle found by PR CI while retaining the existing host factory and operations. Keep runtime viability below host startup and diagnosis.

* fix(process): include broker state in the PR wrapper runtime inventory

Keep extracted native wrapper sources closed over the runtime viability imports. The missing state module broke isolated bootstrap, which cascaded into private provisioning fixture failures. Existing runtime probes remain unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…law#200038)

The Gateway's Node runtime viability check now runs the runtime itself instead of only checking that the binary exists, so a Node whose shared libraries are missing is reported as unavailable with the loader error and the existing restart guidance. Before, health and status reported it as available while every child exited with code 127, and the relay showed only EPIPE.

The probe runs on health, status and readiness reads and on restart reacquisition, never on healthy child launches; a healthy probe costs about 8 ms and is not cached, because removing a shared library leaves the binary's identity unchanged.

Fixes openclaw#199762. Thanks @goldmar for the report.

Proof: natural Linux reproduction (shared library removed), main twice and candidate twice, plus relay proof twice. Production +6, tests net 0.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…w#200133)

* fix(ci): restore worker fixture and readiness checks

Declare the two live spawned test fixtures introduced by openclaw#199560 as exact Knip roots. Hold the current asynchronous executable stat in the HTTP readiness test after openclaw#200038 retired its access call. Preserve all readiness assertions and production behavior.

* fix(test): hold current runtime preparation during startup readiness

* fix(ci): complete live workflow consumer graph after consolidation
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 17, 2026
…penclaw#200370)

* fix(gateway): keep runtime probes off the main spawn thread

Route asynchronous runtime viability probes through the existing broker host without re-entering command diagnosis. Keep broker state separate from startup and detect removed runtimes even while the transport is unavailable. Preserve the detection introduced by @obviyus in openclaw#200038 and the spawn ownership established by openclaw#150564.

* refactor(process): separate the spawn broker host contract

Remove the type dependency cycle found by PR CI while retaining the existing host factory and operations. Keep runtime viability below host startup and diagnosis.

* fix(process): include broker state in the PR wrapper runtime inventory

Keep extracted native wrapper sources closed over the runtime viability imports. The missing state module broke isolated bootstrap, which cascaded into private provisioning fixture failures. Existing runtime probes remain unchanged.
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…200370)

* fix(gateway): keep runtime probes off the main spawn thread

Route asynchronous runtime viability probes through the existing broker host without re-entering command diagnosis. Keep broker state separate from startup and detect removed runtimes even while the transport is unavailable. Preserve the detection introduced by @obviyus in #200038 and the spawn ownership established by #150564.

* refactor(process): separate the spawn broker host contract

Remove the type dependency cycle found by PR CI while retaining the existing host factory and operations. Keep runtime viability below host startup and diagnosis.

* fix(process): include broker state in the PR wrapper runtime inventory

Keep extracted native wrapper sources closed over the runtime viability imports. The missing state module broke isolated bootstrap, which cascaded into private provisioning fixture failures. Existing runtime probes remain unchanged.

(cherry picked from commit df78722)

Companion audit: context-state and host-contract preserve broker owner; focused runtime probe test retained.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 8899507525a1caaf7947d042270257b3f33c24f4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant