Repository navigation
fix(update): keep the openclaw command and Gateway working after a pnpm update - #203401
fuller-stack-dev wants to merge 8 commits into
Conversation
…pm update Backport of openclaw#201735 to the 2026.11.7 line, as adapted and proven for the 2026.11.6 line in openclaw#201739: rewrite pnpm's quoted launcher shim by value, repair launchers left pointing into an update stage, and revalidate the managed service against the pnpm install root.
…/2026.11.7-pnpm-update-keeps-cli-and-gateway
|
🦞👀 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: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
(cherry picked from commit f955f4c)
…updater refuses the restart Shipped updaters 2026.11.4 through 2026.11.6 refuse the Gateway restart after a same-schema pnpm update (`service-revalidation-failed`) and leave the Gateway stopped. The verified recovery is `openclaw gateway install --force` followed by `openclaw gateway restart`; `gateway restart` alone fails while the service still names the previous store directory. One module decides that state: on macOS or Linux, the service this pnpm installation owns and may rewrite still names another version's package in the same pnpm home, and no other active global project uses it. - Doctor, run by such an updater, returns the pair as an update warning once it had to repair the launcher that updater published (the marker of a shipped driver); shipped updaters render it in their final report. - `openclaw update status` names the pair as the next step for a `service-revalidation-failed` run while the Gateway is not responding and its service is stopped. - `openclaw gateway status --deep` names it in the installation drift line while the service is stopped. - Both commands carry the reader's profile. - The update docs no longer claim that these updaters always hand the restart to the new package. Squashed from openclaw#203406.
…nstalls pnpm 11.28 installs a global package into `<group>/.pnpm/...`; layout inference accepted only `<group>/node_modules/.pnpm/...`, so such an install was classified as an unmanaged package root and the refreshed service definition pinned the per-version directory pnpm removes on the next update. Squashed from openclaw#202017.
… bits, from the shim's own base - Launcher repair leaves a launcher owned by another account unchanged and reports why (uid of the owner and of this account) through the existing failed-repair message, instead of replacing it with this account's file. - The replacement keeps permission bits only; setuid, setgid and sticky bits are never carried into a rewritten launcher. - Detection and relocation share one answer for the base a shim's `$basedir` resolves from (physical only when the shim defines `basedir_abs`), so a symlinked bin directory cannot make them disagree. - The update guide lists 2026.11.6 among the updaters that miss these steps and states the ownership rule.
… after activation A pnpm updater that a previous OpenClaw update installed runs from its group's project-local virtual store. Activating the next version moves that group into the transaction backup, so the running updater's own `dist` disappears. Work started inside the update loads workers through the retained-runtime generation, but process-wide owners that start workers from detached or earlier async contexts (the state lease heartbeat carrier, the file-log worker pool) still resolved them from the installed package. Their spawns failed with `Cannot find module`, the plugin lifecycle lease was lost, and the update unwound as `update-recovery-pending` while the new Gateway was already serving. The retained-runtime generation now also registers a process-wide resolver for as long as it is bound, and `createCpuTrackedWorker`, which every tracked worker spawn goes through, applies it. Async-context bindings keep precedence; nothing changes outside an update that retained its runtime. Release-line form of openclaw#203458; this line needs no type move.
…nly once A worker captured inside the generation was resolved again by the process-wide resolver at spawn time. The retained-runtime mapping is idempotent, but a generation's resolver need not be: the heartbeat generation test's wrapping resolver then imported itself and the worker never started (Bun shard timeout). A URL the generation already produced is now final.
|
2026.11.7 is now Setup. Linux container, systemd as PID 1, user Gateway service, pnpm 12.21.0, Node 24.22.1, a 256 MiB agent database with a busy writer, synthetic state. The update command was
So with 2026.11.7 as published, every pnpm update to it or from it leaves a broken command and a stopped Gateway, and the only next step the update prints is published 2026.11.6 → published 2026.11.7: decisive outputnpm installs on the main-line targets I ran alongside were unaffected. Not covered here: pnpm 11 and npm on the 2026.11.7 hops, macOS/launchd, Windows, Bun. Full raw logs are not attached because the artifact store rejects uploads from this machine. |
|
Follow-up runs for people already on published 2026.11.7, same cell shape as above (systemd user service, busy database writer,
What this shows:
Not covered: macOS/launchd, Windows, Bun, Gateway-started updates on these hops. |
|
Closing with #204716. 2026.11.10 has been npm |
What Problem This Solves
For a pnpm user: with this PR,
openclaw updateto 2026.11.7 leaves a workingopenclawcommand on every hop we ran (from 2026.11.5 and 2026.11.6, on pnpm 12 and 11). When the hop migrates the database schema, the Gateway also restarts by itself. From 2026.11.5 or 2026.11.6 the schema does not change, so the already-installed updater leaves the Gateway stopped. The user then runsopenclaw gateway install --forceand thenopenclaw gateway restart; the update output,openclaw update statusandopenclaw gateway status --deepall name these two commands. From 2026.11.7 onward, updates restart the Gateway by themselves.Fixes: after
openclaw updateon a pnpm install (pnpm add -g openclaw), theopenclawcommand fails withCannot find module …/.openclaw-update-native-…/openclaw.mjsand the Gateway stays stopped.This is a backport of #201735 to the 2026.11.7 line, now in preparation. It is a proposal for the release owner; it supersedes #201739, which targeted the already shipped 2026.11.6 line. Published 2026.11.6 and 2026.11.10-beta.1 do not contain the fix.
User Impact
What a pnpm user gets when they update to a 2026.11.7 built from this branch:
openclawcommand keeps working on every hop we ran. The installed updater still publishes a launcher that points into its removed update stage, and this package's Doctor repairs it during the same update.service-revalidation-failed, exit 1) and leaves the Gateway stopped. The updater that is already installed cannot be patched.openclaw gateway install --force, thenopenclaw gateway restart.openclaw gateway restartalone does not work, because the service still names the previous version's store directory.openclaw gateway install --forceand thenopenclaw gateway restart."openclaw update statusandopenclaw gateway status --deepgive the same pair instead of "Runopenclaw triage" or the generic reinstall advice.Once 2026.11.7 is installed, later pnpm updates run its own updater, which relocates the launcher and revalidates the service against the pnpm install root itself.
Why This Change Was Made
This is one commit with the net change of #201739 (which adapted #201735 to this line), plus a merge of the current
release/2026.11.7tip. It does the following:"$basedir_abs"/'<target>') by value, so every quoting form relocates;The fingerprint, name, profile and manager-UID ownership checks are unchanged.
Update behavior: the fix runs when this package is the updater, the Doctor or the Gateway. Updates driven by an installed 2026.11.6 or older updater get only the Doctor launcher repair, plus the Gateway restart on schema-migrating hops, as described above.
Steps still left to a person: the two Gateway commands on same-schema hops from a shipped updater. They cannot be automated inside that updater, which is already installed. The parked draft #201906 tried an automatic restart after the updater exits; it failed in three real runs and is not part of this PR. The commands are now named during and after the update; triage cannot run them without a terminal. Once 2026.11.7 is the installed updater, no step is left: see the fixed-updater cell below.
Commits on this branch
b84ccfe: the fix: keep the openclaw command and Gateway working after updating a pnpm install #201735 change, the net change of fix(update): keep the openclaw command and Gateway working after a pnpm update #201739 adapted to this line.2a2eb41: merge of therelease/2026.11.7tipe0477dd, a single test file.d5c24e4: cherry-pick of fix(ci): keep launcher repair helper internal #201816, which keeps the launcher repair helper internal; main's dead-export scan needs it.91fd884: the true-instructions change from fix(update): name the working Gateway recovery after a shipped pnpm updater leaves it stopped #203406, squashed into one commit:update statusnext step;gateway status --deepdrift advice;d3533f0: the pnpm 11 layout detection from fix(update): recognize pnpm 11 group-local virtual stores as global installs #202017, squashed. On pnpm 11,gateway install --forceand later updates then save the stable<hash>/node_modules/openclawentry instead of the per-version directory.28407d9: launcher-repair hardening from fix(update): repair only this account's pnpm launcher and never keep set-ID bits #203447. The repair touches only a launcher owned by the current account, never keeps set-ID bits, and uses the same base for detection and relocation; the docs now list 2026.11.6.7413c6dandd499c95: the second-update fix from fix(update): a pnpm update no longer fails after activating when the updater itself was installed by an update #203458. On pnpm, an update run by an updater that an earlier update installed no longer fails after activating withupdate-recovery-pending. That failure happened because detached workers were still started from the package activation had just moved away. Without this commit, the first pnpm update after this release would fail falsely, and every later update would be refused.The tip has since moved to
0bfe6a5, with test and CI-only commits. I merged the tip once before the final cells, as agreed, and did not merge again.Evidence
Real pnpm updates through the shipped entry point
Each cell installed published
openclaw@<start>from the public registry withpnpm add -g, ran the Gateway as a managed service under the harness's systemd user shim, with a 256 MiB agent database and a busy writer, then ran a plainopenclaw update --tag <this branch's package tarball>. The target is installed in the same layout class as a registry target. Afterwards the cell ranopenclaw gateway install --forceandopenclaw gateway restart, only if the Gateway was not serving.Cells on this head,
2a2eb41:openclaw updateopenclaw --versionaftergateway install --force+gateway restartservice-revalidation-failed, 154 sOpenClaw 2026.11.7 (2a2eb41)global/v11/926ea0a5…/node_modules/openclaw/openclaw.mjsstore/v11/links/@/openclaw/2026.11.6/…global/v11/926ea0a5…/node_modules/openclawservice-revalidation-failed, 153 sOpenClaw 2026.11.7 (2a2eb41)…/openclaw/2026.11.5/…global/v11/926ea0a5…/node_modules/openclawservice-revalidation-failed, 166 sOpenClaw 2026.11.7 (2a2eb41)global/v11/9440847f…/node_modules/openclaw/openclaw.mjs…/openclaw/2026.11.6/…global/v11/<group>/.pnpm/openclaw@file+…/node_modules/openclaw(see below)d3b5796service-revalidation-failed, 165 sCannot find module …/.openclaw-update-native-fPbx97/…/openclaw.mjs"$basedir_abs"/'../.openclaw-update-native-fPbx97/…/openclaw.mjs', the removed stage…/openclaw/2026.11.6/…Outage. The load probe measured the Gateway from its stop until it served again: 238, 254 and 247 s. That window includes the update and the two commands, which the cell ran immediately after the update. For a user, the outage lasts until they run them. On the bare tip the Gateway was still down when the load window closed (342 s).
Disk. Sampled per directory through the update, as peak / left afterwards:
These are the cell's own paths, not the shared VM disk.
pnpm 11 service path. After
gateway install --force, the pnpm 11 service names the per-version.pnpm/openclaw@…directory instead of the stable entry, and the next update removes that directory. fix(update): recognize pnpm 11 group-local virtual stores as global installs #202017 fixes this on main and is proposed for this branch.Cells on
b84ccfe. The same cells were also run onb84ccfe, this commit before the test-only tip merge, with identical outcomes.Recordings (cell log live, then a summary from the raw cell files; container paths under
/home/appuser):2026.11.6 → head, pnpm 12:
r7-pnpm12-2026.11.6-to-r7-2a2eb41.mp4
2026.11.5 → head, pnpm 12:
r7-pnpm12-2026.11.5-to-r7-2a2eb41.mp4
2026.11.6 → head, pnpm 11.28.13:
r7-pnpm11-2026.11.6-to-r7-2a2eb41.mp4
Negative control, 2026.11.6 → bare tip:
r7-pnpm12-2026.11.6-to-r7tip-d3b5796.mp4
Cells for the added commits, on
2a2eb41plus the squashed true-instructions commitopenclaw updateupdate statusnext stepgateway status --deepdrift adviceservice-revalidation-failed(shipped updater)openclaw doctorstepopenclaw gateway install --force, thenopenclaw gateway restart."okokglobal/v11/926ea0a5…/node_modules/openclawThe 2026.11.5 → head row in the first table is the red counterpart: no note, and
update statusends with "Historical recovery advice: Runopenclaw triage…". The full cell table, recordings and the triage behavior are on #203406. The fixed-updater recording:jt-pnpm12-fixed-r7jt-to-r7jt-eef73b5.mp4
What the 2026.11.6 → head cell printed after the update, then the two recovery commands
Negative control: the same hop onto the bare
release/2026.11.7tipFull raw logs are not attached, because the artifact store rejected uploads from the test host.
Checks on this branch
Run on head
d3533f0, with the bare tip as comparison where something failed:node scripts/run-vitest.mjson the launcher repair, runtime relocation, native stage, allpackage-update-swap*, package filesystem, service install root, Gateway startup plugin, update-restart module outcome and eager import closure tests pass, together with the true-instructions,doctor-health-startup,status.gather, program-args and pnpm owner tests.pnpm tsgo:coreandpnpm tsgo:core:testpass.pnpm check:import-cyclesandpnpm check:madge-import-cyclesreport 0 cycles.pnpm check:docsandgit diff --checkpass.node scripts/package-openclaw-for-docker.mjsrunsruntime-postbuild(14 phases) and the tarball integrity check passes. The bare tip packs too. This line has no compatibility-inventory pack failure; 2026.11.10 had one.pnpm check:baseline-ratchetspasses with the release context that a PR intorelease/*gets in CI, where the test-line budget is skipped. Run as a main-line branch, onlytest-linesfails: the bare tip is already 695 lines over its ceiling, and this branch adds the 424 net regression-test lines that fix: keep the openclaw command and Gateway working after updating a pnpm install #201735 added on main.CI on
2a2eb41passed every check (75 pass, 58 skipped). CI ond3533f0also passed every check (77 pass, 60 skipped).Cherry-pick for the release line
There are six commits; see "Commits on this branch". Each touches only files that exist on this line, and none needs main-only code. On the branch they pass the touched tests and both type lanes, and both import-cycle checks report 0. The squashed commits apply unchanged to
release/2026.11.10(#201740).Not proven
An install already stranded by the second-update failure on an unfixed build is not cleared by this branch; see fix(update): a pnpm update no longer fails after activating when the updater itself was installed by an update #203458.
Launcher-repair hardening (fix(update): repair only this account's pnpm launcher and never keep set-ID bits #203447) is unit-proven only. A root-run repair against another account's launcher on a real host was not run.
A fixed version installed from a registry. A fixed 2026.11.7 is not published, so the target was always this branch's tarball offered with
--tag. The updater installs that in the same project-store layout as a registry target.Windows. Automatic launcher repair is macOS and Linux only.
Real launchd on macOS, and systemd as PID 1. The cells ran Linux with the harness's systemd user shim.
autoreviewdoes not run on this machine.Review notes
ClawSweeper round 1 on
2a2eb41rated it F / C / F. Here is each finding and what this branch does about it:28407d9, with red-first tests.