Repository navigation
fix(update): a pnpm update no longer fails after activating when the installed release came from an update - #205078
Conversation
… after a pnpm activation Port of openclaw#203458 to release/2026.11.10 as one commit. 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 already 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 ended `update-recovery-pending` while the new Gateway was already serving. The retained-runtime generation now also registers a process-wide resolver while it is bound, and `createCpuTrackedWorker` applies it. Async-context bindings keep precedence, a URL the generation already produced is final, and nothing changes outside an update that retained its runtime.
|
🦞👀 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 changesThis PR makes detached workers use the updater’s retained runtime after pnpm activation replaces its installed package. Example: A pnpm user updates from 2026.11.9 to 2026.11.10, then to a same-schema 2026.11.11 test package.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this focused backport fixes a demonstrated release-branch update failure already repaired on main; no blocking defect was found, and CI remains in progress. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe update lifecycle retains running worker code before replacing the installation; worker creation now consumes that same resolver for process owners whose async contexts predate the update. flowchart TD
A[Update CLI] --> B[Retained runtime lifecycle]
B --> C[Generation resolver]
D[Detached process owners] --> E[Tracked worker constructor]
C --> E
E --> F[Retained worker code]
Technical reviewBest possible solution: Land this focused release-line backport after its required checks pass, preserving the existing retention and recovery owners. Do we have a high-confidence way to reproduce the issue? The release-base source leaves detached worker spawns outside retained-runtime resolution, and supplied CLI logs reproduce the resulting second-hop failure; this review ran no target code, and current main already contains the repair. Is this the best way to solve the issue? The patch repairs worker selection at the shared constructor, retains existing async-context selection, and clears process resolution through the established lifecycle; every production hunk serves that boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cc79ae695ddf. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +51, Tests +67, Other +1. Total +119 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label 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 Reviewed November 24, 2026, 11:29 PM ET / November 25, 2026, 04:29 UTC. |
|
Recorded facts for cells B1 to B4 (pnpm 12.23.0 on Linux, systemd user Gateway, 512 MiB agent database under writes, plain B1B2B3B4 |
|
Recorded facts for cells C1, C3 and C4 (pnpm 12.23.0 on Linux, systemd user Gateway, 512 MiB agent database under writes, plain C1C3C4Pack SHA-256 prefixes: 2026.11.11 with this commit |
|
Recorded facts for the macOS cells MC1 and MC2: macOS 27.2 on arm64 in a local VM, Gateway as the MC1 targets carry the fix (SHA-256 prefixes MC1: failure, refusal, repair, clean updateMC2: without the fix, the update after the repair fails againDuring the five-minute watch in MC1, all 31 status reads show the run as |
3d1e4ff
into
openclaw:release/2026.11.11
Related: #205167 (what users see and how to recover), #204836, #203458, #201740
Status on November 25: 2026.11.10 shipped without this, so it now targets
release/2026.11.11latestis 2026.11.10, published from6ea542fd97e. That is the base this PR was measured against, so the published 2026.11.10 has the fault described below.release/2026.11.11(head1be6d3ddc6bwhen retargeted). The commit is unchanged.git merge-tree --write-treeagainst that head is clean. The 8 commits that line adds overv2026.11.10touch none of the five files here and nothing undersrc/update/,src/infra/orsrc/state/. Rechecked on November 25 at 16:20 UTC against7038eed8f33, now 30 commits overv2026.11.10: the merge is still clean, the schema is still state 40 and agent 42, and none of the five files here is touched. That head does change other files undersrc/infra/andsrc/state/(SQLite snapshots and read-only inspection). The R, G and B cells ran on the 2026.11.10 base. The C cells ran this commit on1be6d3ddc6b, the 2026.11.11 head at the time; nothing has been rerun on7038eed8f33.openclaw updategets the exit 1 once, whether or not 2026.11.11 contains this commit. The candidate does not change it (rows B1, B2 and B4 below).openclaw updateand then updates to the final 2026.11.10 exits 1 withupdate-recovery-pending. A beta.3 from a plainpnpm add -gupdates cleanly.openclaw updaterunningopenclaw updaterunningpnpm add -gopenclaw updaterunningopenclaw update repair, as the failed update printsrunningIn every failing row the new version is installed,
openclaw --versionworks and the Gateway serves the target. The schema is state 40 and agent 42 before and after each of these hops. Same setup as the cells in Evidence; one run each. The recorded facts of B1 to B4 are in this comment.Measured after that, with the published packages as the starting point (cells C1, C3 and C4). Each cell starts with
pnpm add -g [email protected]from npm and oneopenclaw update --yesto the published 2026.11.10. That first hop exited 0 in all three, with 64 to 74 s of outage.openclaw update --yesopenclaw updaterunningrunningin all 41 status readsopenclaw update --yesrunningopenclaw update repair, Gateway left runningopenclaw update --yesopenclaw update --yesopenclaw updaterelease/2026.11.15, schema 40/42 → 41/43openclaw update --yesopenclaw updaterunningopenclaw update repairopenclaw update --yesrunningWhat these rows show:
runningin phaseverifyingfor 17 minutes, and the Gateway journal has no reconcile line in that time. The nextopenclaw updateis refused in 1.7 s and namesopenclaw update repair. After that one repair, updates are clean.openclaw update repairwith the Gateway left running (69 to 71 s, about 51 s of outage), thenopenclaw update.openclaw update statusstill lists the failed run's recovery set as "unresolved after a failed update" and its next action is to inspect the capture'smanifest.json. About 534 MiB of capture and about 534 MiB of database snapshot stay on disk for the 512 MiB store.The same chain on macOS (cells MC1 and MC2: macOS 27.2 on arm64 in a local VM, the Gateway as a LaunchAgent, pnpm 12.23.0, the same packs, one run each). The first hop, published 2026.11.9 → published 2026.11.10, exited 0 in both with 75 and 81 s of outage.
openclaw update --yesfrom the published 2026.11.10runningrunningin all 31 status readsopenclaw update --yes, not repairedrunningopenclaw update repair, Gateway left runningopenclaw update --yesopenclaw update --yesfrom the published 2026.11.10runningopenclaw update repairopenclaw update --yesrunningmacOS behaves like Linux here: the fault, the refusal, the repair and the effect of this commit are the same, and the messages match apart from IDs. Outages are longer (103 s against 69 to 76 s for the failing update). After MC1,
openclaw update cleanup --dry-runlists the failed run's capture as protected (unresolved-failed-update, 560 MB) with 0 bytes to clean. The recorded facts are in this comment.Packs for these cells, none published: "2026.11.11 with this commit" is
release/2026.11.11at1be6d3ddc6bplus this commit applied without committing, so its build reports1be6d3d. "2026.11.12" is the same tree with only a version bump. The packs without this commit are the unmodified1be6d3ddc6band its version bump. The 2026.11.15 pack isrelease/2026.11.15atae07e2709f3. The recorded facts of C1, C3 and C4 are in this comment.What Problem This Solves
Fixes: on a pnpm global install, the second
openclaw updateafter reaching 2026.11.10 fails withupdate-recovery-pendingwhen the installed 2026.11.10 was itself put there byopenclaw updateand the target has the same database schema.User Impact
With this commit in a release (2026.11.11 is the next one), a pnpm user who updated to that release can run a plain
openclaw updateto the next same-schema release and get exit 0, a finished run record, and a workingopenclawcommand and Gateway, with no manual step.Without it (measured on the unmodified
release/2026.11.10head), that update:update-recovery-pendingandFirst failure: plugin lifecycle lease core:plugin-lifecycle/global was lost … Cannot find module,running;openclaw update statusshows "needs attention" and two different next steps ("Stop the Gateway first … then run openclaw update repair" and "Next action: openclaw update cleanup --dry-run"),openclaw update repair; even after that,openclaw update statuskeeps reporting the recovery set as "unresolved after a failed update. Retained original state requires manual inspection".The new version is installed, the Gateway serves it, and the
openclawcommand works in both cases. Nothing is lost; the failure is in the record and the next steps the user is told to take.Update behavior: the fix runs in the updater, which is the installed version. It helps updates driven by a 2026.11.10 that contains it. The first update onto 2026.11.10 is unaffected either way (it migrates the schema and passed on the unmodified head, see the table).
Why This Change Was Made
A pnpm updater that an earlier
openclaw updateinstalled runs from its group's project-local store (<pnpm home>/global/v11/<group>/node_modules/openclaw). Activating the next version moves that group into the transaction backup, so the running updater's owndistdisappears. Work started inside the update already loads workers through the retained-runtime generation. 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, so their spawns failed withCannot find module, the plugin lifecycle lease was lost, and the update endedupdate-recovery-pendingwhile the new Gateway was already serving.This is a port of #203458 from main. While it is bound, the retained-runtime generation also registers a process-wide resolver, and
createCpuTrackedWorkerapplies it. Async-context bindings keep precedence, a URL the generation already produced is final, and nothing changes outside an update that retained its runtime.Root cause, checked against the alternatives:
pnpm add -g(row R1, Gateway from the global virtual storestore/v11/links/...). It fails when 2026.11.10 was installed byopenclaw update(rows R2/R3, Gateway fromglobal/v11/<group>/node_modules/openclaw). That store layout is exactly the condition fix(update): a pnpm update no longer fails after activating when the updater itself was installed by an update #203458 fixes.Cannot find module '…/installed/dist/probe.worker.mjs'(ERR_MODULE_NOT_FOUND).service-revalidation-failedrefusal. Here the restart is not refused (Gateway: restarted and verified), the reason isupdate-recovery-pending, and the Gateway is serving. So fix(update): name the working Gateway recovery after a shipped pnpm updater leaves it stopped #203406 is not needed for this failure and is not ported.Cherry-pick for the release line
release/2026.11.10at6ea542fd97e2876aa4c871ccc494ed5419a03c5c(refetched right before opening this PR; unchanged).8e3a9a19e4201da85cf324ccfef518855898897b, 5 files, +121/−2. No schema, config key, protocol, dependency, lockfile, retention or stored-field change.git cherry-pick --no-commit 8e3a9a19e42on a detached checkout oforigin/release/2026.11.10succeeded with no conflicts;git merge-tree --write-tree origin/release/2026.11.10 8e3a9a19e42is clean.runtime-worker-generation.ts, the newruntime-worker-process-generation.tsand the test file are byte-identical to main. Two differences from main:worker-cpu-types.tsto keepworker-cpu.tsunder its line cap. This branch'sworker-cpu.tsstays under the cap (oxlint clean), so only the 2-line change is ported.wrapper-components.txtgets its entry at this branch's position.release/2026.11.11at1be6d3ddc6b918c9f095c9c468958f0d989cb1da:git merge-tree --write-treewith this commit is clean. That line is 8 commits ahead ofv2026.11.10and none of them touches these files.Evidence
Packs built from the release branch with
node scripts/package-openclaw-for-docker.mjs: 2026.11.10 is the commit under test, and 2026.11.11 is the same commit with only a local version bump (never published, same schema).Each cell:
/readyzprobe.openclaw update --yes, with the pack served as the npm registry inside the container.6ea542fd97e6ea542fd97eopenclaw update)update-recovery-pendingrunning; told to runopenclaw update repair6ea542fd97eopenclaw update)update-recovery-pendingopenclaw update repairexit 0 (72 s); status still lists an unresolved recovery set6ea542fd97e8e3a9a19e428e3a9a19e42openclaw update)update status8e3a9a19e42Red, unmodified
release/2026.11.10(6ea542fd97e), 2026.11.9 → 2026.11.10 → 2026.11.11:pnpm-1110-red-R2.mp4
Green, this commit (
8e3a9a19e42), same chain and fixture:pnpm-1110-green-G2.mp4
The recordings replay the recorded cell logs and facts; they are not live captures.
Decisive raw lines, red R2 u2 (base)
openclaw update statusafterwards:R3, after
openclaw update repair(exit 0) and anotheropenclaw update --yes(already-current):Gateway processes in the two layouts (R1 passes, R2 fails):
Decisive raw lines, green G2 u2 (head)
openclaw --version→OpenClaw 2026.11.11 (8e3a9a1); last runsucceeded, 2026.11.10 → 2026.11.11; noCannot find modulein the update output.Reproduce:
release/2026.11.10(node scripts/package-openclaw-for-docker.mjs). Then bump everypackage.jsonversion to an unused version with the same schema, add itsCHANGELOG/<version>.md, and pack again.pnpm add -g --allow-build=openclaw [email protected]andopenclaw gateway install --force.latestand runopenclaw update --yes. Then serve the bumped pack and runopenclaw update --yesagain.update-recovery-pending. With this commit: it exits 0.Checks on
8e3a9a19e42:node scripts/run-vitest.mjs src/infra/runtime-worker-generation.test.ts: 8/8 pass. On the base, with only the new resolver module copied in so the file imports, the 2 new cases fail. The first fails withERR_MODULE_NOT_FOUNDfor the removed installed worker, the second withexpected '/installed/other.mjs' to be '/installed/other.mjs.retained.mjs'.worker-cpuorruntime-worker-generation, run one at a time: 267/267 pass. They includeworker-cpu.test.ts,update-retained-runtime.test.ts,gateway-state-owner.heartbeat.test.tsandworker-task-pool.test.ts.test/scripts/update-restart-module-outcome.test.tsandtest/scripts/eager-import-closure.test.ts: 24/24.pnpm tsgo:coreandpnpm tsgo:core:test: pass.scripts/check-session-identity-ratchet.mts --base 6ea542fd97e --no-merge-base): OK.oxlint --type-awareandoxfmt --checkon the touched files: clean.git diff --check: clean.src/infra/runtime-worker-generation.test.ts. The two new cases come from fix(update): a pnpm update no longer fails after activating when the updater itself was installed by an update #203458 unchanged; nothing was removed. An independent reviewer found nothing blocking. Its nits on the second case are left as they are so the file stays identical to main. Those nits: it checks the resolver rather than a spawn, and its call-count assertion duplicates the identity check.autoreviewwas not run; it does not run on this machine.Not proven
Each C cell ran once.
openclaw triage, the other step the refusal in C1 u3 names, was not run because it needs a model.Whether anything clears the "unresolved" recovery set and the roughly 1 GiB it keeps after the repair.
openclaw update cleanup --dry-runon macOS lists the capture as protected with nothing to clean; I did not apply a cleanup.2026.11.10-beta.1 and beta.2 as the installed version. Only beta.3 was run.
The second recovery
openclaw update statusprints (stop the Gateway, then repair) andopenclaw update cleanup --dry-run. Only the plainopenclaw update repairwas run, with the Gateway left running.Windows, npm and Bun installs, and pnpm versions other than 12.23.0 were not run with this commit. macOS ran once per cell (MC1, MC2). The R1/G1 controls cover an updater that does not retain its runtime.
Updates started from the Gateway (Control UI or automatic) rather than the CLI.
The worker paths that do not go through
createCpuTrackedWorker, named by the reviewer, are unchanged here, the same as on main:new Workersites, such as the package integrity hasher, which falls back to in-process hashing.None failed in these runs.
Every 2026.11.11, 2026.11.12 and 2026.11.15 pack here is a local build, not a release.