Skip to content

feat(update): new releases run their own pre-update rehearsal - #197922

Merged
fuller-stack-dev merged 8 commits into
openclaw:mainfrom
fuller-stack-dev:feat/update-candidate-rehearsal
Nov 14, 2026
Merged

fuller-stack-dev merged 8 commits into
openclaw:mainfrom
fuller-stack-dev:feat/update-candidate-rehearsal

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

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.

  • Updates from releases published before this change behave as they do today. Those updaters ignore the new marker.
  • This adds a package marker, openclaw.updateRehearsalProtocol: 1, and a hidden openclaw update rehearse command. 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).
  • If the candidate's rehearsal crashes, goes silent, times out a check, stalls its private Gateway before it is ready, fails its state copy, sends a report the updater cannot read, or returns an invalid result, the updater names the reason in its output and runs its own rehearsal. The worst case is that the rehearsal runs twice.

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 private 0600 file, 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:

  • Committed progress before forward work. The candidate sends each progress and step receipt, then waits for the updater's answer on its stdin before it continues. The updater answers only after its ledger write has completed. A refused receipt or a lost updater stops the candidate before the announced check. This keeps the contract from fix(update): await progress receipts before advancing commands #162098.
  • Custody of check processes. Each rehearsal check runs in its own process group, and so does each command that inventories or copies state. Stopping the candidate does not reach them. 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.

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.

Update Behavior
Any published updater to a release with this change Unchanged. The old updater runs its own rehearsal.
Updater with this change to a candidate with the marker The candidate rehearses itself and the updater applies its verdict.
Updater with this change to a target without the marker The updater runs its own rehearsal. This is the downgrade case.
Candidate rehearsal ends without a usable result The updater logs the reason and runs its own rehearsal.

Tradeoffs worth a reviewer's attention:

  • The updater does not impose a work deadline on the candidate. It detects a dead or blocked candidate by silence: the candidate sends a heartbeat every 15 seconds, and 15 minutes without any output returns the rehearsal to the updater. An explicit --timeout still ends it.
  • On cancellation the candidate gets five minutes to remove its temporary state copies before it is forced to stop, matching the existing cleanup allowance.
  • The immutable activation path keeps the updater's own rehearsal. updatePreflightProtocol and the external-supervisor update preflight command are unchanged.

Evidence

All Docker runs used scripts/e2e/published-driver-update-docker.sh locally (linux/arm64) with packages built by scripts/package-openclaw-for-docker.mjs.

Both sides marker-aware, packaged. This run predates the rebase onto a83f743; git range-diff shows both commits unchanged by it. The installed updater was this branch at 27f3c52, 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-container npm install --global --prefix step that CI uses to seed a published release.

PASS published 2026.11.3 → candidate 2026.11.3 (c1c7f08eb4e854981e572b287be391aaf9fac7b2): finished, readyz=200, running version verified

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 finished succeeded, 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 unmodified main at a83f743 as the candidate:

Candidate Published updater Result Recorded steps Updater's own rehearsal
this branch 2026.11.3 PASS, Gateway verified 139.1 s 21.0 s
this branch 2026.11.2 PASS, Gateway verified 138.0 s 21.3 s
this branch 2026.10.9 PASS, Gateway verified 171.4 s 32.7 s
this branch 2026.10.1 PASS, Gateway verified 168.1 s 29.2 s
this branch 2026.9.9 FAIL, post-update-failed 178.3 s 24.2 s
main 2026.11.3 PASS, Gateway verified 141.3 s 21.9 s
main 2026.9.9 FAIL, same step and message 180.0 s 23.8 s

Each 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.9 failure is not caused by this change. Both candidates fail at the same step after the package swap, with the same message:

openclaw doctor --fix: Shared state migration did not finish: expected schema 40, found missing.

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 of main):

Candidate Published updater Result Recorded steps Updater's own rehearsal
this branch 2026.11.3 PASS, Gateway verified 170.5 s 25.6 s
this branch 2026.11.2 PASS, Gateway verified 168.9 s 26.1 s
this branch 2026.10.9 PASS, Gateway verified 204.0 s 39.6 s
this branch 2026.10.1 PASS, Gateway verified 199.6 s 35.3 s
this branch 2026.9.9 FAIL, same step and message as before 203.6 s 28.3 s

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 b285a37 build, seeded the same way as before, and the candidate was the next head, b3d920d (one further merge of main):

PASS published 2026.11.3 → candidate 2026.11.3 (b3d920d032670532f6b50699997c6f3a3cba8d50): finished, readyz=200, running version verified

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, including candidate-state-cleanup, the run finished succeeded, 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). On 26150c4, those five files plus update-candidate-canary.test.ts and update-candidate-canary.exit.process.test.ts pass (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. On 26150c4: pnpm tsgo:all, the test-line ratchet, and oxlint --type-aware and the format check on the files that commit changes pass. The mock-export ratchet was not rerun. pnpm check:changed on the first commit reported two failures that this change does not cause: max-lines lint 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 758582e found three more defects, and 26150c4 fixes them:

  • A candidate Gateway that stalled before it was ready was a binding refusal. It is now inconclusive. Only the Gateway startup step counts, so a timed-out exit or cleanup elsewhere leaves a genuine refusal standing; three control cases cover that.
  • A receipt the updater could not parse went unanswered, and the candidate waited behind its heartbeat. The trigger ClawSweeper named, a cleanup progress line longer than the ledger's text bound, is now accepted and bounded the way the ledger bounds it. Any receipt that is still unreadable ends the rehearsal.
  • State inventory and copy commands were not in the updater's custody. They are now reported through the existing CommandProcessCustody interface.

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 the candidate-gateway-startup step at termination: "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.

  • Windows and macOS service managers were not exercised, and process custody after a candidate crash is untested on Windows.
  • No extended-stable updater was run. The harness accepts only updaters that classify as stable.
  • The Docker cells exercise the passing path only. The third commit's failure paths (a stalled Gateway, an unreadable or oversized receipt, a candidate killed during its state copy, and a lost updater) are covered by unit tests and real-subprocess tests, not by a Docker cell.
  • The published-updater cells ran on b285a37 and were not repeated after the last merge of main.
  • CI on b285a37 and b3d920d failed three tests that this change does not cause. They are fixed on main by 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 unmodified main at 858b5b0:
    • 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 worker command/exec returns exit 1 with empty output. This one passes on macOS and fails on Linux; I compared main and this branch in a node:24.20.0-bookworm arm64 container, which is not the CI runner.
  • The stopping of a state-copy command after a candidate crash is covered in two halves: the candidate reports a real command's process, and the updater stops reported processes. No single test kills a candidate during a real state copy.
  • The advisory step post-activation doctor inspections exits 1 in every passing cell, including the main control. Its JSON is identical between the branch and main runs with 2026.11.3 apart from duration and a temporary directory name. It reports 12 info findings and no errors or warnings.
Test notes
  • Net test lines are +850, above the 400-line allowance, so this adds config/test-lines-allocations/update-candidate-rehearsal.txt for 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.
  • In the third commit I read update-command-preflight.test.ts and update-candidate-delegated-rehearsal.test.ts in 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 into afterEach.
  • Touched test files, each read in full: update-candidate-delegated-rehearsal.test.ts (new), update-candidate-canary-process.test.ts, update-command-preflight.test.ts, run-main-update-admission.test.ts, and update-command-candidate-validation.test.ts. No existing case was removed. In run-main-update-admission.test.ts, two inline per-command conditionals became one lookup table.
  • Step timings from the two-sided cell's update run, small fixture state: 177 s of recorded steps in total, of which the candidate-owned rehearsal was 25.5 s.

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: XL labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The installed updater runs snapshot, Doctor, and Gateway checks using its older logic and budgets.
  • After: The candidate runs those checks using its own implementation, while the installed updater retains activation and rollback.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch resolves the earlier findings and has meaningful packaged proof, with limited confidence in the newly repaired failure scenarios.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: A release's corrected rehearsal logic cannot help its own installation when the older installed updater still runs those checks.
Reason: Maintainer-authored direction addresses a documented limitation while preserving installed activation ownership and compatibility with older releases.

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
Reviewed head: b285a37a6188f2b38cf9ae97999da35f9ce9094c

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted production-boundary fault traces after the repairs showing stalled-startup and unreadable-receipt fallback, and termination of a real snapshot command abandoned by a crashed candidate.
Agent review details

How this fits together

Candidate 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]
Loading

Technical review

Best 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

  • Installed-owned rehearsal and budgets changes intended behavior with a stated reason (fix(update): validate candidates before stopping the Gateway #138839: Validate staged candidates against private state before stopping the serving Gateway; fix(update): preserve check budgets after slow candidate snapshots #186139 later preserved independent state-sized check budgets.)
  • Committed progress ordering keeps the original intent (f833bb4: Await committed progress receipts before commands or completion reporting advance; the new acknowledgment transport retains that invariant.)
  • Candidate inspection environment keeps the original intent (acffa76: Inspect the serving profile without inheriting update or service continuation authority; the shared environment extraction preserves that policy.)
  • External supervisor preflight keeps the original intent (0a2bbda: Provide isolated readiness inspection without granting mutable update authority; the shared context extraction retains the existing protocol and coverage.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit f833bb4 adds src/cli/update-cli/update-command-candidate-validation.ts:29 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f833bb42560b; files: src/cli/update-cli/update-command-candidate-validation.ts)
  • Vincent Koc: Raw commit 8f2190b adds src/cli/update-cli/update-command-candidate-validation.ts:79 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8f2190bb63cc; files: src/cli/update-cli/update-command-candidate-validation.ts)
  • Jason (Json): Raw commit cb156d0 adds src/infra/update-candidate-admission.ts:66 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cb156d027f02; files: src/infra/update-candidate-admission.ts)

PR surface

Source +798, Tests +850, Docs +57, Config +1, Other +9. Total +1715 across 19 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 10 870 72 +798
Tests 5 866 16 +850
Docs 2 57 0 +57
Config 1 1 0 +1
Generated 0 0 0 0
Other 1 9 0 +9
Total 19 1803 88 +1715

Preflight source

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

Review metrics

Metric Value Why it matters
Production versus tests Production +798 net lines; tests +850 net lines Growth supplies the two-sided transport, receipt ordering, fallback, and process custody around the existing check engine; tests cover distinct protocol and lifecycle failures.
Protocol surface 1 package marker, 1 hidden command, 1 --request flag Adds an internal negotiated protocol without persisted operator settings.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove merge-risk: 🚨 availability: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Useful update reliability improvement that removes installed-driver lag from subsequent rehearsal fixes.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

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

Workflow

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

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-12T21:36:22.786Z sha 0a48957362f295317650cca93b7bb9f0d9f8f299 :: needs changes before merge. :: [P2] Await committed progress receipts before advancing candidate checks | [P2] Include nested canary processes in delegated rehearsal cleanup
  • reviewed 2026-11-13T02:27:22.976Z sha 758582e :: needs changes before merge. :: [P2] Return Gateway readiness timeouts to the installed rehearsal | [P2] End delegation when a protocol receipt cannot be parsed | [P2] Include snapshot subprocesses in delegated process custody

Reviewed November 13, 2026, 11:55 AM ET / 16:55 UTC (Revision 3).

@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 12, 2026
…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.
@fuller-stack-dev
fuller-stack-dev force-pushed the feat/update-candidate-rehearsal branch from 27f3c52 to 758582e Compare November 13, 2026 02:20
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 13, 2026
@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review November 13, 2026 03:04
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.
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 13, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 3ab80ab into openclaw:main Nov 14, 2026
429 of 432 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the feat/update-candidate-rehearsal branch November 14, 2026 02:10
fuller-stack-dev added a commit to fuller-stack-dev/openclaw that referenced this pull request Nov 14, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 14, 2026
…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.
obviyus added a commit that referenced this pull request Nov 15, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant