Skip to content

fix(update): build and serve Git releases outside node_modules - #201917

Merged
obviyus merged 3 commits into
mainfrom
fix/git-release-outside-node-modules
Nov 19, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/git-release-outside-node-modules

Conversation

@obviyus

@obviyus obviyus commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

#201874: on a managed Git install, a Gateway MCP turn fails before replying:

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 feat(update): run Git checkout installs from releases behind the release link #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 ([Bug]: Managed Git install loads raw DeepSeek web-search contract under node_modules, breaking Gateway MCP startup #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 [Bug]: Managed Git install loads raw DeepSeek web-search contract under node_modules, breaking Gateway MCP startup #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.

- A Git release lived at releases/<id>/lib/node_modules/openclaw. Jiti's "openclaw" native-module rule then loaded a bundled plugin's TypeScript natively, and Node refuses type stripping under node_modules (#201874).
- Releases now live at releases/<id>/openclaw behind <state>/git-install/openclaw, and are built and validated at that path; the build-beside-and-move step is gone.
- The release owner recognizes both shapes with one rule: a release keeps the package at the link's path below the prefix.
- A 2026.11.5 install still serves from lib/node_modules/openclaw until its next update rebuilds the serving commit at the new path and removes the old link.

Fixes #201874
- 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.
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M labels Nov 19, 2026
@obviyus
obviyus marked this pull request as ready for review November 19, 2026 15:57
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR builds and serves managed Git releases outside node_modules and migrates existing release links.

Example: On Node 24.22.1, a WebChat turn through Claude CLI loads DeepSeek’s web-search contract.

  • Before: The managed release selects TypeScript beneath lib/node_modules/openclaw, and Node rejects it before the agent replies.
  • After: The migrated release selects the contract beneath git-install/releases/<release>/openclaw, outside node_modules.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair is focused and useful, but validation is not yet sufficient for merge.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Managed-Git users can lose an entire agent turn because bundled contract loading prevents the Gateway MCP bridge from initializing.
Reason: The maintainer-authored direction repairs a reported workflow through the existing layout owner without adding configuration or a competing loader policy.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it addresses a current managed-Git workflow failure through a focused release-layout repair, and no definite introduced code defect was found.

Priority: P1
Reviewed head: c1550056d9f8823575af48aa87ae20986920cd80

Before merge

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

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted shipped-CLI upgrade evidence covering latest-stable state and the affected legacy layout through activation, Gateway restart, and a successful contract-loading agent turn; hide IPs, keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

The Git updater builds candidate worktrees and selects a release link; the service launcher starts that release, whose Gateway loads bundled plugin contracts.

flowchart LR
  CLI[Update CLI] --> Build[Worktree build and validation]
  Build --> Release[Git release directory]
  CLI --> Link[Selected release link]
  Launcher[Service launcher] --> Link
  Link --> Release
  Release --> Gateway[Gateway]
  Gateway --> Loader[Bundled plugin loader]
Loading

Technical review

Best possible solution:

Keep Git release trees and their stable link outside node_modules while retaining the existing release-selection, lease, retention, and rollback owners.

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

The reported rejected TypeScript path matches current main’s managed-release layout and forced-native openclaw loader rule; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Changing the release-layout owner addresses the cause without weakening native host-module identity or intentional source precedence, and the shared path changes serve that same repair.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Git release location and build-then-move staging changes intended behavior with a stated reason (6747b1e: Immutable worktree releases reused the package-release layout to avoid rewriting serving code; builds ran beside the final location because Node rejected TypeScript beneath node_modules.)
  • Shared release recognition, leases, retention, and deselection timestamps keeps the original intent (b868ed4: Owned npm installs retained separate releases behind a stable link, with leases and a minimum retention period protecting running processes.)
  • Git release snapshot-space exemption keeps the original intent (ee12691: Git release updates take no updater database snapshot, so snapshot-capacity checks must not refuse them.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Raw commit b868ed4 adds src/infra/package-release-slot-path.ts:39 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b868ed4c21ba; files: src/infra/package-release-slot-path.ts)

PR surface

Source +5, Tests +51, Docs +12. Total +68 across 13 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 10 81 76 +5
Tests 2 51 0 +51
Docs 1 12 0 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 144 76 +68

Preflight source

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

Review metrics

Metric Value Why it matters
Production versus test growth Production +81/-76 lines; tests +51/-0 lines The small net production increase replaces npm-specific path arithmetic, while the two added cases protect contract loading and legacy-layout migration.

Labels

Label changes:

  • add P1: A reported current managed-Git installation repeatedly fails an existing agent workflow before replying, and current main retains the responsible layout.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.

Label justifications:

  • P1: A reported current managed-Git installation repeatedly fails an existing agent workflow before replying, and current main retains the responsible layout.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

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

Reviewed November 19, 2026, 11:14 AM ET / 16:14 UTC.

- After a Git install moves out of node_modules, retained releases still keep their package at lib/node_modules/openclaw. Retention looked for every release in the new link's layout, so update status lost them and an open run's naming no longer protected them.
- Retention resolves each release at the link's layout or at npm's, where those releases live.
@obviyus
obviyus merged commit 2ef6f7b into main Nov 19, 2026
132 checks passed
@obviyus
obviyus deleted the fix/git-release-outside-node-modules branch November 19, 2026 17:07
@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 2ef6f7b.

  • Bug: a managed Git install kept each release under node_modules. The plugin loader then loaded bundled plugin TypeScript natively, and Node refused to strip its types ([Bug]: Managed Git install loads raw DeepSeek web-search contract under node_modules, breaking Gateway MCP startup #201874). Updates missed it because each release was built beside its final path and only then moved into place.
  • Fix: releases now live at git-install/releases/<id>/openclaw, behind git-install/openclaw, and are built and checked where they serve. An install on the old layout moves on its next update run by a build that has this change.
  • Proof:
    • A regression test loads DeepSeek's web-search contract from a release path: red on main, green here.
    • A migration test moves an old-layout install to the new layout.
    • A mutation run shows a release build under node_modules fails before activation.
    • CI is green on the exact head.

Thanks @jacobtomlinson for the precise report.

@obviyus

obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator Author

Post-merge proof: a real upgrade from 7db69bedeab6 (the #201874 reporter's build) to 6b5d14b1 (this PR's head), in the upgrade-survivor Docker lane with a service-owned Git install. Exit 0, 23m35s.

Step Result
7db69be converts the install to releases Old layout: git-install/lib/node_modules/openclaw → releases/<id>/lib/node_modules/openclaw
Reproduce With DuckDuckGo configured, the Gateway fails at startup: ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING … releases/<id>/lib/node_modules/openclaw/extensions/duckduckgo/web-search-contract-api.ts. tools.invoke web_search fails: Gateway unreachable
First update, run by 7db69be From the old release's CLI: fails with the same error, for scripts/stage-bundled-plugin-runtime.mts. From the checkout CLI: updates the checkout to the fix. The release stays on the old layout
Second update, run by the fix root: git-install/openclaw. The real path is releases/<id>/openclaw, with no node_modules segment. The old link is gone. The updater restarted the service
Request after it tools.invoke web_search → {"ok":true,"provider":"duckduckgo","count":5}, res ✓ tools.invoke 910ms. Zero stripping errors in the Gateway log after the update

Phase times: baseline build 375 s; conversion 201 s; first hop 444 s; second hop 321 s.

The scenario lands separately as an opt-in git-release upgrade-survivor scenario.

obviyus added a commit that referenced this pull request Nov 19, 2026
## 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…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]>
obviyus added a commit that referenced this pull request Nov 21, 2026
…lace Git runner (#200578)

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

## Problem

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

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

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

## Change

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

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

## Impact

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

## Size

Against the merge base, 32 commits:

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

## Evidence

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

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

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

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
…lace Git runner (openclaw#200578)

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

## Problem

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

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

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

## Change

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

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

## Impact

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

## Size

Against the merge base, 32 commits:

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

## Evidence

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

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

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

Co-authored-by: Ayaan Zaidi <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…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)
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…lace Git runner (#200578)

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

## Problem

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

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

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

## Change

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

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

## Impact

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

## Size

Against the merge base, 32 commits:

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

## Evidence

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

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

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

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

(cherry picked from commit b229b26)

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

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

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant