Skip to content

fix(update): bind rollback backups to verified snapshot bytes - #162383

Merged
steipete merged 1 commit into
mainfrom
codex/updater-verified-snapshot-receipts
Oct 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/updater-verified-snapshot-receipts

Conversation

@steipete

@steipete steipete commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Rollback metadata can certify database bytes changed after snapshot verification because the backup caller hashes the published pathname again.

User Impact

Rollback stays bound to the bytes the snapshot owner actually verified. Later same-size mutation or replacement is rejected, and each backup avoids one redundant full-file hash read. No schema, retention, timeout, or operator configuration changes.

Why This Change Was Made

Return the existing verified SHA-256 and length from the snapshot publisher and consume those facts in backup metadata. Every source, integrity, publication, durability, authority, and restore check remains enabled. Remove one stale Doctor test assertion for the already-retired postMigrationGenerations field; its foreign-write refusal and data-preservation assertions remain intact.

The installed updater must contain this change for its own backups to benefit. Candidate Doctor calls use candidate code; an unchanged older driver retains its existing capture path.

Evidence

  • In-place mutation and pathname replacement after real snapshot publication both fail the new regression on baseline and pass after repair. An existing restore test now uses same-size corruption to prove digest rejection before live files move.
  • Snapshot/backup/restore selection: 66 passed, two Windows-only skips. Both Doctor foreign-write cases pass, and the previously failing commands-doctor type graph passes. Relevant type, lint, formatting, and remaining guard checks pass.
  • Single-worker test-file walls: snapshot 105.86 s, backup 51.62 s; cold worker preparation and shared-host load are included. The new fault cases take about 0.15–0.24 s each. Doctor cases: 18.16 s wrapper wall.
  • Eight counterbalanced real captures of a 167,034,880-byte indexed database reduced published-file read opens from 2 to 1. Wall-time medians were 4.39 s baseline and 5.22 s candidate, so no wall-time speedup is claimed.
  • Fresh independent review and GitHub review: no introduced code findings.
  • Published-driver compatibility passed: integrity-verified npm 2026.9.7 (c074824a) updated to exact candidate 9c08901390217bf4f34152a4b25fecf4b915d2c9, tree 18c4c7c0f49145885526b60cb3f887be37d80566, on Linux/Node 24.19.0. Real build, staging, Doctor and retained canary phases completed; native status succeeded/finished with zero active runs. Both agents, 1,024 sessions, 8,192 transcript events, 20,000 plugin-state rows, three installed plugins and workspace contents were preserved. Wall 182.846 s; this compatibility cell is not a speedup comparison. Testbox run.

@clawsweeper

clawsweeper Bot commented Oct 1, 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 commands Command implementations size: S labels Oct 1, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 1, 2026, 12:23 AM ET / 04:23 UTC.

ClawSweeper review

What this changes

The PR records rollback backup hashes and lengths from the verified SQLite snapshot publisher instead of rereading the published pathname, and adds mutation coverage and update documentation.

Merge readiness

⛔ Blocked before merge - 2 items remain

This remains a useful, focused fix: current main and the latest release still recertify the published pathname. No actionable introduced defect was found.

Likely related people: steipete (routing candidate; medium confidence).

Priority: P2
Reviewed head: 9c08901390217bf4f34152a4b25fecf4b915d2c9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful regression coverage; required released-updater verification remains a merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies a MEMBER author, so the ordinary external-contributor gate does not apply. Reported real database captures exercise the changed snapshot/backup owners, with fault tests supplemental; the separately required published-driver compatibility run remains pending. No stored-data format or schema changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies a MEMBER author, so the ordinary external-contributor gate does not apply. Reported real database captures exercise the changed snapshot/backup owners, with fault tests supplemental; the separately required published-driver compatibility run remains pending. No stored-data format or schema changes.
Evidence reviewed 10 items Pinned introduction and merge result: Reviewed the complete merge-base-to-head patch. The verified test merge retains the same production changes against its main parent; unrelated endpoint drift is not attributed to this PR.
Publisher owns verified content: The snapshot owner hashes validated staged bytes, verifies publication against those facts, and now returns the same expected content. Backup metadata consumes those facts without changing its existing field contract.
Restore safeguards remain intact: Restore verifies every snapshot's digest and byte count before moving live files, rechecks current ownership, and verifies expected content again during publication. The patch changes neither these authorization checks nor which principals can restore.
Findings None None.
Security None None.

How this fits together

OpenClaw snapshots databases before update migrations and retains backup metadata for rollback. Restore checks the retained snapshot bytes before replacing live databases.

flowchart TD
  A[Existing databases] --> B[Verified snapshot publisher]
  B --> C[Published snapshots]
  B --> D[Verified hash and length]
  D --> E[Rollback metadata]
  C --> F[Restore verification]
  E --> F
  F --> G[Restore or refuse]
Loading

Before merge

  • Resolve merge risk (P1) - Published-updater compatibility remains unverified: record the required released-driver × candidate run using existing operator state before landing.
  • Complete next step (P2) - Complete and record the repository-required published-driver × candidate compatibility run before landing.
Agent review details

Security

None.

PR surface

Source -2, Tests +55, Docs +6. Total +59 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 4 6 -2
Tests 4 60 5 +55
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 70 11 +59

Review metrics

Metric Value Why it matters
Redundant snapshot read 1 full-file hash read removed per database The caller now reuses verified content facts; the reported captures support fewer opens without claiming a wall-time speedup.

Merge-risk options

Maintainer options:

  1. Complete released-updater verification (recommended)
    Record a published driver updating to this candidate with existing state, including successful completion and usable retained recovery artifacts.

Technical review

Best possible solution:

Keep snapshot verification authoritative for backup metadata while demonstrating that released updaters can complete the update with the candidate.

Do we have a high-confidence way to reproduce the issue?

Yes, source establishes the failure path: change the published snapshot after verification but before the caller rehashes it, and baseline metadata certifies the changed bytes. The PR reports failing baseline regressions; this review did not execute them.

Is this the best way to solve the issue?

Yes. Returning the publisher's already-verified content facts is the narrow repair and preserves the existing restore checks and metadata shape.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d7b029347fd0.

Labels

Label changes:

  • add P2: This repairs a bounded rollback integrity window without evidence of an active widespread outage.
  • add merge-risk: 🚨 compatibility: The update path crosses released-driver and candidate versions, and its required compatibility run remains pending.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies a MEMBER author, so the ordinary external-contributor gate does not apply. Reported real database captures exercise the changed snapshot/backup owners, with fault tests supplemental; the separately required published-driver compatibility run remains pending. No stored-data format or schema changes.

Label justifications:

  • P2: This repairs a bounded rollback integrity window without evidence of an active widespread outage.
  • merge-risk: 🚨 compatibility: The update path crosses released-driver and candidate versions, and its required compatibility run remains pending.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies a MEMBER author, so the ordinary external-contributor gate does not apply. Reported real database captures exercise the changed snapshot/backup owners, with fault tests supplemental; the separately required published-driver compatibility run remains pending. No stored-data format or schema changes.

Evidence

What I checked:

  • Pinned introduction and merge result: Reviewed the complete merge-base-to-head patch. The verified test merge retains the same production changes against its main parent; unrelated endpoint drift is not attributed to this PR. (src/infra/sqlite-snapshot.ts:669, 9c0890139021)
  • Publisher owns verified content: The snapshot owner hashes validated staged bytes, verifies publication against those facts, and now returns the same expected content. Backup metadata consumes those facts without changing its existing field contract. (src/infra/update-database-backup.ts:286, 9c0890139021)
  • Restore safeguards remain intact: Restore verifies every snapshot's digest and byte count before moving live files, rechecks current ownership, and verifies expected content again during publication. The patch changes neither these authorization checks nor which principals can restore. (src/infra/update-database-restore.ts:169, 9c0890139021)
  • Meaningful fault coverage: Two added cases call the real snapshot publisher before injecting same-size mutation or pathname replacement and checking that metadata retains the original digest. Restore coverage now corrupts bytes without changing length and checks that live databases remain untouched. These are supplemental tests, not reviewer-executed runtime proof. (src/infra/update-database-backup.test.ts:117, 9c0890139021)
  • Still necessary on main: Pinned main still hashes snapshotPath after snapshot publication and records that newly read digest, preserving the reported recertification window. (src/infra/update-database-backup.ts:283, d7b029347fd0)
  • Latest release retains old capture: The v2026.9.7 source still calls sha256File(snapshotPath). Its release commit was independently verified through the GitHub commit endpoint. (src/infra/update-database-backup.ts:226, c074824a27c9)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the published-driver × candidate compatibility result in the PR evidence.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete marked this pull request as ready for review October 1, 2026 04:43
@steipete
steipete enabled auto-merge (squash) October 1, 2026 04:49
@steipete
steipete merged commit 0783e3f into main Oct 1, 2026
310 of 311 checks passed
@steipete
steipete deleted the codex/updater-verified-snapshot-receipts branch October 1, 2026 04:58
@steipete

steipete commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant