Repository navigation
fix(gateway): spawn Node children through the stable runtime path after a Homebrew Node upgrade - #166430
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: needs maintainer review before merge. Reviewed October 7, 2026, 12:43 AM ET / 04:43 UTC (Revision 2). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +32, Tests +111, Docs +5, Other +1. Total +149 across 13 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest 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. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
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.
|
Merged at the reviewed head despite one red check. |
…er a Homebrew Node upgrade (openclaw#166430) Closes openclaw#166170 Reported by @mightyx.
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
resolveLaunchableNodePathfor 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 2beca62e67b1fb3bc1f55ad3025f2eb5d50d4c3dpassed (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 onorigin/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/mainat27ba9720f2c5bad0326fee928ddb562340e0517d.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).
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 nativeENOENTand 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. Finalnode scripts/check-changed.mjs --base 2beca62e67b1fb3bc1f55ad3025f2eb5d50d4c3dpassed 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.