Skip to content

fix(update): retain the running updater by hard link instead of copying the package - #155977

Merged
steipete merged 2 commits into
mainfrom
fix/plugin-update-consent-json
Sep 22, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/plugin-update-consent-json

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

openclaw update retains the running updater's package tree so its workers survive the installer's replacement (#153764). That retention byte-copied the entire package root (package.json, dist/, node_modules/, 37,309 files / 625 MB for 2026.9.6) with three full lstat passes plus a per-file copy and verify. On the release Docker host this ran at ~12 files/s, so every in-place global update stalled in the validating phase for well over the E2E harness's 300 s command budget. Plugin Prerelease lane plugin-update (Full Release Validation 35775979903 → run 35779065106) then reported update-denied did not return JSON: Unexpected end of JSON input because timeout killed the command before any output.

This keeps the retention semantics and makes it cheap:

  • Files are hard-linked into the private runtime directory (fs.link), so the inventoried inodes outlive npm's rename/unlink without copying bytes. Bytes are copied only when the filesystem refuses the link (EXDEV, EPERM, ENOTSUP, ...) or when relocation must rewrite the member in place (.modules.yaml, .bin launchers), so the live package is never edited through a shared inode.
  • One walk performs the inventory check, publication, relocation and escape check per entry (was: pre-check pass, directory pass, file pass with two checks, symlink pass, post-check pass, relocation pass, full verify walk).
  • After each link the private name is checked to reference the inventoried dev:ino; entries sharing an already linked inode (pnpm store hard links) keep every fingerprint field except the change time that the link itself bumps.
  • The IO budget watchdog around retention is unchanged.
  • node_modules stays in the retained tree: retained workers (dist/** entrypoints) resolve their dependencies from it.
  • The shared copy path used for candidate rehearsal snapshots is unchanged in behavior; its plan rebasing, host-link/alias publication and verification moved to update-candidate-plugin-tree-links.ts so both materializers share them.
  • Harness: the consent scenario's "did not return JSON" assertion now includes the command's exit code so a timeout kill (124) is visible in CI.

Evidence

  • Root cause repro on the exact CI candidate bytes (artifacts docker-e2e-package-35777886894-1 + docker-e2e-prepublish-plugin-registry-35777886894-1): update --tag core-denied-future.tgz --yes --json finished npm i in 2 min, then sat in validating copying openclaw-update-runtime-* at 5,264 → 5,513 files in 20 s (~12 files/s); 6,402 files / 102 MB after 9 min; SQLite update_runs row failed/interrupted when the harness killed it.
  • With this change: the same repro (same host, load average ~34) returns the denial payload on stdout with exit 0 (status: ok, postUpdate.plugins.status: warning, PLUGIN_CAPABILITY_CONSENT_REQUIRED, after.version: 2026.9.99-first-hop.0) and the whole update --tag command completes in 3.5 min end to end (npm install 28 s, canary validation, activation, Doctor). Retention alone, measured directly on the installed 38,678-file package with withRetainedUpdateRuntime: 33.9 s to retain (about 1,140 files/s, roughly 95x faster than the copy) and 4.6 s to release.
  • Unit tests: src/infra/update-retained-runtime-tree.test.ts (link path shares inodes and survives source replacement, EXDEV fallback copies bytes with the inventoried mode, changed entries are refused before any link, relocated launcher is copied so the live file is untouched); existing update-retained-runtime.test.ts layouts (npm/pnpm/pnpm-workspace/git/git-linked) and update-candidate-plugin-tree.test.ts pass.
  • OPENCLAW_TESTBOX=1 pnpm check:changed and the plugin-update Docker lane on the packed candidate: results in the PR comments.

…ng the package

Retention of the updater's worker code copied the whole global package (37k files) at ~12 files/s on the release Docker host, so in-place updates stalled in validation past the E2E command budget. Link the inventoried inodes into the private runtime directory in one walk, copy only when the filesystem refuses links or relocation rewrites a member, and report the exit code when the consent scenario gets no JSON.
@clawsweeper

clawsweeper Bot commented Sep 22, 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 scripts Repository scripts size: L maintainer Maintainer-authored PR labels Sep 22, 2026
@steipete steipete self-assigned this Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 22, 2026, 6:23 PM ET / 22:23 UTC (Revision 2).

ClawSweeper review

What this changes

The PR retains updater files through hard links, copies files requiring relocation or unsupported links, shares tree-validation helpers, and adds update-test exit diagnostics.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 4 items remain

The optimization remains useful on current main, and the reported real update supports its value. The previous blocking finding remains unresolved.

Priority: P1
Reviewed head: b14776bd18377db36b17b65dd67168d76dfed48f

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful real-update evidence supports the optimization, but the unchanged fallback defect prevents merge readiness.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured Docker observations exercise runtime retention through the installed update command and show completion with the expected JSON result and substantial speedup. The production materializer is unchanged since that evidence; the separate published-driver compatibility requirement remains outstanding. No stored-data contract changes.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured Docker observations exercise runtime retention through the installed update command and show completion with the expected JSON result and substantial speedup. The production materializer is unchanged since that evidence; the separate published-driver compatibility requirement remains outstanding. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduced change: Read the introduced patch and original candidate-tree implementation. Review ownership uses the supplied merge-base-to-head delta; the stale test merge was not used to infer removal of main-branch behavior.
Prior finding remains unchanged: The retention materializer has identical blob identity at the previous reviewed head and current head. GitHub confirms that the intervening commit only removes a redundant number conversion in the test. A broader local comparison encountered an unavailable historical test blob; the focused production comparison and GitHub commit patch resolved the relevant continuity question.
Copy fallback rejects its own inode change: assertEntry adjusts ctime for previously linked inodes, but copyEntry's assertBeforeMutation callback uses the original inventory. A successful link followed by copying another name of that inode therefore fails the strict ctime comparison.
Findings 1 actionable finding [P2] Use inode-aware validation when copying an already-linked alias
Security None None.

How this fits together

OpenClaw preserves the running updater’s code and dependencies before replacing its installation. Workers use this retained runtime until update reporting, rollback, and cleanup finish.

flowchart TD
  A[Installed updater files] --> B[Inventory files and dependencies]
  B --> C{Safe to hard link?}
  C -->|Yes| D[Retain original inode]
  C -->|No| E[Copy and relocate]
  D --> F[Private updater runtime]
  E --> F
  F --> G[Workers finish update and rollback]
  G --> H[Release retained files]
Loading

Before merge

  • Use inode-aware validation when copying an already-linked alias (P2) - The previous finding remains unresolved. Linking one name changes the shared inode's ctime; if a later alias falls back after EMLINK or requires relocation, this callback compares against the original ctime and throws Plugin entry changed after snapshot inventory, aborting retention. Use the same inode-aware validation as assertEntry, preserving the remaining fingerprint checks, and cover successful linking followed by copying its alias.
  • Resolve merge risk (P1) - Shared-inode installations can newly abort updates when a later alias requires copying after an earlier alias was linked.
  • Resolve merge risk (P1) - The repository-required published-updater-to-candidate compatibility result remains unestablished for this change.
  • Complete next step (P2) - Record the published-driver-to-candidate compatibility result and measured runtime for the changed test file.

Findings

  • [P2] Use inode-aware validation when copying an already-linked alias — src/infra/update-retained-runtime-tree.ts:76-77
Agent review details

Security

None.

PR surface

Source +241, Tests +105, Other 0. Total +346 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 414 173 +241
Tests 1 105 0 +105
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 6 520 174 +346

Review metrics

Metric Value Why it matters
Reported retention performance 38,678 files retained in 33.9 seconds The real-package observation supports the operational value of avoiding byte copies.

Merge-risk options

Maintainer options:

  1. Preserve mixed link-and-copy compatibility (recommended)
    Repair the fallback fingerprint check, cover link-first/copy-second ordering, and record the published-driver update result.

Technical review

Best possible solution:

Preserve efficient retention with consistent inode-aware copy validation and verified compatibility with published updaters.

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

Yes, by source: link one inventoried name, then force EMLINK when retaining its later alias; copy publication compares the changed ctime against the original inventory and throws. This read-only review did not execute that scenario.

Is this the best way to solve the issue?

The hard-link approach fits rename-based installation replacement, but the copy fallback must consistently account for link-induced ctime changes while retaining the other fingerprint checks.

Full review comments:

  • [P2] Use inode-aware validation when copying an already-linked alias — src/infra/update-retained-runtime-tree.ts:76-77
    The previous finding remains unresolved. Linking one name changes the shared inode's ctime; if a later alias falls back after EMLINK or requires relocation, this callback compares against the original ctime and throws Plugin entry changed after snapshot inventory, aborting retention. Use the same inode-aware validation as assertEntry, preserving the remaining fingerprint checks, and cover successful linking followed by copying its alias.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The reported installed-package update stalls beyond its command budget and interrupts an existing update workflow.
  • add merge-risk: 🚨 compatibility: Mixed linking and copying can reject supported shared-inode layouts, and published-driver compatibility remains unverified.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured Docker observations exercise runtime retention through the installed update command and show completion with the expected JSON result and substantial speedup. The production materializer is unchanged since that evidence; the separate published-driver compatibility requirement remains outstanding. No stored-data contract changes.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The captured Docker observations exercise runtime retention through the installed update command and show completion with the expected JSON result and substantial speedup. The production materializer is unchanged since that evidence; the separate published-driver compatibility requirement remains outstanding. No stored-data contract changes.

Label justifications:

  • P1: The reported installed-package update stalls beyond its command budget and interrupts an existing update workflow.
  • merge-risk: 🚨 compatibility: Mixed linking and copying can reject supported shared-inode layouts, and published-driver compatibility remains unverified.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The captured Docker observations exercise runtime retention through the installed update command and show completion with the expected JSON result and substantial speedup. The production materializer is unchanged since that evidence; the separate published-driver compatibility requirement remains outstanding. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Docker observations exercise runtime retention through the installed update command and show completion with the expected JSON result and substantial speedup. The production materializer is unchanged since that evidence; the separate published-driver compatibility requirement remains outstanding. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: Read the introduced patch and original candidate-tree implementation. Review ownership uses the supplied merge-base-to-head delta; the stale test merge was not used to infer removal of main-branch behavior. (b14776bd1837)
  • Prior finding remains unchanged: The retention materializer has identical blob identity at the previous reviewed head and current head. GitHub confirms that the intervening commit only removes a redundant number conversion in the test. A broader local comparison encountered an unavailable historical test blob; the focused production comparison and GitHub commit patch resolved the relevant continuity question. (src/infra/update-retained-runtime-tree.ts:76, b14776bd1837)
  • Copy fallback rejects its own inode change: assertEntry adjusts ctime for previously linked inodes, but copyEntry's assertBeforeMutation callback uses the original inventory. A successful link followed by copying another name of that inode therefore fails the strict ctime comparison. (src/infra/update-retained-runtime-tree.ts:77, b14776bd1837)
  • Existing fallback coverage exercises the opposite order: The fallback test copies worker.js before linking worker-alias.js. It does not cover successful linking followed by EMLINK fallback or relocation-required copying of the same inode. (src/infra/update-retained-runtime-tree.test.ts:74, b14776bd1837)
  • Current main still copies the runtime: Fetched main calls copyUpdateCandidatePluginTrees from withRetainedUpdateRuntime, so the central optimization is not already implemented there. (src/infra/update-retained-runtime.ts:89, 0d947f878155)
  • Latest release check: The supplied latest release, v2026.9.5, has no update-retained-runtime.ts entry. Its tree does not establish that this optimization shipped. (ec9c1a13db89)

Likely related people:

  • Peter Steinberger: Raw commit dd7d596 adds src/infra/update-retained-runtime.ts:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: dd7d596ed3ea; files: src/infra/update-retained-runtime.ts)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Repair shared-inode fallback validation and add link-first/copy-second regression coverage.
  • Record the published-driver-to-candidate result and the changed test file's measured runtime.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-22T22:06:22.996Z sha 7adaa24 :: blocked before merge. :: [P2] Use inode-aware validation when copying an already-linked alias

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 22, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Evidence for head b14776b (test-only lint fix over 7adaa24):

  • pnpm test:docker:plugin-update on the packed candidate from this branch: passed ("Plugin update unchanged and consent Docker E2E passed."), all 24 consent steps including update-denied (code 0), after-denial, repair-accepted, later-repair-denied, update-accepted, fresh-process-accepted, missing-payload-*.
  • CLI repro without Docker on the same package (macOS host, load average ~34): openclaw update --tag core-denied-future.tgz --yes --json exits 0 with status: ok, postUpdate.plugins.status: warning, PLUGIN_CAPABILITY_CONSENT_REQUIRED, after.version: 2026.9.99-first-hop.0. Retention alone on the installed 38,678-file package: 33.9 s (about 1,140 files/s) versus about 12 files/s for the byte copy that never finished within the lane's 300 s command budget.
  • OPENCLAW_TESTBOX=1 pnpm check:changed: running; result follows.

@steipete

Copy link
Copy Markdown
Contributor Author

OPENCLAW_TESTBOX=1 pnpm check:changed on head b14776b: exit 0. CI shard checks-node-compact-large-4 failed once in src/gateway/server-methods/agent.test.ts teardown (SqliteWorkerError: disk I/O error closing shared-state workers, unrelated to this change) and passed on rerun.

@steipete
steipete merged commit eeb450c into main Sep 22, 2026
337 of 339 checks passed
@steipete
steipete deleted the fix/plugin-update-consent-json branch September 22, 2026 22:59
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 22, 2026
* commit '7d7f977ccfc1ac177526232e4f4960febd010015': (91 commits)
  test: avoid unused target setup in package profile fixtures (#155972)
  fix(worktrees): batch snapshot metadata reads
  test(plugin-state): distinguish borrowed and foreign lifecycle owners
  refactor(agents): share external harness session and attempt machinery (#152181)
  chore(i18n): refresh native locales (#156006)
  chore(test): retain Doctor fixture settlement diagnostics (#155944)
  perf(codex): reuse unchanged inference request bytes (#155987)
  perf(test): prepare snapshot ownership subprocess imports (#155973)
  perf(test): consolidate channel registry coverage (#155014)
  fix(runtime): preserve Node worker dependencies and cleanup diagnostics (#155292)
  perf(test): prepare worktree GC child runtime (#155928)
  fix(ui): open browser cards after delayed panel renders (#153253)
  fix(update): retain the running updater by hard link instead of copying the package (#155977)
  feat(decisions): add explicit evaluation and Labs opt-in foundation (#155134)
  fix(state): preserve lifecycle custody across worker dispatch
  improve: reuse shared tooling fixtures and defer legacy updater proof (#155731)
  improve(ui): reduce real-Gateway test preparation (#155979)
  perf(state): move session RPC SQL off the Gateway main thread (#155740)
  docs(freebsd): explain native Codex runtime limits (#155980)
  fix(qa): count Code Mode nested tool activity as transcript tool evidence (#155976)
  ...
steipete added a commit that referenced this pull request Sep 23, 2026
…ng the package (#155977)

## Summary

`openclaw update` retains the running updater's package tree so its workers survive the installer's replacement (#153764). That retention byte-copied the entire package root (`package.json`, `dist/`, `node_modules/`, 37,309 files / 625 MB for 2026.9.6) with three full `lstat` passes plus a per-file copy and verify. On the release Docker host this ran at ~12 files/s, so every in-place global update stalled in the `validating` phase for well over the E2E harness's 300 s command budget. `Plugin Prerelease` lane `plugin-update` (Full Release Validation 35775979903 → run 35779065106) then reported `update-denied did not return JSON: Unexpected end of JSON input` because `timeout` killed the command before any output.

This keeps the retention semantics and makes it cheap:

- Files are hard-linked into the private runtime directory (`fs.link`), so the inventoried inodes outlive npm's rename/unlink without copying bytes. Bytes are copied only when the filesystem refuses the link (`EXDEV`, `EPERM`, `ENOTSUP`, ...) or when relocation must rewrite the member in place (`.modules.yaml`, `.bin` launchers), so the live package is never edited through a shared inode.
- One walk performs the inventory check, publication, relocation and escape check per entry (was: pre-check pass, directory pass, file pass with two checks, symlink pass, post-check pass, relocation pass, full verify walk).
- After each link the private name is checked to reference the inventoried `dev:ino`; entries sharing an already linked inode (pnpm store hard links) keep every fingerprint field except the change time that the link itself bumps.
- The IO budget watchdog around retention is unchanged.
- `node_modules` stays in the retained tree: retained workers (`dist/**` entrypoints) resolve their dependencies from it.
- The shared copy path used for candidate rehearsal snapshots is unchanged in behavior; its plan rebasing, host-link/alias publication and verification moved to `update-candidate-plugin-tree-links.ts` so both materializers share them.
- Harness: the consent scenario's "did not return JSON" assertion now includes the command's exit code so a `timeout` kill (124) is visible in CI.

## Evidence

- Root cause repro on the exact CI candidate bytes (artifacts `docker-e2e-package-35777886894-1` + `docker-e2e-prepublish-plugin-registry-35777886894-1`): `update --tag core-denied-future.tgz --yes --json` finished `npm i` in 2 min, then sat in `validating` copying `openclaw-update-runtime-*` at 5,264 → 5,513 files in 20 s (~12 files/s); 6,402 files / 102 MB after 9 min; SQLite `update_runs` row `failed/interrupted` when the harness killed it.
- With this change: the same repro (same host, load average ~34) returns the denial payload on stdout with exit 0 (`status: ok`, `postUpdate.plugins.status: warning`, `PLUGIN_CAPABILITY_CONSENT_REQUIRED`, `after.version: 2026.9.99-first-hop.0`) and the whole `update --tag` command completes in 3.5 min end to end (npm install 28 s, canary validation, activation, Doctor). Retention alone, measured directly on the installed 38,678-file package with `withRetainedUpdateRuntime`: 33.9 s to retain (about 1,140 files/s, roughly 95x faster than the copy) and 4.6 s to release.
- Unit tests: `src/infra/update-retained-runtime-tree.test.ts` (link path shares inodes and survives source replacement, `EXDEV` fallback copies bytes with the inventoried mode, changed entries are refused before any link, relocated launcher is copied so the live file is untouched); existing `update-retained-runtime.test.ts` layouts (npm/pnpm/pnpm-workspace/git/git-linked) and `update-candidate-plugin-tree.test.ts` pass.
- `OPENCLAW_TESTBOX=1 pnpm check:changed` and the `plugin-update` Docker lane on the packed candidate: results in the PR comments.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…ng the package (openclaw#155977)

## Summary

`openclaw update` retains the running updater's package tree so its workers survive the installer's replacement (openclaw#153764). That retention byte-copied the entire package root (`package.json`, `dist/`, `node_modules/`, 37,309 files / 625 MB for 2026.9.6) with three full `lstat` passes plus a per-file copy and verify. On the release Docker host this ran at ~12 files/s, so every in-place global update stalled in the `validating` phase for well over the E2E harness's 300 s command budget. `Plugin Prerelease` lane `plugin-update` (Full Release Validation 35775979903 → run 35779065106) then reported `update-denied did not return JSON: Unexpected end of JSON input` because `timeout` killed the command before any output.

This keeps the retention semantics and makes it cheap:

- Files are hard-linked into the private runtime directory (`fs.link`), so the inventoried inodes outlive npm's rename/unlink without copying bytes. Bytes are copied only when the filesystem refuses the link (`EXDEV`, `EPERM`, `ENOTSUP`, ...) or when relocation must rewrite the member in place (`.modules.yaml`, `.bin` launchers), so the live package is never edited through a shared inode.
- One walk performs the inventory check, publication, relocation and escape check per entry (was: pre-check pass, directory pass, file pass with two checks, symlink pass, post-check pass, relocation pass, full verify walk).
- After each link the private name is checked to reference the inventoried `dev:ino`; entries sharing an already linked inode (pnpm store hard links) keep every fingerprint field except the change time that the link itself bumps.
- The IO budget watchdog around retention is unchanged.
- `node_modules` stays in the retained tree: retained workers (`dist/**` entrypoints) resolve their dependencies from it.
- The shared copy path used for candidate rehearsal snapshots is unchanged in behavior; its plan rebasing, host-link/alias publication and verification moved to `update-candidate-plugin-tree-links.ts` so both materializers share them.
- Harness: the consent scenario's "did not return JSON" assertion now includes the command's exit code so a `timeout` kill (124) is visible in CI.

## Evidence

- Root cause repro on the exact CI candidate bytes (artifacts `docker-e2e-package-35777886894-1` + `docker-e2e-prepublish-plugin-registry-35777886894-1`): `update --tag core-denied-future.tgz --yes --json` finished `npm i` in 2 min, then sat in `validating` copying `openclaw-update-runtime-*` at 5,264 → 5,513 files in 20 s (~12 files/s); 6,402 files / 102 MB after 9 min; SQLite `update_runs` row `failed/interrupted` when the harness killed it.
- With this change: the same repro (same host, load average ~34) returns the denial payload on stdout with exit 0 (`status: ok`, `postUpdate.plugins.status: warning`, `PLUGIN_CAPABILITY_CONSENT_REQUIRED`, `after.version: 2026.9.99-first-hop.0`) and the whole `update --tag` command completes in 3.5 min end to end (npm install 28 s, canary validation, activation, Doctor). Retention alone, measured directly on the installed 38,678-file package with `withRetainedUpdateRuntime`: 33.9 s to retain (about 1,140 files/s, roughly 95x faster than the copy) and 4.6 s to release.
- Unit tests: `src/infra/update-retained-runtime-tree.test.ts` (link path shares inodes and survives source replacement, `EXDEV` fallback copies bytes with the inventoried mode, changed entries are refused before any link, relocated launcher is copied so the live file is untouched); existing `update-retained-runtime.test.ts` layouts (npm/pnpm/pnpm-workspace/git/git-linked) and `update-candidate-plugin-tree.test.ts` pass.
- `OPENCLAW_TESTBOX=1 pnpm check:changed` and the `plugin-update` Docker lane on the packed candidate: results in the PR comments.
steipete added a commit that referenced this pull request Sep 23, 2026
… Doctor (#156138)

## What Problem This Solves

Fixes: `openclaw update` from 2026.9.5 to the 2026.9.6 candidate fails at the post-install Doctor with `another OpenClaw process owns gateway-lifecycle` when the shipped 2026.9.5 updater could not inspect the managed Gateway service, and the package is rolled back. Release blocker for 2026.9.6 (Package Acceptance lane `update-first-hop-compat`, release-checks run 35803842673 attempts 1 and 2).

## User Impact

User impact: operators on 2026.9.5 whose service manager cannot be inspected by the old updater can now update in place; the candidate stops the still-running predecessor Gateway before Doctor and the updated service is restarted afterwards. No change for updates where the old updater already inspected and stopped the service, or on Windows. Under `--no-restart` the shipped 2026.9.5 driver gives the delegated Doctor no restart consent, so a Gateway the candidate had to stop for Doctor is restarted on the updated installation with an advisory rather than left down.

## Why This Change Was Made

- `src/infra/update-candidate-predecessor-stop.ts` (new): `stopSupervisedPredecessorGateway` runs in the candidate's `--doctor` entrypoint (`runDelegatedDoctor`), which is the step the immutable 2026.9.5 driver invokes as its post-verification Doctor and the step that fails in CI. When the current Gateway owner lease is `live` and `supervised`, it stops that predecessor through the candidate's service adapter (`maybeStopManagedServiceBeforeMutableUpdate`, phase `prepare`) under the composed executor + requester authority (`assertCurrent`, which throws `UpdateRequesterRevokedError` before any native mutation), then records `managed-service:candidate-stop` in the update-run ledger. A `foreground` owner keeps Doctor's existing wait. `adoptCandidateManagedServiceStop` runs in finalization: for a transferred uninspected `unavailable` verdict it re-inspects, adopts the ledger-recorded Doctor stop as `stopped`, and hands the state to `finishUpdate` so the existing restart path starts the updated service. Both paths are skipped on Windows so a candidate-created Scheduled Task suspension can never be dropped. The Doctor records a retained `finalize:predecessor-stop:<stoppedAtMs>:<managerUid>:<pid>:<fingerprint>` receipt in the `onStopped` callback (the native mutation boundary); the identity lives in the step key because published parents strip `detail` from retained steps under the ledger byte limit. Finalization processes that receipt independently of the legacy verdict: it inspects without mutating (`phase: "inspect"`), adopts the stop only when the current service reports the same fingerprint and manager uid, leaves a replaced service untouched with an `exitCode: 1` advisory step, does not stop again a same-identity service that was started after Doctor, and restores (force-restarts, with an advisory) when the run was `--no-restart`, including the case where the old updater had inspected an owned service.

- `src/infra/update-migrated-finalize.worker.ts`: wires the two hooks above; the finalization hook revalidates the requester (`run.requesterAuthority.isCurrent()`) as well as the executor fence before native mutation.
- `src/cli/update-cli/update-command-legacy-service-stop.ts`: the decision helper (`needsCandidateManagedServiceStop`).
- `src/daemon/systemd-scope.ts` / `systemd-lifecycle.ts`: start and restart admission use the same rule (`assertNoSystemGatewayOwnershipForActivation`), so the updated service can start under exactly the condition that admitted the stop; a proven system owner still refuses.
- `src/daemon/systemd-definition-mutation.ts`: when the system-scope ownership probe is unverifiable (`SERVICE_DEFINITION_UNKNOWN [system-ownership-unverified]`, seen in the CI log) and the caller requires a loaded unit, a loaded user unit whose artifacts this account owns keeps its `writable` capability. The refusal is unchanged without `requireLoaded`, for a system-owned unit, and when the user unit is not loaded or not owned.
- `src/cli/update-cli/update-command-service-drain.ts`: a resident whose installation was already replaced closes every connection with `gateway install changed` (1011); the drain now warns and stops it directly instead of polling until the 30 min step deadline. The delegated Doctor stop is additionally bounded by the 330 s service stop budget. Found by the local lane rerun on the b2b8ada bytes, which reproduced the CI handoff (the 2026.9.5 updater skipped its own stop, the candidate `--doctor` hook fired) and then hung in the drain until the container timeout.
- Hard-link retention (#155977) and the lane are untouched.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
… Doctor (openclaw#156138)

## What Problem This Solves

Fixes: `openclaw update` from 2026.9.5 to the 2026.9.6 candidate fails at the post-install Doctor with `another OpenClaw process owns gateway-lifecycle` when the shipped 2026.9.5 updater could not inspect the managed Gateway service, and the package is rolled back. Release blocker for 2026.9.6 (Package Acceptance lane `update-first-hop-compat`, release-checks run 35803842673 attempts 1 and 2).

## User Impact

User impact: operators on 2026.9.5 whose service manager cannot be inspected by the old updater can now update in place; the candidate stops the still-running predecessor Gateway before Doctor and the updated service is restarted afterwards. No change for updates where the old updater already inspected and stopped the service, or on Windows. Under `--no-restart` the shipped 2026.9.5 driver gives the delegated Doctor no restart consent, so a Gateway the candidate had to stop for Doctor is restarted on the updated installation with an advisory rather than left down.

## Why This Change Was Made

- `src/infra/update-candidate-predecessor-stop.ts` (new): `stopSupervisedPredecessorGateway` runs in the candidate's `--doctor` entrypoint (`runDelegatedDoctor`), which is the step the immutable 2026.9.5 driver invokes as its post-verification Doctor and the step that fails in CI. When the current Gateway owner lease is `live` and `supervised`, it stops that predecessor through the candidate's service adapter (`maybeStopManagedServiceBeforeMutableUpdate`, phase `prepare`) under the composed executor + requester authority (`assertCurrent`, which throws `UpdateRequesterRevokedError` before any native mutation), then records `managed-service:candidate-stop` in the update-run ledger. A `foreground` owner keeps Doctor's existing wait. `adoptCandidateManagedServiceStop` runs in finalization: for a transferred uninspected `unavailable` verdict it re-inspects, adopts the ledger-recorded Doctor stop as `stopped`, and hands the state to `finishUpdate` so the existing restart path starts the updated service. Both paths are skipped on Windows so a candidate-created Scheduled Task suspension can never be dropped. The Doctor records a retained `finalize:predecessor-stop:<stoppedAtMs>:<managerUid>:<pid>:<fingerprint>` receipt in the `onStopped` callback (the native mutation boundary); the identity lives in the step key because published parents strip `detail` from retained steps under the ledger byte limit. Finalization processes that receipt independently of the legacy verdict: it inspects without mutating (`phase: "inspect"`), adopts the stop only when the current service reports the same fingerprint and manager uid, leaves a replaced service untouched with an `exitCode: 1` advisory step, does not stop again a same-identity service that was started after Doctor, and restores (force-restarts, with an advisory) when the run was `--no-restart`, including the case where the old updater had inspected an owned service.

- `src/infra/update-migrated-finalize.worker.ts`: wires the two hooks above; the finalization hook revalidates the requester (`run.requesterAuthority.isCurrent()`) as well as the executor fence before native mutation.
- `src/cli/update-cli/update-command-legacy-service-stop.ts`: the decision helper (`needsCandidateManagedServiceStop`).
- `src/daemon/systemd-scope.ts` / `systemd-lifecycle.ts`: start and restart admission use the same rule (`assertNoSystemGatewayOwnershipForActivation`), so the updated service can start under exactly the condition that admitted the stop; a proven system owner still refuses.
- `src/daemon/systemd-definition-mutation.ts`: when the system-scope ownership probe is unverifiable (`SERVICE_DEFINITION_UNKNOWN [system-ownership-unverified]`, seen in the CI log) and the caller requires a loaded unit, a loaded user unit whose artifacts this account owns keeps its `writable` capability. The refusal is unchanged without `requireLoaded`, for a system-owned unit, and when the user unit is not loaded or not owned.
- `src/cli/update-cli/update-command-service-drain.ts`: a resident whose installation was already replaced closes every connection with `gateway install changed` (1011); the drain now warns and stops it directly instead of polling until the 30 min step deadline. The delegated Doctor stop is additionally bounded by the 330 s service stop budget. Found by the local lane rerun on the b2b8ada bytes, which reproduced the CI handoff (the 2026.9.5 updater skipped its own stop, the candidate `--doctor` hook fired) and then hung in the drain until the container timeout.
- Hard-link retention (openclaw#155977) and the lane are untouched.
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant