Repository navigation
fix: let a Git install switch back to the npm package - #204835
Conversation
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
…re npm has a copy 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
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Worked on by: - @RomneyDa Co-authored-by: RomneyDa <[email protected]> OpenClaw-Publication: ecdf2764-e5c4-8a1b-b3be-ed34bfd6646e
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +31, Tests +221, Docs +6. Total +258 across 9 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 24, 2026, 1:26 PM ET / 18:26 UTC. |
* 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)
* 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]>
* 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]>
…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]>
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 stableor--channel betaused 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
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
openclawon PATH and the managed Gateway to the npm package. It does not require a manualgateway install --force.--no-restartstill leaves the service definition alone. The Windows npm-destination reservation fix remains; this change does not add Windows split-root service rebinding.Evidence
service-definition-not-writablerefusal. With the old compensation comparison, the running-service regression fails withENOENT: realpathbefore the missing npm package can be published.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 HEADRemaining live proof: the Docker
update-channel-switchlane 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