Repository navigation
feat(update): run Git checkout installs from releases behind the release link - #199706
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR builds managed Git updates in separate worktrees and switches a stable release link, with launcher-based startup recovery. Example: A managed Git installation updates from release A to release B.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: the previous unmanaged-checkout defect is fixed, and the release-layout change remains useful, distinct work; no additional correctness defect was identified. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe update CLI selects and validates Git candidates, publishes their runtime, and coordinates Gateway restart, recovery, and plugin convergence. flowchart TD
A[Update CLI] --> B[Service ownership selection]
B --> C[Git candidate preflight]
C --> D[Release worktree]
D --> E[Stable release link]
E --> F[Gateway launcher]
F --> G[Verification and plugin convergence]
Technical reviewBest possible solution: Complete the Git-release slice using the existing candidate, link-switch, retention, and convergence owners while preserving supported in-place fallbacks. Do we have a high-confidence way to reproduce the issue? This is an architectural improvement rather than a newly reproduced bug; current-main source confirms the in-place runtime replacement that motivates it, and no target code was executed during review. Is this the best way to solve the issue? The implementation reuses the existing preflight, publication, retention, and plugin owners, and its independent launcher has a concrete purpose when candidate code cannot load; retaining the in-place path preserves supported installations. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3dc7eb96a528. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +812, Tests +647. Total +1459 across 37 files. Added test files: 2. 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
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 HistoryReview history (9 earlier review cycles; latest 8 shown)
Reviewed November 16, 2026, 5:05 AM ET / 10:05 UTC (Revision 10). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
e69c286 to
9bc4b73
Compare
|
@clawsweeper re-review |
- No published release contains #199706: v2026.11.5 updates Git checkouts in place. The old layout comes from main builds since 2026-11-17, which still report 2026.11.5.
## Problem #201874: on a managed Git install, a Gateway MCP turn fails before replying: ```text warn mcp-loopback request handling failed: Stripping types is currently unsupported for files under node_modules, for "<state-dir>/git-install/releases/<release>/lib/node_modules/openclaw/extensions/deepseek/web-search-contract-api.ts" error Embedded agent failed before reply: Claude Code started without the OpenClaw MCP server (status failed). ``` #199706 put each Git release, a full worktree with plugin TypeScript sources, at `releases/<id>/lib/node_modules/openclaw`. Two path rules then meet: 1. `resolvePublicSurfacePath` (`src/plugins/public-surface-runtime.ts`) picks `extensions/<plugin>/<file>.ts` before `dist` when the source exists. Only a Git release has sources; the npm package ships `dist/` only. 2. The plugin loader's Jiti options add `"openclaw"` to `nativeModules` (`src/plugins/sdk-alias.ts`). Jiti 2.7.0 turns that into `node_modules/(openclaw)/` and loads any match natively, even with `tryNative: false` (`src/require.ts:131`). Node then refuses (`lib/internal/modules/typescript.js:188`, `isUnderNodeModules(filename)`). The updater missed it because it validated a different path than it serves: `buildRelease` built and checked the release at `releases/<id>/build`, then `git worktree move` put it under `node_modules`. The only check at the final path was `openclaw.mjs --version` (`update-runner-git-release.ts`, `git-release-smoke`), which loads no plugin. Reproduced on a real release tree built by `main` at 18b04f2 (2026-11-19) on this machine, through Jiti with `nativeModules: ["openclaw"]` and `tryNative: false`: `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING` for `extensions/brave/web-search-contract-api.ts`, through both the real path and the link path. The same class, TypeScript at runtime under `node_modules`, appeared before as #19815 (2026-02-18) and #53953 (2026-03-24). ## Change Remove the cause in the owner: Git releases no longer live under `node_modules`. - Layout: `<state>/git-install/openclaw -> releases/<id>/openclaw`. Moving only the tree is not enough: the Gateway names its root by the link (`openclaw-root.ts`), and Jiti matches the link path string too. - Each release is built and validated where it serves. The build-beside-and-move step (`buildDir`, `git-release-place`) is deleted. A release path that a loader rule breaks now breaks the build before activation. - `package-release-slot-path.ts` keeps one rule for both layouts: a release keeps the package at the link's path below the prefix (npm `lib/node_modules/<name>`, Git `<name>`). Lease, retention and the switch's deselect stamp use it, not npm-only `dirname` math. - Retention resolves each retained release at the link's layout or at npm's `lib/node_modules/<name>`, where releases built before the move still live. `update status` keeps listing them, and an open update run that names one still protects it. - Migration: `servingGitReleaseSlot` reads the old link while it still serves. The first update run by this release rebuilds the serving commit at the new path, publishes the new link, and removes the old link. The old Gateway then sees its installation replaced and restarts through the launcher, which now starts the new link. No loader exception, no second source/dist rule, no flag. ## Impact - Managed Git installs load bundled plugin sources again. - Dev-channel installs on `main` builds since #199706 (they report version 2026.11.5; no published release has the layout) need one more `openclaw update` after the update to this change, because the older updater drives that first hop and still builds under the old path. - npm, plain checkouts, Docker and package-to-Git switches are unchanged. ## Evidence - **Regression test** (`src/infra/git-release.test.ts`, "loads a bundled plugin's source contract from the selected release (#201874)"). It copies `extensions/deepseek` into a release made by `createGitReleaseDirs`, publishes it, and loads `web-search-contract-api` through `loadPluginPublicArtifactModuleSync` from the release link path. - On `main` (307d9c4): fails. Under Vitest the `tsx` hooks strip the types, so the symptom is `ERR_MODULE_NOT_FOUND` for `openclaw/plugin-sdk/lazy-runtime`: the forced native import resolves the bare `openclaw/...` specifier to the release tree itself. Same cause. - On this branch: passes (`git-release.test.ts` 12/12). - **Migration test** (`update-runner-git-release.test.ts`). A release under `lib/node_modules` is rebuilt at the new path, the new link's real path has no `node_modules` segment, and the old link is gone. - **Mixed-layout inventory test** (`git-release.test.ts`). After the link moves out, a release still under `lib/node_modules/openclaw` stays listed by `listPackageReleases`, the source of `openclaw update status`. - **Exact error on a real tree.** A release built by `main` (18b04f2) on a Mac profile, loaded through Jiti 2.7.0 with `nativeModules: ["openclaw"]` and `tryNative: false`: `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING … extensions/brave/web-search-contract-api.ts`, through both the real path and the link path. - **Mutation proof (build at the final path).** The release build (`node --import ./scripts/tsx.mjs scripts/build-all.mts`): - In a worktree at `releases/r1/lib/node_modules/openclaw`: fails at once with `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING … scripts/lib/local-check-runtime.mts`. - The same commit at `out/r2/openclaw`: passes that stage (`runtime:scripts:check` 4.61 s). - So a release path that a loader rule breaks now fails the update before activation. - **Stable tag unaffected.** A Docker lane run with a real service install of tag `v2026.11.5` (e13cf15): its updater returned `status: ok`, `root: …/git-checkout`, steps `clean-check, git-resolve-target, recovery-artifact-cleanup`. No release link was created. No published release has the release layout. - **Gates:** `pnpm tsgo:core` exit 0; line-cap check OK (13 files); oxlint and oxfmt clean on changed files. - **Every test file that reads the release layout:** 21 files. `rg -l 'git-release|gitReleaseSlot|GIT_RELEASE|usesGitReleases|package-release-slot-path|package-release-lease' src --glob '*.test.ts'`, plus `openclaw-root`, `program-args*`, `service-layout` and `stale-install`. All pass. - The first batch run (4 workers, load 22–49) timed out 6 update-cli cases. Rerun with 2 workers: 141/141. - Four suites did not load in that batch because a parallel scenario edit changed `scripts/` during the run. Rerun alone: 40/40 and 35/35. ## Not proven here - **Real upgrade from `7db69bedeab6` (the reporter's build) to this change, with a Gateway request that loads the web-search contracts.** A Linux upgrade-survivor `git-release` scenario reached the stable-tag baseline above; the run from `7db69bedeab6` did not finish before landing. The scenario is not in this PR. The reporter is asked to confirm on #201874. - **Windows.** No Windows host completed a run. On `main`, Windows Git checkouts never use releases (`usesGitReleases` returns false on win32), so they are unaffected by the bug and by this change. That comes from the code, not a run. - **The old Gateway restarting after the old link is removed.** Before this change the Gateway saw the link move; here the link disappears. INFERENCE: it reads as installation replacement too. Co-authored-by: Ayaan Zaidi <[email protected]>
## Problem #201874 shipped because no upgrade lane ran a Git install. All 35 upgrade-survivor scenarios start from an npm package, so the Git release layout from #199706 never booted in CI before users hit it. ## Change - Adds an opt-in `git-release` upgrade-survivor scenario. Starting from `7db69bedeab6` (the #201874 reporter's build), it: 1. builds the checkout and installs the Gateway service (systemctl shim); 2. lets that build convert the install onto the old release layout; 3. reproduces the type-stripping failure through the Gateway; 4. updates to the candidate twice, the first run by the old build and the second by the candidate; 5. asserts the release left `node_modules`, the old link is gone, and `tools.invoke web_search` succeeds with no stripping error in the Gateway log. - The scenario stays out of the aggregate lanes and the published-baseline matrix; run it with `OPENCLAW_UPGRADE_SURVIVOR_SCENARIO=git-release`. Three full builds take about 24 minutes, so it gets a 3600 s container timeout. - Corrects the update guidance in `docs/install/updating.md`. The run showed two things: - The old release cannot run its own updater, so users must update from a terminal with the checkout's `openclaw`. - With a web search provider configured, the Gateway on the old layout fails at startup. ## Evidence - `OPENCLAW_UPGRADE_SURVIVOR_SCENARIO=git-release bash scripts/e2e/upgrade-survivor-docker.sh` against #201917's head `6b5d14b1`: exit 0, `summary.json` `passed`, 23m35s. Step results are in #201917 (comment) - The same scenario against tag `v2026.11.5` shows the published release never takes the release layout: its updater returns `root: …/git-checkout` with no release link. - `ocx test` on the survivor catalog, baseline, plan and qualification tests; `bash -n`; `git diff --check`. Co-authored-by: Ayaan Zaidi <[email protected]>
…law#201917) ## Problem openclaw#201874: on a managed Git install, a Gateway MCP turn fails before replying: ```text warn mcp-loopback request handling failed: Stripping types is currently unsupported for files under node_modules, for "<state-dir>/git-install/releases/<release>/lib/node_modules/openclaw/extensions/deepseek/web-search-contract-api.ts" error Embedded agent failed before reply: Claude Code started without the OpenClaw MCP server (status failed). ``` openclaw#199706 put each Git release, a full worktree with plugin TypeScript sources, at `releases/<id>/lib/node_modules/openclaw`. Two path rules then meet: 1. `resolvePublicSurfacePath` (`src/plugins/public-surface-runtime.ts`) picks `extensions/<plugin>/<file>.ts` before `dist` when the source exists. Only a Git release has sources; the npm package ships `dist/` only. 2. The plugin loader's Jiti options add `"openclaw"` to `nativeModules` (`src/plugins/sdk-alias.ts`). Jiti 2.7.0 turns that into `node_modules/(openclaw)/` and loads any match natively, even with `tryNative: false` (`src/require.ts:131`). Node then refuses (`lib/internal/modules/typescript.js:188`, `isUnderNodeModules(filename)`). The updater missed it because it validated a different path than it serves: `buildRelease` built and checked the release at `releases/<id>/build`, then `git worktree move` put it under `node_modules`. The only check at the final path was `openclaw.mjs --version` (`update-runner-git-release.ts`, `git-release-smoke`), which loads no plugin. Reproduced on a real release tree built by `main` at 777a156 (2026-11-19) on this machine, through Jiti with `nativeModules: ["openclaw"]` and `tryNative: false`: `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING` for `extensions/brave/web-search-contract-api.ts`, through both the real path and the link path. The same class, TypeScript at runtime under `node_modules`, appeared before as openclaw#19815 (2026-02-18) and openclaw#53953 (2026-03-24). ## Change Remove the cause in the owner: Git releases no longer live under `node_modules`. - Layout: `<state>/git-install/openclaw -> releases/<id>/openclaw`. Moving only the tree is not enough: the Gateway names its root by the link (`openclaw-root.ts`), and Jiti matches the link path string too. - Each release is built and validated where it serves. The build-beside-and-move step (`buildDir`, `git-release-place`) is deleted. A release path that a loader rule breaks now breaks the build before activation. - `package-release-slot-path.ts` keeps one rule for both layouts: a release keeps the package at the link's path below the prefix (npm `lib/node_modules/<name>`, Git `<name>`). Lease, retention and the switch's deselect stamp use it, not npm-only `dirname` math. - Retention resolves each retained release at the link's layout or at npm's `lib/node_modules/<name>`, where releases built before the move still live. `update status` keeps listing them, and an open update run that names one still protects it. - Migration: `servingGitReleaseSlot` reads the old link while it still serves. The first update run by this release rebuilds the serving commit at the new path, publishes the new link, and removes the old link. The old Gateway then sees its installation replaced and restarts through the launcher, which now starts the new link. No loader exception, no second source/dist rule, no flag. ## Impact - Managed Git installs load bundled plugin sources again. - Dev-channel installs on `main` builds since openclaw#199706 (they report version 2026.11.5; no published release has the layout) need one more `openclaw update` after the update to this change, because the older updater drives that first hop and still builds under the old path. - npm, plain checkouts, Docker and package-to-Git switches are unchanged. ## Evidence - **Regression test** (`src/infra/git-release.test.ts`, "loads a bundled plugin's source contract from the selected release (openclaw#201874)"). It copies `extensions/deepseek` into a release made by `createGitReleaseDirs`, publishes it, and loads `web-search-contract-api` through `loadPluginPublicArtifactModuleSync` from the release link path. - On `main` (7fedfbe): fails. Under Vitest the `tsx` hooks strip the types, so the symptom is `ERR_MODULE_NOT_FOUND` for `openclaw/plugin-sdk/lazy-runtime`: the forced native import resolves the bare `openclaw/...` specifier to the release tree itself. Same cause. - On this branch: passes (`git-release.test.ts` 12/12). - **Migration test** (`update-runner-git-release.test.ts`). A release under `lib/node_modules` is rebuilt at the new path, the new link's real path has no `node_modules` segment, and the old link is gone. - **Mixed-layout inventory test** (`git-release.test.ts`). After the link moves out, a release still under `lib/node_modules/openclaw` stays listed by `listPackageReleases`, the source of `openclaw update status`. - **Exact error on a real tree.** A release built by `main` (777a156) on a Mac profile, loaded through Jiti 2.7.0 with `nativeModules: ["openclaw"]` and `tryNative: false`: `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING … extensions/brave/web-search-contract-api.ts`, through both the real path and the link path. - **Mutation proof (build at the final path).** The release build (`node --import ./scripts/tsx.mjs scripts/build-all.mts`): - In a worktree at `releases/r1/lib/node_modules/openclaw`: fails at once with `ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING … scripts/lib/local-check-runtime.mts`. - The same commit at `out/r2/openclaw`: passes that stage (`runtime:scripts:check` 4.61 s). - So a release path that a loader rule breaks now fails the update before activation. - **Stable tag unaffected.** A Docker lane run with a real service install of tag `v2026.11.5` (e13cf15): its updater returned `status: ok`, `root: …/git-checkout`, steps `clean-check, git-resolve-target, recovery-artifact-cleanup`. No release link was created. No published release has the release layout. - **Gates:** `pnpm tsgo:core` exit 0; line-cap check OK (13 files); oxlint and oxfmt clean on changed files. - **Every test file that reads the release layout:** 21 files. `rg -l 'git-release|gitReleaseSlot|GIT_RELEASE|usesGitReleases|package-release-slot-path|package-release-lease' src --glob '*.test.ts'`, plus `openclaw-root`, `program-args*`, `service-layout` and `stale-install`. All pass. - The first batch run (4 workers, load 22–49) timed out 6 update-cli cases. Rerun with 2 workers: 141/141. - Four suites did not load in that batch because a parallel scenario edit changed `scripts/` during the run. Rerun alone: 40/40 and 35/35. ## Not proven here - **Real upgrade from `47b219778879` (the reporter's build) to this change, with a Gateway request that loads the web-search contracts.** A Linux upgrade-survivor `git-release` scenario reached the stable-tag baseline above; the run from `47b219778879` did not finish before landing. The scenario is not in this PR. The reporter is asked to confirm on openclaw#201874. - **Windows.** No Windows host completed a run. On `main`, Windows Git checkouts never use releases (`usesGitReleases` returns false on win32), so they are unaffected by the bug and by this change. That comes from the code, not a run. - **The old Gateway restarting after the old link is removed.** Before this change the Gateway saw the link move; here the link disappears. INFERENCE: it reads as installation replacement too. Co-authored-by: Ayaan Zaidi <[email protected]>
…01956) ## Problem openclaw#201874 shipped because no upgrade lane ran a Git install. All 35 upgrade-survivor scenarios start from an npm package, so the Git release layout from openclaw#199706 never booted in CI before users hit it. ## Change - Adds an opt-in `git-release` upgrade-survivor scenario. Starting from `47b219778879` (the openclaw#201874 reporter's build), it: 1. builds the checkout and installs the Gateway service (systemctl shim); 2. lets that build convert the install onto the old release layout; 3. reproduces the type-stripping failure through the Gateway; 4. updates to the candidate twice, the first run by the old build and the second by the candidate; 5. asserts the release left `node_modules`, the old link is gone, and `tools.invoke web_search` succeeds with no stripping error in the Gateway log. - The scenario stays out of the aggregate lanes and the published-baseline matrix; run it with `OPENCLAW_UPGRADE_SURVIVOR_SCENARIO=git-release`. Three full builds take about 24 minutes, so it gets a 3600 s container timeout. - Corrects the update guidance in `docs/install/updating.md`. The run showed two things: - The old release cannot run its own updater, so users must update from a terminal with the checkout's `openclaw`. - With a web search provider configured, the Gateway on the old layout fails at startup. ## Evidence - `OPENCLAW_UPGRADE_SURVIVOR_SCENARIO=git-release bash scripts/e2e/upgrade-survivor-docker.sh` against openclaw#201917's head `6b5d14b1`: exit 0, `summary.json` `passed`, 23m35s. Step results are in openclaw#201917 (comment) - The same scenario against tag `v2026.11.5` shows the published release never takes the release layout: its updater returns `root: …/git-checkout` with no release link. - `ocx test` on the survivor catalog, baseline, plan and qualification tests; `bash -n`; `git diff --check`. Co-authored-by: Ayaan Zaidi <[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]>
…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]>
…ident launcher (#203194) ## Problem A Git install updates in place under the running Gateway, through a managed-service handoff helper. When the new build does not start, recovery depends on that helper and on the old updater that is already installed, so a failed update can leave the Gateway down or stuck in `update-recovery-pending`. ## Change Git installs now update through prepared releases and a resident launcher: 1. `update.run`, `openclaw update` and automatic updates admit the run, resolve the target and run preflight (Node engine, required tools, disk space, container installs refused before any change). 2. The next release is built beside the running one (`git worktree add --detach`, then the target's install and build). The running checkout is not changed. 3. `openclaw update check-release` runs the new code offline against the current config and state and reports broken plugin or config surfaces. It does not migrate state. 4. `openclaw update plugins` runs from the published release: the existing plugin maintenance owner (`updatePluginsAfterCoreUpdate`), with the new core's code and version. A plugin problem, or a target too old to have the command, is recorded as a `plugins` step with a next action and never fails the update. An already-current install still runs it from the serving code and restarts a running Gateway when plugins changed (`docs/install/updating.md`). 5. The release is published as a pending trial, and the Gateway restarts with a process-replacing reason. 6. The launcher switches the release link at the next child start, counts attempts, commits the trial when the new Gateway is ready, and otherwise rolls back and starts the previous release. 7. The Gateway that starts after the switch (new on success, old after a rollback) finishes the run and sends the outcome to a requester that received the start notice. Routing: - `update.run` reads the install kind from the existing install-status owner (`resolveStartupInstallStatus`). `update-run.ts` wraps `update.run`; `update.ts` is unchanged and still serves package installs. - `openclaw update` branches after `prepareUpdateCommand`, so every existing refusal (external supervisor, host-owned, immutable, system package owner, interrupted update) applies first. A requested non-dev channel on a Git checkout still switches it to a package through the existing flow, and `--dry-run` keeps the existing preview. - Package installs move to this path in the next change, which also deletes the old Git machinery that this PR leaves unused. Converting an existing install: - The old entry points of a converted install (`openclaw.mjs`, `dist/index.js`) forward to the release launcher through a marker beside the tree. Existing service definitions and PATH shims keep working without a rewrite. - A first update driven by an older installed updater still migrates state as it does today. Released updaters require migrated state: 23 stable and 6 extended-stable tags contain that check. Fixes found by the real-install runs below, each a separate commit: - `openclaw update --sha` now sends the tracked upstream that the protocol requires. - The new path restarts with `update.run` / `update.auto`, so the process is replaced instead of restarted in place. - A Gateway started by the launcher leaves its update successor to the launcher instead of spawning one outside it. - Preflight skips dangling symlinks in agent homes, such as Codex `arg0` shims, when it sizes state databases. - `check-release` writes its JSON result to stdout. - Plain `openclaw update` keeps following the run while the restarting Gateway refuses connections with a retryable HTTP 503. Before, it exited 1 although the update succeeded. Accepted edge cases: - After `openclaw update` runs in a Git checkout, `openclaw.mjs` and `dist/index.js` in that checkout run the current release. A developer who edits the source of a checkout they also update from runs the release, not their edits. - A stop request handled inside a launcher child exits with code 0, and the launcher starts the child again. A stop through the service manager stops the launcher and its child. - On a Gateway with no service manager, the first update from a released version does not restart it. The released updater does this, and says so. - Package updates now read the install status twice per request: once to route, once in the old handler. - After a rollback, the previous release runs with plugins maintained for the new core. A plugin that cannot load stays off for that boot, as the plugin docs describe. - `openclaw update --accept-capabilities` reaches plugin maintenance when the CLI prepares the release itself (`--no-restart`, or no Gateway answering). Through a running Gateway, `update.run` has no field for it, so a plugin that needs consent is reported with its `openclaw plugins update` next action. Carrying the flag through `update.run` is a protocol change and follows separately. - `openclaw update` run from a different checkout than the one the configured local Gateway serves updates the Gateway's installation, not the invoking checkout. Binding the request to the checkout needs a protocol field and follows with `--accept-capabilities`. ## Evidence Real install on macOS (Apple silicon). Isolated HOME, state, config and port, a foreground Gateway, no launchd service. Every candidate was built from `git archive` of its commit; the final candidate is this branch's head before review. | Step | Run status | Trial | Served after | Health | |---|---|---|---|---| | 2026.11.6 → A (released updater) | succeeded | (old path) | A, after a recorded manual start | 200 / 200 | | A → B′ (B′ fails at startup) | failed, `new build failed to start` | rolled-back, 2 attempts | A, as the launcher's child | 200 / 200 | | A → B | succeeded | committed, 1 attempt | B, as the launcher's child | 200 / 200 | | B → C | succeeded | committed, 1 attempt | C, as the launcher's child | 200 / 200 | - The same launcher process stayed the parent through every replacement. The previous release was kept after each commit. - Phase times (seconds), from the persisted run steps: | Step | Staging (build) | Validating | Restarting | Total | |---|---:|---:|---:|---:| | A → B′ (rollback) | 192.5 | 0.8 | 29.2 | 222.7 | | A → B | 195.7 | 1.1 | 32.9 | 229.8 | | B → C | 201.6 | 0.9 | 36.9 | 239.5 | - `check-release` on a copy of a real state directory (Linux, no network): exit 0 in 3.0 s, 187 surfaces checked, shared state schema 40 → 40, agent databases 43 → 43. Plugin maintenance, real install on macOS (isolated, foreground Gateway, a real third-party npm plugin `@martian-engineering/lossless-claw` served through a scratch registry proxy that advertises 1.1.1, then the real latest 1.2.0): | Case | Run | `plugins` step | Plugin | Gateway | |---|---|---|---|---| | Core update through the new path | succeeded, trial committed (1 attempt) | completed | 1.1.1 → 1.2.0 | one restart into the new release | | Already current, plugin outdated | skipped / already-current | completed | 1.1.1 → 1.2.0 | restarted | | Already current, nothing to change | skipped / already-current | completed | unchanged | no restart | | Already current, registry returns HTTP 503 | skipped / already-current | completed, detail names the plugin and its `openclaw plugins update` retry | kept 1.1.1 | no restart; CLI prints "Plugin notes: …" | | Already current, `--no-restart` | skipped / already-current | completed | 1.1.1 → 1.2.0 | same process, no restart | - An earlier head counted a `warning` result as a failed step with no message; the run above found it and the fix is in this PR. - A run with `--timeout 1` showed the CLI calling a still-running update "Update failed: unknown reason". The fix ("The update did not finish in time. Run `openclaw update status` to see it.") is covered by `src/update/cli.test.ts`; it was not rerun on the real install. Tests: - New: `src/update/*.test.ts` (target, preflight, Git and package preparation, check-release, store, launcher, trial settlement and outcome notice, CLI request shape), plus a launcher-child case in `process-respawn.test.ts`. - The gateway `update*` suites run against package installs. Tests that pinned the old Git handoff, Git preflight delegation, explicit Git targets and foreground parking are deleted. Tests of behavior that package installs still use (notice policy, owner checks, campaign adoption, platform admission) now run on a managed package install. ## Review - `--no-restart` on a Git install now prepares the release in the CLI process instead of asking the Gateway, so the Gateway does not restart. The release starts at the Gateway's next start, and the CLI says so and exits 0, instead of reporting "Updated". - The first conversion creates the `prefix/openclaw` link to the running tree before it writes the forwarding marker. Forwarded commands work between publish and the switch. - The run row is written through the existing asynchronous update-run owner (`update-run-write.async.ts`). The synchronous second writer is deleted, so there is no SQLite work on the Gateway thread. - Rejected: settling trials of the format-1 Git-release launcher (#199706). No released build contains it (not 2026.11.6 `latest`, 2026.10.33 `extended-stable` or 2026.11.10-beta.1 `beta`), and main-only code is not a shipped contract. Only a Git checkout that tracked `main` between 2026-11-17 and this change can have such a trial. - The in-process path (`--no-restart`, or no Gateway answering) uses the requested channel, else the saved `update.channel` (`readUpdateChannelConfig`), else `dev`, as the existing CLI does. The Gateway path passes the checkout's tag and branch facts, as the existing handler does, so a configless checkout on a stable tag stays on stable. - After publishing a Git release, `git worktree repair` records it at its final path, so `git worktree list` and a later `git worktree prune` see the serving release where it is. - `prefix/openclaw` is repointed to the running tree when it does not already resolve there, so a link left from an earlier package install cannot become the rollback target. - Rejected for this PR: carrying the package layout's `lib/node_modules/openclaw` link. That layout belongs to package-release installs, which this PR does not route; the next change moves package installs and owns it. - A new build that exits 78 (it refuses the configuration) during a trial now rolls back like any other failed candidate. Outside a trial, 78 stays terminal. - Rejected again, same reason as the format-1 trial: making `git-install/lib/node_modules/openclaw` follow `prefix/openclaw`. Only the main-only Git-release conversion (#199706) creates that link, and no release contains it. - A Gateway with `OPENCLAW_NO_RESPAWN` set now refuses `update.run` with `restart-unavailable` before anything is recorded or prepared, as the existing handler does. The prepared release starts only in a new process, which that Gateway cannot start. - `openclaw update --timeout <seconds>` on a Git install is the overall budget again: it bounds how long the CLI follows the run, reaches the Gateway as `update.run` `timeoutMs`, and target resolution, the release build and plugin maintenance get only what remains of it. Preflight and `check-release` keep their own short bounds. - Rejected again, same reason as the format-1 trial: settling legacy `.trial` records in `stale-install.ts`. Only #199706 writes them; `settleGitReleaseTrial` is in no released build (2026.11.6 `latest`, 2026.10.33 `extended-stable`, 2026.11.10-beta.1 `beta`). - Rejected: routing `--tag` on a Git install to the package flow. The existing Git flow ignores `--tag` ("--tag applies to npm installs only; git updates ignore it"), so the Git route keeps that behavior. - After merging `main`: Control UI and desktop app requests on a Git install show the update in the app instead of the conversation (#203357), through the same `appUpdateNoticePublisher` owner as package installs. - A manual `update.run` on a Git install during a scheduled campaign adopts the campaign through its existing owner: it applies the pinned commit, records `trigger: campaign` with the campaign ID, binds the run, and refuses a mismatched `--sha` or a campaign already applying, as package installs do. - Rejected a third time: settling legacy `.trial` records (same reason as above). - Rejected: restoring the plugin cohort across a trial rollback. Removing the cohort is the approved design (plugins are non-fatal). After a rollback the previous release runs with plugins maintained for the new core; a plugin that cannot load stays off for that boot. Listed under accepted edge cases. - Updating without a Gateway (`--no-restart`, or none answering) reads the checkout's tag and branch facts, as the Gateway route does, so a stable-tag checkout with no saved `update.channel` stays on stable instead of preparing `dev`. - `openclaw update --no-restart --json` no longer prints the human "is ready" line before the JSON result. - Deferred: carrying `--accept-capabilities` through `update.run` (a protocol change); listed under accepted edge cases. - `openclaw update` delegates to `update.run` only when the call targets the configured local Gateway (`isImplicitLocalGatewayTarget`). With `gateway.mode=remote` or a Gateway URL override it prepares this checkout in-process instead of updating the remote installation. - `check-release` and `update plugins` run through the existing process owner (`runCommandWithTimeout` with process-tree termination), so a timeout ends npm and every descendant and waits for them before the step settles. - A linked Git worktree gets the root-level `.openclaw-launcher` marker (its `.git` is a file); only a main working tree uses `.git/openclaw-launcher`. Before, the marker went to the main working tree, so the linked worktree never forwarded. Not covered by a new test: it needs a full release build through publish. - Deferred with `--accept-capabilities`: binding `update.run` to the CLI's checkout. When the configured local Gateway runs another installation than the checkout the CLI runs from, the Gateway updates its own installation. Matching them needs the admitted root in `update.run` (a protocol change). The previous in-place Git updater had the same mismatch: it updated the invoking checkout and restarted the configured service. - A Git install is already current only when the serving build's commit (`resolveLoadedCommitHash`) matches the target, not when the checkout's `HEAD` does. A checkout pulled to the target without a rebuild still runs the old build, so it now prepares the release. An unknown build commit prepares a release too. - The Git route honors `update.run` `restartDelayMs` when it restarts into a prepared release or after changed plugins, as the package route does. ## Merge danger - Two-way door for the code: a revert restores the old Git update path. The forwarder that reads the launcher marker ships in this change, so after a revert the checkout's `openclaw.mjs` runs the checkout again and the old updater updates it in place; the `git-install/` prefix is left unused. A revert was not exercised. - One-way parts: a converted install has a `git-install/` prefix with releases, the launcher and a forwarding marker beside the checkout; a revert leaves them in place. No schema, stored-row or protocol version change. - Blast radius: Git installs only (source checkouts updating with `openclaw update`, `update.run` and automatic updates). Package installs keep the existing path. Co-authored-by: Ayaan Zaidi <[email protected]>
…ident launcher (openclaw#203194) ## Problem A Git install updates in place under the running Gateway, through a managed-service handoff helper. When the new build does not start, recovery depends on that helper and on the old updater that is already installed, so a failed update can leave the Gateway down or stuck in `update-recovery-pending`. ## Change Git installs now update through prepared releases and a resident launcher: 1. `update.run`, `openclaw update` and automatic updates admit the run, resolve the target and run preflight (Node engine, required tools, disk space, container installs refused before any change). 2. The next release is built beside the running one (`git worktree add --detach`, then the target's install and build). The running checkout is not changed. 3. `openclaw update check-release` runs the new code offline against the current config and state and reports broken plugin or config surfaces. It does not migrate state. 4. `openclaw update plugins` runs from the published release: the existing plugin maintenance owner (`updatePluginsAfterCoreUpdate`), with the new core's code and version. A plugin problem, or a target too old to have the command, is recorded as a `plugins` step with a next action and never fails the update. An already-current install still runs it from the serving code and restarts a running Gateway when plugins changed (`docs/install/updating.md`). 5. The release is published as a pending trial, and the Gateway restarts with a process-replacing reason. 6. The launcher switches the release link at the next child start, counts attempts, commits the trial when the new Gateway is ready, and otherwise rolls back and starts the previous release. 7. The Gateway that starts after the switch (new on success, old after a rollback) finishes the run and sends the outcome to a requester that received the start notice. Routing: - `update.run` reads the install kind from the existing install-status owner (`resolveStartupInstallStatus`). `update-run.ts` wraps `update.run`; `update.ts` is unchanged and still serves package installs. - `openclaw update` branches after `prepareUpdateCommand`, so every existing refusal (external supervisor, host-owned, immutable, system package owner, interrupted update) applies first. A requested non-dev channel on a Git checkout still switches it to a package through the existing flow, and `--dry-run` keeps the existing preview. - Package installs move to this path in the next change, which also deletes the old Git machinery that this PR leaves unused. Converting an existing install: - The old entry points of a converted install (`openclaw.mjs`, `dist/index.js`) forward to the release launcher through a marker beside the tree. Existing service definitions and PATH shims keep working without a rewrite. - A first update driven by an older installed updater still migrates state as it does today. Released updaters require migrated state: 23 stable and 6 extended-stable tags contain that check. Fixes found by the real-install runs below, each a separate commit: - `openclaw update --sha` now sends the tracked upstream that the protocol requires. - The new path restarts with `update.run` / `update.auto`, so the process is replaced instead of restarted in place. - A Gateway started by the launcher leaves its update successor to the launcher instead of spawning one outside it. - Preflight skips dangling symlinks in agent homes, such as Codex `arg0` shims, when it sizes state databases. - `check-release` writes its JSON result to stdout. - Plain `openclaw update` keeps following the run while the restarting Gateway refuses connections with a retryable HTTP 503. Before, it exited 1 although the update succeeded. Accepted edge cases: - After `openclaw update` runs in a Git checkout, `openclaw.mjs` and `dist/index.js` in that checkout run the current release. A developer who edits the source of a checkout they also update from runs the release, not their edits. - A stop request handled inside a launcher child exits with code 0, and the launcher starts the child again. A stop through the service manager stops the launcher and its child. - On a Gateway with no service manager, the first update from a released version does not restart it. The released updater does this, and says so. - Package updates now read the install status twice per request: once to route, once in the old handler. - After a rollback, the previous release runs with plugins maintained for the new core. A plugin that cannot load stays off for that boot, as the plugin docs describe. - `openclaw update --accept-capabilities` reaches plugin maintenance when the CLI prepares the release itself (`--no-restart`, or no Gateway answering). Through a running Gateway, `update.run` has no field for it, so a plugin that needs consent is reported with its `openclaw plugins update` next action. Carrying the flag through `update.run` is a protocol change and follows separately. - `openclaw update` run from a different checkout than the one the configured local Gateway serves updates the Gateway's installation, not the invoking checkout. Binding the request to the checkout needs a protocol field and follows with `--accept-capabilities`. ## Evidence Real install on macOS (Apple silicon). Isolated HOME, state, config and port, a foreground Gateway, no launchd service. Every candidate was built from `git archive` of its commit; the final candidate is this branch's head before review. | Step | Run status | Trial | Served after | Health | |---|---|---|---|---| | 2026.11.6 → A (released updater) | succeeded | (old path) | A, after a recorded manual start | 200 / 200 | | A → B′ (B′ fails at startup) | failed, `new build failed to start` | rolled-back, 2 attempts | A, as the launcher's child | 200 / 200 | | A → B | succeeded | committed, 1 attempt | B, as the launcher's child | 200 / 200 | | B → C | succeeded | committed, 1 attempt | C, as the launcher's child | 200 / 200 | - The same launcher process stayed the parent through every replacement. The previous release was kept after each commit. - Phase times (seconds), from the persisted run steps: | Step | Staging (build) | Validating | Restarting | Total | |---|---:|---:|---:|---:| | A → B′ (rollback) | 192.5 | 0.8 | 29.2 | 222.7 | | A → B | 195.7 | 1.1 | 32.9 | 229.8 | | B → C | 201.6 | 0.9 | 36.9 | 239.5 | - `check-release` on a copy of a real state directory (Linux, no network): exit 0 in 3.0 s, 187 surfaces checked, shared state schema 40 → 40, agent databases 43 → 43. Plugin maintenance, real install on macOS (isolated, foreground Gateway, a real third-party npm plugin `@martian-engineering/lossless-claw` served through a scratch registry proxy that advertises 1.1.1, then the real latest 1.2.0): | Case | Run | `plugins` step | Plugin | Gateway | |---|---|---|---|---| | Core update through the new path | succeeded, trial committed (1 attempt) | completed | 1.1.1 → 1.2.0 | one restart into the new release | | Already current, plugin outdated | skipped / already-current | completed | 1.1.1 → 1.2.0 | restarted | | Already current, nothing to change | skipped / already-current | completed | unchanged | no restart | | Already current, registry returns HTTP 503 | skipped / already-current | completed, detail names the plugin and its `openclaw plugins update` retry | kept 1.1.1 | no restart; CLI prints "Plugin notes: …" | | Already current, `--no-restart` | skipped / already-current | completed | 1.1.1 → 1.2.0 | same process, no restart | - An earlier head counted a `warning` result as a failed step with no message; the run above found it and the fix is in this PR. - A run with `--timeout 1` showed the CLI calling a still-running update "Update failed: unknown reason". The fix ("The update did not finish in time. Run `openclaw update status` to see it.") is covered by `src/update/cli.test.ts`; it was not rerun on the real install. Tests: - New: `src/update/*.test.ts` (target, preflight, Git and package preparation, check-release, store, launcher, trial settlement and outcome notice, CLI request shape), plus a launcher-child case in `process-respawn.test.ts`. - The gateway `update*` suites run against package installs. Tests that pinned the old Git handoff, Git preflight delegation, explicit Git targets and foreground parking are deleted. Tests of behavior that package installs still use (notice policy, owner checks, campaign adoption, platform admission) now run on a managed package install. ## Review - `--no-restart` on a Git install now prepares the release in the CLI process instead of asking the Gateway, so the Gateway does not restart. The release starts at the Gateway's next start, and the CLI says so and exits 0, instead of reporting "Updated". - The first conversion creates the `prefix/openclaw` link to the running tree before it writes the forwarding marker. Forwarded commands work between publish and the switch. - The run row is written through the existing asynchronous update-run owner (`update-run-write.async.ts`). The synchronous second writer is deleted, so there is no SQLite work on the Gateway thread. - Rejected: settling trials of the format-1 Git-release launcher (openclaw#199706). No released build contains it (not 2026.11.6 `latest`, 2026.10.33 `extended-stable` or 2026.11.10-beta.1 `beta`), and main-only code is not a shipped contract. Only a Git checkout that tracked `main` between 2026-11-17 and this change can have such a trial. - The in-process path (`--no-restart`, or no Gateway answering) uses the requested channel, else the saved `update.channel` (`readUpdateChannelConfig`), else `dev`, as the existing CLI does. The Gateway path passes the checkout's tag and branch facts, as the existing handler does, so a configless checkout on a stable tag stays on stable. - After publishing a Git release, `git worktree repair` records it at its final path, so `git worktree list` and a later `git worktree prune` see the serving release where it is. - `prefix/openclaw` is repointed to the running tree when it does not already resolve there, so a link left from an earlier package install cannot become the rollback target. - Rejected for this PR: carrying the package layout's `lib/node_modules/openclaw` link. That layout belongs to package-release installs, which this PR does not route; the next change moves package installs and owns it. - A new build that exits 78 (it refuses the configuration) during a trial now rolls back like any other failed candidate. Outside a trial, 78 stays terminal. - Rejected again, same reason as the format-1 trial: making `git-install/lib/node_modules/openclaw` follow `prefix/openclaw`. Only the main-only Git-release conversion (openclaw#199706) creates that link, and no release contains it. - A Gateway with `OPENCLAW_NO_RESPAWN` set now refuses `update.run` with `restart-unavailable` before anything is recorded or prepared, as the existing handler does. The prepared release starts only in a new process, which that Gateway cannot start. - `openclaw update --timeout <seconds>` on a Git install is the overall budget again: it bounds how long the CLI follows the run, reaches the Gateway as `update.run` `timeoutMs`, and target resolution, the release build and plugin maintenance get only what remains of it. Preflight and `check-release` keep their own short bounds. - Rejected again, same reason as the format-1 trial: settling legacy `.trial` records in `stale-install.ts`. Only openclaw#199706 writes them; `settleGitReleaseTrial` is in no released build (2026.11.6 `latest`, 2026.10.33 `extended-stable`, 2026.11.10-beta.1 `beta`). - Rejected: routing `--tag` on a Git install to the package flow. The existing Git flow ignores `--tag` ("--tag applies to npm installs only; git updates ignore it"), so the Git route keeps that behavior. - After merging `main`: Control UI and desktop app requests on a Git install show the update in the app instead of the conversation (openclaw#203357), through the same `appUpdateNoticePublisher` owner as package installs. - A manual `update.run` on a Git install during a scheduled campaign adopts the campaign through its existing owner: it applies the pinned commit, records `trigger: campaign` with the campaign ID, binds the run, and refuses a mismatched `--sha` or a campaign already applying, as package installs do. - Rejected a third time: settling legacy `.trial` records (same reason as above). - Rejected: restoring the plugin cohort across a trial rollback. Removing the cohort is the approved design (plugins are non-fatal). After a rollback the previous release runs with plugins maintained for the new core; a plugin that cannot load stays off for that boot. Listed under accepted edge cases. - Updating without a Gateway (`--no-restart`, or none answering) reads the checkout's tag and branch facts, as the Gateway route does, so a stable-tag checkout with no saved `update.channel` stays on stable instead of preparing `dev`. - `openclaw update --no-restart --json` no longer prints the human "is ready" line before the JSON result. - Deferred: carrying `--accept-capabilities` through `update.run` (a protocol change); listed under accepted edge cases. - `openclaw update` delegates to `update.run` only when the call targets the configured local Gateway (`isImplicitLocalGatewayTarget`). With `gateway.mode=remote` or a Gateway URL override it prepares this checkout in-process instead of updating the remote installation. - `check-release` and `update plugins` run through the existing process owner (`runCommandWithTimeout` with process-tree termination), so a timeout ends npm and every descendant and waits for them before the step settles. - A linked Git worktree gets the root-level `.openclaw-launcher` marker (its `.git` is a file); only a main working tree uses `.git/openclaw-launcher`. Before, the marker went to the main working tree, so the linked worktree never forwarded. Not covered by a new test: it needs a full release build through publish. - Deferred with `--accept-capabilities`: binding `update.run` to the CLI's checkout. When the configured local Gateway runs another installation than the checkout the CLI runs from, the Gateway updates its own installation. Matching them needs the admitted root in `update.run` (a protocol change). The previous in-place Git updater had the same mismatch: it updated the invoking checkout and restarted the configured service. - A Git install is already current only when the serving build's commit (`resolveLoadedCommitHash`) matches the target, not when the checkout's `HEAD` does. A checkout pulled to the target without a rebuild still runs the old build, so it now prepares the release. An unknown build commit prepares a release too. - The Git route honors `update.run` `restartDelayMs` when it restarts into a prepared release or after changed plugins, as the package route does. ## Merge danger - Two-way door for the code: a revert restores the old Git update path. The forwarder that reads the launcher marker ships in this change, so after a revert the checkout's `openclaw.mjs` runs the checkout again and the old updater updates it in place; the `git-install/` prefix is left unused. A revert was not exercised. - One-way parts: a converted install has a `git-install/` prefix with releases, the launcher and a forwarding marker beside the checkout; a revert leaves them in place. No schema, stored-row or protocol version change. - Blast radius: Git installs only (source checkouts updating with `openclaw update`, `update.run` and automatic updates). Package installs keep the existing path. Co-authored-by: Ayaan Zaidi <[email protected]>
…aw#194058) Failed-update triage now captures the operator's environment before managed candidate admission, so a coding agent installed only on the operator's PATH is still offered when the Gateway service's PATH differs. Restores the operator-environment contract from openclaw#134490 and keeps the launch confirmation from openclaw#143139. Proof: shipped CLI on isolated Linux (Crabbox) with a running systemd Gateway: accept launches the operator-only agent, decline starts nothing, base 18bee8e reports no agent found; published 2026.11.1 upgrades to the fix with settings intact. Co-authored-by: TorstenW <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: steipete <[email protected]> (cherry picked from commit 7c702c3) Release adaptation: Capture invoking operator env before candidate admission, forward to interactive triage only; preserve latest target selectors, confirmation and lease cleanup ordering. Exact three authorized production paths plus real lifecycle regression. Follow-up dispositions: ad4863d fix: preserve the running installation when an agent updates its Gateway (openclaw#201570); dc73ec0 fix: let updates finish when another tool briefly reads OpenClaw's databases (openclaw#202541); d07b530 fix: clarify PostgreSQL schema upgrades for Git installs (openclaw#202098); e60ea9f test(update): add a Git release upgrade-survivor scenario (openclaw#201956); 2ef6f7b fix(update): build and serve Git releases outside node_modules (openclaw#201917); dbc1aa0 fix: keep the openclaw command and Gateway working after updating a pnpm install (openclaw#201735); f5e7641 fix: Git checkout updates across a schema change no longer end as post-update-failed after the new release starts (openclaw#201600); 2183caf fix: Git checkout updates no longer fail before the new release starts on a schema change or a busy database (openclaw#201463); 47e8649 fix: explain why Doctor cannot restore a scheduled job’s account (openclaw#201550); 8f2cfd4 fix: remove updater-only restrictions from agent maintenance guidance; cb5cfb2 fix: keep a doubtful killed-update recovery on the repair path (openclaw#201361); 24cb734 fix: keep carried-over scheduled jobs running after updates (openclaw#200653); d1276e1 feat(doctor): check OpenClaw ID member roles and honor an optional roles default (openclaw#197785); 0a39956 fix: finish updates when another tool reads OpenClaw's databases during the update (openclaw#201330); ea1c9d5 fix(update): settle remounted package publications before admission (openclaw#201336); 66b5212 fix(update): isolate malformed retained-install markers (openclaw#201199); 7e79c83 fix: let the next update finish a killed source checkout update (openclaw#201009); d905d8a fix: let the next update finish a killed update after the machine restarted (openclaw#200994); fdf0c95 fix: let the next update finish a killed update that had already installed the new version (openclaw#200866); 0c19bcd chore(release): close out 2026.11.5 on main (openclaw#200577); a1940e0 fix(matrix): keep explicit recovery available during deferred migration (openclaw#200805); 18b4776 improve: explain package baseline drift during updates (openclaw#200802); 1ad4cad fix(doctor): reclaim macOS updater runtimes blocked by non-updater processes (openclaw#200732); 427c857 fix: keep one missing archived transcript from blocking every update (openclaw#200733); 802e3f7 fix(update): keep valid cold archives from blocking updates (openclaw#200659); 23fca1a fix: let the next update continue after a killed update when nothing is left to repair (openclaw#200680); 3afe212 fix: let Doctor publish unchanged plugin migrations in any order (openclaw#200658); f65e4db fix(doctor): reclaim runtimes blocked by unrelated Linux processes (openclaw#200657); dab086c fix(update): let candidate Doctor read plugin dependencies from the staged package (openclaw#200595); 3447bee fix(update): keep updates going when the predecessor writes during its stop (openclaw#200569); 0ce9c77 fix: let the next update settle a package publication that a killed update left behind (openclaw#200550); ae31ea3 fix(update): repair handoffs in the journal-pinned lease store (openclaw#200532); 74020ea fix: continue updates when initial SQLite capture is stale (openclaw#200328); 6747b1e feat(update): run Git checkout installs from releases behind the release link (openclaw#199706); e3f8a67 fix(state): keep completed retained agent stores out of startup upgrade (openclaw#200284); 3c512c5 fix(gateway): move managed update lease operations off the main thread (openclaw#200169); ea69fcb chore(release): close out 2026.11.4 on main (openclaw#199956); 618bf31 fix(state): bound startup upgrade copies and pruning to owned state (openclaw#199929); e4a3093 perf(update): replace the candidate canary with a runtime contract check (openclaw#198268); 5dbf569 fix(update): plugin failures never fail an update or Gateway health; 764761e fix(update): refuse missing host prerequisites in one line and record a cause per attempt; 4c4fef4 fix(ui): update dialog claims installation before progress is confirmed (openclaw#199254); 136e1f6 fix(update): retrying an update from a dev checkout is refused after a killed update (openclaw#198673); 3bd03da fix(update): avoid duplicate database copies while the Gateway is stopped (openclaw#198148); 68a839b fix: isolate held agent databases until explicit restoration (openclaw#198180); e333f7e chore(ci): drop retired test-lines allocation records (3/3) (openclaw#197657); fd6fa47 fix: converge Gateway updates with environment-only service overrides (openclaw#196371); 7cf5e75 fix: clarify split-install updates and blocked Doctor repairs (openclaw#196342); 6ff8c86 fix(update): retain lazy sqlite catalog generation (openclaw#197095); 930e1f7 fix: keep stable updates and recovery free of premature migrations (openclaw#196474); a15f737 fix: preserve external plugin data during update rehearsal (openclaw#196301); 92798ae fix: updates survive interrupted heartbeat runs (openclaw#195656); c1e55e2 fix(update): restore LaunchAgent registration after repair contention (openclaw#195406); 715c610 fix(doctor): repair retained ISO session end timestamps (openclaw#194685); 689cfc8 fix(update): reclaim dead closing triage repair leases (openclaw#194503); 86bc89e fix(doctor): keep standing Codex parameter advice out of retirement blockers (openclaw#193650); 691bc8d fix(backup): read the backup engine without copying the live database (openclaw#194234); 000542f fix(backup): backups and updates fail on slow storage when a header probe batch misses its deadline (openclaw#194239); 31a65d5 fix(update): skip --no-lazy-fetch on Git versions without it (openclaw#194198); e45e99d fix(update): preserve dev update sources in tag-only Git clones (openclaw#193109) Validation: Baseline2 intended operator-agent failures/32 controls passed; candidate34/34passed (194058-green.log). Accept launches synthetic operator-only CLI with expected env, decline starts nothing. Isolated updater flow, not live systemd/upgrade qualification. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 6689fd575ada8fe40a9593784deac18ec73041cd) (cherry picked from commit 92e7a9fa223b0dc35801f25f70be90b472d9a6b7)
…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]>
Problem
A Git checkout install runs its Gateway from
<checkout>/dist/index.js, andopenclaw updaterewrites that same tree. Everything around the rewrite exists to survive it: the updater copies its own runtime first (133–892 s on a 183k-file checkout), builds the candidate in a private repository and imports it through a pack (256 MB cap), stops and parks the serving Gateway, and rewrites the service definition every update.Change
Extends #198835's linked package root (merged as
b868ed4c) to Git checkouts, per the #197949 design. Based onmain. It reuses #198835's release resolver,switchPackageReleaseLink, leases and 24 h collection unchanged. Its fallback followsinstallStagedPackage: when the layout can't be used, the update runs in place with arecoverable-maintenancewarning, and the next update tries the layout again. The Gateway process never writes the release link. The only other writer is the boot launcher, and it only points the link back to the release recorded in a failed trial.<stateDir>/git-install/lib/node_modules/openclaw -> releases/<id>/lib/node_modules/openclaw. Each release isgit worktree add --detachoff the developer's checkout (shared object store, no clone or copy).pnpm install --frozen-lockfile, build, candidate checks) runs in the new release's worktree, then--versionwith the service's Node. A same-source no-op requires the serving release to be at the checkout's commit and its artifacts to verify (fix: rebuild incomplete Git runtimes when source is current #158931).releases/<id>/build, then moved into place withgit worktree move. Node refuses to strip types undernode_modules(ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING), and the build runs.mtsscripts. The built tree has no absolute symlinks, so the move is safe.switchPackageReleaseLinkfrom feat(update): keep each release in its own directory on OpenClaw-owned installs #198835. The serving Gateway keeps its release (Node resolves the entry's real path), so nothing is stopped, parked or verified before the flip.update.run) would end the updater itself.<stateDir>/git-install/openclaw-launcher.mjs. A unit that names the launcher is never regenerated. The launcher is needed because a release that fails while loading never reaches Gateway code.releases/.trial. The launcher counts starts.*.pre-<buildId>state files (falling back to feat(state): upgrade state by copy and swap at Gateway startup #198389's*.pre-<version>). Each SQLite family is restored together, and trial-created WAL/journal/SHM/seal files without a preserved predecessor are removed. The launcher mirrors feat(state): upgrade state by copy and swap at Gateway startup #198389'scompanionRemovalslist because it must not load release code.releases/cannot be created, or something other than a release link sits at the package path, the update records a warning and takes the in-place runner. The next update tries the layout again.--no-restartthe release is unverified, so only the requested channel is persisted and plugins converge on a later update.git worktree prune.git-installis excluded from backups and from the startup state-upgrade copy. The latter is the same change as fix(state): leave Git release installations out of the startup upgrade copy #199770, included here so the stack stands alone.usesGitReleasesselects releases. Windows checkouts and package-to-Git switches keep the in-place runner, and the in-place CLI tests are pinned to that runner.For Git releases this skips:
In-place fallback (decided)
Windows Git checkouts, package-to-Git switches, and checkouts with no installed Gateway service still use the in-place runner, so this PR bypasses that runner on POSIX instead of deleting it. A checkout with no service is run by hand, so nothing would start through the release link and its next start would run the old commit.
gatewayServiceOwnsGitInstallreads the installed service once and accepts it only when the service owns the checkout or its release link. The command decides once and hands that decision to the runner. Prod LOC is net +980. Decided 2026-11-16: Windows Git updates are not refused. A follow-up, slice 4b (stacked on this PR), moves Windows to releases using junctions and then deletes the in-place Git runner.E2E (mbp-m5, launchd, isolated profiles, shared-clone checkout; ≤15 min per run, ≤3 in parallel)
Final head
0b96d640(rebased onmainat8a82b5e0): local ClawSweeper review clean (gpt-6.1-sol, normal speed). After the rebase:sweepPackageReleaseTemporaryLinksis exported again, because the first Git publish uses it. The CI ratchets are satisfied: a lazy generation name, Node-only release tests, and an allocation record for the regression tests. A conversion's first release is now the commit the checkout'sdistserves, not a pulled HEAD that was never rebuilt. A failed trial also restores a symlinked config: a preserved symlink is judged by its own time, not its target's.Rollback across same-version upgrades (decision d): the state upgrade now keeps a replaced file as
<file>.pre-<buildId>, named after the build that replaced it, so two builds of one version each keep their own predecessor. Builds without a build ID, and earlier releases, still write.pre-<version>. Retention handles both forms. A failed trial restores the.pre-<buildId>of its own build, falling back to.pre-<version>. Fixes to the trial and launcher from the review rounds:~and external paths included);The release layout is used only when the release switch actually reaches the next start: either the service already starts the launcher, or it owns the checkout and this update rewrites its definition and restarts it.
--no-restarton a converted install leaves the serving release selected. The next start, which the operator triggers, selects the new release, without the two-start fallback. A first conversion requested with--no-restartstays in place.d6d30a5e(the final head changes only how a symlinked backup is dated)build-id-mismatchafter 179 s; two "e2e boot crash" starts, then "failed to start twice; switched back"; link back on the previous release, trial cleared,readyd6d30a5eCurrent head
6d9acd6e(onmain), mbp-m5, isolated launchd profiles:update.runthrough the Gatewayfinished|succeeded, 135 s; link moved, Gateway restarted, plist unchanged; outage 7.8 sgit-install/releases, resultok, modegit0e3fefae)build-id-mismatchafter 188 s; after two "e2e boot crash" starts the launcher logs "failed to start twice; switched back", and the previous release servesreadyOlder rows below ran at earlier heads.
Rows marked ‡ ran at head
8a720e49, rows marked † at6032dedf; the rest ran at1140b601, before plugin convergence moved after verification. At the final head99b7f080(rebased onto823fa6d2), three runs ran in parallel on mbp-m5. (1) Conversion and release→release passed again, with the root on the release link and a longest outage of 7.6 s. (2)update.runfinishedsucceeded(link moved, Gateway restarted, plist unchanged, outage 8.0 s). (3) A checkout with no Gateway service updated in place: checkout HEAD moved to the bumped commit, nogit-install/releaseswas created, and the result wasok, modegit, root the checkout. An intermediate head2d2387b6keyed this choice on a preflight fact that Git installs never fill in, so conversion fell back to in-place (about 120 s outage). That head was never pushed.releases/--no-restarton a switched releaseupdate.runvia the Gateway (openclaw gateway call update.run)60503ab3)skipped: already-current, link unchanged, 113 sbuild-id-mismatch; longest outage 28.9 sskipped: already-current; the Gateway restarts itself into the new release and the trial is clearedenv -i+umask 077(conversion, then release→release)0700under umask 077integrity_checkok. 2026.11.3's own updater could not reach head on mbp-m5: it walked back toalready-current(Node 24.21 below head'sengines), so that hop was done withgit reset+ocx build90c601fctook 4,150 s, with 892 s retention and a 300 s outageNot exercised: a plugin-only restart (SIGUSR2) after npm plugins actually change; the fixtures have no npm plugins.
Data-model compatibility
update_runs), Gateway owner lease and config are read and written exactly as on the base.originstays compatible.UpdateRunRecordSchema.origin(including feat(update): keep each release in its own directory on OpenClaw-owned installs #198835'spackageStageandpackageRelease) is unchanged, and Git-release updates write no neworiginkey. A Git release records its switch in the result step and the release directories, not the ledger. So rows written by older builds parse as before, and rows written by this build parse in an older build. A Git checkout that can't use the layout falls back to the in-place runner with arecoverable-maintenanceadvisory (git-release-layoutstep), the same contract asinstallStagedPackage's swap fallback.<stateDir>/git-install/:releases/<id>/(detached worktrees), thelib/node_modules/openclawlink,releases/.trial, and the launcher. An install without them is treated as unconverted and gets the conversion path. If the layout is unusable, the update falls back to in-place (decision 8).6d9acd6e).--profile, createdstate/openclaw.sqlite(schema 22) and an agent DB.gateway installthen stopped with "Client credentials require backed-up migration custody; … run openclaw doctor --fix". Plainmain(964ab522) stops with the same message on a copy of that state, so it comes frommain, not this diff.openclaw doctor --fix --non-interactivemigrated the state to schema 40. After that, install succeeded and the update converted the checkout onto the release link. Theupdate_runsrow in the stable-created database readsfinished|succeeded, and the stable config (Gateway port) still reads back.openclaw.sqlite,-wal,-shm) captured before the trial. The previous build reopens its own database (crash row, 28.9 s).Tests
src/infra/git-release.test.ts:src/infra/update-runner-git-release.test.ts:update-command-post-update.test.ts: a switched release converges plugins only after its restart.git-release.test.ts: a checkout with no owning Gateway service keeps the in-place runner. The test fails without the gate.update-command-execution-validation.test.ts: when a developer build holds the checkout's artifact lock, a Git release update still runs. It never takes that lock, because releases build in their own worktrees. The test fails without the fix.update-command-convergence-authority.test.ts: under--no-restart, a switched release persists the channel and leaves plugins alone; an already-current rerun from the checkout of a converted install completes.update-runner-git-release.test.ts: a successful rebuild of an incomplete runtime reports the new release's verdict.update-command-convergence-authority.test.ts: release convergence runs in the updater, with no fresh process and no Doctor.update-command-verification.test.ts:src/state/state-upgrade.test.ts:git-installstays out of the startup upgrade copy.pnpm tsgo:core,pnpm check:test-types, oxlint/oxfmt on changed files. On mbp-m5 at99b7f080, the broad update suite plus the package-release and package-update tests pass 1,944 / 1,948, with 1 skipped. The 3 failures are environmental:update-runner-git-node-preflight×3: mbp-m5's Node 24.21 is belowengines.LOC
prod +1018 / −38 (net +980); test +951 / −3.
Draft: lands after #198835. #198389 has merged; #199770 carries the same startup-copy exclusion for main.