Skip to content

fix: stop openclaw update from bricking a pnpm-linked Git checkout when switching to the package - #201701

Merged
fuller-stack-dev merged 5 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-does-not-start-unsafe-package-switch
Nov 19, 2026
Merged

fuller-stack-dev merged 5 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-does-not-start-unsafe-package-switch

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

A developer who runs OpenClaw from a Git checkout, with openclaw installed 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 with openclaw update --channel beta (or stable). 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 and openclaw --version fails with Cannot find module .../.openclaw-update-native-*/.../openclaw.mjs. No openclaw command 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 to openclaw triage or 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 reports OpenClaw 2026.11.5 (e13cf15) and the Gateway serves it with /readyz 200. Keep <PNPM_HOME>/.openclaw.package-backup-* until Doctor passes.

Why This Change Was Made

An explicit non-dev --channel on a Git install means "switch to the npm package" (documented in docs/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 --channel means 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.ts into update-command-service-plan.ts unchanged, 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 beta refuses before staging, prints the commands that finish the switch, and leaves the link, the checkout, the config and the Gateway untouched.

  • New src/cli/update-cli/update-command-checkout-link-switch.test.ts runs the real updateCommand against 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 reaches Phase: staging; on this head it is refused at target admission with reason unsupported-package-target, no install command runs, the link still resolves to the checkout, update.channel is unchanged, and triage is not started. JSON and terminal output are both checked.
  • Inspector cases on real symlinks: a pnpm link with a service (no install recipe, channel and triage routes), a Bun link without a service (channel-change commands), and negative controls that stay allowed: an npm link (the npm root-link transaction already restores it), a pnpm package directory (installer wrapper layout), and a pnpm link that points to another directory.
  • RED, published 2026.11.5 checkout (e13cf15) with a pnpm 12.21.0 global link and a systemd-managed Gateway: openclaw update --yes --json --channel beta exited 1 with service-revalidation-failed and rollbackOutcome: not-attempted. Afterwards openclaw --version fails with Cannot 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
  • GREEN, end-to-end in an isolated Linux Docker cell (update-matrix harness, systemd shim, real openclaw update through the installed checkout): on this head e6ddc5c, with a pnpm 12.21.0 global link to the checkout and a systemd-managed Gateway running it, openclaw update --yes --json --channel beta exited 1 with unsupported-package-target and the refusal text. Afterwards openclaw --version still prints OpenClaw 2026.11.5 (e6ddc5c), the Gateway still serves that build with /readyz 200, and the global entry is still the link to the checkout. The plain openclaw update that 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 beta exited 1, reason: service-revalidation-failed, rollbackOutcome: not-attempted:

Failing check managed-service-ownership (service-ownership-changed): Required: admitted service ownership owned; manager UID 1001; detected: foreign; runtime stopped
Update install root: <pnpm-home>/global/v11/f04-.../node_modules/.pnpm/[email protected]_.../node_modules/openclaw
Gateway install root: /home/appuser/openclaw (differs from update install)

Afterwards openclaw --version failed with Cannot 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. oxlint on 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.
  • autoreview does not run on this machine; an independent read-only reviewer was used instead.

Steps left to a person

  • Finishing the switch on this layout goes through openclaw triage or the instance's agent until the follow-up makes the switch itself safe. The JSON result carries the follow-the-channel commands as recoverySteps.
  • An instance already bricked by a published updater needs the recovery below; an updater cannot be patched after the fact.

Proposal (not in this PR)

On a Git checkout, openclaw update --channel beta could 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

  • Bun global links are covered by the inspector test only, not by an end-to-end run.
  • macOS launchd was not exercised end to end; the refusal happens before any service manager call.

Review rounds

ClawSweeper round 1 (on 7611bb3) rated it overall F / proof C / patch F. Each finding was checked:

  • "The guard may not be reached on a real pnpm link layout": not real. The end-to-end cell above shows the guard firing on a real pnpm 12.21.0 global link with the real manager detection.
  • "Do not print install commands whose compatibility is unverified" and "gateway install --force can change a Gateway's explicit port": real. The manual recipe is removed; the switch is handed to openclaw triage or the instance's agent (e6ddc5c).
  • "The install advice omits --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 recoverySteps in the JSON were not checked. Both were fixed in e9863e0.

…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.
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M labels Nov 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This 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 openclaw update --channel beta.

  • Before: The update can replace the link, fail service revalidation, and leave the Gateway stopped and CLI launcher broken.
  • After: The updater refuses before staging and prints commands for completing the package switch manually.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The mitigation is useful and narrowly placed, but the recovery sequence has a concrete channel-handoff defect and required installed-CLI proof is unfinished.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Switching a pnpm-linked Git checkout to a package can leave the Gateway stopped and every CLI command broken.
Reason: Preventing a demonstrated outage before mutation has clear value, and the maintainer-authored PR explicitly accepts temporary refusal while retaining the documented installation-switch meaning.

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
Reviewed head: e9863e04d9636f625d7cfa961560b1380baf675e

Before merge

  • Set the requested channel in the manual package-switch steps (P2) - With the fixture's existing update.channel: dev, requesting beta now refuses without changing config, as intended. However, the printed recovery sequence only installs the package and reinstalls/restarts the service; none of those commands changes update.channel. After following all instructions, the next plain openclaw update reads dev and sets switchToGit in update-command-target.ts:274-276, undoing the intended package switch or refusing it through the pnpm/Bun package-to-Git restriction. Add the existing openclaw config set update.channel &lt;requestedChannel> command to the package-switch recovery steps when needed, and update the docs and recovery assertions.

Findings

  • [P2] Set the requested channel in the manual package-switch steps — src/cli/update-cli/update-command-package-destination.ts:214-220

Tests

  • Missing end-to-end proof: Provide redacted installed-CLI output from the latest-stable pnpm-linked layout with the corrected updater, showing refusal leaves the Gateway, launcher, checkout, settings, and data intact and the printed manual sequence completes the intended package-channel switch.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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:

  • [P2] Set the requested channel in the manual package-switch steps — src/cli/update-cli/update-command-package-destination.ts:214-220
    With the fixture's existing update.channel: dev, requesting beta now refuses without changing config, as intended. However, the printed recovery sequence only installs the package and reinstalls/restarts the service; none of those commands changes update.channel. After following all instructions, the next plain openclaw update reads dev and sets switchToGit in update-command-target.ts:274-276, undoing the intended package switch or refusing it through the pnpm/Bun package-to-Git restriction. Add the existing openclaw config set update.channel &lt;requestedChannel> command to the package-switch recovery steps when needed, and update the docs and recovery assertions.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0c3f2a4ea2b3.

Provenance checked

  • Package destination and ownership admission keeps the original intent (80b9230: Prevent runtime recovery from overwriting another installation; later diagnostics retained that protection.)
  • Service-plan presentation keeps the original intent (6486d28: Separate read-only update planning from execution and reuse service discovery; subsequent changes preserve managed-runtime selection.)
  • Git-to-package conversion changes intended behavior with a stated reason (unknown: Current documentation explicitly defines non-dev channel selection as package conversion. Scoped history searches encountered unavailable historical blobs before establishing the original introduction; the PR explains its temporary refusal rather than redefining channels.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/cli/update-cli/update-command-checkout-link-switch.test.ts --maxWorkers=1
  • pnpm test 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 --maxWorkers=1
  • pnpm tsgo:core
  • pnpm tsgo:core:test
  • pnpm check:docs

What I checked:

Likely related people:

  • Jason (Json): Raw commit b868ed4 adds src/cli/update-cli/update-command-package-destination.ts:109 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b868ed4c21ba; files: src/cli/update-cli/update-command-package-destination.ts)
  • Peter Steinberger: Raw commit 80b9230 adds src/cli/update-cli/update-command-package-destination.ts:73 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 80b92306e409; files: src/cli/update-cli/update-command-package-destination.ts)

PR surface

Source +101, Tests +239, Docs +14. Total +354 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 134 33 +101
Tests 1 239 0 +239
Docs 1 14 0 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 387 33 +354

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: The reported published-updater path can stop a working Gateway and break the CLI during an explicit installation switch.
  • add merge-risk: 🚨 compatibility: The supplied recovery sequence retains the previous update channel, which can send the next package update back to Git; the deliberate early refusal itself is accepted by the maintainer-authored PR.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: The reported published-updater path can stop a working Gateway and break the CLI during an explicit installation switch.
  • merge-risk: 🚨 compatibility: The supplied recovery sequence retains the previous update channel, which can send the next package update back to Git; the deliberate early refusal itself is accepted by the maintainer-authored PR.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 19, 2026, 2:49 AM ET / 07:49 UTC.

@fuller-stack-dev
fuller-stack-dev merged commit 3a173da into openclaw:main Nov 19, 2026
143 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/update-does-not-start-unsafe-package-switch branch November 19, 2026 13:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…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
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…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]>
tideclaw-bot added a commit that referenced this pull request Nov 24, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant