Repository navigation
fix: stop openclaw update from bricking a pnpm-linked Git checkout when switching to the package - #201701
Conversation
…e checkout A Git checkout whose openclaw command is a pnpm or Bun global link to the checkout, with the managed Gateway running from that checkout, cannot be switched to the package by this updater: replacing the link changes what every later ownership check sees, so revalidation, rollback and recovery refuse and leave the Gateway stopped. Refuse at target admission instead, before anything is stopped or changed, and name the commands that complete the switch through the owning manager.
|
🦞👀 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. |
…its recovery steps
|
Codex review: needs changes before merge. What this changesThis PR refuses unsafe package switches from pnpm- or Bun-linked Git checkouts before stopping the Gateway and provides manual recovery commands. Example: A pnpm-linked 2026.11.5 checkout runs a managed Gateway and receives
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this maintainer-authored PR addresses a documented update outage, but its manual recovery instructions omit the requested channel setting. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe CLI updater resolves installation ownership, package destinations, and managed-service plans before staging code or stopping the Gateway; this change adds a refusal at that admission boundary. flowchart TD
A[Update CLI request] --> B[Resolve checkout and channel]
B --> C[Resolve package and service targets]
C --> D[Inspect pnpm or Bun checkout link]
D --> E[Refuse with recovery commands]
D --> F[Existing update transaction]
Technical reviewBest possible solution: Keep the early refusal and existing admission owner, but include the requested channel-setting command in the manual package-switch sequence and matching documentation. Do we have a high-confidence way to reproduce the issue? The body records a concrete 2026.11.5 failure trace, and source confirms both the missing current-main refusal and the recovery-channel defect; no target code was executed during this read-only review. Is this the best way to solve the issue? Early admission refusal is a focused, explicitly accepted mitigation that preserves ownership checks; its recovery commands must also preserve the user's requested update track. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0c3f2a4ea2b3. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +101, Tests +239, Docs +14. Total +354 across 5 files. Added test files: 1. 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:
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 19, 2026, 2:49 AM ET / 07:49 UTC. |
… an unchecked manual install
…tart-unsafe-package-switch
|
Merged via squash.
|
…en switching to the package (openclaw#201701) * fix(update): refuse a package switch through a pnpm or Bun link to the checkout A Git checkout whose openclaw command is a pnpm or Bun global link to the checkout, with the managed Gateway running from that checkout, cannot be switched to the package by this updater: replacing the link changes what every later ownership check sees, so revalidation, rollback and recovery refuse and leave the Gateway stopped. Refuse at target admission instead, before anything is stopped or changed, and name the commands that complete the switch through the owning manager. * test(update): prove the refusal keeps the stored channel and returns its recovery steps * fix(update): name no manual install for a package older than the checkout's databases * fix(update): leave the package switch to an agent instead of printing an unchecked manual install
…en switching to the package (#201701) * fix(update): refuse a package switch through a pnpm or Bun link to the checkout A Git checkout whose openclaw command is a pnpm or Bun global link to the checkout, with the managed Gateway running from that checkout, cannot be switched to the package by this updater: replacing the link changes what every later ownership check sees, so revalidation, rollback and recovery refuse and leave the Gateway stopped. Refuse at target admission instead, before anything is stopped or changed, and name the commands that complete the switch through the owning manager. * test(update): prove the refusal keeps the stored channel and returns its recovery steps * fix(update): name no manual install for a package older than the checkout's databases * fix(update): leave the package switch to an agent instead of printing an unchecked manual install (cherry picked from commit 3a173da) Gap-sweep intake (Dallin, 2026-11-24): ledger-high/P0-P1 fix not yet on 2026.11.10. Clean apply. Later main mentions of #201701: none. Co-authored-by: RomneyDa <[email protected]>
…en switching to the package (#201701) Baseline adaptation: Use the stable package destination resolver and command refusal owner before staging. Keep CLI plan formatting in its presentation module to stay within the target owner file budget. Prove the linked-checkout refusal in both output modes. (cherry picked from commit 3a173da) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 90e516f322a2a57e4066dfd52e5813bd9ddffa39)
What Problem This Solves
A developer who runs OpenClaw from a Git checkout, with
openclawinstalled as a pnpm global link to that checkout (pnpm add -g openclaw@link:<checkout>) and the Gateway running as a managed service from the checkout, can ask for the npm package withopenclaw update --channel beta(orstable). On published 2026.11.5 that switch stops the Gateway, replaces the link with the package, and then fails service revalidation. Rollback and the recovery restart fail the same check, so the Gateway stays down andopenclaw --versionfails withCannot find module .../.openclaw-update-native-*/.../openclaw.mjs. Noopenclawcommand works afterwards; only the checkout itself is intact.User Impact
User impact: on this layout
openclaw update --channel <beta|stable>now refuses before it stops or changes anything. The CLI and Gateway keep running the checkout. The message states what is true, names the command that keeps the checkout and follows the channel through its release tags, and hands the switch itself toopenclaw triageor the instance's agent. It prints no manual install recipe, because that would skip the schema, runtime and service-definition checks. npm links and the installer's wrapper layout are unchanged.Update behavior: the check belongs to the installed updater. Checkouts whose installed code contains this change refuse the unsafe switch; a checkout still on 2026.11.5 (or any updater without it) can still start the switch and end bricked. Recovery for that state, run in the same cell (each command exited 0):
node <checkout>/openclaw.mjs --version(the checkout still works),pnpm remove -g openclaw,pnpm add -g openclaw@link:<checkout>,openclaw gateway start,openclaw gateway status --deep,openclaw doctor --non-interactive. Afterwards the CLI reportsOpenClaw 2026.11.5 (e13cf15)and the Gateway serves it with/readyz200. Keep<PNPM_HOME>/.openclaw.package-backup-*until Doctor passes.Why This Change Was Made
An explicit non-dev
--channelon a Git install means "switch to the npm package" (documented indocs/install/updating/update-methods.md). For a pnpm or Bun global link, the link path is the installation identity that the pre-stop service verdict records. The switch replaces the link with the package, so every later ownership check that names that path (post-update revalidation, rollback's service stop, the recovery restart) sees the package while the unit still runs the checkout, and refuses. Separately, pnpm 12.15+ writes shims as"$basedir"/'target', which the launcher relocation does not recognize, so the published launcher still points into the update stage that activation moves away.Neither can be repaired by the updater that is running, so this PR keeps the documented contract and refuses the switch at target admission, where the install target, the link and the managed service plan are already known and nothing has been stopped. The follow-up PR makes the switch itself safe (pinned checkout identity for the stopped service, pnpm 12.15+ launcher relocation, rollback proof) and can then remove this refusal.
Changing what
--channelmeans on a Git install (for example "follow that channel through Git tags") is a documented-contract change and is not made here; see "Proposal" below.The non-JSON service-plan logging moved from
update-command-target.tsintoupdate-command-service-plan.tsunchanged, to keep the target file within the 700-line lint limit.Evidence
Behavior checked: on a Git checkout reached through a pnpm global link, with a managed Gateway on the checkout,
openclaw update --channel betarefuses before staging, prints the commands that finish the switch, and leaves the link, the checkout, the config and the Gateway untouched.src/cli/update-cli/update-command-checkout-link-switch.test.tsruns the realupdateCommandagainst a real pnpm global link on disk (detection seams for install kind, registry and service plan are stubbed). On the base the same test is red because the update is admitted and reachesPhase: staging; on this head it is refused at target admission with reasonunsupported-package-target, no install command runs, the link still resolves to the checkout,update.channelis unchanged, and triage is not started. JSON and terminal output are both checked.2026.11.5checkout (e13cf15) with a pnpm 12.21.0 global link and a systemd-managed Gateway:openclaw update --yes --json --channel betaexited 1 withservice-revalidation-failedandrollbackOutcome: not-attempted. Afterwardsopenclaw --versionfails withCannot find module '<pnpm-home>/.openclaw-update-native-QK47k3/v11/926ea…/openclaw.mjs'and the Gateway is down. The recording also runs the recovery sequence above.red-v5-brick-recovery.mp4
openclaw updatethrough the installed checkout): on this heade6ddc5c, with a pnpm 12.21.0 global link to the checkout and a systemd-managed Gateway running it,openclaw update --yes --json --channel betaexited 1 withunsupported-package-targetand the refusal text. Afterwardsopenclaw --versionstill printsOpenClaw 2026.11.5 (e6ddc5c), the Gateway still serves that build with/readyz200, and the global entry is still the link to the checkout. The plainopenclaw updatethat follows (the "keep following the channel" route) succeeded. This also answers the review question of whether the guard is reached on a real pnpm link layout: it is.green-pr1-e6ddc5c6870.mp4
Root cause evidence from the published 2026.11.5 run
openclaw update --yes --json --channel betaexited 1,reason: service-revalidation-failed,rollbackOutcome: not-attempted:Afterwards
openclaw --versionfailed withCannot find module '<pnpm-home>/.openclaw-update-native-qf5mGV/v11/926ea.../node_modules/openclaw/openclaw.mjs'. pnpm 12.15+ writes the live launcher's target as"$basedir_abs"/'../.openclaw-update-native-…/…/openclaw.mjs'; the relocation pattern only recognizes"$basedir_abs/…", so the staged path survives activation.Checks
node scripts/run-vitest.mjs src/cli/update-cli/update-command-checkout-link-switch.test.ts: 7 passed (red on base: both end-to-end cases fail at staging).node scripts/run-vitest.mjs src/cli/update-cli.already-current.test.ts src/cli/update-cli.git-service.test.ts src/cli/update-cli.node-runtime.test.ts src/cli/update-cli/update-command-install-layout.test.ts: 51 passed (covers the moved service-plan log lines).pnpm tsgo:core,pnpm tsgo:core:test: pass.oxlinton touched files: clean.pnpm check:baseline-ratchets --base <base> --no-merge-base: pass (test lines +237 of 400).pnpm check:docs: pass.git diff --check: clean.autoreviewdoes not run on this machine; an independent read-only reviewer was used instead.Steps left to a person
openclaw triageor the instance's agent until the follow-up makes the switch itself safe. The JSON result carries the follow-the-channel commands asrecoverySteps.Proposal (not in this PR)
On a Git checkout,
openclaw update --channel betacould mean "follow beta through this checkout's release tags" instead of "switch to the package", with the package switch moved to an explicit flag. That changes a documented contract, so it is only proposed here.Not proven
Review rounds
ClawSweeper round 1 (on
7611bb3) rated it overall F / proof C / patch F. Each finding was checked:gateway install --forcecan change a Gateway's explicit port": real. The manual recipe is removed; the switch is handed toopenclaw triageor the instance's agent (e6ddc5c).--allow-build=openclaw": moot once the recipe was removed.The independent read-only reviewer found two weak assertions: the stored channel matched the requested one, so "config unchanged" could not fail, and
recoveryStepsin the JSON were not checked. Both were fixed ine9863e0.