Skip to content

fix: stop marking data at risk when a rollback cannot read the schema or has no baseline - #201498

Merged
fuller-stack-dev merged 11 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-data-at-risk-needs-evidence
Nov 19, 2026
Merged

fuller-stack-dev merged 11 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-data-at-risk-needs-evidence

Conversation

@fuller-stack-dev

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

Copy link
Copy Markdown
Member

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 repair refuses 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 with dataAtRisk = rollback-state-unverified. Each remaining mark is set where its evidence appears:

  • unknown active root (no runtime can be named to serve the state);
  • a newly created store the previous version cannot open (set at that throw);
  • databases or the plugin cohort restored, then a recheck that cannot be read (restoredStateUnchanged);
  • config that cannot be restored after the package was;
  • forward schema and operator config edits (unchanged).

History: the default came from #172784, which made dataAtRisk the 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 pid with serviceRunning: true, or versionMatch: 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.5 and v2026.10.33 keep their behavior. Marks they already recorded are left to the guidance/repair owner, keyed on verification.recovery.dataAtRisk and the finalize:data-at-risk step.

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

  • Schema read fails (agent store unreadable) and no baseline: rollback refused with rollback-state-unverified, no dataAtRisk, rendered guidance without "Keep the Gateway stopped" or "data at risk". Base: dataAtRisk: rollback-state-unverified.
  • Negative controls, still at risk: a recheck that cannot be read after a database restore, and after a plugin cohort restore (keeps the risk when the recheck after a databases|plugin cohort restore cannot be read): both end with dataAtRisk: rollback-state-unverified and no package rollback. Each fails when its guard is removed from restoredStateUnchanged (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.

  • Base / red: product code at 3b03d9c6c4f with the tests of that time → schema-read-denied and no-baseline fail with rollback-state-unverified as the mark; the controls pass.
pr1-unit-base-red-3b03d9c6c4f.mp4
  • Head / green: 8ceae53538f → the same cases pass; excludes a competing config writer fails identically on base (a macOS setgid directory check).
pr1-unit-head-green-8ceae53538f.mp4
  • Guard mutations at the current head: dropping cohortConfigSettled from the condition fails only the plugin-cohort control; dropping databasesRestored fails only the database control (each 1 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

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: autoreview does 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

  • The database and plugin cohort restores in the two recheck controls are stubbed at their owners (restoreFailedUpdateDatabases, settleUpdatePluginCohortInCandidate); the recheck read failure is real (unreadable agent store).
  • No installed end-to-end run reaches this rollback path (see above).
  • Git release and Git legacy end to end: not exercised.

Steps this change still leaves to a person, and why:

  • Genuine risks still stop the Gateway: they need a decision about data the updater cannot make. Their guidance text is owned by the guidance/repair owner.
  • The migrated-update stamp (P0-2) is unchanged by this PR; a readiness failure after migration still records "data at risk". See the proposal above.

… 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.
@clawsweeper

clawsweeper Bot commented Nov 18, 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 cli CLI command changes size: M labels Nov 18, 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. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

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

  • Before: The update records state-migrated-no-rollback as a data risk, blocking repair from starting the Gateway.
  • After: The update retains the readiness failure without the blanket risk mark.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch appears correct, but the promised installed-upgrade and recovery proof is still outstanding.
Proof confidence 🧂 unranked krab (1/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: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A recoverable update failure can incorrectly prohibit starting the installed Gateway.
Reason: The maintainer-authored direction restores useful recovery while retaining named risk refusals.

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
Reviewed head: 8ceae53538f615d1493f2fe01026324d32ccf4fc

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted shipped-CLI evidence of the latest-stable upgrade failure and subsequent update repair starting the candidate, with settings and stored data preserved.
Agent review details

How this fits together

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

Technical review

Best 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

  • Rollback risk defaults changes intended behavior with a stated reason (73bb905: Make producer-recorded data risk the stop signal while preserving earlier rollback refusal behavior.)
  • Candidate restart and rollback ownership keeps the original intent (d1a69c0: Hand migrated finalization to candidate code and restrict restoration to compatible state.)
  • Database restoration verification keeps the original intent (d780fdc: Restore retained database snapshots only through guarded rollback and preserve unverifiable state.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 73bb905 adds src/cli/update-cli/update-command-rollback.ts:118 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 73bb90549706; files: src/cli/update-cli/update-command-rollback.ts)

PR surface

Source +28, Tests +128. Total +156 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 39 11 +28
Tests 2 153 25 +128
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 192 36 +156

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.

Labels

Label changes:

  • add P1: False data-risk marks can leave the managed Gateway stopped and prevent update repair from recovering it.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: False data-risk marks can leave the managed Gateway stopped and prevent update repair from recovering it.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.

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.

Reviewed November 18, 2026, 5:58 PM ET / 22:58 UTC.

@fuller-stack-dev
fuller-stack-dev marked this pull request as draft November 19, 2026 00:52
…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.
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.
@fuller-stack-dev fuller-stack-dev changed the title fix: stop marking data at risk when a migrated update's restart fails or a rollback cannot read the schema fix: stop marking data at risk when a rollback cannot read the schema or has no baseline Nov 19, 2026
@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review November 19, 2026 08:12
@fuller-stack-dev
fuller-stack-dev merged commit 4c11507 into openclaw:main Nov 19, 2026
125 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
… 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
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
… 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant