Repository navigation
fix(update): agent databases falsely flagged as changed during snapshot capture - #170351
Conversation
Verified activation deletes the pre-migration snapshot directory. The snapshot step still recorded that those copies remain available, and the success report reprints that warning after cleanup. Refs: openclaw#170335
|
🦞👀 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: needs maintainer review before merge. What this changesThis PR uses private database-family copies during snapshot capture under confirmed maintenance custody. Example: An update captures agents/main/agent/openclaw-agent.sqlite with WAL sidecars left by an exited writer.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR owns a useful capture fix that current main lacks; no introduced defect was found, and the supplied installed-updater evidence demonstrates the changed behavior. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe installed updater captures shared and agent SQLite databases before candidate activation, producing verified snapshots and generation records consumed by guarded rollback. flowchart TD
A[Installed updater] --> B[Maintenance custody]
B --> C[Private database acquisition]
C --> D[Verified snapshots and generations]
D --> E[Candidate Doctor]
E --> F[Guarded database rollback]
D --> G[Update report]
Technical reviewBest possible solution: Land the focused private-acquisition repair while preserving existing rollback refusals for later database changes. Do we have a high-confidence way to reproduce the issue? Source establishes the native-open and generation-comparison failure path, supported by the reported base-failing regression and installed unfixed control; this review ran no target code. Is this the best way to solve the issue? Reusing artifact-preserving acquisition fixes capture's own source mutation without weakening generation checks; Doctor pre-admission changes are a separate existing limitation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9ffb5595942b. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +7, Tests +36, Docs +3. Total +46 across 5 files. Added test files: 1. View PR surface stats
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 HistoryReview history (8 earlier review cycles)
Reviewed October 13, 2026, 6:03 PM ET / 22:03 UTC (Revision 9). |
Package activation retires snapshots only when cleanup finishes. Git snapshots stay under .artifacts, and a recoverable package cleanup warning can leave them in place. One removal sentence covered none of those cases. Refs: openclaw#170335
Package and git updater runs now keep the lifetime sentences on the report and check the snapshot directory when activation does not succeed. Git runtime cleanup still leaves the .artifacts copy in place. Refs: openclaw#170335
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
A native open of a WAL family left by an exited writer rebuilds its WAL index and resets iChange, so the snapshot step's own read changed the recorded generation and disabled automatic restoration (openclaw#170335). Capture under confirmed maintenance custody now preserves source artifacts; unconfirmed custody keeps the online backup path. Reword the per-database capture warning so it no longer reads as an action item after success.
openclaw#170523 now keeps unrestorable snapshots after verified activation and owns their wording, so take main's text, tests, and docs for that policy. This branch keeps only the capture fix: copy database families privately under maintenance custody so the snapshot step's own read cannot change the recorded generation.
…ot capture (#170351) * fix(update): stop promising retained database snapshots after success Verified activation deletes the pre-migration snapshot directory. The snapshot step still recorded that those copies remain available, and the success report reprints that warning after cleanup. Refs: #170335 * fix(update): scope snapshot lifetime to package cleanup or git retention Package activation retires snapshots only when cleanup finishes. Git snapshots stay under .artifacts, and a recoverable package cleanup warning can leave them in place. One removal sentence covered none of those cases. Refs: #170335 * test(update): record snapshot lifetime on the update report Package and git updater runs now keep the lifetime sentences on the report and check the snapshot directory when activation does not succeed. Git runtime cleanup still leaves the .artifacts copy in place. Refs: #170335 * fix(update): copy database families privately under maintenance custody A native open of a WAL family left by an exited writer rebuilds its WAL index and resets iChange, so the snapshot step's own read changed the recorded generation and disabled automatic restoration (#170335). Capture under confirmed maintenance custody now preserves source artifacts; unconfirmed custody keeps the online backup path. Reword the per-database capture warning so it no longer reads as an action item after success. --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 648fb53)
…ot capture (openclaw#170351) * fix(update): stop promising retained database snapshots after success Verified activation deletes the pre-migration snapshot directory. The snapshot step still recorded that those copies remain available, and the success report reprints that warning after cleanup. Refs: openclaw#170335 * fix(update): scope snapshot lifetime to package cleanup or git retention Package activation retires snapshots only when cleanup finishes. Git snapshots stay under .artifacts, and a recoverable package cleanup warning can leave them in place. One removal sentence covered none of those cases. Refs: openclaw#170335 * test(update): record snapshot lifetime on the update report Package and git updater runs now keep the lifetime sentences on the report and check the snapshot directory when activation does not succeed. Git runtime cleanup still leaves the .artifacts copy in place. Refs: openclaw#170335 * fix(update): copy database families privately under maintenance custody A native open of a WAL family left by an exited writer rebuilds its WAL index and resets iChange, so the snapshot step's own read changed the recorded generation and disabled automatic restoration (openclaw#170335). Capture under confirmed maintenance custody now preserves source artifacts; unconfirmed custody keeps the online backup path. Reword the per-database capture warning so it no longer reads as an action item after success. --------- Co-authored-by: Dallin Romney <[email protected]>
…ot capture (openclaw#170351) * fix(update): stop promising retained database snapshots after success Verified activation deletes the pre-migration snapshot directory. The snapshot step still recorded that those copies remain available, and the success report reprints that warning after cleanup. Refs: openclaw#170335 * fix(update): scope snapshot lifetime to package cleanup or git retention Package activation retires snapshots only when cleanup finishes. Git snapshots stay under .artifacts, and a recoverable package cleanup warning can leave them in place. One removal sentence covered none of those cases. Refs: openclaw#170335 * test(update): record snapshot lifetime on the update report Package and git updater runs now keep the lifetime sentences on the report and check the snapshot directory when activation does not succeed. Git runtime cleanup still leaves the .artifacts copy in place. Refs: openclaw#170335 * fix(update): copy database families privately under maintenance custody A native open of a WAL family left by an exited writer rebuilds its WAL index and resets iChange, so the snapshot step's own read changed the recorded generation and disabled automatic restoration (openclaw#170335). Capture under confirmed maintenance custody now preserves source artifacts; unconfirmed custody keeps the online backup path. Reword the per-database capture warning so it no longer reads as an action item after success. --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 648fb53)
Related: #170335 (closed by #170523)
What Problem This Solves
Fixes: during
openclaw updatewith the Gateway already stopped, the database snapshot step reported agent databases as "Database changed during capture" and disabled automatic database restoration, even though nothing had written to them. The snapshot step's own read caused it.User Impact
User impact: updates keep automatic database rollback for agent databases left with WAL sidecars by their last writer. Since #170523, unrestorable snapshots are retained after success, so these false alarms also left a snapshot directory behind on every update; that stops too. Real changes during capture are still detected and reported, and capture without confirmed Gateway custody is unchanged.
Why This Change Was Made
Opening a WAL database natively with no other holder makes SQLite rebuild its WAL index, which resets the
-shmchange counter that is part of the recorded write generation. The snapshot step opened live agent databases natively, so its "after" generation never matched its "before". With maintenance custody confirmed, capture now copies each database family privately (the existingpreserveSourceArtifactspath) and never opens the source. The state database was not flagged in #170335 because it had been closed cleanly and took the raw-copy path.Update behavior: the installed updater runs the snapshot, so this takes effect for updates driven from a release containing it.
History: this PR originally reworded the snapshot-lifetime messages (DonnieFi's commits, kept in the branch). #170523 merged a different retention policy and owns that wording now, so the merge from
maintakes main's text, tests, and docs; the remaining diff is only the capture fix. Credit to DonnieFi for the report analysis and the original PR.Evidence
exited-writerscenario inupdate-command-database-rollback.test.ts: the agent database is left as a WAL family from an exited writer just before capture. Without the fix (re-verified on currentmainincluding fix: preserve unsealed database snapshots after successful updates #170523):expected [ …(2) ] to deeply equal [](changed-during-capture + restoration-disabled warnings). With it: no warnings, generation recorded, restore path exercised.pnpm testrollback +update-database-backup.test.ts36/36 andupdate-command-database-retention.test.ts(fix: preserve unsealed database snapshots after successful updates #170523) 2/2, 466s wall.tsgo:core:test, oxlint, oxfmt,format:docs:check,git diff --checkclean.Installed-updater proof (Docker, synthetic state)
These runs use the packed branch head
2c5441bc576installed withnpm install -gas the driver. Each one sets up Doctor, a managed Gateway (systemd shim) and a durable session, then updates to the same build relabeled2026.10.6. A synthetic SQLite writer stays active on the shared database until original capture.The "unfixed" control is the same tarball with only the
preserveSourceArtifactsline removed from the compiled capture module, which matchesmain.Database changed during capture … openclaw-agent.sqlitedatabase snapshotwarnings:[])Automatic database restoration unavailable: databases changed after snapshot capture; the writer is unknownDatabase changed during capture …database rollbackrefuses:Databases changed after snapshot capture: …/openclaw-agent.sqlite. The candidate stays installed and the Gateway serves the preserved state.In every run, the session written before the update is still present afterward,
/readyzreturns 200, andopenclaw.jsonis byte-identical.Result: the capture-time false warning is fixed. Automatic restoration is still not eligible in the installed-updater flow, so this PR does not yet restore the rollback contract.
A timestamped watcher on the agent database's WAL and
-shmheader shows the cause:-shmiChange=4. The snapshot leaves it unchanged, which is the fix working.state/openclaw-agent-schema-inspection.worker.js→withSqliteSourceReadDatabase) natively opens the source with no holder. The WAL index rebuilds (iChange=0) before the Doctor write capture'sadmit()readsfromGenerations.createUpdateDoctorDatabaseWriteCapturetreats any change during Doctor as unattributed (unchanged=false).Remaining work needs the rollback owner's direction:
Published driver → candidate
scripts/e2e/published-driver-update-docker.shran with published[email protected]as the driver and this branch as the candidate:finished, readyz 200, running version and build verified.