Repository navigation
feat(update): new releases run their own pre-update rehearsal - #197922
fuller-stack-dev merged 8 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR lets staged releases run their own update rehearsal and relay progress and results to the installed updater. Example: An updater stages a release declaring openclaw.updateRehearsalProtocol: 1.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this useful, maintainer-authored PR open: current main still runs the installed updater's rehearsal, and all three previous code findings are repaired. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherCandidate validation sits between staging and activation, consuming the resolved configuration and state sources and returning check results and committed progress. flowchart TD
A[Installed updater] --> B[Candidate rehearsal command]
B --> C[Private state snapshot]
C --> D[Doctor and Gateway checks]
B --> E[Progress receipt relay]
E --> F[Installed update ledger]
B --> A
A --> G[Activation or recovery]
Technical reviewBest possible solution: Keep the existing canary as the check owner behind the negotiated process adapter, with progress persistence and activation owned by the installed updater. Do we have a high-confidence way to reproduce the issue? Current-main source directly establishes the installed-driver limitation; this read-only review executed no target code. Is this the best way to solve the issue? A negotiated adapter around the existing canary is a coherent first slice: existing external preflight lacks the full result and receipt contract, and fallback preserves older targets. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 68542b21d0d2. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +798, Tests +850, Docs +57, Config +1, Other +9. Total +1715 across 19 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed November 13, 2026, 11:55 AM ET / 16:55 UTC (Revision 3). |
…ater After staging, the updater runs the candidate's hidden `update rehearse` command in place of its own rehearsal when the target declares `openclaw.updateRehearsalProtocol`. The candidate checks copied state with its own logic and budgets, holds no update authority, and reports each step back for the run ledger. The updater runs its own rehearsal when the target lacks the marker, or when the candidate exits abnormally, returns an invalid or contradictory result, reports a timed-out check or failed state copy, or stays silent for 15 minutes. A candidate refusal stays binding. On cancellation the candidate gets five minutes to remove its temporary copies before it is forced to stop. The immutable activation path keeps the updater's own rehearsal.
The candidate now waits for the updater's answer to each progress receipt on its stdin, so no check starts or completes before the updater has recorded it. A refused receipt or a lost updater stops the candidate before the announced check. Each rehearsal check runs in its own process group, which stopping the candidate does not reach. The candidate reports those processes, and the updater stops any still running after the candidate exits, crashes, or is forced to stop. It signals a process only while it still has the start time it had when reported.
27f3c52 to
758582e
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
A candidate Gateway that stalled before it was ready was reported as a binding refusal. Only that step is now inconclusive, so the installed updater runs its own rehearsal; a timed-out exit or cleanup elsewhere leaves a refusal standing. A receipt the updater could not read was dropped without an answer, and the candidate waited behind its own heartbeat. The updater now closes the candidate's stdin and takes the rehearsal back, including when its line reader drops an oversized event. Progress text is bounded the way the ledger bounds it, and the candidate refuses to send a receipt too large to deliver. An unknown event without a receipt number is still ignored. State inventory and copy commands are reported to the updater through the command process custody interface, so it can stop them after a candidate crash. The candidate removes its state copy even when the updater is no longer there to record the cleanup.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
openclaw#197922 merged. The linked-root cell is in review as openclaw#198489.
…aw#197922) * feat(update): let the candidate rehearse itself for the installed updater After staging, the updater runs the candidate's hidden `update rehearse` command in place of its own rehearsal when the target declares `openclaw.updateRehearsalProtocol`. The candidate checks copied state with its own logic and budgets, holds no update authority, and reports each step back for the run ledger. The updater runs its own rehearsal when the target lacks the marker, or when the candidate exits abnormally, returns an invalid or contradictory result, reports a timed-out check or failed state copy, or stays silent for 15 minutes. A candidate refusal stays binding. On cancellation the candidate gets five minutes to remove its temporary copies before it is forced to stop. The immutable activation path keeps the updater's own rehearsal. * fix(update): keep receipt order and check custody in candidate rehearsal The candidate now waits for the updater's answer to each progress receipt on its stdin, so no check starts or completes before the updater has recorded it. A refused receipt or a lost updater stops the candidate before the announced check. Each rehearsal check runs in its own process group, which stopping the candidate does not reach. The candidate reports those processes, and the updater stops any still running after the candidate exits, crashes, or is forced to stop. It signals a process only while it still has the start time it had when reported. * test(update): drop a redundant type argument in the rehearsal test * fix(update): close fallback and custody gaps in the candidate rehearsal A candidate Gateway that stalled before it was ready was reported as a binding refusal. Only that step is now inconclusive, so the installed updater runs its own rehearsal; a timed-out exit or cleanup elsewhere leaves a refusal standing. A receipt the updater could not read was dropped without an answer, and the candidate waited behind its own heartbeat. The updater now closes the candidate's stdin and takes the rehearsal back, including when its line reader drops an oversized event. Progress text is bounded the way the ledger bounds it, and the candidate refuses to send a receipt too large to deliver. An unknown event without a receipt number is still ignored. State inventory and copy commands are reported to the updater through the command process custody interface, so it can stop them after a candidate crash. The candidate removes its state copy even when the updater is no longer there to record the cleanup.
…eck (#198268) ## Problem Before activation, `openclaw update` rehearses the candidate. It copies all SQLite state and plugin payloads into a scratch directory, runs the candidate's `doctor --fix`, `doctor --lint`, `config validate` and `plugins list` against the copy, then boots a private Gateway on it. On Peanutto's production-sized state this took 10–15 minutes of a 26-minute update (about 46%). #197851 made that rehearsal redundant. Post-activation rollback now always has a pre-activation SQLite schema baseline, and `--no-restart` updates boot the activated release once (`activated-gateway-startup`) and roll back when it cannot become ready. Doctor and Gateway startup are proven on real state after activation, with rollback. ## Change The driver no longer rehearses. Before activation it runs only the candidate's recovery worker once: `update-migrated-finalize --check` (step `candidate-recovery`). That one stateless call already produced every canary output used later: | Canary output | Replacement | | --- | --- | | `candidateSchemaVersions` (activation schema baseline, PostgreSQL baseline gate, post-Doctor schema check) | `--check` `state`/`agent` | | `gatewayRestartCompletion` | `--check` `gatewayRestartCompletion` | | `doctorConfigWrites` (delegated Doctor config writes) | `--check` `doctorConfigWrites: "pid-start-v1"` | | `doctorConfigChanges` | Removed. Activation Doctor reports its own `configChanges` and refusal keys. | | `validatedConfigSnapshot` | Unchanged: the config read before the check | | Observed canary Gateway startup ms (previous-Gateway readiness window) | Removed; the existing five-minute floor or `--timeout` applies | | Missing worker → "uses the current updater" advisory | Kept as-is | Call sites: - `openclaw update` (`validateUpdateCandidateWithProgress`) calls `checkUpdateCandidate`. The progress-writer and state-worker scaffolding that kept WAL readable during the copy is gone. - `openclaw update preflight` (external supervisors) reads config and runs `--check`. Its receipt `coverage` changes from `isolated-core-startup` to `candidate-runtime`, so a supervisor can tell the weaker proof apart. `--source-root` is still accepted. - Immutable activation runs `--check` before drain and before rollback. The post-start private canary and its second observation are removed; live readiness verification and rollback are unchanged. - `snapshot-space-preflight` keeps only the activation database backup/rollback space check. - Automatic-update backoff keys on repeated identical activation failures (`openclaw doctor`, `post-update verification`, `activated-gateway-startup`) instead of `candidate-doctor`, which no longer runs. It counts runs recorded as `rolled-back` as well as `failed`, because a failed activation usually restores the previous release (ClawSweeper finding; the `rolled back` campaign case fails without it). - The previous-Gateway readiness budget uses the existing floor (5 min, 90 min on Windows) or `--timeout`. - **Fix found by E2E:** `captureUpdateDatabases` retires idle state-read workers before acquiring capture ownership. A reader started before activation lazy-imported `gateway-owner-lease.worker` by its old hashed chunk name; when the target rehashes that chunk the ownership check fails and automatic restore is disabled. - **Fix found by E2E:** the no-restart `activated-gateway-startup` boot (#197851) writes boot bookkeeping to real state, after which database rollback saw "changes after Doctor" and refused. `adoptUpdateBootDatabaseWrites` attributes the boot's own writes to the update when nothing else wrote since Doctor. Accepted edge case: a foreign write during the boot window is attributed the same way. Covered by the `activated-boot` case of `update-command-database-rollback.test.ts` (settlement and restore, not helper output). - Restore uses the plugin-cohort binding captured before Doctor, because the previous build cannot open a state database Doctor migrated to a newer schema (`newer-schema` case). ### #197922's delegated rehearsal is removed #197922 (merged 11-14) made the candidate run its own rehearsal (`openclaw update rehearse`, package marker `openclaw.updateRehearsalProtocol: 1`) when the installed updater supports delegation. This PR removes the rehearsal, so it also removes the delegation: the driver-side delegated rehearsal, the candidate-side `update rehearse` command, the rehearsal contract and the marker (−1,803 lines of #197922). - **No released version depends on it.** `git tag --contains 3ab80ab` lists only `release-publish/*` cuts of 2026.11.3; `v2026.11.3` (npm `latest`) and `v2026.11.5-beta.1..3` do not contain it, and `npm view [email protected] openclaw.updateRehearsalProtocol` is empty. Per AGENTS.md, main and beta are not shipped contracts. - **Updaters built from main since #197922 fall back.** When the target lacks the marker, they run their own rehearsal (the path #197922 kept for unsupported targets). Proven below: a main updater (merge base, which contains #197922) updated to this branch, rehearsed it itself and finished `ok`. ### Rollback no longer runs without the retained runtime Runtime retention copies the running updater so its lazy imports and workers keep working after the package or checkout is replaced. Since #185178 a retention failure only logged "continuing update without a verified retained rollback runtime". With the canary gone, rollback is the only safety net, and it loads code from that retained runtime. Reproduced (package install, retention fault injected, then a migration that commits and a Doctor that fails): Doctor committed the migration, `database rollback` failed with `Cannot find module …/dist/update-candidate-state-<hash>.mjs`, the update ended `state-migrated-no-rollback` and **left the target release active**. The same faults without the retention failure roll back the databases and the package. Chosen behavior: **every retention failure now stops the update before staging or activation**, with "Could not retain the running updater (<reason>). The update stopped before changing the installation; retry it." Cancellation and uncertain subprocess cleanup still propagate unchanged. - Least complex: it deletes #185178's fallback (−26 production lines) instead of making rollback independent of the copy, which would mean preloading every lazy rollback import and pinning every worker entry, a second retention mechanism. - Measured cost on large installs: #185178 was motivated by a worker output cap that #184958 has since fixed. Peanutto (183k entries, ~4 GB retained) completed retention on all 17 updates since 2026-10-27, so this refusal would not have fired once. The remaining causes are a source file changing during the copy (retry) and a host-owned plugin link (documented fix in `docs/cli/update.md#runtime-retention-failures`). - Retention itself goes away with Git releases in a later slice; this does not redesign it. ### What was removed - Driver: `update-candidate-canary.ts`, `update-candidate-canary-commands.ts`, canary-only lint/failure/config helpers, Git startup-runtime selection, the validation wrapper scaffolding, and #197922's delegated rehearsal. - Candidate: `update rehearse`, `update-rehearsal-contract.ts`, the `updateRehearsalProtocol` marker. - #185178's retention fallback. - Tests: the canary suites and their test-support, and the delegated-rehearsal tests. Against the merge base: **production +383 / −2,198** (net −1,815), tests +648 / −6,140, docs +111 / −134, config −18. ### What stays, and why Released updaters, including stable 2026.11.3, still rehearse whatever candidate they install, using **the candidate's** state-copy worker, rehearsal-aware Doctor and lint, `update-candidate-rehearsal`/`-snapshot`, plugin-tree copy and `--update-canary` startup progress. Deleting those would break upgrades from every shipped version, so the candidate side stays until no supported update source runs the canary. Historical step identities (`candidate-doctor` etc.) stay so existing `update_runs` history renders. ## Review findings - **Config-convergence test** (`update-cli.config-convergence.test.ts`): the stateless check no longer receives config, so the test now asserts what the check does receive at its boundary, the owning profile's `stateDir` and `OPENCLAW_CONFIG_PATH`, keeps an explicit `candidate-recovery` refusal through the result contract, and asserts authored config bytes are unchanged. - **Data-model compatibility:** no schema, config or stored-data shape changes. Existing state from 2026.11.3 (state schema 22 → 40) and Peanutto's production databases (3.3 GB) load through the real update path below. - **Boot-writes test:** replaced by the `activated-boot` settlement-and-restore case in the database rollback matrix; it fails when boot-write adoption is disabled. ## Evidence Harness: real `openclaw update --yes --no-restart --json --tag <packed tarball>` from an npm-global install on isolated `env -i` state (cloned per run with `cp -c`), run on mbp-m5, three at a time. Base = merge base `1e64efd` with inert env-gated faults; head = this branch on the same base (`8065ed6`; the "with fix" rows use `097a6ba`, the retention fix before its refusal wording). The merged head `97ca0de` is that change with current `main` merged in. Fault targets are the same tarball plus env-gated faults: `gateway-crash` (Gateway throws at boot), `plugin-crash` (acpx throws at load), `migration-broken` (state v41 adds a column then throws), `committed-migration` (v41 commits, then Doctor throws), `retention` (runtime retention throws after the native helper is bound). "Gateway after" = a fresh Gateway on the post-update state reaches `/readyz`. Schema = state `user_version` after the run (base 40, fault target 41). | Case | main (canary) | this PR | | --- | --- | --- | | clean update | ok; validating 65 s (retention 18, candidate Doctor 7, candidate Gateway 6) | ok; validating 52 s (retention 32, `candidate-recovery` + admission ~20); **no candidate Doctor/Gateway phase** | | gateway crash | refused at `candidate-gateway-startup`; base kept | activated, `activated-gateway-startup` failed → **database rollback + package rollback**; base active; Gateway after ok | | committed migration + failed Doctor | refused at `candidate-doctor` | v41 committed, Doctor failed → **database rollback (state back to v40) + package rollback**; base active; Gateway after ok | | broken migration | refused at `candidate-doctor` | Doctor failed → database + package rollback; state v40; Gateway after ok | | plugin crash | ok (plugin failure recorded) | ok (plugin failure recorded) | | retention failure + gateway crash | refused at `candidate-gateway-startup` | before fix: rolled back; **with fix: refused before activation** | | retention failure + committed migration | refused at `candidate-doctor` | before fix: **`Cannot find module`, rollback failed, `state-migrated-no-rollback`, target left active, state stuck at v41**; with fix: refused before staging, base active, state v40, Gateway after ok | | 2026.11.3 → head | — | ok (2026.11.3's own canary against the kept candidate surfaces); state schema 22 → 40; Gateway after ok | | main updater (contains #197922) → head | — | target lacks the marker → updater ran its own rehearsal → ok; Gateway after ok | | Peanutto-shaped clean update (3.28 GB SQLite: Peanutto's state + 3.1 GB agent DB, its plugin set) | ok; **validating 236 s** (retention 50, candidate snapshot 47, candidate Doctor 64, lint 22, candidate Gateway 27); update 949 s | ok; **validating 68 s** (retention 50, `candidate-recovery` + admission ~18); update 839 s; Gateway after ok | Peanutto-shaped: the validating phase drops by **168 s** (236 → 68 s), all of it the four rehearsal steps (160 s). Those two runs overlapped each other, so their activation and total times are not a clean comparison; small-state wall times are likewise not comparable across rows (runs overlapped three at a time). The ~950 s mean saving estimated from Peanutto's live history (where the candidate Doctor took 200–670 s) is unmeasured here. Tests: 31 touched update test files plus the admission test pass (mbp-m5, `ocx test`, 957 s). The retention suites pass (50); 7 of them fail on the previous head because retention resolved instead of stopping. `pnpm tsgo:core`, `pnpm check:test-types`, oxfmt clean. oxlint reports one inherited `max-lines` on `update-command-service-maintenance.ts` (750 lines here, 756 on main). **Exact-head check on `97ca0de`** (same harness, run after the last merge of `main`): 2026.11.3 → head ok, schema 22 → 40, Gateway after ok (398 s); clean head update ok, schema unchanged, Gateway after ok (383 s); Peanutto-shaped clean update ok, Gateway after ok (738 s). ### CI notes - `update-cli.candidate-admission.test.ts` > "blocks package updates when the target requires a newer Node runtime" still asserted the multi-line diagnostic that `764761e` moved into the saved report; it fails the same way on main `f24c2097`, whose changed-lane CI does not select this suite. Updated to assert the one-line refusal and the recovery steps. - `extensions/a2a/src/inbound.test.ts` (interleaved same-context replies) failed in an earlier run of this PR and fails locally on main `f24c2097` too; this PR does not touch that plugin. The branch now includes main through #199736, the fix for the earlier memory-core `manager-shadow-write.test.ts` failure. - `src/gateway/github-pr-workspace-preparation.test.ts` > "recovers an interrupted initial exact install (bound runtime=true)" (`checks-node-changed-compact-large-22`) fails 3/3 locally on both this head `97ca0de5` and main `e182b8d5`, also fails on main `a1dd4938`, and failed again on the rerun of the failed job (run 43763967024, attempt 2), with the same `expect(runtime?.isPaused()).toBe(true)` assertion at line 884. This PR does not touch `src/gateway`. ## Accepted edge cases - Problems only Doctor or Gateway startup reveal are found after activation. The update rolls back the release and the pre-activation database baseline instead of refusing first: one activation/rollback cycle (with restart, a brief Gateway outage) in exchange for skipping the rehearsal on every successful update. - `--no-restart` with a Gateway still running the old code: the activated release is not booted (reported), as in #197851. - External supervisors using `update preflight` get less proof (`coverage: "candidate-runtime"`) and must verify readiness after activation. - A retention failure now stops the update; the user retries or fixes the named cause. ## Gaps - `checks-fast-baseline-ratchets` on `dffdf91` reported `database-worker`/`database-dialect` failures after a runner shutdown signal. Both ratchets pass locally against the merge base (`SQLite T1 live calls: 166 -> 166`; dialect: no construct-group growth). - The Git-checkout path was not re-run in this round (the m5 repository was mid-repack). Retention and rollback share one owner across package and Git installs, and the earlier Git runs are in this PR's history. - The fixed refusal message was proven in unit tests; the E2E refusal ran on the fix before the message wording was added. - The main updater at the merge base refuses a relocated state directory in its canary snapshot ("Restored client credentials do not match the captured shared database": the credential receipt pins the shared database inode). The harness repoints the receipt after each `cp -c`; head never runs that snapshot. Co-authored-by: Ayaan Zaidi <[email protected]>
…eck (openclaw#198268) ## Problem Before activation, `openclaw update` rehearses the candidate. It copies all SQLite state and plugin payloads into a scratch directory, runs the candidate's `doctor --fix`, `doctor --lint`, `config validate` and `plugins list` against the copy, then boots a private Gateway on it. On Peanutto's production-sized state this took 10–15 minutes of a 26-minute update (about 46%). openclaw#197851 made that rehearsal redundant. Post-activation rollback now always has a pre-activation SQLite schema baseline, and `--no-restart` updates boot the activated release once (`activated-gateway-startup`) and roll back when it cannot become ready. Doctor and Gateway startup are proven on real state after activation, with rollback. ## Change The driver no longer rehearses. Before activation it runs only the candidate's recovery worker once: `update-migrated-finalize --check` (step `candidate-recovery`). That one stateless call already produced every canary output used later: | Canary output | Replacement | | --- | --- | | `candidateSchemaVersions` (activation schema baseline, PostgreSQL baseline gate, post-Doctor schema check) | `--check` `state`/`agent` | | `gatewayRestartCompletion` | `--check` `gatewayRestartCompletion` | | `doctorConfigWrites` (delegated Doctor config writes) | `--check` `doctorConfigWrites: "pid-start-v1"` | | `doctorConfigChanges` | Removed. Activation Doctor reports its own `configChanges` and refusal keys. | | `validatedConfigSnapshot` | Unchanged: the config read before the check | | Observed canary Gateway startup ms (previous-Gateway readiness window) | Removed; the existing five-minute floor or `--timeout` applies | | Missing worker → "uses the current updater" advisory | Kept as-is | Call sites: - `openclaw update` (`validateUpdateCandidateWithProgress`) calls `checkUpdateCandidate`. The progress-writer and state-worker scaffolding that kept WAL readable during the copy is gone. - `openclaw update preflight` (external supervisors) reads config and runs `--check`. Its receipt `coverage` changes from `isolated-core-startup` to `candidate-runtime`, so a supervisor can tell the weaker proof apart. `--source-root` is still accepted. - Immutable activation runs `--check` before drain and before rollback. The post-start private canary and its second observation are removed; live readiness verification and rollback are unchanged. - `snapshot-space-preflight` keeps only the activation database backup/rollback space check. - Automatic-update backoff keys on repeated identical activation failures (`openclaw doctor`, `post-update verification`, `activated-gateway-startup`) instead of `candidate-doctor`, which no longer runs. It counts runs recorded as `rolled-back` as well as `failed`, because a failed activation usually restores the previous release (ClawSweeper finding; the `rolled back` campaign case fails without it). - The previous-Gateway readiness budget uses the existing floor (5 min, 90 min on Windows) or `--timeout`. - **Fix found by E2E:** `captureUpdateDatabases` retires idle state-read workers before acquiring capture ownership. A reader started before activation lazy-imported `gateway-owner-lease.worker` by its old hashed chunk name; when the target rehashes that chunk the ownership check fails and automatic restore is disabled. - **Fix found by E2E:** the no-restart `activated-gateway-startup` boot (openclaw#197851) writes boot bookkeeping to real state, after which database rollback saw "changes after Doctor" and refused. `adoptUpdateBootDatabaseWrites` attributes the boot's own writes to the update when nothing else wrote since Doctor. Accepted edge case: a foreign write during the boot window is attributed the same way. Covered by the `activated-boot` case of `update-command-database-rollback.test.ts` (settlement and restore, not helper output). - Restore uses the plugin-cohort binding captured before Doctor, because the previous build cannot open a state database Doctor migrated to a newer schema (`newer-schema` case). ### openclaw#197922's delegated rehearsal is removed openclaw#197922 (merged 11-14) made the candidate run its own rehearsal (`openclaw update rehearse`, package marker `openclaw.updateRehearsalProtocol: 1`) when the installed updater supports delegation. This PR removes the rehearsal, so it also removes the delegation: the driver-side delegated rehearsal, the candidate-side `update rehearse` command, the rehearsal contract and the marker (−1,803 lines of openclaw#197922). - **No released version depends on it.** `git tag --contains e32cb9a` lists only `release-publish/*` cuts of 2026.11.3; `v2026.11.3` (npm `latest`) and `v2026.11.5-beta.1..3` do not contain it, and `npm view [email protected] openclaw.updateRehearsalProtocol` is empty. Per AGENTS.md, main and beta are not shipped contracts. - **Updaters built from main since openclaw#197922 fall back.** When the target lacks the marker, they run their own rehearsal (the path openclaw#197922 kept for unsupported targets). Proven below: a main updater (merge base, which contains openclaw#197922) updated to this branch, rehearsed it itself and finished `ok`. ### Rollback no longer runs without the retained runtime Runtime retention copies the running updater so its lazy imports and workers keep working after the package or checkout is replaced. Since openclaw#185178 a retention failure only logged "continuing update without a verified retained rollback runtime". With the canary gone, rollback is the only safety net, and it loads code from that retained runtime. Reproduced (package install, retention fault injected, then a migration that commits and a Doctor that fails): Doctor committed the migration, `database rollback` failed with `Cannot find module …/dist/update-candidate-state-<hash>.mjs`, the update ended `state-migrated-no-rollback` and **left the target release active**. The same faults without the retention failure roll back the databases and the package. Chosen behavior: **every retention failure now stops the update before staging or activation**, with "Could not retain the running updater (<reason>). The update stopped before changing the installation; retry it." Cancellation and uncertain subprocess cleanup still propagate unchanged. - Least complex: it deletes openclaw#185178's fallback (−26 production lines) instead of making rollback independent of the copy, which would mean preloading every lazy rollback import and pinning every worker entry, a second retention mechanism. - Measured cost on large installs: openclaw#185178 was motivated by a worker output cap that openclaw#184958 has since fixed. Peanutto (183k entries, ~4 GB retained) completed retention on all 17 updates since 2026-10-27, so this refusal would not have fired once. The remaining causes are a source file changing during the copy (retry) and a host-owned plugin link (documented fix in `docs/cli/update.md#runtime-retention-failures`). - Retention itself goes away with Git releases in a later slice; this does not redesign it. ### What was removed - Driver: `update-candidate-canary.ts`, `update-candidate-canary-commands.ts`, canary-only lint/failure/config helpers, Git startup-runtime selection, the validation wrapper scaffolding, and openclaw#197922's delegated rehearsal. - Candidate: `update rehearse`, `update-rehearsal-contract.ts`, the `updateRehearsalProtocol` marker. - openclaw#185178's retention fallback. - Tests: the canary suites and their test-support, and the delegated-rehearsal tests. Against the merge base: **production +383 / −2,198** (net −1,815), tests +648 / −6,140, docs +111 / −134, config −18. ### What stays, and why Released updaters, including stable 2026.11.3, still rehearse whatever candidate they install, using **the candidate's** state-copy worker, rehearsal-aware Doctor and lint, `update-candidate-rehearsal`/`-snapshot`, plugin-tree copy and `--update-canary` startup progress. Deleting those would break upgrades from every shipped version, so the candidate side stays until no supported update source runs the canary. Historical step identities (`candidate-doctor` etc.) stay so existing `update_runs` history renders. ## Review findings - **Config-convergence test** (`update-cli.config-convergence.test.ts`): the stateless check no longer receives config, so the test now asserts what the check does receive at its boundary, the owning profile's `stateDir` and `OPENCLAW_CONFIG_PATH`, keeps an explicit `candidate-recovery` refusal through the result contract, and asserts authored config bytes are unchanged. - **Data-model compatibility:** no schema, config or stored-data shape changes. Existing state from 2026.11.3 (state schema 22 → 40) and Peanutto's production databases (3.3 GB) load through the real update path below. - **Boot-writes test:** replaced by the `activated-boot` settlement-and-restore case in the database rollback matrix; it fails when boot-write adoption is disabled. ## Evidence Harness: real `openclaw update --yes --no-restart --json --tag <packed tarball>` from an npm-global install on isolated `env -i` state (cloned per run with `cp -c`), run on mbp-m5, three at a time. Base = merge base `6b9404d` with inert env-gated faults; head = this branch on the same base (`8065ed6`; the "with fix" rows use `097a6ba`, the retention fix before its refusal wording). The merged head `97ca0de` is that change with current `main` merged in. Fault targets are the same tarball plus env-gated faults: `gateway-crash` (Gateway throws at boot), `plugin-crash` (acpx throws at load), `migration-broken` (state v41 adds a column then throws), `committed-migration` (v41 commits, then Doctor throws), `retention` (runtime retention throws after the native helper is bound). "Gateway after" = a fresh Gateway on the post-update state reaches `/readyz`. Schema = state `user_version` after the run (base 40, fault target 41). | Case | main (canary) | this PR | | --- | --- | --- | | clean update | ok; validating 65 s (retention 18, candidate Doctor 7, candidate Gateway 6) | ok; validating 52 s (retention 32, `candidate-recovery` + admission ~20); **no candidate Doctor/Gateway phase** | | gateway crash | refused at `candidate-gateway-startup`; base kept | activated, `activated-gateway-startup` failed → **database rollback + package rollback**; base active; Gateway after ok | | committed migration + failed Doctor | refused at `candidate-doctor` | v41 committed, Doctor failed → **database rollback (state back to v40) + package rollback**; base active; Gateway after ok | | broken migration | refused at `candidate-doctor` | Doctor failed → database + package rollback; state v40; Gateway after ok | | plugin crash | ok (plugin failure recorded) | ok (plugin failure recorded) | | retention failure + gateway crash | refused at `candidate-gateway-startup` | before fix: rolled back; **with fix: refused before activation** | | retention failure + committed migration | refused at `candidate-doctor` | before fix: **`Cannot find module`, rollback failed, `state-migrated-no-rollback`, target left active, state stuck at v41**; with fix: refused before staging, base active, state v40, Gateway after ok | | 2026.11.3 → head | — | ok (2026.11.3's own canary against the kept candidate surfaces); state schema 22 → 40; Gateway after ok | | main updater (contains openclaw#197922) → head | — | target lacks the marker → updater ran its own rehearsal → ok; Gateway after ok | | Peanutto-shaped clean update (3.28 GB SQLite: Peanutto's state + 3.1 GB agent DB, its plugin set) | ok; **validating 236 s** (retention 50, candidate snapshot 47, candidate Doctor 64, lint 22, candidate Gateway 27); update 949 s | ok; **validating 68 s** (retention 50, `candidate-recovery` + admission ~18); update 839 s; Gateway after ok | Peanutto-shaped: the validating phase drops by **168 s** (236 → 68 s), all of it the four rehearsal steps (160 s). Those two runs overlapped each other, so their activation and total times are not a clean comparison; small-state wall times are likewise not comparable across rows (runs overlapped three at a time). The ~950 s mean saving estimated from Peanutto's live history (where the candidate Doctor took 200–670 s) is unmeasured here. Tests: 31 touched update test files plus the admission test pass (mbp-m5, `ocx test`, 957 s). The retention suites pass (50); 7 of them fail on the previous head because retention resolved instead of stopping. `pnpm tsgo:core`, `pnpm check:test-types`, oxfmt clean. oxlint reports one inherited `max-lines` on `update-command-service-maintenance.ts` (750 lines here, 756 on main). **Exact-head check on `97ca0de`** (same harness, run after the last merge of `main`): 2026.11.3 → head ok, schema 22 → 40, Gateway after ok (398 s); clean head update ok, schema unchanged, Gateway after ok (383 s); Peanutto-shaped clean update ok, Gateway after ok (738 s). ### CI notes - `update-cli.candidate-admission.test.ts` > "blocks package updates when the target requires a newer Node runtime" still asserted the multi-line diagnostic that `4281497` moved into the saved report; it fails the same way on main `7e26d771`, whose changed-lane CI does not select this suite. Updated to assert the one-line refusal and the recovery steps. - `extensions/a2a/src/inbound.test.ts` (interleaved same-context replies) failed in an earlier run of this PR and fails locally on main `7e26d771` too; this PR does not touch that plugin. The branch now includes main through openclaw#199736, the fix for the earlier memory-core `manager-shadow-write.test.ts` failure. - `src/gateway/github-pr-workspace-preparation.test.ts` > "recovers an interrupted initial exact install (bound runtime=true)" (`checks-node-changed-compact-large-22`) fails 3/3 locally on both this head `97ca0de5` and main `ec3e3d7e`, also fails on main `9a5e62f0`, and failed again on the rerun of the failed job (run 43763967024, attempt 2), with the same `expect(runtime?.isPaused()).toBe(true)` assertion at line 884. This PR does not touch `src/gateway`. ## Accepted edge cases - Problems only Doctor or Gateway startup reveal are found after activation. The update rolls back the release and the pre-activation database baseline instead of refusing first: one activation/rollback cycle (with restart, a brief Gateway outage) in exchange for skipping the rehearsal on every successful update. - `--no-restart` with a Gateway still running the old code: the activated release is not booted (reported), as in openclaw#197851. - External supervisors using `update preflight` get less proof (`coverage: "candidate-runtime"`) and must verify readiness after activation. - A retention failure now stops the update; the user retries or fixes the named cause. ## Gaps - `checks-fast-baseline-ratchets` on `dffdf91` reported `database-worker`/`database-dialect` failures after a runner shutdown signal. Both ratchets pass locally against the merge base (`SQLite T1 live calls: 166 -> 166`; dialect: no construct-group growth). - The Git-checkout path was not re-run in this round (the m5 repository was mid-repack). Retention and rollback share one owner across package and Git installs, and the earlier Git runs are in this PR's history. - The fixed refusal message was proven in unit tests; the E2E refusal ran on the fix before the message wording was added. - The main updater at the merge base refuses a relocated state directory in its canary snapshot ("Restored client credentials do not match the captured shared database": the credential receipt pins the shared database inode). The harness repoints the receipt after each `cp -c`; head never runs that snapshot. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #145252
What Problem This Solves
A fix to the pre-update rehearsal cannot help the update that needs it. The installed updater runs its own copy of the state snapshot, Doctor rehearsal, test Gateway, and their time budgets before the new release takes over, so a corrected check only reaches users one update later.
User Impact
User impact: once an installation runs a release with this change, later releases rehearse themselves, so rehearsal fixes and budget changes take effect on the update that ships them. A successful update otherwise looks the same, apart from one output line saying the candidate ran its own checks.
openclaw.updateRehearsalProtocol: 1, and a hiddenopenclaw update rehearsecommand. The marker is a protocol addition. A maintainer accepted it on November 13, 2026 (decision 5 in docs: propose a linked package root and staged candidate handoff for updates #197949).Why This Change Was Made
After staging, the updater runs the candidate's
openclaw update rehearse --request <file>in place of its own rehearsal. The candidate receives the config source the updater resolved in a private0600file, holds no update authority, and touches copied state only.A candidate refusal stays binding, and the candidate refuses only when its Doctor rehearsal or its private Gateway fails on the copied state. A pass grants nothing: the installed updater still owns drain, activation, verification, and rollback.
Two existing guarantees carry across the process boundary:
One rule is new with this protocol: a receipt is answered or the rehearsal ends. The candidate's heartbeat would otherwise hide a wait on a receipt the updater never read. The updater closes the candidate's stdin and takes the rehearsal back when it receives an event line it cannot read, including one its line reader dropped for length. The candidate does not send a receipt longer than that reader accepts. An unknown event that carries no receipt number is still ignored, so protocol 1 can gain events. After the updater is gone, the candidate still removes its own state copy.
Tradeoffs worth a reviewer's attention:
--timeoutstill ends it.updatePreflightProtocoland the external-supervisorupdate preflightcommand are unchanged.Evidence
All Docker runs used
scripts/e2e/published-driver-update-docker.shlocally (linux/arm64) with packages built byscripts/package-openclaw-for-docker.mjs.Both sides marker-aware, packaged. This run predates the rebase onto
a83f743;git range-diffshows both commits unchanged by it. The installed updater was this branch at27f3c52, and the candidate was a second build of the same tree with a different build identity. The harness is written for a published updater, so I seeded this build through its driver seed cache, using the same in-containernpm install --global --prefixstep that CI uses to seed a published release.The label says "published" because that is the harness's wording; the updater was the local build. The update's output contains
The candidate release ran its own update checks.once and no fallback line. All eight rehearsal steps were relayed with exit 0, the run finishedsucceeded, and the harness's durable and incognito session checks before and after the update passed.Published updaters to this change. On the pushed head
758582e, one cell per published updater, plus two control cells with unmodifiedmainata83f743as the candidate:post-update-failedmainmainEach published updater ran its own rehearsal, as designed:
The candidate release ran its own update checks.appears in no output of these cells.The
2026.9.9failure is not caused by this change. Both candidates fail at the same step after the package swap, with the same message:In both runs the new Gateway serves the candidate version with
readyz: true, the run is recorded as failed, and rollback is not attempted (state-migrated-no-rollback). The cause is not established.Rerun after the third commit. The same five published-updater cells, with the candidate built from
b285a37(the third commit plus a merge ofmain):The candidate release ran its own update checks.appears in no output of these cells. The machine was doing other work during this run, so these timings are not comparable with the first table.The two-sided cell was rerun as well. The installed updater was the
b285a37build, seeded the same way as before, and the candidate was the next head,b3d920d(one further merge ofmain):The update's output contains
The candidate release ran its own update checks.once and no fallback line. All eight candidate steps were relayed with exit 0, includingcandidate-state-cleanup, the run finishedsucceeded, and the session checks before and after passed. Recorded steps came to 188.8 s, of which the candidate-owned rehearsal was 25.7 s.Focused tests. Before the rebase, 174 tests in 8 files passed. On
758582e, the five test files this change touches pass (58 tests). On26150c4, those five files plusupdate-candidate-canary.test.tsandupdate-candidate-canary.exit.process.test.tspass (169 tests in 7 files). Four cases use a real child process: acceptance, fallback, a refused receipt stopping the candidate before its announced check, and the updater stopping a check process that a crashed candidate left running. I removed each guarded behavior in turn (exit-status and document agreement, commit-before-answer, the refused-receipt stop, silence detection, the inconclusive-outcome rule, and process custody) and confirmed tests fail each time.Checks. On
758582e:pnpm tsgo:all, the mock-export ratchet, and the test-line ratchet pass. On26150c4:pnpm tsgo:all, the test-line ratchet, andoxlint --type-awareand the format check on the files that commit changes pass. The mock-export ratchet was not rerun.pnpm check:changedon the first commit reported two failures that this change does not cause:max-lineslint errors in files it does not touch, and the Plugin SDK surface budget.Review. An autoreview pass (Codex, P0 and P1 scope) found that the candidate treated a timed-out check or failed state copy as a binding refusal; fixed in the first commit. ClawSweeper then found the two lifecycle gaps described above; the second commit fixes both.
ClawSweeper's re-review of
758582efound three more defects, and26150c4fixes them:CommandProcessCustodyinterface.Each new test failed before its fix. For the cases that reproduce the hang, the failure was the test timing out. I also confirmed the real canary reports a stalled Gateway the way the fixture does:
runtime-verification-failed, with thecandidate-gateway-startupstep attermination: "timeout".An independent reviewer agent read the fix before it was committed. It found that my first version of the stall rule voided genuine refusals, and that a candidate could not remove its state copy once the updater stopped answering, because the cleanup waits on a progress receipt. Both are fixed in
26150c4, with tests. The autoreview helper could not run for the third commit, so that commit has not had an autoreview pass. A maintainer accepted the reviewer-agent pass together with the ClawSweeper re-review in its place.Gaps.
stable.b285a37and were not repeated after the last merge ofmain.b285a37andb3d920dfailed three tests that this change does not cause. They are fixed onmainby test(qa): two QA lab end-to-end tests fail on main #198417 and test(codex): worker command test fails on fork pull requests #198418, which this branch now includes. Each failed the same way on unmodifiedmainat858b5b0:telegram-model-picker-prepared-gateway.e2e.test.ts: "Could not resolve built prepared-model-runtime- module".gateway-timeout-recovery-subagent.e2e.test.ts: a child completion delivery list does not match.extensions/codex/src/node-app-server.runtime.test.ts: a workercommand/execreturns exit 1 with empty output. This one passes on macOS and fails on Linux; I comparedmainand this branch in anode:24.20.0-bookwormarm64 container, which is not the CI runner.post-activation doctor inspectionsexits 1 in every passing cell, including themaincontrol. Its JSON is identical between the branch andmainruns with2026.11.3apart from duration and a temporary directory name. It reports 12infofindings and no errors or warnings.Test notes
config/test-lines-allocations/update-candidate-rehearsal.txtfor 450 lines (319 before the third commit). A maintainer accepted the 450-line allocation on November 13, 2026. The excess covers the updater-side fallback table (nine invalid-result shapes), receipt acknowledgement ordering, liveness and cancellation timing, inconclusive candidate outcomes, the real-subprocess cases, and the regressions for the three re-review defects with their controls.update-command-preflight.test.tsandupdate-candidate-delegated-rehearsal.test.tsin full again. No case was removed. The stalled-Gateway case joined the existing inconclusive-outcome table, the state-copy removal check joined the existing refused-receipt table, two cases that shared a title now have distinct titles, and the fake-timer restore moved from the end of one test intoafterEach.update-candidate-delegated-rehearsal.test.ts(new),update-candidate-canary-process.test.ts,update-command-preflight.test.ts,run-main-update-admission.test.ts, andupdate-command-candidate-validation.test.ts. No existing case was removed. Inrun-main-update-admission.test.ts, two inline per-command conditionals became one lookup table.