Repository navigation
fix(update): retain the running updater by hard link instead of copying the package - #155977
Conversation
…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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 22, 2026, 6:23 PM ET / 22:23 UTC (Revision 2). ClawSweeper reviewWhat this changesThe 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 provenancePossible 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 Review scores
Verification
How this fits togetherOpenClaw 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]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +241, Tests +105, Other 0. Total +346 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0d947f878155. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Evidence for head b14776b (test-only lint fix over 7adaa24):
|
|
|
|
Merged via squash.
|
* 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) ...
…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.
…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.
… 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.
… 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.
Summary
openclaw updateretains 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 fulllstatpasses 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 thevalidatingphase for well over the E2E harness's 300 s command budget.Plugin Prereleaselaneplugin-update(Full Release Validation 35775979903 → run 35779065106) then reportedupdate-denied did not return JSON: Unexpected end of JSON inputbecausetimeoutkilled the command before any output.This keeps the retention semantics and makes it cheap:
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,.binlaunchers), so the live package is never edited through a shared inode.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.node_modulesstays in the retained tree: retained workers (dist/**entrypoints) resolve their dependencies from it.update-candidate-plugin-tree-links.tsso both materializers share them.timeoutkill (124) is visible in CI.Evidence
docker-e2e-package-35777886894-1+docker-e2e-prepublish-plugin-registry-35777886894-1):update --tag core-denied-future.tgz --yes --jsonfinishednpm iin 2 min, then sat invalidatingcopyingopenclaw-update-runtime-*at 5,264 → 5,513 files in 20 s (~12 files/s); 6,402 files / 102 MB after 9 min; SQLiteupdate_runsrowfailed/interruptedwhen the harness killed it.status: ok,postUpdate.plugins.status: warning,PLUGIN_CAPABILITY_CONSENT_REQUIRED,after.version: 2026.9.99-first-hop.0) and the wholeupdate --tagcommand 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 withwithRetainedUpdateRuntime: 33.9 s to retain (about 1,140 files/s, roughly 95x faster than the copy) and 4.6 s to release.src/infra/update-retained-runtime-tree.test.ts(link path shares inodes and survives source replacement,EXDEVfallback copies bytes with the inventoried mode, changed entries are refused before any link, relocated launcher is copied so the live file is untouched); existingupdate-retained-runtime.test.tslayouts (npm/pnpm/pnpm-workspace/git/git-linked) andupdate-candidate-plugin-tree.test.tspass.OPENCLAW_TESTBOX=1 pnpm check:changedand theplugin-updateDocker lane on the packed candidate: results in the PR comments.