Skip to content

fix(update): shorten database rehearsal preparation - #157115

Merged
steipete merged 2 commits into
mainfrom
codex/update-single-snapshot
Sep 24, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/update-single-snapshot

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Database rehearsal preparation takes longer than necessary because it backs up each already-private SQLite snapshot a second time.

User Impact

Updates using the newer updater prepare copied database state faster with less disk work. Existing installed updaters keep their first-hop behavior. Source databases, recovery backups, migration checks, compaction, and verified publication retain their existing guarantees; no schema or configuration change is required.

Why This Change Was Made

The snapshot verifier now acquires and consumes its own fresh private image in the isolated updater process. It keeps WAL-aware acquisition and crash-residue handling, validates before transformation, and joins all consumer work before cleanup. Ordinary backup callers retain their existing acquisition path.

Evidence

Isolated Blacksmith Testbox benchmark: Linux x64, 4 vCPUs, Node 24.19.0; two 128 MiB synthetic databases with an independent WAL writer. After excluded warmups, three alternating baseline/candidate pairs ran the real inventory and snapshot workers. Source and output integrity, full payload hashes, and coherent generations passed in every trial. Baseline 3e3b870b2571; candidate abed6d816926.

Median Baseline Candidate Improvement
Inventory + snapshot 3.896 s 3.653 s 6.2% less time
Snapshot phase 2.929 s 2.555 s 12.8% less time
Native backup output 671,817,728 bytes 403,091,456 bytes 40% less
Native backups 5 3 Two redundant backups removed

All three paired wall times improved; CPU was essentially flat (4.22 to 4.14 s). These are preparation-stage measurements, not whole-update latency. The Testbox lease was stopped after verification.

  • Regression: the real worker test fails before the change with four backups for two live databases, then passes with two while an independent WAL writer commits and both copies remain coherent.
  • Local: 103 focused checks passed across snapshot publication, updater state, inventory drift, and cleanup failures. Final snapshot-owner checks passed (42 tests, two Windows-only skips), including source symlinks and unchanged source bytes; the two concurrent-writer checks passed. Core types, all 26 core-test type graphs, ratchets, dead exports, lint, schema/storage/import/auth guards passed. One test-variable shadow was corrected after lint identified it.
  • Exact-head CI passed at abed6d816926, including Linux and Windows coverage.
  • Changed test cost (pnpm test <file> --maxWorkers=1): snapshot owner 59.85 s local command wall; concurrent-writer boundary 22.15 s. Linux CI summed test durations were 1.425 s and 1.293 s respectively; Windows was 1.280 s and 2.973 s. Local command wall includes worker preparation.
  • Independent Codex review found no actionable P0–P2 issues; ClawSweeper reported no code findings.
  • Published-driver upgrade validation passed: published [email protected] upgraded existing synthetic operator state to candidate 2026.9.6 / 0e60e06c258a, with tooling pinned to 3e3b870b2571. The native outcome was success; state/config survival, prepublish recovery-request assertions, Doctor checks, Gateway startup, health and readiness passed. The lane took 733 s. It used manual Gateway startup; forced rollback was not exercised. The final head differs only by a test-variable rename; production bytes are identical.

@clawsweeper

clawsweeper Bot commented Sep 24, 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 size: M labels Sep 24, 2026
@steipete
steipete marked this pull request as ready for review September 24, 2026 07:18
@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. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 24, 2026, 4:04 AM ET / 08:04 UTC (Revision 2).

ClawSweeper review

What this changes

The branch changes update rehearsal to validate and publish one freshly acquired private SQLite image per database, and updates cleanup, tests, and update documentation.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open. Current main still makes the redundant backup, and the proposed optimization is coherent. The required published-updater upgrade validation has not completed.

Priority: P2
Reviewed head: abed6d816926cbbe376347e4e0d56d549f0692a0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The owner-level change and reported worker-boundary proof support a good patch, with published-updater qualification still outstanding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured PR body reports an after-fix run of the production candidate snapshot worker with real SQLite databases and an independent WAL writer: two coherent copies required two native backups rather than four. That supports the changed preparation path; the separate published-updater upgrade gate remains incomplete. No stored-data format or schema contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured PR body reports an after-fix run of the production candidate snapshot worker with real SQLite databases and an independent WAL writer: two coherent copies required two native backups rather than four. That supports the changed preparation path; the separate published-updater upgrade gate remains incomplete. No stored-data format or schema contract changes.
Evidence reviewed 7 items Current-main behavior: Current main acquires a private rehearsal image and passes it to the verifier, which performs another native backup; the central optimization is not yet implemented there.
Introduced rehearsal path: The pinned PR diff routes rehearsal through isolated source acquisition in the existing verified snapshot owner.
Verification and publication: The isolated path skips the second backup while retaining source validation, private transformation, integrity checks, synchronization, and verified publication.
Findings None None.
Security None None.

How this fits together

During an OpenClaw update, an isolated candidate worker copies live SQLite state for rehearsal. Verified copies and their schema versions feed candidate validation before activation.

flowchart LR
  A[Live SQLite state] --> B[Candidate snapshot worker]
  B --> C[Private SQLite image]
  C --> D[Integrity and rehearsal checks]
  D --> E[Verified database copy]
  E --> F[Candidate validation]
  F --> G[Update decision]
Loading

Before merge

  • Resolve merge risk (P1) - The published-updater-to-candidate upgrade run is still incomplete, so existing-state upgrade and recovery behavior has not yet met the repository's update proof gate.
  • Complete next step (P2) - Record the published-updater-to-candidate upgrade result on existing state, including preparation and recovery or rollback behavior.
Agent review details

Security

None.

PR surface

Source +37, Tests +53, Docs +5. Total +95 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 148 111 +37
Tests 2 78 25 +53
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 231 136 +95

Review metrics

Metric Value Why it matters
Native rehearsal backups 4 → 2 for two live databases The worker-boundary check measures the disk-work reduction this change is intended to deliver.

Merge-risk options

Maintainer options:

  1. Complete the published upgrade check (recommended)
    Record the running published-updater-to-candidate result, including preparation and recovery or rollback behavior on existing state, before merge.

Technical review

Best possible solution:

Keep one verified private image per rehearsal database, then confirm that a published updater completes or safely recovers an upgrade using existing state.

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

Yes. Current main visibly backs up an already-private rehearsal image; the focused worker test supplies a real-SQLite backup-count path, though this read-only review did not execute it.

Is this the best way to solve the issue?

Yes. The branch reuses the existing snapshot acquisition, validation, publication, and cleanup owners; its remaining qualification is the published-updater upgrade run.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b078de41c413.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded update performance improvement without evidence of a current user-blocking failure.
  • merge-risk: 🚨 compatibility: Candidate rehearsal changes during an upgrade, and the required published-updater compatibility run remains incomplete.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured PR body reports an after-fix run of the production candidate snapshot worker with real SQLite databases and an independent WAL writer: two coherent copies required two native backups rather than four. That supports the changed preparation path; the separate published-updater upgrade gate remains incomplete. No stored-data format or schema contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body reports an after-fix run of the production candidate snapshot worker with real SQLite databases and an independent WAL writer: two coherent copies required two native backups rather than four. That supports the changed preparation path; the separate published-updater upgrade gate remains incomplete. No stored-data format or schema contract changes.

Evidence

What I checked:

  • Current-main behavior: Current main acquires a private rehearsal image and passes it to the verifier, which performs another native backup; the central optimization is not yet implemented there. (src/infra/update-candidate-state.ts:629, b078de41c413)
  • Introduced rehearsal path: The pinned PR diff routes rehearsal through isolated source acquisition in the existing verified snapshot owner. (src/infra/update-candidate-state.ts:610, abed6d816926)
  • Verification and publication: The isolated path skips the second backup while retaining source validation, private transformation, integrity checks, synchronization, and verified publication. (src/infra/sqlite-snapshot.ts:614, abed6d816926)
  • Worker-boundary coverage: The process test exercises the candidate worker with real SQLite databases and an independent WAL writer, asserting two native backups and checking the published copies. The captured PR body reports that its baseline used four backups. (src/infra/update-candidate-state.online-backup.process.test.ts:177, abed6d816926)
  • Reported real-setup proof: The captured PR body reports alternating baseline and candidate runs on an isolated Linux Testbox with two 128 MiB databases and an independent WAL writer. It reports coherent copies and a 12.8% shorter snapshot phase. The linked workflow was canceled after the reported verification, and its job log was unavailable through the review proxy; the measurements are assessed as contributor-provided evidence. (abed6d816926)
  • Upgrade gate: Repository policy requires a published-driver-to-candidate proof cell for update changes. The linked published-updater validation had completed candidate resolution, but the overall run remained in progress when checked. (AGENTS.md:83, abed6d816926)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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-updater-to-candidate result on existing state, including recovery or rollback behavior.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-24T07:34:21.176Z sha abed6d8 :: blocked before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The published-driver proof is complete: https://github.com/openclaw/openclaw/actions/runs/35968993857 passed using published [email protected] against candidate 0e60e06c258a (production bytes identical to the final head; the only later change renames a test variable). The receipt records native update outcome success, installed version 2026.9.6, state/config survival, prepublish recovery-request assertions, Doctor checks, and passing Gateway health/readiness after manual startup. Forced rollback was not exercised. The PR body now includes that qualification, green exact-head CI, and the isolated alternating performance measurements.

@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit a095b72 into main Sep 24, 2026
223 checks passed
@steipete
steipete deleted the codex/update-single-snapshot branch September 24, 2026 08:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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