Skip to content

fix(gateway): spawn Node children through the stable runtime path after a Homebrew Node upgrade - #166430

Merged
steipete merged 4 commits into
mainfrom
upd/upd-spawn-stable-node-path
Oct 7, 2026
Merged

steipete merged 4 commits into
mainfrom
upd/upd-spawn-stable-node-path

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Completes recovery and actionable diagnostics for exec and stdio MCP startup after Homebrew removes the Node executable used by a still-running Gateway. This follows the stable-path fix already merged in #166222.

Closes #166170. Thanks @mightyx for the report and reproduction.

User Impact

Exec and stdio MCP command relays can launch through the matching stable Homebrew path after the old executable disappears. When an exact-runtime child cannot start, the operator and agent receive the existing “Gateway runtime is stale after Node upgrade … Restart the Gateway.” diagnostic. The supervisor records that condition once while retaining each failed call's actionable error.

No new settings or automatic restart. No state migration or data mutation. Restart remains necessary for workers that require the running Gateway's exact runtime.

Why This Change Was Made

The exec tool and MCP transport share the service-child relay owner. This uses the canonical resolveLaunchableNodePath for the relay and its nested process-group anchor, and passes the selected interpreter through argument construction. Healthy executables and non-Homebrew paths retain their existing selection; the target command itself is never rewritten.

The spawn broker deliberately keeps process.execPath: its bidirectional V8 serialization and native-resource worker mode require the parent's exact runtime. SQLite, native worktree, and desktop workers keep their interpreter as well. Broker startup and supervisor failures reuse the existing viability check and warning, preserve errno/path metadata, and distinguish missing commands or working directories from a removed Node executable.

Evidence

Three new regressions failed on the original production code. The repair passes real exec and owned MCP stdio launches after removing a synthetic Homebrew executable, preserves explicitly selected/native broker runtimes, and returns the restart action once through the supervisor. The eight focused suites passed 80 tests in three runs. The broker retry-budget suite passed 20 standalone runs; its final fixture typing correction passed three more runs.

Validation also exposed two retry-budget tests that repeatedly booted cold subprocesses and raced 7-second/20-second windows. Their budget assertions now run against controlled child events and fake timers: measured healthy-generation / exhausted-budget test times fell from 10.464s / 9.198s to 3ms / 1ms in the integrated run. Real process loss, cleanup, and recovered-command routing remain covered by the broker integration suites.

The full local runtime build passed in 25m 25s. The initial importer run reported 831 passed, one failed, and 15 skipped; the remaining 54 selected files then completed with 541 passed and 11 skipped in 275.31s. Together they cover all 96 direct/one-barrel importer selections. After integrating main, the eight focused suites passed 82 tests in 33.44s, and the wrapper import-closure check passed in 12.60s. Final node scripts/check-changed.mjs --base 2beca62e67b1fb3bc1f55ad3025f2eb5d50d4c3d passed (exit 0), including production/test typechecks, core/script lint, all export scans, and ownership guards.

Diff against integrated main: production +50/-18; tests +203/-92; docs +7/-2; wrapper inventory +1/-0. The resolver itself is unchanged from main.

The integrated check initially reported seven unused auth-facade exports because main's new exact-allowlist test used a type-only namespace import in its partial mock. Using the equivalent inline typeof import(...) type removes that false namespace signal without changing the mock or assertions. All three export scans now report zero findings; the two allowlist cases passed three runs (24.24s, 11.29s, 9.23s wall; test time below one second per run).

Known pre-existing timing flake / follow-up: src/worker/worker.runtime.test.ts — stops registered background execs after anchor. The initial importer run observed capacity 0 where 1 was expected. A controlled A/B run reproduced the same failure on origin/main; the test and lifecycle logic are unchanged by this PR. Follow up on anchor-loss cleanup/lineage confirmation and its capacity observation.

A = pinned origin/main at 27ba9720f2c5bad0326fee928ddb562340e0517d.
B = this repair at 4f530b81060496c69d37d9427a3527cc81da902e.
Only the named anchor-loss test ran, in the following order. Capacity is the value established by the final capacity assertion (expected 1 on macOS).

Run Result Capacity Test time Wall time
A1 FAIL 0 25.025s 100.78s
B1 PASS 1 13.326s 53.64s
A2 PASS 1 9.723s 39.72s
B2 PASS 1 10.776s 36.45s
A3 PASS 1 20.306s 71.92s
B3 PASS 1 12.813s 34.67s

Linux CI correction: At c17a252f05a512edc71ddb0cfbb1237d7e68f93a, the explicitly selected runtime test failed in the Linux process shard. This was a production startup-reporting bug: Linux's OOM-score shell started successfully, then failed to exec the already-deleted Node binary. The target stayed pinned, but the shell masked native ENOENT and the supervisor returned a run instead of the restart diagnostic. The fixture already owned and deleted its temporary runtime path.

The OOM owner now uses the existing runtime-viability check to retain a direct native launch when the selected executable is the missing Gateway runtime. Healthy-runtime OOM wrapping is unchanged. The regression runs the real Darwin and Linux OOM policies with an empty temporary PATH; its rejection and once-only warning assertions are preserved. The Linux-policy case reproduced the CI failure locally before the production change.

At 7ffb51e63b7b321fe2d98e1ef1e0d19d31d9c050, the four-case file passed three times on macOS with Linux OOM policy exercised (28.28s / 6.88s / 9.85s wall; less than one second of tests per run). The 118 selected touched/direct/one-barrel importer files passed across 26 shards: 1,925 tests passed, 54 existing skips. Total wall time was 27m08s including a 7m49s runtime build; no single test exceeded 30s or file exceeded 120s of test time. Final node scripts/check-changed.mjs --base 2beca62e67b1fb3bc1f55ad3025f2eb5d50d4c3d passed with exit 0. This correction is production +3/-0 and tests +33/-17; native Linux CI will validate the pushed head.

P1 autoreview was attempted but the local runner could not maintain isolation, so no independent review verdict is claimed. Maintainer P1 review remains pending. All proof ran locally with isolated OpenClaw state; CI timing will be available after submission.

Resolve removed Homebrew Node executables at the independent command relay owner, preserving exact runtimes for native and V8 workers. Reuse the stale-runtime restart warning at failed supervisor and broker launches.

Closes #166170. Thanks @mightyx for the report and reproduction.
@clawsweeper

clawsweeper Bot commented Oct 7, 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 scripts Repository scripts size: M labels Oct 7, 2026
@steipete
steipete marked this pull request as ready for review October 7, 2026 03:40
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 12:43 AM ET / 04:43 UTC (Revision 2).

ClawSweeper review

What this changes

The branch repairs command-relay launches after Homebrew removes Node, preserves exact runtimes for broker workers, improves restart diagnostics, and replaces slow retry-budget tests with controlled events.

Merge readiness

✅ Ready for maintainer review

This PR remains useful beyond the earlier merged repair. No introduced correctness or security defect was found, and the documented exact-runtime tradeoff is already accepted within this maintainer-authored change.

Priority: P1
Reviewed head: 7ffb51e63b7b321fe2d98e1ef1e0d19d31d9c050

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful subprocess regressions, reported validation, and no actionable introduced defect.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: Repository State identifies this as a MEMBER-authored follow-up, so the external-contributor proof gate does not apply. The body reports isolated real subprocess recovery through the supervisor and owned-stdio owner, including the Linux-policy correction; this reviewer did not execute those runs. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies this as a MEMBER-authored follow-up, so the external-contributor proof gate does not apply. The body reports isolated real subprocess recovery through the supervisor and owned-stdio owner, including the Linux-policy correction; this reviewer did not execute those runs. No stored-data contract changes.
Evidence reviewed 9 items Introduced change identity: Reviewed the pinned introduction delta from 2beca62 to the original PR head. Endpoint drift was not treated as contributor work, and the stale test merge was not used to claim removal of current-main behavior.
Meaningful work remains beyond current main: At fetched main, the nested relay anchor still launches process.execPath, broker startup still selects the replacement runtime, and Linux OOM preparation lacks the missing-runtime exception. The PR changes these concrete behaviors rather than duplicating the existing resolver.
Earlier repair is merged but only partially overlaps: GitHub confirms #166222 merged as f0c9bcf. Its launch-time resolver is reused unchanged here; it does not contain this PR’s nested-anchor repair or startup diagnostics. The supplied latest release is v2026.9.8, and the local tag-containment check found no tag containing that earlier merge.
Findings None None.
Security None None.

How this fits together

The Gateway’s process supervisor and command relays launch exec tools and stdio MCP servers. Runtime selection determines whether those children can start after a Node upgrade, while the supervisor reports failures and retains cleanup ownership.

flowchart TD
  A[Exec and MCP requests] --> B[Process supervisor]
  B --> C[Command relay]
  C --> D[Available Homebrew runtime]
  D --> E[Process group anchor]
  E --> F[Requested command]
  B --> G[Exact-runtime broker]
  G --> H[Startup or restart diagnostic]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +32, Tests +111, Docs +5, Other +1. Total +149 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 6 50 18 +32
Tests 4 203 92 +111
Docs 2 7 2 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 13 261 112 +149

Review metrics

Metric Value Why it matters
Production versus test growth production +50/-18; tests +203/-92 The body justifies production growth for runtime selection and diagnostics, while the test rewrite removes repeated cold-process timing budgets.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #166170
Summary: This PR completes recovery and diagnostics for the reported executable-removal mechanism after an earlier partial repair closed the report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Recover independent command relays through the existing Homebrew resolver while preserving exact-runtime workers and actionable restart errors.

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

Yes, from source: remove the Node executable held by a running Gateway, then request exec/MCP startup or an exact-runtime child. The captured regression exercises these boundaries, but this read-only review did not run it.

Is this the best way to solve the issue?

Yes. Reusing the existing resolver for independent relays and retaining exact runtimes for native/V8 workers keeps runtime selection in its existing owners without new settings or restart automation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 078ca8950dbc.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The reported official-release failure blocks exec and MCP startup after a routine Homebrew Node upgrade.
  • merge-risk: 🚨 compatibility: The broker intentionally stops using a replacement interpreter after runtime removal and requires restart; the maintainer-authored design explicitly accepts this exact-runtime constraint.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies this as a MEMBER-authored follow-up, so the external-contributor proof gate does not apply. The body reports isolated real subprocess recovery through the supervisor and owned-stdio owner, including the Linux-policy correction; this reviewer did not execute those runs. No stored-data contract changes.

Evidence

What I checked:

  • Introduced change identity: Reviewed the pinned introduction delta from 2beca62 to the original PR head. Endpoint drift was not treated as contributor work, and the stale test merge was not used to claim removal of current-main behavior. (7ffb51e63b7b)
  • Meaningful work remains beyond current main: At fetched main, the nested relay anchor still launches process.execPath, broker startup still selects the replacement runtime, and Linux OOM preparation lacks the missing-runtime exception. The PR changes these concrete behaviors rather than duplicating the existing resolver. (src/process/supervisor/service-child-relay.ts:167, 078ca8950dbc)
  • Earlier repair is merged but only partially overlaps: GitHub confirms fix(process): exec and MCP servers fail with ENOENT after a Homebrew Node upgrade #166222 merged as f0c9bcf. Its launch-time resolver is reused unchanged here; it does not contain this PR’s nested-anchor repair or startup diagnostics. The supplied latest release is v2026.9.8, and the local tag-containment check found no tag containing that earlier merge. (src/infra/stable-node-path.ts:22, f0c9bcfbe30f)
  • Accepted exact-runtime compatibility tradeoff: The maintainer-authored body explicitly retains the broker’s exact interpreter because native resources and bidirectional V8 frames require it, and documents that these workers require a Gateway restart after executable removal. The code and Node installation guidance implement that same scoped decision; no repeated product approval is needed. (src/process/spawn-broker/host.ts:387, 7ffb51e63b7b)
  • Linux error preservation: OOM preparation bypasses its shell only when the selected command equals the missing Gateway runtime. Healthy-runtime wrapping and shell-environment hardening remain intact. The new formatter requires matching ENOENT/path metadata and independently checks runtime availability before producing the restart message. (src/process/linux-oom-score.ts:164, 7ffb51e63b7b)
  • Boundary regression and reported validation: The new regression deletes a temporary Homebrew-shaped executable, uses real subprocesses through the supervisor and owned-stdio owner, checks exec-ok/mcp-ok output, and verifies restart rejection when recovery is unavailable. Separate cases preserve exact broker selection and exercise Darwin/Linux OOM policies. The captured body reports final-head repeated passes and 1,925 passing importer tests; these were not executed by this read-only review. (src/process/spawn-broker/node-runtime.test.ts:32, 7ffb51e63b7b)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jay Zhou: Raw commit f0c9bcf adds src/infra/stable-node-path.ts:22 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f0c9bcfbe30f; files: src/infra/stable-node-path.ts)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-07T03:46:17.035Z sha c17a252 :: needs maintainer review before merge. :: none

Keep the native launch failure when the Gateway executable is gone instead of accepting a shell wrapper's successful spawn. Exercise both OOM policies with the deleted temporary executable and an empty PATH.
@steipete
steipete merged commit 520db50 into main Oct 7, 2026
141 of 144 checks passed
@steipete
steipete deleted the upd/upd-spawn-stable-node-path branch October 7, 2026 04:47
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged at the reviewed head despite one red check. checks-node-changed-extensions-bundle-2 failed with an unhandled recvmsg ECONNREFUSED in extensions/openai/realtime-quicksilver-peer-worker.test.ts under Bun. That test runs its workers as in-process worker_threads and never reaches the spawn broker, the process supervisor or the Linux OOM wrapper, which are the only runtime files this PR changes, so the failure is unrelated to this change. Every other check on this head passed.

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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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.

[Bug]: After brew upgrade node, running Gateway spawns children from removed Cellar path (spawn ENOENT) until restart

1 participant