Skip to content

fix: check a recorded data-at-risk mark before repair or the next update acts on it - #201668

Merged
fuller-stack-dev merged 40 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-verify-data-at-risk-marks
Nov 22, 2026
Merged

fuller-stack-dev merged 40 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-verify-data-at-risk-marks

Conversation

@fuller-stack-dev

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

Copy link
Copy Markdown
Member

What Problem This Solves

When an update step fails after it may have touched state, the updater records a "data at risk" mark on that run, for example rollback-state-unverified. Most of these marks come from a failed read or a timeout, not from real damage. The published 2026.10.33 and 2026.11.5 updaters keep writing them, and nothing ever checked a mark:

  • The update report said "Keep the Gateway stopped" even when the Gateway was running.
  • openclaw update repair then refused to start the Gateway for that run every time, naming only openclaw gateway status --deep.
  • The next openclaw update ignored the mark completely. When the installation was already current, it exited 0 without a word.

User Impact

User impact: a recorded data-at-risk mark is now checked against the state on disk, without the user having to run anything first.

  • State consistent: the next plain openclaw update prints one line, resolves the mark and continues. That includes automatic updates and updates that find the installation already current. openclaw update repair does the same and also starts a Gateway the marked update stopped.
  • Real inconsistency: the update or repair still refuses and changes nothing. It says what is wrong and whether the Gateway is running, records the finding on the run, and names openclaw triage first and the manual command last.
  • Killed-update refusals from fix: keep a doubtful killed-update recovery on the repair path #201361 now also name openclaw triage before the manual command.

Why This Change Was Made

  • One verification owner (src/infra/update-data-at-risk.ts) answers "is the state on disk consistent with the installed version?".
    • It reuses the runtime schema preflight: a child process reads the database in one native read transaction, with no copy, so it is safe beside a live writer. It also uses the existing recovery-admission readers.
    • Findings: a database newer than the installed build, a database behind it (unfinished migration), unfinished update recovery, an interrupted restore directory, retained .migrated-<run> files from the marked run's database rollback (state may be only partly restored), or unreadable state (unverifiable).
    • An active-mutation mark (Doctor writers that may still be alive) is not resolved from schemas alone. Before Doctor it is deferred to Doctor. After the run's own Doctor maintenance has held exclusive state and agent ownership, no earlier writer can still hold the state, and the schema check decides.
  • History is not rewritten. A consistent verification records the step finalize:data-at-risk-verified:<marked run> on the run that checked. Readers in src/infra/update-run-data-at-risk.ts treat "marked, later verified" as resolved. No new field, schema or protocol. Published updaters store the mark as the finalize:data-at-risk step, which the current reader already decodes, so their marks are handled the same way.
  • Repair. Before it touches the Gateway, repair verifies every unverified mark in recent history, not only the run that stopped the Gateway. Git release updates and refusals before mutation never stop it. Any inconsistent finding keeps every Gateway as it is, whichever run stopped it. The managed-handoff interrupted-update path reads the same receipt before it restarts.
  • Next update. Admission runs the same check after foreground admission and before it creates its run, so already-current updates are covered too.
    • Consistent: one line, plus receipts on the new run.
    • Newer state or unreadable: a warning, and the update continues, because its own schema checks still guard activation and updating is the fix for newer state.
    • Anything else: refusal. The refusal happens after the run exists, so the finding is recorded for the agent openclaw triage opens.
  • Messages.
    • Update failure guidance states whether the Gateway was observed running or stopped, which version is installed and whether the update was rolled back, and says the mark is unverified.
    • With the Gateway running, it says nothing is needed now. With it stopped, it names repair to bring it back.
    • Refusals put the next steps before the finding, so the recorded warning's 500-character limit cannot cut them off.
    • Update-path guidance that asks you to stop the managed Gateway names openclaw gateway stop --force, because a non-interactive shell refuses the bare command. That covers the repair, status and maintenance-error messages and their docs; fix: let updates finish when plugins change no config and openclaw.json is read-only #201331 changed one more line in update-recovery-guidance.ts.
Genuine refusals kept, and their negative controls
  • Database newer than the installed version. Repair refuses and leaves the Gateway as it was (owner test with real SQLite; Docker cell inconsistent-repair). The next update warns and continues, and its target schema check still refuses a target that cannot open that state.
  • Unfinished migration (database behind the installed version): owner test with real SQLite. The next update refuses, and the finding is recorded on the refused run.
  • Unfinished update recovery or an interrupted restore directory: owner tests with real fixtures. Repair and update admission already refuse these first.
  • Partial database rollback (the marked run left .migrated-<run> files): owner test. Another run's leftover does not count.
  • active-mutation: never resolved by a schema check alone. It is checked only after the run's own Doctor maintenance has held exclusive state ownership.
  • Unreadable state or an unlistable state directory: reported as unverifiable, never as consistent or as an interrupted restore.

Update behavior for published updaters

The installed updater runs first and cannot be patched:

  • Marks written by 2026.10.33, 2026.11.5 and main are read through the same finalize:data-at-risk step.
  • A published updater still writes false marks; P0-0 and the catch-alls in the audit belong to other changes.
  • When the state is consistent, the first update or repair run by a CLI containing this change resolves the mark without user action.
  • A published Gateway's managed-update helper still logs its old text on exit 79. The helper this change ships logs "gateway left stopped: data at risk (...) recorded and not yet verified; run openclaw update repair to verify the state and restart the gateway".

Steps still left to a person

  • A Gateway left stopped by a marked update when no further update or repair runs. The Gateway is down, so no Gateway-driven path can run. The next openclaw update (or an automatic one, if the user re-enables it) resolves the mark; starting the Gateway takes repair. Agent route: openclaw triage. Follow-up: verify the mark inside the failing update's own recovery before it decides the restart.
  • Managed handoff exit 79 (P1-4). Not changed; see the design below.
  • A real inconsistency. By definition it needs a decision: finish a migration, restore a backup, or install a newer build. The message leads with openclaw triage, and the finding is recorded on the run.
  • An interrupted restore directory or partial rollback leftovers. No command finishes these safely. The existing docs procedure applies, and the agent gets the file paths.
  • active-mutation while the earlier Doctor writers are still alive. Doctor's maintenance admission waits for them and refuses while they hold the state. Once they exit, one repair or update resolves the mark.
  • An unreadable agent database registry. Rollback leftovers beside agent databases cannot be looked for, so update and repair refuse and name openclaw triage. Retrying once the registry is readable resolves it.
  • openclaw update repair in Git release mode. It refuses as on main and leaves the service untouched; the message names openclaw triage. A plain openclaw update still resolves the mark, as the green-repeat cell shows.

Follow-ups

  • Verdict inside Doctor restoration admission. After a mark was deferred to Doctor, Doctor restores a Gateway it parked before the post-Doctor recheck runs. Moving the check into Doctor's restoration admission closes that gap. Owner: Doctor maintenance restoration.

  • Unresolved-mark lookup independent of the 100-row history window.

  • Git release-mode repair ownership belongs with fix: finish a half-switched Git update instead of reporting it current #201538 (fix/update-git-release-running-build-from-evidence). Two pieces are needed:

    • The ownership change this PR reverted, which accepts openclaw-launcher.mjs services whose release is a linked worktree of this checkout.
    • The Doctor stale-Gateway check, which must compare the running Gateway with the active release's build, not the checkout's.

    The landing review's two findings that fix: finish a half-switched Git update instead of reporting it current #201538 must address are recorded with the diff in the release-mode worker's notes: the stale-build stop, and sibling git worktree checkouts that share a common Git directory.

P1-4 design (managed handoff exit 79)

  • Why it diverges: the direct CLI restarts a stopped Gateway after a failure with no data risk (update-command-failure-recovery.ts). Under the handoff, the helper stopped the service, not the updater, so preManagedServiceStop.stopped is false in the child. The updater then reports serviceRestartSafe:false, and the helper exits 79 and leaves the Gateway down.
  • Fix that keeps the exit-79 contract: a candidate updater running under OPENCLAW_UPDATE_RUN_HANDOFF=1 could take the helper's recorded service-stop as its own stop evidence. It would then run the same restart and verification and report service: "healthy" with serviceRestartSafe: true. The helper already restores nothing in that case and exits non-79.
  • Why it is left out: it only helps once the installed updater contains it, and it needs its own red and green handoff proof. It is left for a follow-up.

Evidence

Behavior checked, on the exact head unless noted. Base for red is origin/main f4b42cc9ae7, or f5b717d232f where stated.

  • Owner (real SQLite), src/infra/update-data-at-risk.test.ts:
    • Current state is consistent beside an open BEGIN IMMEDIATE writer, and the in-process copy path (prepareSqliteReadOnlyLocation) is never called.
    • Newer schema, behind schema, unfinished recovery, interrupted restore and partial-rollback leftovers are inconsistent.
    • Unreadable state and an unlistable directory are unverifiable; active-mutation is never resolved.
    • Red first: the no-copy and unlistable-directory cases failed on the first implementation, which used the maintenance copy path and labeled listing errors as an interrupted restore, then passed.
  • Repair (update-repair-service.test.ts, real ledger and finalization):
    • A false mark with the Gateway stopped is verified, the receipt recorded, and the Gateway started.
    • The same with the Gateway running is verified, not restarted.
    • A mark on a run that never stopped the Gateway is verified once; a second repair does not check it again.
    • Inconsistent and unverifiable verdicts keep the Gateway as it was and print the exact refusal. One case uses a realistic UUID and path to prove the next steps survive the 500-character limit; another reports a running Gateway's version.
    • Reviewer-found regression: a Gateway another run stopped stays down when a later mark is inconsistent.
  • Next update (update-command-run.test.ts):
    • A consistent mark prints one line and records the receipt on the new run, and a later update does not check it again.
    • An unfinished migration refuses and records the finding on the refused run.
    • Newer state warns and continues.
  • Guidance (update-recovery-guidance.test.ts): exact text for running, stopped, rolled-back, failed-rollback and unobserved Gateways. Red on base f5b717d232f (11 cases fail), green on head.
  • Killed-update refusals (update-command-killed-run-refusals.process.test.ts): every refusal names the agent route before the manual command.
  • Timeout attribution. Two update-command-database-rollback cases and one update-repair-cancellation case timed out at 120 s in a 15-file local batch at load ~30. Run alone on the same machine:
    • The git/git-edited cases took 69 s/54 s on head against 71 s/59 s on base, and printed no data-at-risk verification.
    • update-repair-cancellation passed 7/7 on head.
    • Base failed a different case in that file in its own loaded batch. The timeouts were machine load, not added cost.
  • End to end: the Docker cells below. The package and Git release-mode green cells ran on 787cf1befff. The commits after it are merges of main (release tooling, UI, and the pnpm and Git-checkout update fixes fix: keep the openclaw command and Gateway working after updating a pnpm install #201735 and fix: stop openclaw update from bricking a pnpm-linked Git checkout when switching to the package #201701) and touch no mark, verification or repair path.

End-to-end: package install (installed tarball, real managed Gateway under a systemd shim)

scripts/e2e/upgrade-survivor-docker.sh with OPENCLAW_UPGRADE_SURVIVOR_INSTALLED_RECOVERY_CUT=data-at-risk. It installs the packed tarball, starts a managed Gateway, kills real openclaw update runs at fixed points, and writes the mark a failed rollback read leaves onto the killed run, in the row shape published updaters persist. Everything after that point goes through the installed CLI.

Step Red: base f4b42cc9ae7 Green: head 787cf1befff
after-mark-update: next plain update after a false mark (Gateway stopped by the killed run) exit 1. The update refuses: "the Gateway that update stopped is still not running" exit 0 in 262 s. Prints ... verification found the state schemas match installed OpenClaw ... so that mark is resolved., records the receipt, installs the next version, and the Gateway serves it
marked-repair: repair after another false mark with the Gateway stopped not reached exit 0 in 53 s. Repair verifies the mark, records finalize:data-at-risk-verified:<run> on its own run, then starts the Gateway and verifies it (new PID, marked-repair-probe 0)
inconsistent-repair: the marked run's rollback left openclaw.sqlite.migrated-<run> not reached exit 1 in 18 s. ... The Gateway is stopped. Repair left the Gateway as it was. Run \openclaw triage` for an agent with the recorded facts, or by hand: keep that file and the update's backup; ... Found: the database rollback of update left .../openclaw.sqlite.migrated- ...`. The Gateway stays stopped and no receipt is written
restored-repair: the leftover removed not reached exit 0 in 50 s. Receipt recorded; the Gateway starts and serves

The green cell took 736 s under host load 18 to 22. Gateway outage in each repair case is the repair's own time (53 s and 50 s), which ends with a verified serving Gateway.

autoreview does not run on this machine. Two independent read-only reviewers reviewed the diff and the tests; their findings and what changed are listed below.

Tests changed or removed

  • update-repair-service.test.ts: the "named data risk" case of "does not start a Gateway after %s" is replaced by the verified, inconsistent, unverifiable and later-mark cases. The old behavior (refuse forever) is what this change fixes.
  • update-recovery-guidance.test.ts: assertions on "Keep the Gateway stopped" are replaced by exact rendered text.
  • update-command-post-update-repair.test.ts, cleanup.test.ts, status.test.ts, update-repair-command.test.ts, the killed-run tests and update-managed-service-handoff-lifecycle.test.ts: expectations follow the new text.
  • update-data-at-risk.test.ts: "never resolves a mark that records live Doctor writers" is replaced by a case that proves both halves: unverifiable (deferred to Doctor) before Doctor holds the state, consistent after. The old expectation was the repair loop that round 2 finding 4 reported.
  • doctor-health.legacy-update.test.ts: "reports stale stop failure" gains an identity-uninspectable case. When service identity cannot be inspected, the stop is skipped, and the error must say so rather than "did not stop".
  • service-layout.test.ts: the Git release-mode ownership cases are removed along with the reverted change; they move to the follow-up.
  • Net test growth is +923 lines; config/test-lines-allocations/update-data-at-risk-verification.txt records 523 beyond the 400 allowance, with the reason.

Reviewer findings

First review (before the next-update and release-mode work):

  • The owner copied the database (the default preflight purpose was maintenance): fixed red then green.
  • A listing failure was labeled an interrupted restore: fixed red then green.
  • Some bare gateway stop instances remained: fixed in the update path.
  • Repair only verified the stopping run's mark: fixed.
  • The handoff reader ignored the receipt: fixed.

Second review:

  • Repair could start a Gateway after reporting an inconsistent later mark (blocker): fixed, with a regression test.
  • The 500-character limit cut off the next steps: the next steps now come first, multiple databases collapse to "(and N more)", and a realistic-length test covers it.
  • active-mutation and partial-rollback marks could be falsely resolved: both now refuse resolution, with tests.
  • A dangling "By hand:" in refuse(): fixed.
  • Verification ran before foreground admission: moved after it.
  • Only the newest mark got a receipt: all unverified marks are now resolved at once.
  • Keep the Gateway stopped in update-command-database-backup.ts rollback-start messages: left as is. It belongs to the restore/rollback catch-all fixes (audit P2-1), not this change.
  • No unit test for the handoff receipt reader: not added; that path is covered only by its existing refusal test.

Not proven

  • A mark written by the published [email protected] binary itself. The Docker cells use a copied record in the exact row shape that v2026.11.5:src/infra/update-run-write.ts and its codec persist.
  • Windows.
  • The managed handoff (update.run) trigger end to end; the Git cell uses the CLI trigger.
  • An active-mutation mark end to end. It is covered by the owner test and the repair test (red on the previous head, green now), not by a Docker cell.
  • Inherited failure, not caused here: update-command-rollback.test.ts "excludes a competing config writer..." fails on base 4c11507 as well.

Rating round 1 findings and what changed

The round 1 rating was F/F/F; the reviewer saw no end-to-end evidence yet. Each finding was checked against the code:

  1. Rollback leftovers of agent databases were missed. Real: the scan only listed the shared directory. Verification now walks the state directory, bounded in depth and entry count, for the marked run's .migrated-<run> files. A walk that cannot finish is unverifiable. Tested with both a shared and an agent leftover.
  2. The staged handoff helper's history read could reject an advanced schema. Real: it ran for every run. It now reads history only when the run carries a mark. If that read fails, the mark stands, as before this change, so an unmarked recovery restarts as it did.
  3. A refusal did not reach the helper that restarts the Gateway. Real: repair returned coreUpdate: completed. A mark refusal now makes repair report coreUpdate: "pending", which the helper already treats as "post-core repair did not complete", so it leaves the Gateway stopped. Covered in the repair tests.
  4. A newer shared database cannot reach the verifier in the Docker cell. Real: repair's own admission refuses newer shared state first. The Docker negative control now uses a rollback leftover, which reaches the verifier. A newer shared database is still refused by that existing admission, with its existing message.
  5. A newer database masked an unfinished migration. Real: the warn-and-continue exception now applies only when no database is behind.
  6. "Repair changed nothing" overstated what repair did. Real: Doctor and plugin maintenance had already run. It now says "Repair left the Gateway as it was".

Rating round 2 findings and what changed

Round 2 rated proof D, patch F. Each finding was checked against the code:

  1. Rollback files beside an external agent store were missed. Real. Leftover detection now reads the agent database registry (readRegisteredAgentDatabases) and checks the exact <db>.migrated-<run>{,-wal,-shm,-journal} family beside the shared database and every registered agent database. A registry read failure is unverifiable. Tested with a shared leftover and one beside an agent store outside the state directory.
  2. Doctor could cycle the Gateway before the check. Real. Repair now checks unverified marks before Doctor maintenance starts and refuses there, so Doctor never parks or restarts the Gateway on an inconsistent mark (expectRefusedBeforeDoctor). An unfinished migration, and now a live-writer mark, are deferred to Doctor and checked again after it.
  3. The original-runtime handoff fallback could restart past a refusal. Real. assertRestartSafe in the interrupted-handoff helper now checks every unverified mark in history, not only the interrupted run's, and falls back to the run's own mark when history cannot be read.
  4. active-mutation marks could never be resolved. Real: repair told you to run repair again, and the next repair said the same thing. Before Doctor, the mark is now deferred to Doctor. After the run's own Doctor maintenance has held exclusive state and agent ownership, no writer the marked run left can still hold the state, so the schema check decides. One repair resolves it (red on the previous head, green now).
  5. The state-tree walk could exhaust its entry limit on large release-mode installs. Real. The walk is gone; finding 1's registry check replaces it, so git-install/releases is never read.
  6. History was read with a cold synchronous snapshot before admission. Real. The next-update check uses the async worker history read (listUpdateRunsAsync).
  7. Ahead and behind together named only the ahead database. Real. The refusal names both, and its next step is to restore the pre-update backup, since neither openclaw update nor doctor --fix settles both.
  8. An unknown runtime was reported as stopped. Real. The Gateway is reported stopped only when the runtime says stopped; otherwise its state is reported as unknown.

The low-value-test note on update-recovery-guidance.test.ts was not taken: the exact rendered text is what the brief asks to prove, and each case covers a distinct Gateway state.

Rating round 3 findings and what changed

Round 3 rated proof D, patch F. Each finding was checked against the code:

  1. A live-writer mark hid a rollback leftover. Real. The active-mutation deferral is now the verifier's last check, so a leftover, an interrupted restore, or a schema finding reports first. Owner test: an active-mutation mark beside a leftover now returns the leftover (red on the previous head).
  2. The interrupted-handoff helper checks history-wide marks. Rejected in round 3; the landing review showed it was real (see below) and it is now fixed. assertRestartSafe runs after finalize(), and finalize verifies every unverified mark first and records receipts. A false earlier mark is resolved in the same finalize and does not hold the Gateway. Only a mark that finalize could not resolve keeps it down, which is the intended outcome.
  3. Restoration ignored receipts from earlier repairs. Real for consistency. restoreRepairGateway now reads receipts across recent history, as admission does. No dedicated test: in the repair harness, a repair whose start failed does not leave a stop intent for the next repair to restore. So the path the reviewer describes is not reachable through repair today.
  4. A refusal after Doctor finished finalization with exit 0. Real. A mark still refused after Doctor now fails finalization: abandoned runs are not acknowledged, the handoff is not completed, text mode prints Update finalization failed., and the command exits 1 with the refusal. The next repair retries it. Repair test: red (repair succeeded), green (failed, and a later repair resolves the mark and starts the Gateway).
  5. Files a completed rollback keeps on purpose were treated as a partial restore. Real. restoreUpdateDatabaseBackup keeps the displaced <db>.migrated-<run> files after a successful restore and records a completed database rollback step. A mark whose run has that step no longer counts those files. Owner test covers it.
  6. A registry read failure replaced a schema verdict. Real. The round-3 fix let an unfinished migration hide unchecked agent leftovers; the landing review caught that and the fix below replaces it. Shared-database leftovers are checked without the registry. Agent leftovers are checked after the schema verdict, and when the registry cannot be read, the schema finding is reported instead of a generic registry error. An unfinished migration or newer state still cannot hide an agent leftover. No separate test, because the registry read failure cannot be produced from a fixture without mocking the reader.
  7. The skipped-stop message inferred liveness from the stop flag. Real. The message now comes from the existing liveness check, so an already-offline service passes. When the stop was skipped, the error says Stale Gateway PID <pid> was not stopped: <reason> Observed: service=..., PID=..., port ...=.... Doctor test: red on the previous code (did not stop), green now.

Landing review findings and what changed

The landing review on 231fdd86e36 rated proof C, patch F. Each finding was checked against the code:

  1. Release-mode ownership stopped a healthy Gateway (P1, service-layout.ts). Real, and reproduced under real systemd. Reverted; see "Git release-mode repair: moved to a follow-up".

  2. Sibling git worktree checkouts could claim each other's service (P2, service-layout.ts). Real. Reverted with finding 1.

  3. Unchecked agent leftovers were deferred or continued past (P1, update-data-at-risk.ts, the coordinator's fix-6 blocker and its sibling). Real.

    • An unreadable agent registry with an unfinished migration returned the deferrable migration verdict, so Doctor maintenance could park and restart the Gateway without anyone having looked for agent leftovers.
    • An unreadable agent database returned unverifiable before the leftover scan, and a plain update continued past a leftover it never saw.

    The verifier now looks for leftovers first, beside the shared database and every registered agent database, before any other check. When the registry cannot be read, the result is unverifiable with leftoversUnchecked. It keeps any schema finding beside that fact ("the agent database registry could not be read, so database rollback leftovers beside agent databases are unchecked; and "), and is never finishable or newerState. Every consumer of the verdict refuses on it:

    • Repair before maintenance: it is not deferrable, so repair refuses before Doctor and leaves the Gateway as it was.
    • The next plain update: it refuses on leftoversUnchecked instead of warning and continuing.
    • Finalize after Doctor: any result other than consistent refuses and fails finalization.
    • Managed handoff: it restarts only on a receipt, and receipts are written only after a consistent verdict.

    Tests, red on 231fdd86e36 and green now:

    • unreadable registry with an unfinished migration, with and without an agent leftover, at the owner and through repair before Doctor;
    • an unreadable agent database beside its leftover;
    • a readable registry, unchanged;
    • the plain-update refusal.
  4. The interrupted-handoff entry guard blocked on older marks (P1, update-managed-service-handoff-interrupted.ts). Real. The entry guard now judges only the interrupted run's own mark, as on main. The history-wide check stays after finalize(), which verifies older marks and records their receipts. Handoff lifecycle test: an interrupted managed update with only an earlier false mark recovers and restarts. Red on 231fdd86e36 (gateway left stopped: data at risk (rollback-state-unverified)), green now.

  5. The rollback-completed exception read a step compaction evicts (P2, update-run-data-at-risk.ts). Real. It now also reads diagnostic:database rollback, which only a completed restore writes ("Restored pre-migration databases from ..."). The ledger's compaction keeps that step and its text. Owner test with a ledger compacted past the ordinary step: the retained .migrated-<run> file no longer counts. No new stored field.

Rating round after the landing review

On 33e6184dbc6: proof C, patch F. Each finding was checked against the code:

  1. Doctor can restore a parked Gateway before the post-Doctor check (P1, update-command-finalize.ts). Real but narrow. A mark deferred to Doctor (an unfinished migration, or live Doctor writers) lets Doctor maintenance park a running Gateway, and Doctor restores it before the post-Doctor recheck runs. main has no recheck at all, so this is no worse than main.
    • Changed here: the refusal after Doctor no longer claims the Gateway was left as it was. It now says Repair did not start or restart the Gateway after this check. Tested in the after-Doctor refusal case.
    • Not changed: making the verdict part of Doctor's restoration admission changes Doctor's restoration owner. It is listed as a follow-up.
  2. The original-runtime branch of the interrupted handoff restores without the history-wide check (P1, update-managed-service-handoff-interrupted.ts). Rejected for this PR. With no plugin cohort, no finalize runs there, so no receipt can be written. A history-wide check would bring back the stuck state the landing review reported, where a false older mark keeps the Gateway down. The branch behaves exactly as on main.
  3. An inaccessible rollback path was read as absent (P2). Real. Leftover probes now separate "not there" (ENOENT, ENOTDIR) from "could not look". The latter goes down the same leftoversUnchecked refusal path. Owner test with an unreadable directory: red, then green.
  4. An unfinished migration was deferred while another database could not be read (P2). Real. An unreadable database next to a behind or newer one is now unverifiable and never deferrable, with both findings in the detail. Owner test with real SQLite: red, then green.
  5. The repair's own row can push the oldest of 100 marked runs out of the window (P2). Not changed. Only a mark at row 101 is affected, and that is the same history window main reads everywhere. The stopping run's mark is read by run ID, so it is never skipped. Listed as a follow-up.

CI on 787cf1befff

Three jobs in run 44525460079 failed, and none of them came from this change:

  • check-test-types-core-2 and check-test-types-core-3 failed with eight TS2739 errors in test/scripts/release-* fixtures. main's own CI run 44524514068 at dbc1aa04e88 (the main merged here) shows the same errors in the same jobs. fix(release): complete the evidence test client #201811 fixed them.
  • checks-node-compact-small-3 failed in test/scripts/package-acceptance-workflow.test.ts ("Expected workflow step Download full release validation manifest"). This change touches no workflow or release tooling.

Merging current main cleared them. The root test-type stripes pass locally on the merged head.

The later package-acceptance-workflow failure came from #201802 removing a workflow step without updating its test. It was inherited from main, and #201805 fixed it by restoring the step. This head merges main after #201805.

End-to-end: Git release mode (installed checkout, real managed service, busy database)

These cells drive the update-matrix harness in Docker. Each one installs a real Git checkout, converts it to release mode through a real openclaw update, and runs a second real update under database write load. It then writes the mark that a failed post-activation schema read leaves, in the published row shape, onto that update's run while the Gateway keeps serving. Everything after that point goes through the shipped CLI.

Cell Code Result
red-repeat (inside the red-repair cell) base cf9a9839e03 The plain repeat update reports already-current, exits 0 and says nothing about the mark.
green-repeat head 787cf1befff (earlier also b7f71419149) The plain repeat update, already current, prints Update <run> recorded data at risk (rollback-state-unverified); verification found the state schemas match installed OpenClaw 2026.11.5 and no migration or restore is unfinished, so that mark is resolved. It records finalize:data-at-risk-verified:<run> on its run (read back through openclaw update status) and exits 0 in 145 s. Busy load held throughout: 1278 write commits at 8 MiB/s on a 512 MiB database and 1278 readiness probes, with 0 failed and 0 outages. The Gateway served the same build before and after.

green-repeat does not depend on the reverted release-mode ownership change. A plain update's mark check runs at update admission and never asks whether the service belongs to this checkout. The same cell's repeat step on base passed that path silently, with no ownership refusal.

Git release-mode repair: moved to a follow-up

This PR no longer changes release-mode repair ownership. An earlier head accepted a Git release-mode service as the checkout's own (src/daemon/service-layout.ts). The landing review found two problems with that change, both of which make release-mode repair worse than on main:

  • Once the service is accepted, Doctor's stale-Gateway inspection reads the expected build from the source checkout, not from the active release. It then stops a healthy Gateway that serves the release, and repair exits 1. A real-systemd cell reproduced this on 1e39a2c5828 (raw output).
  • Two independent git worktree checkouts share a common Git directory, so one could claim the other's release-mode service.

The change is reverted here. Release-mode repair behaves as on main: it refuses and changes nothing. The refusal is now true for this case. It names the Git release launcher, says this checkout cannot yet confirm that the release is its own, says the service was left untouched, and leads with openclaw triage (rendered-text test in update-command-service-maintenance.test.ts). The ownership change and both findings move to the release-mode follow-up (#201538), which also carries the Doctor stale-build fix.

Two related message fixes stay in this PR. Doctor's stale-Gateway stop now reports a stop that was skipped (was not stopped: <reason>) and one it could not confirm (could not be confirmed stopped) instead of always did not stop. Both have red/green tests in doctor-health.legacy-update.test.ts.

Raw terminal lines from every cell are in this PR comment. The full outputs (fix.stderr, repeat.stderr, update status JSON, asciinema casts) are kept locally, because the artifact store rejects uploads from this machine.

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

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

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes scripts Repository scripts docker Docker and sandbox tooling size: XL labels Nov 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro 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:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head d2a60fd5594c9128b9be91b958c5497b3021840b, but the PR head is now eb64f3be1758e6f6d1bfad127161079a943cbf56. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-19T06:42:01.531Z sha d2a60fd :: needs changes before merge. :: [P2] Remove the new circular dependency from admission-root selection

…t mark, resolve all marks, harden release ownership
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Raw terminal evidence (Docker cells)

Lines copied from the cell outputs, unchanged except for truncation of long lines. Package cells use the upgrade-survivor-docker.sh data-at-risk cut. Git release-mode cells use the update-matrix harness with a seeded mark.

Package red, base f4b42cc9ae7: after-mark-update (exit 1)

[openclaw] Reason: Interrupted update 8efba727-b843-41d7-a8c2-70cfeb4a272a was settled, but finishing its installed version as openclaw update repair does failed: the Gateway that update stopped is still not running (update run 852b1f92-9b3a-47b0-b189-584e340d3c1d, warning). Run openclaw update repair, then retry openclaw update.

Package green, head 787cf1befff: after-mark-update (exit 0)

Update 9891392d-610e-4915-95b1-e8c5d9814126 recorded data at risk (rollback-state-unverified); verification found the state schemas match installed OpenClaw 2026.11.6-first-hop.1 and no migration or restore is unfinished, so that mark is resolved.

marked-repair (exit 0)

Update c58030a6-b2bb-4d2b-a319-2aa5ba0d2bfe recorded data at risk (rollback-state-unverified); verification found the state schemas match installed OpenClaw 2026.11.6-first-hop.3 and no migration or restore is unfinished, so that mark is resolved.

inconsistent-repair (exit 1)

Update 97856033-c99a-45ff-90a3-b4dbccc30359 recorded data at risk (rollback-state-unverified). The Gateway is stopped. Repair left the Gateway as it was. Run `openclaw triage` for an agent with the recorded facts, or by hand: keep that file and the update's backup; an agent or a person must compare them before the Gateway starts. Found: the database rollback of update 97856033-c99a-45ff-90a3-b4dbccc30359 left /home/appuser/.openclaw/state/openclaw.sqlite.migrated-97856033-c99a-45ff-90a3-b4dbccc30359, so the state may be only partly restored.

restored-repair (exit 0)

Update 97856033-c99a-45ff-90a3-b4dbccc30359 recorded data at risk (rollback-state-unverified); verification found the state schemas match installed OpenClaw 2026.11.6-first-hop.5 and no migration or restore is unfinished, so that mark is resolved.

Git release-mode red, base cf9a9839e03: repair (exit 1)

[update finalize] finalize:doctor: failed: Doctor could not enter maintenance. Error: Gateway service management skipped: the service belongs to a different OpenClaw installation and was left untouched. Run openclaw gateway status --deep to fi

Git release-mode green-repeat, head 787cf1befff: already-current update (exit 0)

Update 1b0f531f-2d69-4f80-af3d-4c147e329dc2 recorded data at risk (rollback-state-unverified); verification found the state schemas match installed OpenClaw 2026.11.5 and no migration or restore is unfinished, so that mark is resolved.
"step": "finalize:data-at-risk-verified:1b0f531f-2d69-4f80-af3d-4c147e329dc2"

Git release-mode green-repair, head b7f71419149: past the ownership refusal, then blocked by the harness

Gateway restoration identity could not be inspected; the managed service was not stopped. Run openclaw gateway status --deep to inspect the native service manager.
[update finalize] finalize:doctor: failed: Doctor gateway-stop failed. Error: Stale Gateway PID 10705 did not stop: service=running, PID=10705, port 42075=busy, legacy lock owner=none. Run openclaw gateway status --deep; resolve the reported f

@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Nov 19, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Raw terminal evidence: Git release-mode repair under real systemd

systemd is PID 1 in the container, with a lingering user@1001 and a real user D-Bus. The Gateway is a real systemctl --user unit. Lines are copied from the cell outputs and truncated only.

Red, base cf9a9839e03: openclaw update repair (exit 1)

degraded
active
srw-rw-rw- 1 appuser appuser 0 Nov 19 15:44 /run/user/1001/bus
[openclaw] Reason: Doctor could not enter maintenance. Error: Gateway service management skipped: the service belongs to a different OpenClaw installation and was left untouched. Run openclaw gateway status --deep to find the Gateway installation. If an operator-owned launcher override points there, update or remove that override; reinstalling alone will not fix it. Inspect systemd overrides with systemctl cat (--user for user services). The service was left unchanged.

Green, head 1e39a2c5828: openclaw update repair (exit 1, mark resolved, then the stale-build follow-up)

degraded
active
srw-rw-rw- 1 appuser appuser 0 Nov 19 15:00 /run/user/1001/bus
Update c768d33a-1e9b-4fe0-ba22-cde1c2c7f1b4 recorded data at risk (rollback-state-unverified); verification found the state schemas match installed OpenClaw 2026.11.5 and no migration or restore is unfinished, so that mark is resolved.
Restarted systemd service: openclaw-gateway.service
Warning: Gateway started after Doctor maintenance, but readiness was not verified. Gateway build mismatch: expected 2026.11.5-1e39a2c5828e-2026-11-19T15-01-07.069Z, running gateway reported 2026.11.5-2b460c936935-2026-11-19T15-06-56.642Z. Service runtime: status=running, state=active, pid=13706 Port 43601 is already in use. - Port is in use but process details are unavailable (install lsof or run as an admin user). P
[update finalize] finalize:doctor: failed: Doctor gateway-stop failed. Error: Stale Gateway PID 8485 did not stop: service=unknown, PID=8485, port 43601=free, legacy lock owner=none. Run openclaw gateway status --deep; resolve the reported fai
Gateway build mismatch: expected 2026.11.5-1e39a2c5828e-2026-11-19T15-01-07.069Z, running gateway reported 2026.11.5-2b460c936935-2026-11-19T15-06-56.642Z.

After repair (green): readyz true, serving the release build:

{"cliVersion": "OpenClaw 2026.11.5 (1e39a2c)", "serving": {"version": "2026.11.5", "buildId": "2026.11.5-2b460c936935-2026-11-19T15-06-56.642Z"}, "readyz": true}

@openclaw-barnacle openclaw-barnacle Bot removed the gateway Gateway runtime label Nov 19, 2026
@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 21, 2026
@fuller-stack-dev
fuller-stack-dev merged commit a28f211 into openclaw:main Nov 22, 2026
149 of 150 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/update-verify-data-at-risk-marks branch November 22, 2026 03:12
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Final-head cell result (recorded after merge; the cell ran before it).

Package green cell on the exact final head eb64f3be1758e6f6d1bfad127161079a943cbf56: PASS. The cell script refuses any other HEAD.

  • Ran 2026-11-19 20:52:18Z to 21:05:39Z, exit 0, wall time 801 s. installed-recovery.json status: passed.
  • Next plain update after a mark: exit 0.
  • Marked repair: exit 0, repairStatus succeeded.
  • Inconsistent repair (real rollback leftover): exit 1, repairStatus failed. This refusal is intended.
  • Restored repair after cleanup: exit 0, repairStatus succeeded.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 22, 2026
…ate acts on it (openclaw#201668)

* fix(update): verify recorded data-at-risk marks before repair acts on them

* fix(update): verify any unverified data-at-risk mark and honor receipts in handoff recovery

* fix(update): recognize a Git release-mode service as its checkout's own

* fix(update): check a recorded data-at-risk mark before the next update, including already-current runs

* fix(update): lead data-at-risk refusals with triage and record them on the refused run

* fix(update): keep data-at-risk refusals within the recorded warning limit

* test(e2e): finish the seeded data-at-risk run with a terminal phase

* fix(update): name the agent route in killed-update recovery refusals

* fix(update): drop an unused import

* test(update): expect the agent route in killed-update refusals

* fix(update): verify the newest mark before restoration without comparing run ids

* fix(update): address review: keep the Gateway down on any inconsistent mark, resolve all marks, harden release ownership

* fix(update): break the admission-root import cycle and type the e2e schema read

* fix(update): address rating findings: agent rollback leftovers, helper restart, blocking findings first, shared Git metadata

* test(e2e): prove the next plain update resolves a mark with the Gateway running

* fix(update): address rating round 2: refuse marks before Doctor, registry-based rollback check, handoff fallback, async history read

* test(update): pick the repair run, not a settlement row, in the data-at-risk cell

* fix(update): resolve live-writer marks after Doctor holds the state

* fix(doctor): say a skipped stale-Gateway stop left the PID running

* fix(update): address rating round 3: leftovers before deferrals, retained rollback files, refusal after Doctor fails finalization

* docs(update): note retained rollback files and refusals after Doctor

* fix(doctor): say a stale Gateway stop could not be confirmed when nothing shows it running

* fix(update): address landing review: revert release-mode ownership, check leftovers first, handoff entry guard, durable rollback evidence

* test(update): follow main's Git release link layout in the launcher refusal test

* fix(update): treat uninspectable leftovers and unreadable databases as unchecked; true wording after Doctor
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…e Node (#203152)

* fix(update): drain a Gateway that runtime recovery reran under another Node

A service whose Node is unsupported or lacks a recommended security patch
reruns the Gateway under a compatible Node as a child of the launcher, so the
service's main PID never equals the PID the resident reports. Maintenance drain
refused every such update with 'Gateway process changed during maintenance
drain'. Accept the resident when every Gateway port listener is that process
and its parent is the service's main process, matching restart port ownership.

Refs #202954

* docs(update): runtime recovery reruns the Gateway only when its Node fails admission

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit a27f0c3)
Release-companions: #204017 is a separate Linux release-install Doctor fallback when lsof/ss cannot attribute listeners; it is not required for this attributed-listener runtime-recovery case. #203486 pnpm recovery, #201668 data-risk repair, and #202591 snapshot cleanup only overlap documentation; #203236 is independent auto-update retry policy. The neighboring native drain suite remains unchanged.
Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…ate acts on it (#201668)

* fix(update): verify recorded data-at-risk marks before repair acts on them

* fix(update): verify any unverified data-at-risk mark and honor receipts in handoff recovery

* fix(update): recognize a Git release-mode service as its checkout's own

* fix(update): check a recorded data-at-risk mark before the next update, including already-current runs

* fix(update): lead data-at-risk refusals with triage and record them on the refused run

* fix(update): keep data-at-risk refusals within the recorded warning limit

* test(e2e): finish the seeded data-at-risk run with a terminal phase

* fix(update): name the agent route in killed-update recovery refusals

* fix(update): drop an unused import

* test(update): expect the agent route in killed-update refusals

* fix(update): verify the newest mark before restoration without comparing run ids

* fix(update): address review: keep the Gateway down on any inconsistent mark, resolve all marks, harden release ownership

* fix(update): break the admission-root import cycle and type the e2e schema read

* fix(update): address rating findings: agent rollback leftovers, helper restart, blocking findings first, shared Git metadata

* test(e2e): prove the next plain update resolves a mark with the Gateway running

* fix(update): address rating round 2: refuse marks before Doctor, registry-based rollback check, handoff fallback, async history read

* test(update): pick the repair run, not a settlement row, in the data-at-risk cell

* fix(update): resolve live-writer marks after Doctor holds the state

* fix(doctor): say a skipped stale-Gateway stop left the PID running

* fix(update): address rating round 3: leftovers before deferrals, retained rollback files, refusal after Doctor fails finalization

* docs(update): note retained rollback files and refusals after Doctor

* fix(doctor): say a stale Gateway stop could not be confirmed when nothing shows it running

* fix(update): address landing review: revert release-mode ownership, check leftovers first, handoff entry guard, durable rollback evidence

* test(update): follow main's Git release link layout in the launcher refusal test

* fix(update): treat uninspectable leftovers and unreadable databases as unchecked; true wording after Doctor

Release adaptation: Retain the stable installed-recovery harness. Do not add main's installed Docker service cell, later retired by #203808, or Git release-launcher wording/test because stable uses the in-place Git updater. Keep the state-verification, next-update, repair and interrupted-handoff paths and their compatible regressions.

Companion audit: #203486 is present-equivalent at 3081077 (preserved). #201978 is selected next in this lane. #203808 and #203966 involve the inapplicable installed service-cell layout; #203497 and #203194 change main's package/Git activation layout and are not applicable; #204017 depends on that release-install layout. #204077, #204043, #203555 and #203520 are independent authority, cleanup, helper-fixture and config-validation changes. #204151, #203917, #203849 and #203406 are separate guidance, cleanup or status changes, not required by the data-risk verifier. #203569 fixes a separate cron receipt fixture in the same Doctor suite; the touched stale-stop cases do not depend on it.

(cherry picked from commit a28f211)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit f8d4bc138ed2512c413cf96f66fe0eefb3b28d65)
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…s on a schema change or a busy database (#201463)

* fix(update): report an inconclusive schema read as data at risk only after a candidate opened state

* fix(update): keep a shipped updater's hold unless the reread confirms the baseline

* test(update): assert the recovered verdict carries no data-at-risk mark

* fix(update): keep recorded risk and the in-place Git runner on the conservative inspection route

* fix(update): fall back only to a release of the serving build before a recovered restart

* test(update): finalize an unmatched in-place checkout hold unchanged

* test(update): share the release build fixture and record the test-line allocation

* refactor(update): narrow to the installed updater's Git release inspection

(cherry picked from commit 2183caf)

Release adaptation: Keep only the package update warning when neither Doctor nor the no-restart check could open state. Unknown evidence, recorded risk and changed-schema paths retain conservative behavior. Do not import the Git release switch.

Companion audit: PR #201463 is the source. #201668 handles revalidation of recorded risk, not needed for this warning; #201600 and later Git release activation follow-ups are out of scope. Deferred Doctor selector retention is independently ordered at row 17.

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

Labels

cli CLI command changes commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant