Repository navigation
fix: stop marking data at risk when a rollback cannot read the schema or has no baseline - #201498
Conversation
… or a failed rollback check A migrated update no longer records 'data at risk' once its candidate Gateway has started; later failures keep their own reason. A rollback that cannot read the schema or has no baseline refuses rollback without a risk mark, while forward schemas, partial restores, operator edits and an unknown active root still name one.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR prevents failed restart attempts and inconclusive rollback checks from automatically marking update data as at risk. Example: A migrated candidate Gateway fails readiness with readyz-unhealthy after its restart starts.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it addresses a source-confirmed recovery bug still present on main, and no definite introduced defect was found. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe CLI update finalizer coordinates candidate activation, guarded rollback, service recovery, and durable update outcomes consumed by update repair. flowchart TD
A[CLI update] --> B[Candidate activation]
B --> C[Post update finalizer]
C --> D[Gateway restart]
C --> E[Guarded rollback]
D --> F[Recovery verdict]
E --> F
F --> G[Update ledger and repair]
Technical reviewBest possible solution: Keep risk classification in the existing finalization and rollback owners, preserving explicit data risks while allowing recovery from runtime-only failures. Do we have a high-confidence way to reproduce the issue? The current source shows both failure paths, and the PR reports regressions failing on the base; this read-only review executed no target code. Is this the best way to solve the issue? The patch is a focused producer-side correction using existing lifecycle notifications and recovery facts, with distinct negative controls for genuine risks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3eee09d9b462. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +28, Tests +128. Total +156 across 4 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 18, 2026, 5:58 PM ET / 22:58 UTC. |
…sk after a cohort restore A restart command that fails before the service manager launches the candidate keeps the migrated rollback block and its mark. A plugin cohort restore followed by an unreadable recheck stays rollback-state-unverified. Drop the shared-schema row that duplicated the table's existing case.
…sk-needs-evidence
…sk-needs-evidence
…sk-needs-evidence
Three review rounds found ways the service manager can report a restart without the candidate actually taking over the migrated state (failed command, queued Windows task, a task that never runs). Without positive launch evidence the post-start release cannot be defended, so this PR keeps only the rollback change.
…sk-needs-evidence
…t restore cannot be read
…sk-needs-evidence
|
Merged via squash.
|
… or has no baseline (openclaw#201498) * fix: mark an update's data at risk only with evidence after migration or a failed rollback check A migrated update no longer records 'data at risk' once its candidate Gateway has started; later failures keep their own reason. A rollback that cannot read the schema or has no baseline refuses rollback without a risk mark, while forward schemas, partial restores, operator edits and an unknown active root still name one. * fix: keep the migrated block until the candidate launches and keep risk after a cohort restore A restart command that fails before the service manager launches the candidate keeps the migrated rollback block and its mark. A plugin cohort restore followed by an unreadable recheck stays rollback-state-unverified. Drop the shared-schema row that duplicated the table's existing case. * refactor: keep post-update finalization under its line cap * fix: release the migrated block only after a service restart, not a queued install * revert: keep the migrated-update stamp until launch evidence exists Three review rounds found ways the service manager can report a restart without the candidate actually taking over the migrated state (failed command, queued Windows task, a task that never runs). Without positive launch evidence the post-start release cannot be defended, so this PR keeps only the rollback change. * test: keep the risk when the recheck after a database or plugin cohort restore cannot be read
… or has no baseline (#201498) * fix: mark an update's data at risk only with evidence after migration or a failed rollback check A migrated update no longer records 'data at risk' once its candidate Gateway has started; later failures keep their own reason. A rollback that cannot read the schema or has no baseline refuses rollback without a risk mark, while forward schemas, partial restores, operator edits and an unknown active root still name one. * fix: keep the migrated block until the candidate launches and keep risk after a cohort restore A restart command that fails before the service manager launches the candidate keeps the migrated rollback block and its mark. A plugin cohort restore followed by an unreadable recheck stays rollback-state-unverified. Drop the shared-schema row that duplicated the table's existing case. * refactor: keep post-update finalization under its line cap * fix: release the migrated block only after a service restart, not a queued install * revert: keep the migrated-update stamp until launch evidence exists Three review rounds found ways the service manager can report a restart without the candidate actually taking over the migrated state (failed command, queued Windows task, a task that never runs). Without positive launch evidence the post-start release cannot be defended, so this PR keeps only the rollback change. * test: keep the risk when the recheck after a database or plugin cohort restore cannot be read (cherry picked from commit 4c11507) Companion audit: Rollback preserves safety but reports risk only after actual evidence or partial restore; healthy current/older schemas do not imply corruption. Update/database contracts read; no schema/durability change. No later pinned path fixes. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 81dac4fbe40e9fc0e604f57b4d02074789502921) (cherry picked from commit c8f02aa0085ab509e31930ab67da7313f55b8601)
What Problem This Solves
When an update fails after activation, the updater tries to roll the package back and first checks that the database schemas are unchanged. If that check could not run — the schema read failed (an unreadable store, a timeout, a lock), or there was no baseline at all (PostgreSQL state has none before activation) — the run was marked "Keep the Gateway stopped: data at risk (rollback-state-unverified)", although nothing had been restored and the new version was still installed.
openclaw update repairrefuses to start the Gateway for a run with that mark, and the next steps named only manual commands.User Impact
User impact: a failed update whose rollback cannot read the schema, or has no baseline, now refuses the rollback without a data-risk mark: the new version stays installed, final recovery may start it, and the recorded next action no longer says "Keep the Gateway stopped". Real risks still stop the Gateway exactly as before: a forward schema, operator config edits, an unknown active install root, a newly created store the previous version cannot open, a recheck that cannot be read after databases or the plugin cohort were restored, and config that cannot be restored after the package was.
Why This Change Was Made
Invariant: "data at risk" needs evidence. A schema read that fails before any restoration, or a missing baseline, leaves the candidate installed with nothing restored: that is "could not verify", not a risk.
rollbackFailedUpdate(update-command-rollback.ts) no longer starts withdataAtRisk = rollback-state-unverified. Each remaining mark is set where its evidence appears:restoredStateUnchanged);History: the default came from #172784, which made
dataAtRiskthe only "keep stopped" signal and labeled every "cannot roll back" as a risk so the previous never-restart behavior was preserved.Not shipped here: the blanket migrated-update stamp (P0-2). An earlier version of this PR released the migrated rollback block once the candidate had been restarted, so a later readiness failure would not be marked. Three review rounds found ways the restart owner can report a restart without the candidate actually taking over the migrated state: a restart command that fails before launching, a Windows task that is only queued, a task that the scheduler never runs. Without positive launch evidence (for example the recorded verification showing the candidate's version answering) that release cannot be defended with a negative control, so it was taken out. The proposal for the follow-up: release the block only when the run's recorded verification shows the candidate process (a
pidwithserviceRunning: true, orversionMatch: true), and add a negative control for each "accepted but not launched" outcome.Update behavior for published updaters
The rollback runs in the installed updater, so this applies from the next update driven by a fixed version;
v2026.11.5andv2026.10.33keep their behavior. Marks they already recorded are left to the guidance/repair owner, keyed onverification.recovery.dataAtRiskand thefinalize:data-at-riskstep.Paths: package (npm link and pnpm/bun swap) and Git legacy both use
rollbackFailedUpdate. Git release mode has no updater rollback. CLI and managed-handoff triggers reach the same code; on the handoff path an unsafe result still exits 79 (separate item), but the run is no longer marked at risk.Evidence
Owner-level checks with real failures (real
rollbackFailedUpdate, real schema reads in the update state worker):rollback-state-unverified, nodataAtRisk, rendered guidance without "Keep the Gateway stopped" or "data at risk". Base:dataAtRisk: rollback-state-unverified.keeps the risk when the recheck after a databases|plugin cohort restore cannot be read): both end withdataAtRisk: rollback-state-unverifiedand no package rollback. Each fails when its guard is removed fromrestoredStateUnchanged(recorded below); config that cannot be restored after the package was restored (rollback-state-unverified, package root is the previous version); every refusal row of the schema-change table now asserts its mark (unknown root and stores the previous version cannot open →rollback-state-unverified; forward shared/agent schema, schema change during stop and operator config edits →state-migrated-no-rollback), which no test checked before.Recordings (terminal, this Mac, raw output, idle gaps capped at 1 s, 3x speed). They were taken on an earlier head that also carried the stamp change; the rollback cases shown are the ones in this PR.
3b03d9c6c4fwith the tests of that time →schema-read-deniedandno-baselinefail withrollback-state-unverifiedas the mark; the controls pass.pr1-unit-base-red-3b03d9c6c4f.mp4
8ceae53538f→ the same cases pass;excludes a competing config writerfails identically on base (a macOS setgid directory check).pr1-unit-head-green-8ceae53538f.mp4
cohortConfigSettledfrom the condition fails only the plugin-cohort control; droppingdatabasesRestoredfails only the database control (each1 failed | 1 passed,expected … to match object). The source was restored after each run.pr1-mutations.mp4
End to end (installed package, Docker): attempted for the stamp change, not for this rollback change. Published
2026.11.5→ this branch's candidate, with a restarted Gateway made to fail; the updater restarted it again and the update succeeded, so the run did not reach rollback. It shows the migrated flow recovering on its own, not this PR's difference. Raw outputs are not attached because the artifact store rejected uploads from this machine.Commands and results at the current head
node scripts/run-vitest.mjsonupdate-command-rollback,update-command-post-update-repair,update-command-post-update-recovery,update-command-database-rollback: rollback file 49 passed, 1 failed (the macOS setgid case, identical on base); repair, recovery and database-rollback files passed on the previous head and are unchangedmain(fix: Git checkout updates no longer fail before the new release starts on a schema change or a busy database #201463, fix(update): keep updating when a pre-migration database image does not fit #201579, fix: Git checkout updates across a schema change no longer end as post-update-failed after the new release starts #201600, fix: let package updates start while the Gateway is writing to an agent database #201545): the wider update-cli set (migrated, migrated-schema, post-update, legacy-finalize, recovery, recovery-guidance) passed.pnpm tsgo:core:all: pass. oxlint on touched files: pass.git diff --check: clean.Test file audited in full:
update-command-rollback.test.ts(new cases, the two post-restore recheck controls, the risk assertion added to the schema table; no case removed).Review:
autoreviewdoes not run on this machine. A fresh independent reviewer and three ClawSweeper rounds read the diff (round tiers: F/F/D, F/F/C, F/F/D; every patch finding in rounds 2 and 3 was about the stamp change, which is now out). Fixed from them for the rollback part: unknown root checked before the missing baseline, the post-restore recheck and the plugin-cohort restore keep their mark, the schema table asserts the mark.Not proven
restoreFailedUpdateDatabases,settleUpdatePluginCohortInCandidate); the recheck read failure is real (unreadable agent store).Steps this change still leaves to a person, and why: