Skip to content

feat(update): run every Git install from releases and delete the in-place Git runner - #200578

Merged
obviyus merged 38 commits into
mainfrom
feat/update-git-releases-windows
Nov 21, 2026
Merged

obviyus merged 38 commits into
mainfrom
feat/update-git-releases-windows

Conversation

@obviyus

@obviyus obviyus commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

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 [Bug]: Managed Git install loads raw DeepSeek web-search contract under node_modules, breaking Gateway MCP startup #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):

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.

@clawsweeper

clawsweeper Bot commented Nov 17, 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 cli CLI command changes size: XL scripts Repository scripts labels Nov 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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:feature Preliminary submission classification; full source review pending. labels Nov 17, 2026
@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head ec70cb33c859bc62c292cb92067eb171788e4b91, but the PR head is now 9e0c560e47303020c687b563b14e074f26322945. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-17T13:14:41.145Z sha ec70cb3 :: blocked before merge. :: [P1] Route existing source entry points through the selected release

@obviyus
obviyus force-pushed the feat/update-git-releases-windows branch from 48c47f3 to 3a85c26 Compare November 18, 2026 19:10
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 18, 2026
@obviyus
obviyus force-pushed the feat/update-git-releases-windows branch 2 times, most recently from 1b57ac9 to 9e0c560 Compare November 19, 2026 14:32
- Restore 12 Git cases on the release route: post-core plugin convergence warnings and blocked plugins, the downgraded compatibility host version (#87914), plugin load errors staying advisory, captured paths after cwd loss, the update flag lifetime, sentinel consumption on restart health failure, and wizard consent forwarding.
- The update fixture builds its release at releases/<id>/openclaw, the layout updateGitRelease publishes; it still built the old lib/node_modules layout, so the tests never took the release path.
- Docs: releases are built where they serve; document the Windows junction switch gap and its recovery.
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 20, 2026
- An updater before this change switched npm to Git by linking the global package to the checkout. Releases never rebuild the checkout, so `openclaw` on PATH stayed on the old build.
- A Git release update now replaces that link with a directory whose `openclaw.mjs` starts the selected release.
- Cut test rows for steps a Git release no longer takes (service stop and checkout under maintenance contention, Git Doctor delegation).
- Add the package-to-git, no-service and kill-point routes to the git-release upgrade-survivor scenario.
…se scenario

- Baselines v2026.11.5, 7db69be and main; package-to-git, no-service, and SIGKILL at stage, build, publish, link switch and launcher restore.
@obviyus
obviyus force-pushed the feat/update-git-releases-windows branch from 9e0c560 to 87b5bd0 Compare November 20, 2026 11:18
@openclaw-barnacle openclaw-barnacle Bot added the docker Docker and sandbox tooling label Nov 20, 2026
- The npm `openclaw.mjs` and the installer wrapper run the release launcher, so `openclaw gateway` selects a `--no-restart` release and its starts count toward the trial.
- The launcher counts only `openclaw gateway` and `openclaw gateway run`; other commands run the release's `dist/entry.js` and never count.
- A checkout-linked npm package is replaced only when the link resolves to the checkout, and its stub keeps `dist/index.js` for a service definition that names the package path.
- Restore the Git row of the agent-initiated handoff test.
…restart service refresh

- The release launcher never counts or activates on `-h`, `--help`, `-V` or `--version`.
- A `--no-restart` Git release update whose service still starts the checkout records the owed `service-definition` step with its two commands; one helper in the owed-step owner serves both paths.
- The launcher reads arguments as the CLI's command-path parser does: after `--` every argument is a literal positional.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
…lace Git runner (openclaw#200578)

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

## Problem

Since openclaw#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 openclaw#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 (e4b7909), 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 `47b219778879`-era updaters (openclaw#201874): bundled plugin public surfaces there load the built `dist/extensions/<plugin>/` JavaScript, so those installs update by themselves; the manual bridge in the openclaw#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`, `47b219778879`, `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`); `47b219778879` (`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 `47b219778879` → 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
…it updates (openclaw#203247)

* fix(update): admit Git-to-npm switch back and repoint the Windows installer wrapper

A Git release install leaves the npm package forwarding to its launcher, but
the executor's occupied-slot check only accepted a package path that resolves
to the installation, so switching back to npm failed with 'Occupied slot does
not resolve to its original installation.' Reserve this install's exact
forwarding package, the same ownership proof destination admission uses.

install.ps1 wrote the Git wrapper as dist\\entry.js (a literal double
backslash), which the updater's exact match never recognized, so Windows Git
installs kept running the checkout's installer-time build from PATH. Match the
wrapper's entry by normalized Windows path and write single backslashes.

Refs openclaw#200578

* fix(update): admit the forwarding package only for its own Git install's executor

Refs openclaw#200578

* fix(update): rewrite the Windows Git wrapper so the running cmd.exe exits cleanly

cmd.exe rereads a running batch file at its saved byte offset. openclaw update
usually runs through the wrapper it rewrites, so after the update returned cmd
resumed inside the new command line and the update exited 1 with 'The system
cannot find the path specified.' Pad the new wrapper so the old length lands on
an exit line that keeps the update's exit code.

Drop the npm switch-back slot admission: package publication recovery also
requires the executor's installation to be the npm directory, so the switch
back needs a root decision in the package update owner, not a slot exception.

Refs openclaw#200578

* fix(update): leave a wrapper that already runs the release launcher unchanged

Refs openclaw#200578
steipete added a commit that referenced this pull request Nov 22, 2026
…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
steipete added a commit that referenced this pull request Nov 22, 2026
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
steipete added a commit that referenced this pull request Nov 22, 2026
…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
steipete added a commit that referenced this pull request Nov 22, 2026
…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
steipete added a commit that referenced this pull request Nov 22, 2026
steipete added a commit that referenced this pull request Nov 22, 2026
…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
@steipete

Copy link
Copy Markdown
Contributor

Switching back from Git to npm still fails on main as of feea72c1863, which includes #203194. openclaw update --channel stable on a Git release install refuses before changing anything. The error depends on the npm destination:

  • On Linux, where an npm-to-Git switch left the forwarding openclaw.mjs, it fails with Occupied slot does not resolve to its original installation.
  • On Windows, for a Git install that never had an npm copy, it fails with ENOENT: realpath C:\Program Files\nodejs\node_modules\openclaw.

The cause is that the update executor is keyed by the Git install, while the package swap writes the npm destination.

Draft #203619 keys a switch to a package by its package destination. On Crabbox Linux it gets npm 2026.11.30 → Git (--channel dev) → npm 2026.11.31 → 2026.11.32 to all succeed, with readyz 200 throughout. The Gateway service is still left on the Git release, with the existing "service management skipped" warning. Rebinding a Git release launcher service is an owner decision, and the draft is open for it. Not yet released.

Until it ships, use the manual procedure from the docs (https://docs.openclaw.ai/install/updating/update-methods#alternative-manual-npm-pnpm-or-bun). Create a verified backup first, and run each command only after the previous one succeeds:

openclaw gateway stop
npm i -g openclaw@latest --allow-scripts=openclaw
openclaw doctor --fix
openclaw gateway install --force
openclaw gateway start
openclaw gateway status --deep

The last command should show the service starting the npm package.

RomneyDa 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]>
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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…it updates (#203247)

* fix(update): admit Git-to-npm switch back and repoint the Windows installer wrapper

A Git release install leaves the npm package forwarding to its launcher, but
the executor's occupied-slot check only accepted a package path that resolves
to the installation, so switching back to npm failed with 'Occupied slot does
not resolve to its original installation.' Reserve this install's exact
forwarding package, the same ownership proof destination admission uses.

install.ps1 wrote the Git wrapper as dist\\entry.js (a literal double
backslash), which the updater's exact match never recognized, so Windows Git
installs kept running the checkout's installer-time build from PATH. Match the
wrapper's entry by normalized Windows path and write single backslashes.

Refs #200578

* fix(update): admit the forwarding package only for its own Git install's executor

Refs #200578

* fix(update): rewrite the Windows Git wrapper so the running cmd.exe exits cleanly

cmd.exe rereads a running batch file at its saved byte offset. openclaw update
usually runs through the wrapper it rewrites, so after the update returned cmd
resumed inside the new command line and the update exited 1 with 'The system
cannot find the path specified.' Pad the new wrapper so the old length lands on
an exit line that keeps the update's exit code.

Drop the npm switch-back slot admission: package publication recovery also
requires the executor's installation to be the npm directory, so the switch
back needs a root decision in the package update owner, not a slot exception.

Refs #200578

* fix(update): leave a wrapper that already runs the release launcher unchanged

Refs #200578

(cherry picked from commit 9809b28)

Release adaptation: Keep only normalized install paths and recognition of the owned stable wrapper when its legacy entry path contains repeated separators. Exclude resident launcher and its retirement rewrite.

Companion audit: PR #203247 is the source. #203588 atomic replacement is already present via NullString.Value; later memory gating is out of scope.

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 docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants