Repository navigation
feat(cloud): provision verified Node toolchains - #170796
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bba94df1a2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (requirement && requirement !== "system") { | ||
| const npm = spawnSync("sh", ["-c", "command -v npm"], { encoding: "utf8" }); | ||
| if (npm.status !== 0) throw new Error("Repository Node resolution requires npm beside bootstrap Node; repair the image or profile setup and retry"); | ||
| const semver = require(require.resolve("semver", { paths: [path.dirname(fs.realpathSync(npm.stdout.trim()))] })); |
There was a problem hiding this comment.
Resolve SemVer independently of the npm launcher
On Linux images where a supported Node installation is exposed through Volta, asdf, or mise, command -v npm returns a manager shim rather than npm's package directory. Resolving semver relative to that shim therefore throws MODULE_NOT_FOUND, so every repository with a non-system Node declaration fails preparation even though Node and npm are functional. Resolve SemVer from the actual npm installation or carry the resolver with the generated preparation script instead.
Useful? React with 👍 / 👎.
| let nodeBin = path.dirname(process.execPath); | ||
| const fetchText = async (url) => { | ||
| try { | ||
| const response = await fetch(url, { signal: AbortSignal.timeout(120000), redirect: "error" }); |
There was a problem hiding this comment.
Honor standard proxy variables when fetching release metadata
On workers whose outbound HTTPS access requires the usual HTTPS_PROXY/HTTP_PROXY environment variables, the archive download via curl can succeed but Node's bare fetch does not use those variables unless separate Node proxy support is explicitly enabled. Repository Node selection consequently fails while fetching index.json or SHASUMS256.txt, including on the proxy setup that the new troubleshooting guidance tells users to check. Use the same proxy-aware downloader as the archive path or explicitly configure fetch from the proxy environment.
Useful? React with 👍 / 👎.
bba94df to
83957d0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83957d0731
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| root="$HOME/.openclaw-worker/toolchains/node" | ||
| mkdir -p "$root" | ||
| destination="$root/$version-linux-$arch-$digest" | ||
| if [ -s "$destination/.files.sha256" ] && (cd "$destination" && sha256sum --status -c .files.sha256) && [ "$("$destination/bin/node" --version)" = "v$version" ]; then |
There was a problem hiding this comment.
Keep bootstrap credentials out of mutable Node reuse
When a bare Linux worker runs an authorized repository setup script before enrollment, that script executes as the same user and can rewrite both this shared toolchain and its colocated .files.sha256; a replacement node can then regenerate the manifest and return the expected version. Enrollment subsequently forwards the bootstrap token and setup code while this check and the reused node execute, so repository code can silently capture those credentials. Perform toolchain installation/revalidation in a separate secretless phase and only forward enrollment credentials after selecting a bootstrap executable that repository code cannot modify.
AGENTS.md reference: AGENTS.md:L100-L102
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8a2feee5a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ...(process.platform === "linux" | ||
| ? { PATH: path.join(homeDir, ".local", "bin") + path.delimiter + (baseEnv.PATH ?? "") } |
There was a problem hiding this comment.
Keep writable repository shims out of host Git PATH
When repository setup or a session writes $HOME/.local/bin/git, this PATH causes host-owned operations such as runNodeWorkspaceManifestCapture and initializeNodeWorkerGitWorkspace to execute that repository-controlled binary instead of the worker's trusted Git. A checkout can therefore falsify manifest/capture results or corrupt later workspace synchronization; use the repository shim PATH only for repository/session commands, while internal Git operations retain the original host PATH.
Useful? React with 👍 / 👎.
f8a2fee to
d4f3bb5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4f3bb5e43
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const enabled = spawnSync(path.join(bin, "corepack"), ["enable", "--install-directory", bin], { | ||
| env: { PATH: setupPath, HOME: homeDir }, encoding: "utf8", timeout: 60000, |
There was a problem hiding this comment.
Run fallback Corepack with its owning Node
When a repository selects a Node release that does not bundle Corepack (for example, a pre-Corepack Node release) and declares packageManager, the fallback Corepack comes from the bootstrap installation, but this invocation prepends the repository's selected node to PATH. Corepack's launcher therefore runs under that older Node and can fail its own engine or syntax requirements, preventing an otherwise valid repository setup. Invoke the fallback Corepack with its bootstrap Node, or reject repository Node/Corepack combinations that cannot run together.
Useful? React with 👍 / 👎.
|
Merged with a pinned-head REST squash on |
Repository Node releases without Corepack (pre-16.9, and Node 25+, which no longer bundles it) fell back to the worker's Corepack, whose env-node shebang then ran it under the repository Node even when Corepack's engines reject that release. Preparation failed in `corepack enable`, and the shims would have failed the same way in sessions. When the fallback Corepack's engines exclude the repository Node, preparation now copies it into the prepared HOME with entry stubs that exec the worker Node. Corepack links shims into its own package, so preparation, the detected install recipe's second enable, and user setup all produce pinned shims. The package manager runs in-process on the worker Node; node on PATH remains the repository release. Compatible releases keep running Corepack on the repository Node as before. Follow-up to the landing review of #170796.
Linux cloud workers no longer need a hand-written Node.js setup script. Before runtime installation, a bare machine gets an official Node.js 24.21.0 release verified against digests pinned in source, installed into a content-addressed toolchain directory that snapshots reuse. A repository's requested Node version (.nvmrc, .node-version, .tool-versions/mise.toml, or package.json engines) is installed separately, verified against nodejs.org SHASUMS256.txt, and put first on PATH for setup and sessions, while the worker runtime keeps its own supported Node. Corepack shims are user-writable. Download and integrity failures name the next step. macOS and Windows targets keep their image-provided Node contract. Live AWS proof: a bare x64 lease without Node installed bootstrap Node v24.21.0 and repository Node v22.23.3, ran npm/npx/Corepack/pnpm, and reused the toolchain in 19.9 s. Refs: openclaw#170796
) Repository Node releases without Corepack (pre-16.9, and Node 25+, which no longer bundles it) fell back to the worker's Corepack, whose env-node shebang then ran it under the repository Node even when Corepack's engines reject that release. Preparation failed in `corepack enable`, and the shims would have failed the same way in sessions. When the fallback Corepack's engines exclude the repository Node, preparation now copies it into the prepared HOME with entry stubs that exec the worker Node. Corepack links shims into its own package, so preparation, the detected install recipe's second enable, and user setup all produce pinned shims. The package manager runs in-process on the worker Node; node on PATH remains the repository release. Compatible releases keep running Corepack on the repository Node as before. Follow-up to the landing review of openclaw#170796.
Problem
What Problem This Solves
A bare Linux cloud worker cannot prepare a project or install the OpenClaw runtime until Node is on PATH. Profiles currently work around that with a long OS-specific setup script. A repository's Node requirement also needs to be independent of the supported Node used by the worker runtime.
Solution
Use one core-owned Linux installer for project preparation and runtime bootstrap. It downloads official Node.js 24.21.0 (the repository's CI pin), checks source-pinned SHA-256 digests for x64/arm64, and publishes a toolchain directory keyed by release, architecture, and digest. Existing installations pass file checksum and version checks before reuse. Supported installations with npm, npx, and Corepack are preserved.
Resolve repository requirements through
resolveRepositoryNodeRequirement(files), in precedence order:.nvmrc,.node-version,.tool-versions,mise.toml[tools] node, thenpackage.jsonengines.node. Resolve the latest matching official release using npm's bundled SemVer implementation and verify its archive against the release's HTTPS SHASUMS256.txt. Prepared-HOME shims put repository Node first for setup and session commands.packageManagerenables Corepack shims in that user-writable directory. Runtime installation and enrollment retain their supported Node by absolute path. Crabbox records that executable for later diagnostic and snapshot scrub commands in fresh shells, updating an older image binding before using it.The existing runtime grant carries the Linux prerequisite script to Crabbox, avoiding a new SDK helper export. The small repository resolver is ready for the separate devcontainer lane to add another source.
Impact
Linux x64/arm64 Crabbox workers no longer need a Node installation recipe in profile
setup. Toolchains stay inside captured images and verified installations are reused on forks. Existing profile setup scripts and the committed.openclaw/worktree-setup.shconvention continue to work. Newly provisioned workers receive the behavior when the Gateway is updated; no config migration is needed. macOS and Windows retain image/setup-provided Node. Linux images require compatible glibc, curl, tar, and sha256sum.The docs remove the long bash recipe, describe optional setup, and add actionable download/integrity troubleshooting.
Evidence
pnpm build:runtime— passed, 198.30 s. Includes runtime postbuild and UI budget checks; no budget or baseline changes.pnpm tsgo— passed, 14.19 s.pnpm test src/gateway/worker-environments/node-toolchain.test.ts src/gateway/worker-environments/project-preparation-verification.test.ts src/gateway/worker-environments/node-enrollment.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment.test.ts --maxWorkers=1— passed, 70 tests, 206.93 s; final source verification passed.pnpm test src/gateway/worker-environments/node-toolchain.test.ts --maxWorkers=1— passed, 9 tests, 12.61 s wall time / 2.57 s inside Vitest.node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/gateway/worker-environments/node-toolchain.ts src/gateway/worker-environments/repository-node-requirement.ts src/gateway/worker-environments/repository-node-toolchain.ts src/gateway/worker-environments/node-toolchain.test.ts src/gateway/worker-environments/node-enrollment.ts src/gateway/worker-environments/project-setup-script.ts src/gateway/worker-environments/project-seed-script.ts src/gateway/worker-environments/project-preparation.test-support.ts src/node-host/node-worker-environment.ts src/node-host/node-worker-workspace-commands.ts src/plugins/capability-provider.types.ts— passed, 29.78 s.node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/crabbox/src/crabbox-worker-node-enrollment.ts— passed, 323.13 s including SDK boundary declaration preparation.pnpm format:check docs/gateway/cloud-workers.md docs/gateway/cloud-workers/setup-and-bundle-installation.md docs/gateway/cloud-workers/troubleshooting.md docs/plugins/sdk-runtime.md extensions/crabbox/src/crabbox-worker-node-enrollment.ts src/gateway/worker-environments/node-enrollment.ts src/gateway/worker-environments/node-toolchain.ts src/gateway/worker-environments/node-toolchain.test.ts src/gateway/worker-environments/project-preparation.test-support.ts src/gateway/worker-environments/project-seed-script.ts src/gateway/worker-environments/project-setup-script.ts src/gateway/worker-environments/repository-node-requirement.ts src/gateway/worker-environments/repository-node-toolchain.ts src/node-host/node-worker-environment.ts src/node-host/node-worker-workspace-commands.ts src/plugins/capability-provider.types.ts— passed, 1.45 s.git diff --check— passed, 1.00 s.Rebased onto
831df7209940to resolve a documentation-only wording conflict. At that point all executable and test files were byte-identical to the reviewed/testedbba94df1a27fcommit; the fresh-shell follow-up below is additional work. The rebased docs passpnpm format:check docs/gateway/cloud-workers.md docs/gateway/cloud-workers/setup-and-bundle-installation.md docs/gateway/cloud-workers/troubleshooting.md docs/plugins/sdk-runtime.md(1.60 s) andgit diff --check(0.90 s);pnpm install --frozen-lockfilecompleted after the rebase (17.2 s reported by pnpm).node scripts/worktree-setup.mjs fullinstalled dependencies successfully. Its broad declaration build was stopped after 1404.43 s; the supported runtime build and source typecheck above completed instead. An early test fixture depended on an environment variable that production intentionally strips; the fixture was fixed. An intermediate combined run was invalidated by source edits, then rerun against frozen final sources. Prior-head PR CI succeeded on83957d07313ef01dee18e7134661538f7ee5987a: 76 jobs completed with no failures, 664 s elapsed including queue/setup time. Per-file Vitest CI timing is not reported here. The PR context check also passed after adding its required problem subheading; no source repush or CI rerun was used for that metadata correction.Live AWS proof used one stock Linux x64
tiny/t3.smalllease (cbx_56a79c55e7bc), with no repository sync or credential hydration. Running the generated installer viacrabbox run --provider aws --network public --tailscale=false --id cbx_56a79c55e7bc --no-sync --no-hydrate --script-stdin --timing-jsonstarted with no Node on PATH and produced:The command completed in 19.897 s.
crabbox stop --provider aws --id cbx_56a79c55e7bccompleted and inspection confirmedreleased. This live run preceded the final prerequisite checks and comment-parsing polish, which are covered by local tests. Arm64 was not exercised live. The lead's integrated session/snapshot proof remains a follow-up.Fresh-shell runtime follow-up
The final caller audit found that standalone snapshot scrub and diagnostic commands open new shells. Persist the bootstrap-selected executable in
~/.openclaw-worker/runtime-node/node, and use that binding in subsequent Linux transport commands. Bootstrap binds its current selection before consulting an older snapshot link. A shell regression proves replacement of a stale link and execution with no other Node on PATH; the scrub regression proves capture uses and preserves the retained executable.pnpm test extensions/crabbox/src/crabbox-worker-script.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment-diagnostics.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment-errors.test.ts extensions/crabbox/src/crabbox-worker-bootstrap-download.test.ts extensions/crabbox/src/crabbox-worker-warm-image.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment-replay.test.ts --maxWorkers=1— passed, 92 tests, 372.56 s; completed compiler-generation verification passed.pnpm test extensions/crabbox/src/crabbox-worker-script.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment-diagnostics.test.ts extensions/crabbox/src/crabbox-worker-warm-image.test.ts src/gateway/worker-environments/node-toolchain.test.ts --maxWorkers=1— 399.42 s, 53 passed and two diagnostics fixture failures. The added shell prelude invalidated their fixed-line extraction. All three affected VM fixtures now extract the named heredoc body; the final run above passes. The 26 enrollment cases and nine core toolchain cases passed unchanged in this run.pnpm tsgo— passed, 487.21 s including the artifact-lock wait.node scripts/run-oxlint.mjs --tsconfig extensions/tsconfig.json extensions/crabbox/src/crabbox-worker-script.ts extensions/crabbox/src/crabbox-worker-script.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment.ts extensions/crabbox/src/crabbox-worker-warm-image-scrub.ts extensions/crabbox/src/crabbox-worker-warm-image.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment-diagnostics.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment-errors.test.ts extensions/crabbox/src/crabbox-worker-bootstrap-download.test.ts— passed, 207.14 s including artifact preparation/wait.pnpm format:check extensions/crabbox/src/crabbox-worker-script.ts extensions/crabbox/src/crabbox-worker-script.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment.ts extensions/crabbox/src/crabbox-worker-warm-image-scrub.ts extensions/crabbox/src/crabbox-worker-warm-image.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment-diagnostics.test.ts extensions/crabbox/src/crabbox-worker-node-enrollment-errors.test.ts extensions/crabbox/src/crabbox-worker-bootstrap-download.test.ts docs/gateway/cloud-workers/setup-and-bundle-installation.md— passed, 1.62 s.git diff --check— passed, 1.63 s.pnpm build:runtime— passed, 933.57 s including the artifact-lock wait; runtime postbuild and UI performance gates passed without baseline changes.The AWS installer proof above predates this transport follow-up. The new transport behavior is covered by local shell and capture regressions; the lead still owns integrated live session/snapshot proof. No additional lease was created.
Final head:
f8a2feee5a2b27e736bb2965423344ffcc39ad43. CI run 38375015824 attached to this exact head and was in progress with no reported failures at handoff. The PR is ready and mergeable. The bounded watcher was stopped after verifying attachment; remote CI continues. The prior successful CI run above is not claimed as final-head evidence.Release-note context
Cloud workers automatically provision verified Node.js toolchains on Linux x64/arm64, honor repository Node requirements for setup and sessions, and enable declared package managers through Corepack without sudo. Profile setup is optional for Node, and captured environments reuse their toolchains.