Repository navigation
fix(update): preserve failure history during database rollback - #160614
Conversation
Carry complete current update_runs rows into the private database restore source under the existing exclusion, leaving original snapshots unchanged. Keep the inspection worker on the retained updater runtime after package replacement. Related: #144005, #145169, #158491 Co-authored-by: Jason (Json) <[email protected]>
|
🦞👀 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. Reviewed September 29, 2026, 1:35 AM ET / 05:35 UTC (Revision 8). ClawSweeper reviewWhat this changesThe branch prepares a private SQLite restore copy that carries forward current update history, adds rollback and retained-runtime coverage, and documents the recovery behavior. Merge readiness⛔ Blocked before merge - 4 items remain Current main still restores the captured shared database without preserving update records written afterward. This PR addresses that loss, but its changed rollback contract needs explicit acceptance and existing-state upgrade proof. Priority: P1 Review scores
Verification
How this fits togetherThe updater captures application databases before migration and restores them if activation fails. The restore path decides whether recovery is safe, then replaces database files and records the outcome in update history. flowchart LR
A[Failed update] --> B[Captured databases]
A --> C[Current update history]
B --> D[Restore preparation]
C --> D
D --> E{Safe to restore?}
E -->|Yes| F[Restored application data and history]
E -->|No| G[Retained data and recovery guidance]
Decision needed
Why: That choice changes the documented rollback and persistence contract; source correctness alone cannot accept its operator impact. Before merge
Agent review detailsSecurityNone. PR surfaceSource +214, Tests +201, Docs +3. Total +418 across 8 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Preserve the canonical update ledger alongside restored application data, keep unsupported layouts fail-safe with clear recovery guidance, and qualify the supported upgrade path against copied existing state. Do we have a high-confidence way to reproduce the issue? Yes, from source: write or remove update-history rows after capture, then restore the captured shared database on current main. Its publication loop replaces those later rows; no current-main execution was performed in this read-only review. Is this the best way to solve the issue? Yes, provisionally. Preparing a private restore image within the existing exclusion preserves history without altering original snapshots; the intentional mismatch refusal and supported upgrade path still need acceptance and proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ec101d561e2c. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
Integrate pinned main 4d4d99d with the history-preserving restore owner. Keep prepared-copy cleanup and retain main's generation-mismatch diagnostic. Extend the existing foreign-write case to assert that the refusal identifies the changed database. The diagnostic omission fails its targeted negative control. All 24 restore and CLI database-rollback cases pass on the integrated tree. Independent P2 review reports no actionable findings. Earlier installed proof remains bound to 50d8306; it is not execution of this integrated candidate.
|
Merged via squash.
|
…law#160614) * fix(update): preserve failure history during database rollback Carry complete current update_runs rows into the private database restore source under the existing exclusion, leaving original snapshots unchanged. Keep the inspection worker on the retained updater runtime after package replacement. Related: openclaw#144005, openclaw#145169, openclaw#158491 Co-authored-by: Jason (Json) <[email protected]> * fix(update): clean settled restore preparation failures * test(update): route restore preparation through host SQLite * fix(update): clean restore copies after refused first move --------- Co-authored-by: Jason (Json) <[email protected]>
What Problem This Solves
Fixes lost update history when a failed update restores its database snapshot: rollback could erase failure details, revive deleted runs, and discard runs created since capture.
User Impact
Database rollback preserves current update history while restoring captured application state. Original recovery snapshots remain unchanged. This requires the repaired updater to drive the update; already-running older drivers retain their existing recovery limits.
Unsupported history schemas, changed application data, or lost ownership still refuse restoration before displacement. Current data and recovery snapshots remain available; the updater does not force a lossy rollback.
Why This Change Was Made
The existing restore owner prepares a private copy of the shared snapshot and overlays complete current history rows, including rowids and opaque fields. Existing database exclusions remain held through preparation and publication. Inspection uses the retained updater runtime after package replacement. Completed work and settled refusals clean the private copy; a move or uncertain child settlement retains recovery material.
Integration with current main preserves its generation-mismatch diagnostic inside that cleanup structure. No new manager, ledger, schema, dependency, or configuration option is introduced by this change.
Related: #144005, #145169, #158491. Continues the recovery work contributed by @fuller-stack-dev.
Evidence
Current candidate
f4e8100d137217e0e1d88d50ef260b1279ca74b5integrates pinned main4d4d99d6250ff63e9de09da840ad9e65836d201c.The test command was
node scripts/run-vitest.mjs src/infra/update-database-restore.test.ts src/cli/update-cli/update-command-database-rollback.test.ts --maxWorkers=1. Existing native SQLite, filesystem, ownership, and subprocess coverage accounts for the runtime; the added assertion reuses an existing scenario.Historical installed proof, not execution of the current candidate: Crabbox run qualified source head
50d83060e95e4df8032d408086cfa6804505bba2. Maintainers independently inspected the completed native payload and retained results despite the canceled public Actions run. The source-built package was SHA-25677d8c541faad314c8e208a1fdabfb878e0b1a002480360079491f18265bc9015(113,893,441 bytes). Build/packaging took 538.50 s and the installed scenario 471.30 s.That installed updater preserved all three nonexecuting history rows and all 18 fields, opaque JSON, additions/deletions, and rowid
9007199254740993while restoring application databases after an injected Doctor failure. The active run finishedrolled-back; original snapshots, backup/session records, restored package identity, and the previous Gateway's serving build and health were verified. A refusing candidate worker confirmed use of the retained updater runtime. Those restore/inspection implementations are unchanged except for main's preserved refusal diagnostic; the new source integration tests above are separate evidence.Installed Linux CLI, SQLite, package recovery, and Gateway processes were real. Service-manager responses, candidate metadata, and admitted Doctor writes/failure were synthetic. This is not proof of the integrated candidate's installed package, native systemd/macOS/Windows, model inference, general NOCOW behavior, or post-serving rollback. The canonical build's report-only size warning and post-run tooling warnings were retained and reconciled; no budget or bypass was changed.
The older 50d CI run remains recorded as 117 successful, 45 canceled, 20 skipped, and two failed jobs (an unrelated UI request-timing assertion and its aggregate). The canonical UI correction is included from #160366. That old CI result and its admin attribution are not current-candidate CI proof; this integration push receives fresh CI, Security Review, and ordinary native merge admission.