Skip to content

fix: let a Git install switch back to the npm package - #204835

Merged
RomneyDa merged 10 commits into
mainfrom
openclaw/ember-krill-119307
Nov 24, 2026
Merged

RomneyDa merged 10 commits into
mainfrom
openclaw/ember-krill-119307

Conversation

@tideclaw-bot

@tideclaw-bot tideclaw-bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #203619 by @steipete. Its commits and authorship are preserved here, integrated with current main. Related: #200578

What Problem This Solves

A Git release installation switching back to npm with openclaw update --channel stable or --channel beta used the Git install as the update executor key. The npm publication could not reserve its own destination, including the forwarding package left by an earlier npm-to-Git switch or a destination that did not yet exist. Keying the publication by the npm destination fixed the CLI switch but still left the managed Gateway on the Git release. The existing rebind path rejected the Git service as unwritable even when it had verified ownership of a writable definition.

What Changed

  • Keep the npm destination as executor and package-publication owner. Retain the verified Git service root separately, so the existing managed-service rebind owns the stop, definition rewrite, restart, and verification.
  • Use the existing update kind during service admission: a Git launcher or converted checkout must stay in place for Git release updates, but an owned, writable definition is refreshable when the target is a package. Foreign ownership, protected definitions, and fingerprint and manager checks still apply.
  • Compare the retained service and target with the shared install-identity owner, which can classify a destination before it is published. This lets the updater certify the incumbent for recovery without claiming the npm destination already exists or runs the Gateway.

The fix needs to be present in the running Git updater: a newer npm candidate cannot change the old updater's preflight or activation decisions. No state schema or protocol change is needed. The rebind follow-up is +21/−5 production lines; the full PR is +56/−25 versus merged main (excluding tests and docs).

User Impact

On Linux and macOS, a successful switch with an owned, writable service and a compatible npm target moves both openclaw on PATH and the managed Gateway to the npm package. It does not require a manual gateway install --force. --no-restart still leaves the service definition alone. The Windows npm-destination reservation fix remains; this change does not add Windows split-root service rebinding.

Evidence

  • On the merged base, restoring only the retained Git service root reproduces the service-definition-not-writable refusal. With the old compensation comparison, the running-service regression fails with ENOENT: realpath before the missing npm package can be published.
  • The Linux test fixtures exercise the real npm destination inspection and executor reservation (forwarding package and empty destination), an owned Git launcher through managed-service preflight and post-publication revalidation, and recovery certification with an empty destination. Native service-manager I/O is stubbed.
  • The prior fix: let a Git install switch back to the npm package #203619 test-type failure was in the root release-script graph; this branch integrates main without changing release scripts. The baseline-ratchet failure was three closed mocks in the PR's test; they now preserve real exports or use the real destination owner directly.

Local validation on signed head eb03086ec6fb (tree identical to this head): 120 tests passed across 7 files; a rerun of the two regression files passed 53/53. Both test type graphs, lint, format, and the mock-export and line-cap ratchets passed. No e2e assertions were changed.

node scripts/run-vitest.mjs src/cli/update-cli/update-command-{target.git-to-package,original-service,service-install-root,service-maintenance,restart-context,package-destination.release-link,package-destination.interrupted-link}.test.ts --maxWorkers=1
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.cli-update.json --incremental
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.root.scripts.json --incremental
node scripts/run-oxlint.mjs $(git diff --name-only dbe48a24e0b4 -- '*.ts')
node scripts/run-format.mts --check $(git diff --name-only dbe48a24e0b4)
pnpm check:test-mock-exports --base dbe48a24e0b4
pnpm check:line-cap-ratchet --base dbe48a24e0b4
git diff --check dbe48a24e0b4 HEAD

Remaining live proof: the Docker update-channel-switch lane in this PR's CI runs the real npm→Git→npm switch. A live systemd/launchd service rebind through Gateway readiness, and the earlier ~800 s hop timing, are not yet measured on this head. Windows was not run.

Published by the Gateway after authoritative workspace reconciliation.

Worked on by

steipete and others added 10 commits November 22, 2026 08:35
The npm package an npm-to-Git switch leaves forwarding to the Git release launcher (#200578) is this installation's own, but the update executor refused to reserve it ('Occupied slot does not resolve to its original installation') and package activation refused to publish into it, so openclaw update --channel stable on a Git release install always failed.

Refs #200578
…authority

The post-update continuation compared the publication's recorded authority (keyed by the reserved npm package) with the executor's installation authority, so a completed switch back from Git reported 'Package publication recovery is pending'. One helper now gives both package activation and its continuation the authority this executor publishes at a root.

Refs #200578
Drops the executor slot and publication-authority changes: the post-core continuation runs the installed target, whose executor authority is the parent's install lease, so the lease itself must be the npm package for every published target to accept the recorded publication.

Refs #200578
…to its package

The package-root executor admission moves to the package-activation module so the switch can admit the package destination after its inspection.

Refs #200578
…a switch to its package

A Git release service definition is not refreshable here (service-definition-not-writable), so the rebind attempt refused the whole switch. The service stays on the Git release with the existing skip warning; rebinding it is a maintainer decision.

Refs #200578
…ion through target resolution

Through resolveUpdateCommandTarget and a real executor: on base the package swap's reservation refuses with 'Occupied slot does not resolve to its original installation.' (forwarding package) or ENOENT realpath (no npm copy); both pass with the destination-keyed admission. Replaces the executor-only case.

Refs #200578
Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: ecdf2764-e5c4-8a1b-b3be-ed34bfd6646e
@clawsweeper

clawsweeper Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M labels Nov 24, 2026
@tideclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR keys Git-to-npm updates by the npm destination and allows the verified, writable Gateway service to move there.

Example: A Git release installation runs openclaw update --channel stable with an owned Linux Gateway service.

  • Before: Publication refuses with “Occupied slot does not resolve to its original installation.”
  • After: The intended result is that both the CLI and managed Gateway run the selected npm package.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation has credible boundary tests and no definite code finding, but the added live service transition and preservation of its persisted service binding across upgrade remain unproven.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Switching a Git release installation back to npm fails before publication or leaves the CLI and Gateway on different installations.
Reason: This maintainer-authored repair restores the documented install-switch contract and resolves the earlier PR's incomplete service transition.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it repairs a current Git-to-npm update failure using the existing publication and service-rebind owners, with no definite introduced code defect found.

Priority: P1
Reviewed head: 813271e640444c20aeced36af12c355c3f6466b4

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Provide a redacted real CLI Git-to-npm run through systemd or launchd showing the service rebound to npm and the target Gateway ready, with a latest-stable upgrade preserving existing settings and data.
Agent review details

How this fits together

The CLI updater resolves the destination, acquires installation ownership, publishes the package, and uses the existing native-service owner to rebind and verify the Gateway.

flowchart TD
  A[Update CLI] --> B[Inspect npm destination]
  B --> C[Admit destination executor]
  C --> D[Publish npm package]
  A --> E[Verify retained Git service]
  E --> F[Rebind owned service]
  D --> F
  F --> G[Verify Gateway readiness]
Loading

Technical review

Best possible solution:

Keep destination-keyed publication and use the existing owned-service rebind to move the CLI and Gateway together.

Do we have a high-confidence way to reproduce the issue?

Current-main admission, executor reservation, and publication checks explain both reported failures, corroborated by the linked Linux runs; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch fixes the ownership mismatch at target selection, preserves publication checks, and reuses the existing service and recovery owners; the extracted admission operation serves both package paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 986ad151d123.

Provenance checked

  • Package executor admission and publication recovery keeps the original intent (ce2985b: Retain ownership through admitted command cleanup; publication recovery separately requires authority for the package being replaced.)
  • Stable Git service definitions changes intended behavior with a stated reason (6747b1e: Git release updates switch behind a stable launcher instead of rewriting its service definition; fix: let Doctor repair a Git checkout install after its first update #204676 extended that treatment to forwarded checkout entries.)
  • Original managed-service compensation keeps the original intent (97c7b35: Certify the exact incumbent runtime before stopping it so a failed split-root activation can recover safely.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7d2933b adds src/cli/update-cli/update-command-service-plan.ts:230 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7d2933bd1bff; files: src/cli/update-cli/update-command-service-plan.ts)
  • Jason (Json): Raw commit 97c7b35 adds src/cli/update-cli/update-command-original-service.ts:232 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 97c7b3593392; files: src/cli/update-cli/update-command-original-service.ts)
  • Ayaan Zaidi: Raw commit 6747b1e adds src/cli/update-cli/update-command-service-plan.ts:323 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6747b1ec5ae3; files: src/cli/update-cli/update-command-service-plan.ts)
  • Dallin Romney: Raw commit fd6fa47 adds src/cli/update-cli/update-command-service-plan.ts:491 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fd6fa470a6cc; files: src/cli/update-cli/update-command-service-plan.ts)

PR surface

Source +31, Tests +221, Docs +6. Total +258 across 9 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 56 25 +31
Tests 2 221 0 +221
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 283 25 +258

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.

Review metrics

Metric Value Why it matters
Production versus test changes Production +56/−25; tests +221/−0 The growth covers destination admission, service-policy propagation, and distinct forwarding-package, empty-destination, and incumbent-certification regressions without adding another lifecycle owner.

Root-cause cluster

Relationship: canonical
Canonical: #204835
Summary: This PR preserves the earlier destination-ownership repair and adds the managed Gateway transition.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P1: Current Git installations cannot complete the documented return-to-npm update workflow.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: Current Git installations cannot complete the documented return-to-npm update workflow.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

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 24, 2026, 1:26 PM ET / 18:26 UTC.

@RomneyDa
RomneyDa merged commit 152254c into main Nov 24, 2026
147 checks passed
@RomneyDa
RomneyDa deleted the openclaw/ember-krill-119307 branch November 24, 2026 19:32
tideclaw-bot added a commit that referenced this pull request Nov 24, 2026
* fix(update): let a Git release install switch back to its npm package

The npm package an npm-to-Git switch leaves forwarding to the Git release launcher (#200578) is this installation's own, but the update executor refused to reserve it ('Occupied slot does not resolve to its original installation') and package activation refused to publish into it, so openclaw update --channel stable on a Git release install always failed.

Refs #200578

* fix(update): settle a switch-back publication with the package's own authority

The post-update continuation compared the publication's recorded authority (keyed by the reserved npm package) with the executor's installation authority, so a completed switch back from Git reported 'Package publication recovery is pending'. One helper now gives both package activation and its continuation the authority this executor publishes at a root.

Refs #200578

* fix(update): key a Git-to-package switch by its package destination

Drops the executor slot and publication-authority changes: the post-core continuation runs the installed target, whose executor authority is the parent's install lease, so the lease itself must be the npm package for every published target to accept the recorded publication.

Refs #200578

* fix(update): rebind the Git install's Gateway service after a switch to its package

The package-root executor admission moves to the package-activation module so the switch can admit the package destination after its inspection.

Refs #200578

* fix(update): leave the Git install's Gateway service to its owner on a switch to its package

A Git release service definition is not refreshable here (service-definition-not-writable), so the rebind attempt refused the whole switch. The service stays on the Git release with the existing skip warning; rebinding it is a maintainer decision.

Refs #200578

* test(update): key a Git-to-npm switch by its package destination before npm has a copy

Refs #200578

* test(update): prove a Git-to-npm switch reserves its package destination through target resolution

Through resolveUpdateCommandTarget and a real executor: on base the package swap's reservation refuses with 'Occupied slot does not resolve to its original installation.' (forwarding package) or ENOENT realpath (no npm copy); both pass with the destination-keyed admission. Replaces the executor-only case.

Refs #200578

* fix(update): rebind the managed Gateway when switching back to npm

Co-authored-by: RomneyDa <[email protected]>

* fix: let a Git install switch back to the npm package

Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: ecdf2764-e5c4-8a1b-b3be-ed34bfd6646e

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 152254c)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
* fix(update): let a Git release install switch back to its npm package

The npm package an npm-to-Git switch leaves forwarding to the Git release launcher (openclaw#200578) is this installation's own, but the update executor refused to reserve it ('Occupied slot does not resolve to its original installation') and package activation refused to publish into it, so openclaw update --channel stable on a Git release install always failed.

Refs openclaw#200578

* fix(update): settle a switch-back publication with the package's own authority

The post-update continuation compared the publication's recorded authority (keyed by the reserved npm package) with the executor's installation authority, so a completed switch back from Git reported 'Package publication recovery is pending'. One helper now gives both package activation and its continuation the authority this executor publishes at a root.

Refs openclaw#200578

* fix(update): key a Git-to-package switch by its package destination

Drops the executor slot and publication-authority changes: the post-core continuation runs the installed target, whose executor authority is the parent's install lease, so the lease itself must be the npm package for every published target to accept the recorded publication.

Refs openclaw#200578

* fix(update): rebind the Git install's Gateway service after a switch to its package

The package-root executor admission moves to the package-activation module so the switch can admit the package destination after its inspection.

Refs openclaw#200578

* fix(update): leave the Git install's Gateway service to its owner on a switch to its package

A Git release service definition is not refreshable here (service-definition-not-writable), so the rebind attempt refused the whole switch. The service stays on the Git release with the existing skip warning; rebinding it is a maintainer decision.

Refs openclaw#200578

* test(update): key a Git-to-npm switch by its package destination before npm has a copy

Refs openclaw#200578

* test(update): prove a Git-to-npm switch reserves its package destination through target resolution

Through resolveUpdateCommandTarget and a real executor: on base the package swap's reservation refuses with 'Occupied slot does not resolve to its original installation.' (forwarding package) or ENOENT realpath (no npm copy); both pass with the destination-keyed admission. Replaces the executor-only case.

Refs openclaw#200578

* fix(update): rebind the managed Gateway when switching back to npm

Co-authored-by: RomneyDa <[email protected]>

* fix: let a Git install switch back to the npm package

Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: ecdf2764-e5c4-8a1b-b3be-ed34bfd6646e

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot added a commit that referenced this pull request Nov 28, 2026
* fix(update): let a Git release install switch back to its npm package

The npm package an npm-to-Git switch leaves forwarding to the Git release launcher (#200578) is this installation's own, but the update executor refused to reserve it ('Occupied slot does not resolve to its original installation') and package activation refused to publish into it, so openclaw update --channel stable on a Git release install always failed.

Refs #200578

* fix(update): settle a switch-back publication with the package's own authority

The post-update continuation compared the publication's recorded authority (keyed by the reserved npm package) with the executor's installation authority, so a completed switch back from Git reported 'Package publication recovery is pending'. One helper now gives both package activation and its continuation the authority this executor publishes at a root.

Refs #200578

* fix(update): key a Git-to-package switch by its package destination

Drops the executor slot and publication-authority changes: the post-core continuation runs the installed target, whose executor authority is the parent's install lease, so the lease itself must be the npm package for every published target to accept the recorded publication.

Refs #200578

* fix(update): rebind the Git install's Gateway service after a switch to its package

The package-root executor admission moves to the package-activation module so the switch can admit the package destination after its inspection.

Refs #200578

* fix(update): leave the Git install's Gateway service to its owner on a switch to its package

A Git release service definition is not refreshable here (service-definition-not-writable), so the rebind attempt refused the whole switch. The service stays on the Git release with the existing skip warning; rebinding it is a maintainer decision.

Refs #200578

* test(update): key a Git-to-npm switch by its package destination before npm has a copy

Refs #200578

* test(update): prove a Git-to-npm switch reserves its package destination through target resolution

Through resolveUpdateCommandTarget and a real executor: on base the package swap's reservation refuses with 'Occupied slot does not resolve to its original installation.' (forwarding package) or ENOENT realpath (no npm copy); both pass with the destination-keyed admission. Replaces the executor-only case.

Refs #200578

* fix(update): rebind the managed Gateway when switching back to npm

Co-authored-by: RomneyDa <[email protected]>

* fix: let a Git install switch back to the npm package

Worked on by:
- @RomneyDa

Co-authored-by: RomneyDa <[email protected]>
OpenClaw-Publication: ecdf2764-e5c4-8a1b-b3be-ed34bfd6646e

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 152254c)

Release adaptation: Admit an inspected empty npm destination as the primary install root, while keeping the checkout lease for existing targets and acquiring it before restoring any interrupted npm link. Retain the stable writable-service and ownership checks, using the existing split-root rebind and recovery owners. Adapt regressions to a legacy checkout; do not import #200578 or its launcher/forwarder fixtures.

Follow-ups: 4afbe0b (#205010) changes pnpm virtual-store behavior and documents it separately; not required for the npm lease or service recovery. No later production code touches.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…lace Git runner (#200578)

Slice 4b of the update foundation. Follows #199706 (slice 4), #201917 (releases outside `node_modules`) and #201538 (half-switched Git updates).

## Problem

Since #199706, POSIX Git checkouts with a Gateway service update through releases: a detached worktree at `<state>/git-install/releases/<id>/openclaw`, behind the link `<state>/git-install/openclaw`, started by a launcher that switches back after two failed starts. Three cases still used the in-place Git runner, which rewrites the checkout the Gateway runs from:

- Windows checkouts;
- package-to-Git switches;
- checkouts with no Gateway service.

That runner is RC1 of the update RCA: in-place replacement at a path running processes use. Keeping it meant keeping its rollback, retention, pack transfer, staging and handoff code.

## Change

Every Git install now updates through releases. The in-place Git runner and its command-side rollback are deleted on every platform in one cutover. `openclaw update` no longer moves the checkout `HEAD` or rebuilds its `dist`. (`scripts/update-gateway.sh`, a separate maintainer script, still rebuilds a checkout in place; it is unchanged.)

- **Windows:**
  - The release link is an NTFS junction, which needs no administrator rights. It is owned by the existing `package-release-slot*` code; the win32 exclusions there and in the release lease are removed.
  - Windows cannot rename onto a junction, so a switch removes the old junction and then renames.
  - The Windows task supervisor starts its Gateway child through the release launcher, so the child's starts count toward the trial.
- **Package-to-Git:**
  - The checkout is cloned and the target is built as the release on trial. Its fallback is the npm package that was serving, kept intact: if the Git build fails to start twice, the launcher switches the link back to the package, and the Gateway and `openclaw` on PATH run the npm build again with no manual step. A deferred (`--no-restart`) switch keeps the same fallback. The package counts as this install's only while its `openclaw.mjs` is exactly this install's forwarding entry; retention never touches it.
  - The global npm package's `openclaw.mjs` is rewritten once to import the release launcher, so the existing npm bin shims run the release. Without that, `openclaw` on PATH would keep running the old npm build, whose updater treats the install as npm.
  - The rejected alternative, re-pointing the npm package path at the release, would name the release through `node_modules/openclaw` again, the cause of #201874.
  - Installs whose switch was done by an older updater have the npm package path linked to the checkout, which releases never rebuild. A Git release update replaces that link (only a link to the checkout) with a directory holding `openclaw.mjs` and `dist/index.js`, both starting the launcher; the second keeps a service definition that names the package path working after a `--no-restart` update. Without this, the CLI and its updater stayed on the version the switch built (found by the package-to-Git upgrade lane).
- **No service:** a checkout run by hand updates through a release too. The next `openclaw gateway` runs it.
- **CLI on PATH:** after a Git release update, the installer's `openclaw` wrapper (POSIX and Windows) is rewritten once to run the release launcher, and a global npm, pnpm (`pnpm add -g openclaw@link:`) or Bun (`bun link`) link to the checkout is replaced the same way as the npm link above. The launcher selects a `--no-restart` release on the next Gateway run and counts `openclaw gateway` / `openclaw gateway run` as trial starts; other commands (`gateway status`, `--version`) never count.
- **Service definition:** `serviceUsesUpdatedRoot` reads the service definition, not the running process. A `--no-restart` Git release update whose service still starts the checkout writes a definition that starts the launcher without starting or restarting the Gateway (`stage`; systemd reloads unit metadata only). Every OpenClaw restart route on macOS (`openclaw gateway restart` and the Gateway's own restart) re-bootstraps the job when the loaded command is known to differ from the plist on disk; otherwise it kickstarts. Only a failed write leaves an owed `service-definition` step.
- **Conversion stop:** a Git update stops a Gateway whose service does not yet name the launcher before the release activates, so the existing install rebinds it. A Dashboard update on macOS runs inside the Gateway's LaunchAgent, which cannot rewrite itself while loaded; without the stop, the update reported success, the Gateway kept the old checkout and the result asked for `openclaw gateway install --force`. This replaces `main`'s macOS in-place fallback (247b958), whose runner this PR deletes. An update the previous definition does not start is reported as pending, not succeeded. Services that already name the launcher still switch without a stop.
- **Restart:** the converted service restarts once, not twice. Git release updates no longer warn to restart a live Gateway by hand: a release replaces no root the Gateway uses.
- **No manual steps (Ayaan, 2026-11-20):**
  - Releases built under `lib/node_modules` by `7db69bedeab6`-era updaters (#201874): bundled plugin public surfaces there load the built `dist/extensions/<plugin>/` JavaScript, so those installs update by themselves; the manual bridge in the #201874 comment is no longer needed.
  - A killed npm link swap leaves the link under npm's backup name; the next Git update restores it and retries.
  - The launcher finishes a Windows link switch killed between removing the old junction and renaming the new one.
  - npm -> Git -> npm: destination ownership recognizes this install's exact forwarding `openclaw.mjs`, so switching back is admitted.

## Impact

- One update path for Git installs on macOS, Linux and Windows.
- `openclaw` on PATH runs the current release after an update.
- **Accepted edge cases:**
  - Two checkouts that share one state directory share its single release install.
  - After a package-to-Git switch, the old npm package keeps its disk space until a switch back to npm replaces it.
  - A Gateway run for another profile through the default `openclaw` on PATH counts toward the default install's trial (accepted by Ayaan, 2026-11-20).
  - `--no-restart` selects the new release at the next start without the two-start switch-back.
  - A checkout installed at `<state>/git-install/openclaw` (the release link path; the installer default is `~/openclaw`) is left in place, and every update fails visibly with nothing changed, naming the fix: move the checkout or reinstall with another `--git-dir` (accepted by Ayaan, 2026-11-21).
  - The first update of an install whose service still names the checkout has a one-time outage while the Gateway stops and the LaunchAgent or unit is rebound (26 s on the macOS Dashboard run).
  - If a macOS release's `launchctl print` omits the job's arguments, a definition staged by `--no-restart` applies at the next login or update instead of the next restart.
  - Unchanged follow-up: when local commits conflict with every newer commit, the preflight reports `already-current` instead of naming the conflict. This predates the PR and gets its own PR.

## Size

Against the merge base, 32 commits:

- Production code: +821 / −2,166 (56 files).
- Tests: +1,391 / −8,893 (74 files). Cut tests covered steps a Git release no longer takes (checkout rollback, in-place staging, service stop before checkout); each is listed in the contract.
- Upgrade-survivor scenario: +836 / −104 (4 files): baselines `v2026.11.5`, `7db69bedeab6`, `main`; package-to-Git; no service; SIGKILL at stage, build, publish, link switch and launcher restore.
- Docs: +132 / −104.

## Evidence

Final head `99ecf23e04e8`. Each row names the head its end-to-end proof ran on; later commits change tests, the e2e helper's lint, the restart warning text, the macOS reload probe's unknown case, the npm/pnpm/Bun link lookup and the deferred-switch staging (unit-proven, red on base).

| Invariant | Result | Proof |
|---|---|---|
| Release built where it serves; no `node_modules` in the link or realpath | Pass | Linux upgrade-survivor lanes; macOS launchd (isolated profile on a maintainer Mac); hosted Crabbox Windows Server 2025 |
| Gateway serves the new release and `tools.invoke web_search` works after every update | Pass | every hop on all three OSes |
| SIGKILL at stage, build, publish, link switch, launcher restore leaves a serving install | Pass | Linux kill-point lane (`8f63330`) |
| Two failed starts switch back and restore `.pre-` state | Pass | Linux lanes; macOS `8f63330` (`failed to start twice; switched back`); Windows `9cbc4b5`, automatic through the Scheduled Task, 67.5 s outage. Older-supervisor and pending cases: unit tests red on base (`6003675`, `75e7bd5`) |
| The release updates itself | Pass | Linux; macOS `8f63330`; Windows `9cbc4b5` |
| The checkout is never written (HEAD, status) | Pass | every lane and OS run |
| Every shipped layout reaches releases with no manual step | Pass | `v2026.11.5`, merge-base `main` (`8f63330`); `7db69bedeab6` (`6003675`) |
| npm → Git switch; `openclaw` on PATH runs the release | Pass | Linux `75e7bd5` |
| No service: the next `openclaw gateway` runs the release | Pass | Linux `8f63330` |
| `--no-restart` keeps the Gateway up; the next restart runs the release | Pass | macOS `8f63330`: 0 s outage, `gateway restart` reloads launchd arguments |
| macOS Dashboard update (`update.run`) on a LaunchAgent that names the checkout, twice, then a terminal update | Pass | `80d9587`, isolated profile on a maintainer Mac: each update served its new commit, launchd runs `openclaw-launcher.mjs`, `web_search` passed, checkout unchanged, no manual step needed. Red on `3c14869` (Gateway kept the checkout, manual install step) |
| Linux `7db69bedeab6` → head and npm → Git | Pass | `80d9587` |
| Windows junction; a release held open is retained, then collected | Pass | hosted Crabbox (Windows Server 2025) |
| Windows without admin rights | Not run | S4U Limited stays admin on the Crabbox image |
| Installer-made partial clones (`--filter=blob:none`) | Not run | all lanes clone fully |

Reviews: local ClawSweeper on every head (last finding accepted above); Fable 5.2 contract reviews. Unit: release, update-runner, launcher, wrapper, service, launchd, systemd, restart, task-supervisor, plugin loader suites; `tsgo:core` and `tsgo:core:test` clean.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit b229b26)

Release adaptation: Extract only the three public-surface resolver, caller and regression paths. Preserve globals, source checkouts and already-bound plugin instances; exclude the Git updater rewrite.

Companion audit: PR #200578 is the source; #203247 and #204835 follow the excluded Windows launcher and install switch. No follow-up modifies the selected public-surface files.

Co-authored-by: RomneyDa <[email protected]>
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 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants