Skip to content

fix(update): hand the private Node runtime to npm lifecycle children - #164677

Merged
steipete merged 1 commit into
mainfrom
upd/upd-private-node-npm-lifecycle-path
Oct 4, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-private-node-npm-lifecycle-path

Conversation

@steipete

@steipete steipete commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Closes #164525

What Problem This Solves

Fixes npm installs during update or recovery selecting an unsupported system Node for lifecycle scripts even though npm itself runs with a compatible private Node. Reported by @jarvisnextgeneration20-lang.

Why This Change Was Made

A dependency-free helper prepends the selected Node directory to the child PATH during startup recovery, explicit Node-driven npm/pnpm execution, and update runtime selection. Explicit executable invocation remains in place, and npm_config_node is preserved. Plain npm, pnpm, and bun commands retain the caller's runtime selection.

The helper is included in npm, Docker, worker-bootstrap, and PR-wrapper source inventories. The PR-wrapper inventory change contains only node-runtime-env.mjs.

User Impact

Recovery and package-manager updates can keep lifecycle children on the compatible runtime while the system Node remains unsupported. This changes child environments only; no new options, dependency versions, state schemas, or shell settings are introduced.

Evidence

Runtime and regression proof

  • Real installed npm, an offline fixture package with preinstall: node -p "process.version", and a fake system Node first in PATH: before the fix, stdout contained v22.22.3; afterward it reported the selected private runtime (v26.10.0 locally and v24.19.0 on Linux).
  • Four focused suites passed three times: 87 tests per pass. Eighteen packaging/launcher fixture suites also completed three passing runs, retaining two existing skips. Four old launcher expectations were updated to require the selected runtime prefix plus the complete inherited PATH.
  • The npm lifecycle case took 0.69 s locally and about 0.14 s on Linux. The local single-file Node test-wrapper run took 29.38 s including 23.16 s of shared compiler preparation.
  • Final trimmed wrapper inventory and source-closure guards: 2 files, 20 tests passed in 65.53 s wall time. The four CI test-plan suites passed. Export-name collision guard passed; the requested restart-swap fixture command exited 0.
  • Direct-route Codex P1 review: no accepted/actionable findings for the Node handoff and minimal helper inventory change.
  • Local node scripts/check-changed.mjs completed: all preceding checks, all typecheck lanes, and all three dead-export scans passed; lint failed only on the inherited findings listed below. The remaining pnpm check:import-cycles was run separately and passed with zero runtime value cycles.

Main-side wrapper failure (waived; FIX1)

The lead explicitly waived the existing macOS cold/warm provisioning failure in test/scripts/pr-worktree-provision.test.ts. Its failing guard is:

expect(existsSync(templates)).toBe(true);

The missing-runtime diagnostic below is quoted with only the temporary fixture prefix normalized:

[agents/worktrees] worktree acceleration unavailable; using Git checkout: Error: Cannot find module '<fixture>/canonical/src/state/openclaw-state-worker-runtime.js' imported from '<fixture>/canonical/src/state/openclaw-state.worker.ts'

The known APFS variant reports Error: Test timed out in 120000ms. (134.53 s wall time). FIX1 owns this worker-dispatch gap; this PR does not add those inventory entries or change the timeout/assertions.

Slow pre-existing suites (waived)

  • src/cli/update-cli/update-command-original-service.test.ts: 188.537 s across 54 cases.
  • src/cli/update-cli.npm-runtime.test.ts: preserves split-root package updates when the service definition is writable-overridden, 30.190 s.
  • Existing native PR provisioning case preserves a symlinked parent through native Git with acceleration enabled: 31.999 s on the loaded Mac.

These are covered by the lead's standing slow-suite waiver; no timeout, retry, assertion, or baseline changes were made for them.

Importer coverage and waiver

The direct and single-barrel search selected 395 importer files. Completed importer groups reported 112 files passed and one skipped before Testbox cancellation interrupted infrastructure coverage. The remaining 282 files are waived under the final L1421 ruling; no new remote lease was requested on resume. The repeated focused and packaging proof above is retained.

Inherited lint findings outside this diff

None of these files is modified by this PR. The relevant existing lint limits remain unchanged; the two extension files match both the base and current main.

extensions/crabbox/src/crabbox-worker-provider.ts:747:2: error eslint(max-lines): File has too many lines (710). help: Maximum allowed is 700.
extensions/google-meet/src/voice-call-gateway.ts:46:15: error typescript(prefer-promise-reject-errors): Expected the Promise rejection reason to be an Error.
src/gateway/worker-environments/transcript-commit.test.ts:1094:4: error eslint(max-lines): File has too many lines (1028). help: Maximum allowed is 1000.
src/state/openclaw-state-read.worker.ts:704:3: error eslint(max-lines): File has too many lines (701). help: Maximum allowed is 700.
src/plugins/doctor-contract-registry.ts:781:2: error eslint(max-lines): File has too many lines (707). help: Maximum allowed is 700.
src/config/sessions/session-transcript-worker.types.ts:753:3: error eslint(max-lines): File has too many lines (703). help: Maximum allowed is 700.

No lint suppression or baseline was changed. This is qualified validation, not a claim that the whole-repository lint gate is green.

Change size

Production/tooling +49/-8; tests/support +115/-5; docs +5/-3. Total: 21 files, +169/-16.

Propagate the selected runtime through child PATH while retaining explicit executable invocation and npm_config_node. Include the helper in runtime and wrapper packaging inventories and cover real npm preinstall execution with an unsupported PATH node.

Closes #164525.
@clawsweeper

clawsweeper Bot commented Oct 4, 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 gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations docker Docker and sandbox tooling size: S labels Oct 4, 2026
@steipete
steipete marked this pull request as ready for review October 4, 2026 01:38
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 4, 2026
@clawsweeper

clawsweeper Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 9:44 PM ET / October 4, 2026, 01:44 UTC.

ClawSweeper review

What this changes

The PR carries the selected Node runtime into package-manager lifecycle children and includes the shared environment helper in shipped runtime inventories.

Merge readiness

✅ Ready for maintainer review

The PR remains useful: current main covers managed-update PATH selection but lacks the startup-recovery and explicit package-manager handoffs added here. No actionable introduced defect was found.

Priority: P2
Reviewed head: 74201f40c54880fd11ad727c06202929545b32eb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful npm lifecycle proof, compatible environment handling, and complete helper distribution.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured body records real installed npm exercising the production process runner against an offline lifecycle package, with the child changing from the unsupported PATH runtime to the selected runtime on local and Linux runs. Launcher coverage supplements recovery handoff validation; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body records real installed npm exercising the production process runner against an offline lifecycle package, with the child changing from the unsupported PATH runtime to the selected runtime on local and Linux runs. Launcher coverage supplements recovery handoff validation; no stored-data contract changes.
Evidence reviewed 8 items Pinned introduced change: Read the complete merge-base-to-head diff. The functional changes share one dependency-free PATH helper; the remaining changes distribute that helper and update regression fixtures.
Distinct current-main gap: Current main's recovery respawn preserves the original environment without placing the selected runtime directory first. Its process environment resolver likewise lacks the explicit npm/pnpm runtime handoff. Managed update selection already prepends the runtime, so that existing path alone does not establish redundancy.
Latest-release boundary: The supplied latest release, v2026.9.8, also respawns recovery with the original environment. The startup handoff is therefore absent from both the inspected release and fetched main.
Findings None None.
Security None None.

How this fits together

OpenClaw selects a compatible Node runtime for startup recovery and package updates. Its process runner launches package managers, whose lifecycle scripts resolve their own Node executable through PATH.

flowchart TD
  A[Startup recovery or package update] --> B[Selected Node runtime]
  B --> C[Child environment]
  D[Inherited PATH and npm settings] --> C
  C --> E[Package manager]
  E --> F[Lifecycle scripts]
  F --> G[Compatible Node execution]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +10, Tests +110, Docs +2, Config +1, Other +30. Total +153 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 3 17 7 +10
Tests 9 115 5 +110
Docs 1 5 3 +2
Config 1 1 0 +1
Generated 0 0 0 0
Other 7 31 1 +30
Total 21 169 16 +153

Review metrics

None.

Technical review

Best possible solution:

Keep runtime selection and lifecycle-child PATH aligned through the shared startup-safe helper while preserving caller npm configuration.

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

Yes, source establishes the missing handoff when an absolute compatible Node launches npm while an unsupported Node remains first in PATH; the supplied before/after npm run exercises that mechanism. Current main was inspected, not executed.

Is this the best way to solve the issue?

Yes, the startup-safe helper centralizes this handoff without importing application dependencies into recovery, and the patch preserves plain package-manager selection and npm settings.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 91e9b93bcebd.

Labels

Label changes:

  • add P2: This is a bounded runtime-selection repair for recovery and package-manager lifecycle execution.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured body records real installed npm exercising the production process runner against an offline lifecycle package, with the child changing from the unsupported PATH runtime to the selected runtime on local and Linux runs. Launcher coverage supplements recovery handoff validation; no stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body records real installed npm exercising the production process runner against an offline lifecycle package, with the child changing from the unsupported PATH runtime to the selected runtime on local and Linux runs. Launcher coverage supplements recovery handoff validation; no stored-data contract changes.

Label justifications:

  • P2: This is a bounded runtime-selection repair for recovery and package-manager lifecycle execution.
  • 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. Sufficient (live_output): The captured body records real installed npm exercising the production process runner against an offline lifecycle package, with the child changing from the unsupported PATH runtime to the selected runtime on local and Linux runs. Launcher coverage supplements recovery handoff validation; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body records real installed npm exercising the production process runner against an offline lifecycle package, with the child changing from the unsupported PATH runtime to the selected runtime on local and Linux runs. Launcher coverage supplements recovery handoff validation; no stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: Read the complete merge-base-to-head diff. The functional changes share one dependency-free PATH helper; the remaining changes distribute that helper and update regression fixtures. (node-runtime-env.mjs:4, 74201f40c548)
  • Distinct current-main gap: Current main's recovery respawn preserves the original environment without placing the selected runtime directory first. Its process environment resolver likewise lacks the explicit npm/pnpm runtime handoff. Managed update selection already prepends the runtime, so that existing path alone does not establish redundancy. (node-runtime-recovery.mjs:749, 91e9b93bcebd)
  • Latest-release boundary: The supplied latest release, v2026.9.8, also respawns recovery with the original environment. The startup handoff is therefore absent from both the inspected release and fetched main. (node-runtime-recovery.mjs, fc23bc864e45)
  • Verified merge composition: Raw test-merge parents match the pinned base followed by the exact PR head. Comparing that result with its base retains the intended recovery and process-runner changes; endpoint drift was not attributed to this PR. (src/process/exec-spawn.ts:454, b9c791d86c68)
  • Real lifecycle behavior and regression coverage: The captured PR body reports installed npm executing an offline preinstall fixture through the production process runner: the pre-fix child reported v22.22.3, while after-fix runs reported the selected v26.10.0 locally and v24.19.0 on Linux. The inspected regression uses real npm and runCommandWithTimeout, with Windows casing/config preservation and plain-manager compatibility cases. These observations were supplied, not rerun during this read-only review. (src/process/exec.package-manager.test.ts:12, 74201f40c548)
  • Related issue disposition: [Bug]: Private Node runtime is not propagated to npm lifecycle child processes #164525 is closed. Its closing discussion correctly distinguishes manual npm invocation from the existing managed-update handoff. This PR additionally repairs owned startup-recovery and explicit process-runner paths, so that disposition does not supersede the branch.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; 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.

@steipete
steipete merged commit 070b747 into main Oct 4, 2026
352 of 361 checks passed
@steipete
steipete deleted the upd/upd-private-node-npm-lifecycle-path branch October 4, 2026 02:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…penclaw#164677)

When the updater or recovery selected the compatible private Node runtime and ran npm's JavaScript CLI with it, npm lifecycle children (preinstall and friends) resolved plain node from PATH and picked the unsupported system Node, so the install rejected itself. One shared PATH handoff now prepends the selected runtime's bin directory for every package-manager spawn in recovery, update environments, and explicit npm/pnpm execution, preserving npm_config_node and the explicit executable, scoped to the child only. Real-npm regression: lifecycle child reported v22.22.3 before, the private runtime after. Closes openclaw#164525.
RomneyDa pushed a commit that referenced this pull request Oct 11, 2026
…164677)

When the updater or recovery selected the compatible private Node runtime and ran npm's JavaScript CLI with it, npm lifecycle children (preinstall and friends) resolved plain node from PATH and picked the unsupported system Node, so the install rejected itself. One shared PATH handoff now prepends the selected runtime's bin directory for every package-manager spawn in recovery, update environments, and explicit npm/pnpm execution, preserving npm_config_node and the explicit executable, scoped to the child only. Real-npm regression: lifecycle child reported v22.22.3 before, the private runtime after. Closes #164525.

(cherry picked from commit 070b747)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S 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]: Private Node runtime is not propagated to npm lifecycle child processes

1 participant