Repository navigation
fix(daemon): avoid versioned pnpm paths in Gateway launchers - #167905
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. What this changesGateway service launchers use pnpm’s verified stable package link instead of a version-specific package directory, keeping newly written launchers usable after package replacement. Example: A pnpm-global installation replaces OpenClaw 2026.9.6 with a newer package.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a source-proven launcher defect that remains on current main. The reduced scope removes the earlier Doctor recovery finding, and no concrete introduced bug was found. Priority: P1 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherService installation turns the selected OpenClaw package and runtime into a saved operating-system launcher. On Windows, the Scheduled Task executes that launcher with Node directly supervising the Gateway. flowchart TD
A[Gateway service installation] --> B[Invoking package path]
B --> C[Verify pnpm installation and stable link]
C --> D{Link matches invoking package?}
D -->|Yes| E[Stable package entrypoint]
D -->|No| F[Existing entrypoint selection]
E --> G[Saved service launcher]
F --> G
G --> H[Node runs Gateway]
Technical reviewBest possible solution: Keep stable-link selection in shared service argument planning and preserve the existing direct-Node launcher and forced-reinstall recovery owner. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the failure path: install from a pnpm generation, replace that package outside the managed updater, delete the old generation, and start the saved task. Native reporter observations corroborate it; this review did not execute target code. Is this the best way to solve the issue? Yes, the patch repairs the shared planner using existing pnpm ownership and canonical entrypoint helpers, rather than adding launcher-time scans or shim delegation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8eb960d42a70. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +21, Tests +144, Docs +6. Total +171 across 3 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 9, 2026, 3:19 PM ET / 19:19 UTC (Revision 2). |
9485fc0 to
9bae390
Compare
…penclaw#167905) On a pnpm-global install, openclaw gateway install wrote the Windows Scheduled Task launcher (gateway.cmd) with the realpath of one pnpm store generation (.pnpm/openclaw@<version>/...). Replacing the package removed that generation, so the task launched a missing file, schtasks reported success, and the Gateway never started (about two hours down in the report). Service argument planning now persists the verified stable pnpm package link instead of the replaceable store generation, falling back to the previous behavior when the link cannot be verified. Installs already broken by an older launcher recover with openclaw gateway install --force. Doctor auto-repair of stale launchers is a separate follow-up. Refs openclaw#167835. Reported by @SMF12138.
…167905) On a pnpm-global install, openclaw gateway install wrote the Windows Scheduled Task launcher (gateway.cmd) with the realpath of one pnpm store generation (.pnpm/openclaw@<version>/...). Replacing the package removed that generation, so the task launched a missing file, schtasks reported success, and the Gateway never started (about two hours down in the report). Service argument planning now persists the verified stable pnpm package link instead of the replaceable store generation, falling back to the previous behavior when the link cannot be verified. Installs already broken by an older launcher recover with openclaw gateway install --force. Doctor auto-repair of stale launchers is a separate follow-up. Refs #167835. Reported by @SMF12138. (cherry picked from commit 9b46148)
## What Problem This Solves Fixes node services installed through `npx openclaw connect <join-url> --service` or `npx openclaw node install` pointing at npm's disposable `_npx` cache. ## User Impact The one-paste command installs the selected OpenClaw release into a durable npm prefix under the node's state directory before writing the service. Removing npm's exec cache no longer removes the service's executable. Installation prints the package version, chosen runtime, service command, and a fresh-npx node update command. ## Why This Change Was Made The service argument resolver previously used the running package's resolved path. #167905 fixes pnpm's replaceable store-generation paths by selecting its existing stable link; npm exec has no stable link to select. This preserves that pnpm behavior and adds node-install promotion through the existing npm update owners (`resolveGlobalInstallTarget`, `runGlobalPackageUpdateSteps`, and their staged publication/rollback/cleanup). There is one `<state-dir>/npm` prefix, not a prefix per release. The normal state-directory/profile resolver chooses its location. Run `npx -y openclaw@latest node install --force` on the node to update it, retaining the same profile/state-directory settings. An exact version or `@beta` can replace `@latest`. Reinstalling an already-selected version repairs damaged package files. No new settings or package manager. This does not change `openclaw update` or its existing co-located Gateway selection behavior. Node auto-update still follows the node's npm channel, not the connected Gateway's version/build. The rebase preserves #168653's paired-credential filtering and explicit `--auth-from-env` service argument. No overlap with Pash/Sarah changes. ## Evidence Final code: `27b447dc07b737126124ff8847f2059cb8a4f921`. Packaged live proof ran on `292bd19fe934ecf4ee4e3b20b00a03a1b08f7933`; production feature code and docs are unchanged since that proof. The final revision only corrects regression-test platform handling and rebases onto green main. - **Before:** the regression on baseline `e40606fdea96135758ec5bc0b1a355d08ead0c7e` selected `.npm/_npx/.../node_modules/openclaw/dist/index.js`. In the live isolated replay, published `[email protected]` completed real join-URL enrollment; deleting its npm exec cache made the saved command exit 1 with `MODULE_NOT_FOUND`. - **After:** the canonical self-contained package passed `scripts/package-openclaw-for-docker.mjs --skip-build --allow-unreleased-changelog` and its tarball inventory/import-graph integrity check. Real `npm exec --package=<candidate.tgz> -- openclaw connect <join-url> --service` promoted that selected package into the node's state-owned npm prefix. Both actual launchd and systemd generators selected the durable entrypoint. After removing `_npx`, executing the persisted command as a separate process connected to the isolated Gateway. The published driver's device identity and node settings were unchanged. - **Upgrade and repair:** seeded the durable prefix with published `[email protected]`, retained the enrolled node state, and invoked the candidate through fresh npx with `--profile upgrade node install --force`. The prefix became the candidate version. Overwriting its `dist/index.js` and repeating the same command restored the exact original file bytes. The runtime, device identity, and node settings remained unchanged; the repaired persisted command connected after deleting `_npx` again. The prefix contained only `bin` and `lib`, with one `openclaw` package rather than per-release directories. - **Package identity:** the unpublished candidate shares the version string `2026.9.9` with the public release. An isolated loopback npm registry served the canonical candidate tarball for that version, while forwarding dependency requests to npm. This prevents accidentally testing promotion of the older public package with the same version string; no product behavior was mocked. - **Focused checks:** 50 tests passed across `src/commands/node-daemon-install-npx.test.ts`, `src/commands/node-daemon-install-helpers.test.ts`, and `src/cli/node-cli/daemon.test.ts`. The new regression uses actual generators and executes their commands after cache deletion. The final portability correction keeps systemd coverage on non-Windows platforms and reads launchd artifacts only on macOS. That corrected regression passed (1.285 s test execution), and the `core-test-commands` type graph passed. Its unchanged durable-path assertion failed on the baseline as expected (pueue 2903). - **Changed checks:** formatting, conflict/line-count/assertion/SQLite/mock-export ratchets, config docs, plugin boundaries, dependency guards, and the core type graph boundary passed. The prior head's local core typecheck stopped on unrelated `channel-presence-policy.ts:519` TS6133; the branch is now rebased onto the main fix rather than carrying a separate repair. - **Independent review:** LAND on exact final head `27b447dc07b737126124ff8847f2059cb8a4f921`, including the corrected test, updater-step adapter, and paired-auth preservation. Sanitized live results: ```text before-cache-deleted: exit 1 (MODULE_NOT_FOUND) after: /state/npm/lib/node_modules/openclaw/dist/index.js node host gateway connected: ws://127.0.0.1:<isolated-port> upgrade: 2026.9.8 -> candidate 2026.9.9 sameVersionRepair: true runtimePreserved: true pairingAndSettingsPreserved: true connectedAfterCacheDeletion: true ``` **Native-supervisor limitation:** supervisor activation was not verified. Native service installation reaches the existing systemd user-session/profile guards in the unprivileged container; macOS refuses native installation from an isolated HOME. The proof runs actual generated service arguments as a separate live node, not under an activated OS supervisor. Launchd XML was decoded in Linux and passed through the production generated-environment resolver; the macOS regression exercises the actual plist reader. No HOME-guard bypass, privileged container, existing Gateway, or real laptop installation was used. **CI:** [final-head run 38097819645](https://github.com/openclaw/openclaw/actions/runs/38097819645) passed, including production types, test types, lint, source contracts, and the corrected Linux regression. All applicable PR checks finished with no failure, cancellation, or pending check. The final head is rebased onto green main; no inherited failure waiver or SDK budget change is needed. ClawSweeper is **ready, 5/6**, and the independent reviewer returned **LAND**, both on `27b447dc07b737126124ff8847f2059cb8a4f921`. ## Bounded cost Only npx-backed node installation needs an additional npm installation. It uses one state-owned prefix and the existing updater's staging, verification, rollback, and cleanup; it does not accumulate per-version prefixes. Reuse verifies the installed package and advertised content inventory, so a same-version damaged package is repaired. Ordinary node execution and model/session paths are unchanged. Non-npx installation adds only entrypoint inspection and installation diagnostics. Source +104/-2, tests +88/-0, docs +34/-0; net +224 across seven files. The growth reuses the existing package updater rather than adding another installation or state owner. ## Merge Danger Two-way code change, with a durable npm installation left in the selected node state directory if reverted. A revert restores the old npx service-install behavior; it does not remove an already installed package. Blast radius is headless node service installation and its printed diagnostics; Gateway installation and pnpm launcher resolution are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
…w#168644) ## What Problem This Solves Fixes node services installed through `npx openclaw connect <join-url> --service` or `npx openclaw node install` pointing at npm's disposable `_npx` cache. ## User Impact The one-paste command installs the selected OpenClaw release into a durable npm prefix under the node's state directory before writing the service. Removing npm's exec cache no longer removes the service's executable. Installation prints the package version, chosen runtime, service command, and a fresh-npx node update command. ## Why This Change Was Made The service argument resolver previously used the running package's resolved path. openclaw#167905 fixes pnpm's replaceable store-generation paths by selecting its existing stable link; npm exec has no stable link to select. This preserves that pnpm behavior and adds node-install promotion through the existing npm update owners (`resolveGlobalInstallTarget`, `runGlobalPackageUpdateSteps`, and their staged publication/rollback/cleanup). There is one `<state-dir>/npm` prefix, not a prefix per release. The normal state-directory/profile resolver chooses its location. Run `npx -y openclaw@latest node install --force` on the node to update it, retaining the same profile/state-directory settings. An exact version or `@beta` can replace `@latest`. Reinstalling an already-selected version repairs damaged package files. No new settings or package manager. This does not change `openclaw update` or its existing co-located Gateway selection behavior. Node auto-update still follows the node's npm channel, not the connected Gateway's version/build. The rebase preserves openclaw#168653's paired-credential filtering and explicit `--auth-from-env` service argument. No overlap with Pash/Sarah changes. ## Evidence Final code: `27b447dc07b737126124ff8847f2059cb8a4f921`. Packaged live proof ran on `292bd19fe934ecf4ee4e3b20b00a03a1b08f7933`; production feature code and docs are unchanged since that proof. The final revision only corrects regression-test platform handling and rebases onto green main. - **Before:** the regression on baseline `d1abe907cb7cfa63aeee7168099fabc81dd8309a` selected `.npm/_npx/.../node_modules/openclaw/dist/index.js`. In the live isolated replay, published `[email protected]` completed real join-URL enrollment; deleting its npm exec cache made the saved command exit 1 with `MODULE_NOT_FOUND`. - **After:** the canonical self-contained package passed `scripts/package-openclaw-for-docker.mjs --skip-build --allow-unreleased-changelog` and its tarball inventory/import-graph integrity check. Real `npm exec --package=<candidate.tgz> -- openclaw connect <join-url> --service` promoted that selected package into the node's state-owned npm prefix. Both actual launchd and systemd generators selected the durable entrypoint. After removing `_npx`, executing the persisted command as a separate process connected to the isolated Gateway. The published driver's device identity and node settings were unchanged. - **Upgrade and repair:** seeded the durable prefix with published `[email protected]`, retained the enrolled node state, and invoked the candidate through fresh npx with `--profile upgrade node install --force`. The prefix became the candidate version. Overwriting its `dist/index.js` and repeating the same command restored the exact original file bytes. The runtime, device identity, and node settings remained unchanged; the repaired persisted command connected after deleting `_npx` again. The prefix contained only `bin` and `lib`, with one `openclaw` package rather than per-release directories. - **Package identity:** the unpublished candidate shares the version string `2026.9.9` with the public release. An isolated loopback npm registry served the canonical candidate tarball for that version, while forwarding dependency requests to npm. This prevents accidentally testing promotion of the older public package with the same version string; no product behavior was mocked. - **Focused checks:** 50 tests passed across `src/commands/node-daemon-install-npx.test.ts`, `src/commands/node-daemon-install-helpers.test.ts`, and `src/cli/node-cli/daemon.test.ts`. The new regression uses actual generators and executes their commands after cache deletion. The final portability correction keeps systemd coverage on non-Windows platforms and reads launchd artifacts only on macOS. That corrected regression passed (1.285 s test execution), and the `core-test-commands` type graph passed. Its unchanged durable-path assertion failed on the baseline as expected (pueue 2903). - **Changed checks:** formatting, conflict/line-count/assertion/SQLite/mock-export ratchets, config docs, plugin boundaries, dependency guards, and the core type graph boundary passed. The prior head's local core typecheck stopped on unrelated `channel-presence-policy.ts:519` TS6133; the branch is now rebased onto the main fix rather than carrying a separate repair. - **Independent review:** LAND on exact final head `27b447dc07b737126124ff8847f2059cb8a4f921`, including the corrected test, updater-step adapter, and paired-auth preservation. Sanitized live results: ```text before-cache-deleted: exit 1 (MODULE_NOT_FOUND) after: /state/npm/lib/node_modules/openclaw/dist/index.js node host gateway connected: ws://127.0.0.1:<isolated-port> upgrade: 2026.9.8 -> candidate 2026.9.9 sameVersionRepair: true runtimePreserved: true pairingAndSettingsPreserved: true connectedAfterCacheDeletion: true ``` **Native-supervisor limitation:** supervisor activation was not verified. Native service installation reaches the existing systemd user-session/profile guards in the unprivileged container; macOS refuses native installation from an isolated HOME. The proof runs actual generated service arguments as a separate live node, not under an activated OS supervisor. Launchd XML was decoded in Linux and passed through the production generated-environment resolver; the macOS regression exercises the actual plist reader. No HOME-guard bypass, privileged container, existing Gateway, or real laptop installation was used. **CI:** [final-head run 38097819645](https://github.com/openclaw/openclaw/actions/runs/38097819645) passed, including production types, test types, lint, source contracts, and the corrected Linux regression. All applicable PR checks finished with no failure, cancellation, or pending check. The final head is rebased onto green main; no inherited failure waiver or SDK budget change is needed. ClawSweeper is **ready, 5/6**, and the independent reviewer returned **LAND**, both on `27b447dc07b737126124ff8847f2059cb8a4f921`. ## Bounded cost Only npx-backed node installation needs an additional npm installation. It uses one state-owned prefix and the existing updater's staging, verification, rollback, and cleanup; it does not accumulate per-version prefixes. Reuse verifies the installed package and advertised content inventory, so a same-version damaged package is repaired. Ordinary node execution and model/session paths are unchanged. Non-npx installation adds only entrypoint inspection and installation diagnostics. Source +104/-2, tests +88/-0, docs +34/-0; net +224 across seven files. The growth reuses the existing package updater rather than adding another installation or state owner. ## Merge Danger Two-way code change, with a durable npm installation left in the selected node state directory if reverted. A revert restores the old npx service-install behavior; it does not remove an already installed package. Blast radius is headless node service installation and its printed diagnostics; Gateway installation and pnpm launcher resolution are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Windows pnpm-global Gateway launchers could record a versioned
.pnpm/openclaw@...entrypoint. A package replacement then deleted that path, leaving the registered Scheduled Task unable to start the Gateway.Closes #167835. Thanks @SMF12138 for the native Windows reproduction and measurements.
User Impact
Newly written launchers use the verified stable
node_modules/openclawpackage link, which survives package replacement. Node remains the direct launcher child, preserving task supervision.For an installation already broken by an older launcher, run
openclaw gateway install --forcefrom the current installation. Forced install rebuilds the arguments and rewritesgateway.cmd; without--force, a registered task can return “already installed” without being rewritten.Why This Change Was Made
Shared service argument planning now reuses the existing package-root and pnpm install-owner helpers, verifies that the stable link resolves to the invoking package, and chooses an accessible canonical entrypoint. Unverified or unrelated links retain the existing behavior.
This PR contains only the planner fix, its regression suite, and the recovery note. Doctor auto-repair for launchers whose package metadata disappeared is a named follow-up. That work must address maintenance reachability, fresh update admission, native locking, and activation after failed maintenance. No Doctor, service-audit, reconciliation, restoration, or baseline edits remain here.
The branch was rebased onto main at
164210c355ea5acd51ed290471d317547af48ac6and updated with--force-with-leaseto replace the earlier broader implementation. Auto-merge remains off.Evidence
program-args.pnpm.test.tspassed three times: 4 tests per run; command wall times 24.12, 7.16, and 6.47 seconds. Vitest file durations were 20.64, 4.66, and 4.58 seconds; the cold run was dominated by compilation, with individual tests below one second. Commands usednode scripts/run-vitest.mjs ... --maxWorkers=1.node scripts/check-changed.mjs --base 164210c355ea5acd51ed290471d317547af48ac6passed in 631.64 seconds. Madge passed with 0 cycles in 11.39 seconds.git diff --checkpassed.Numstat: production +21/-0, tests +144/-0, docs +6/-0; 3 files, +171/-0 total.