Skip to content

perf(update): avoid duplicate snapshot integrity scans - #162996

Merged
steipete merged 2 commits into
mainfrom
codex/updater-snapshot-cost
Oct 2, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/updater-snapshot-cost

Conversation

@steipete

@steipete steipete commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Updates with large databases spend avoidable time validating their private snapshots.

User Impact

User impact: update snapshot preparation does less work while preserving full integrity checks, source data, and existing backup and rollback guarantees.

The published 2026.9.7 updater selects its own snapshot worker, so installing this candidate does not improve its initial snapshot on that first upgrade. Updaters that select the staged candidate's worker can use this implementation. No schema, retention, or configuration changes are required.

Why This Change Was Made

Remove the intermediate integrity and caller-validation pass over transformed output. The source still receives full validation, and the final private staging image is fully validated before publication. All byte hashes, file identities, schema-version comparisons, durability checks, authority guards, and failure cleanup remain.

Evidence

Exact-head CI succeeded for eaee973bf7f14fddce91375a56935bfe9cdfb5bb (recorded October 2, 2026).

Three alternating paired trials per worker mode used the same two synthetic indexed SQLite databases totaling 131.24 MiB. These are local warm-filesystem measurements including worker startup, not complete update timings.

Worker mode Baseline median wall Candidate median wall Median paired wall change Median paired CPU change
Candidate snapshot 2.375 s 2.023 s 14.81% faster 5.42% lower
Recovery database backup 5.354 s 5.873 s 9.68% slower 1.30% higher

Backup timing varied substantially and does not establish an end-to-end backup speedup. Every measured run reduced integrity and foreign-key checks from six each to four each. All 12 outputs passed data, sparse-ID, index, integrity, foreign-key, version, lease, registry-path, and backup-digest checks; both source hashes remained unchanged.

  • pnpm test src/infra/sqlite-snapshot.test.ts --maxWorkers=1: 43 passed, two platform skips; 30.49 s command wall. The three added corruption cases totaled 537 ms.
  • Row-preservation and recovery-backup sibling suites: 19 passed; 40.10 s command wall.
  • Negative controls: temporarily removing final validation made all three transformed index, foreign-key, and caller-validation cases fail because invalid snapshots were accepted. Final validation remains enabled.
  • Full changed-code gate passed, including core and 27 test typecheck groups, lint, formatting, dead exports, and repository guards. git diff --check passed. Fresh independent P2 review found no actionable findings.

CI per-file durations were not recoverable from the bounded selected changed/boundary logs or artifacts; local costs are retained. The benchmark capsule initially omitted a runtime support file; that harness-only setup error was corrected before measurement.

The shared Linux comparison ran six warm, unchanged-tree source updates in A,B,B,A,A,B order (n=3 each), using the same logical synthetic corpus, including 5,000 retained subagent runs:

Variant Full-update wall samples Median
A: baseline 745.059 / 664.157 / 675.873 s 675.873 s
B: combined candidate 702.441 / 648.208 / 654.916 s 654.916 s

The median was 20.958 s / 3.1% lower observed. All six passed native restart, readiness, settlement at exit, and data-preservation checks. Downtime medians were effectively unchanged: 157.058 → 156.603 s. Warming and dependency-time variance confound attribution; this is neither per-PR causal evidence nor a cold-update claim. Four source-path fixes apply together; package fingerprinting was measured separately.

Exact runtime builds passed for A (ee0b30ef65203430572ce6397f419fbadc1367af) and corrected B. Both reused identical verified declaration/AI prerequisites from full builds of A and preceding B (39a785f2df931f5e8f2795201b04c911bfe9849e); corrected B's full declarations were not rebuilt. Each update advanced to a new commit with an unchanged source tree. Preparation was outside timing; no updater timeout or declaration override was supplied. Three untimed harness setup failures (canonical profile paths, private HOME permissions, and systemd WorkingDirectory display parsing) were corrected before timing; no timed update attempt was replayed.

Published first-hop limitation: The single published 2026.9.7 → corrected B attempt failed after 216.596 s; published → A failed after 216.787 s with the same installed-driver error: SQLite journal state changed while copying. B built successfully, but the shipped driver selected its own snapshot worker and failed before candidate Doctor/config/plugin/canary validation or activation. Both attempts settled with zero active runs, preserved all seeded data and schema 19, and retained the original source/runtime. Neither attempt proves candidate acceptance. A progress-only CI cell passed in 505.845 s with fresh two-agent state, plugins disabled, providers/channels skipped, and no Doctor seeding; it does not replace populated combined-B first-hop or failure-recovery proof.

This head also carries Vincent Koc’s model-control readiness fixture correction from #162869. Earlier affected runs failed on the premature assertion; the corrected test passed on main, and this exact refreshed head's CI succeeded.

@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 size: S labels Oct 1, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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, 8:25 PM ET / October 2, 2026, 00:25 UTC (Revision 3).

ClawSweeper review

What this changes

The PR removes a duplicate SQLite snapshot validation pass, adds transformed-output rejection coverage and updater documentation, and inherits a merged UI test readiness correction.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: the optimization remains useful and is absent from current main. No actionable introduced correctness defects were found.

Priority: P2
Reviewed head: eaee973bf7f14fddce91375a56935bfe9cdfb5bb

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and preserves final validation, but required upgrade qualification is incomplete.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: 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.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 8 items Pinned introduced change: The verified merge-base-to-head diff removes only the intermediate integrity and caller-validation calls from production code; the additional UI hunk changes an existing readiness assertion.
Final validation remains before publication: Publication invokes final staging validation before exposing the target, then verifies the expected bytes and file identity. The final validator retains full integrity, caller validation, and user-version comparison.
Current-main necessity: Fetched main still performs intermediate integrity and caller validation and repeats them in final publication staging, so it does not already contain this optimization.
Findings None None.
Security None None.

How this fits together

OpenClaw prepares private SQLite snapshots for update rehearsals and recovery backups. Source databases enter this subsystem, and verified standalone database files leave it for migration checks or backup publication.

flowchart TD
  A[Source databases] --> B[Validate source]
  B --> C[Create private snapshot]
  C --> D[Apply required transformations]
  D --> E[Validate final staging image]
  E --> F[Verify bytes and publish]
  F --> G[Update rehearsal or recovery backup]
Loading

Before merge

  • Resolve merge risk (P1) - The required published 2026.9.7 updater × candidate qualification remains outstanding; isolated worker results do not establish successful upgrade completion with existing operator state preserved.
  • Complete next step (P2) - Complete and record the published 2026.9.7 updater × candidate qualification with successful upgrade completion and preserved existing operator state.
Agent review details

Security

None.

PR surface

Source -1, Tests +63, Docs +9. Total +71 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 2 -1
Tests 2 67 4 +63
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 77 6 +71

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Complete published-driver qualification (recommended)
    Record successful published 2026.9.7 updater execution against the candidate and verify preservation of existing operator state before landing.

Technical review

Best possible solution:

Retain full source and final-staging validation while eliminating the intermediate scan, with published-updater qualification confirming the existing upgrade and recovery guarantees.

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

Not applicable to a discrete bug: source inspection confirms the duplicate validation work, and the body supplies paired worker measurements; this read-only review ran no tests or benchmarks.

Is this the best way to solve the issue?

Yes: removing the intermediate pass is a focused simplification because equivalent final validation still precedes publication and exact-byte checks remain intact.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded update-performance improvement without evidence of an urgent user-facing regression.
  • merge-risk: 🚨 compatibility: Snapshot validation changes affect update and recovery guarantees whose required published-driver compatibility qualification remains incomplete.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

  • Pinned introduced change: The verified merge-base-to-head diff removes only the intermediate integrity and caller-validation calls from production code; the additional UI hunk changes an existing readiness assertion. (src/infra/sqlite-snapshot.ts:656, eaee973bf7f1)
  • Final validation remains before publication: Publication invokes final staging validation before exposing the target, then verifies the expected bytes and file identity. The final validator retains full integrity, caller validation, and user-version comparison. (src/infra/sqlite-snapshot.ts:412, eaee973bf7f1)
  • Current-main necessity: Fetched main still performs intermediate integrity and caller validation and repeats them in final publication staging, so it does not already contain this optimization. (src/infra/sqlite-snapshot.ts:656, 1c739851e6ad)
  • Meaningful corruption coverage: The three added cases introduce transformed index inconsistency, a foreign-key violation, or caller-invalid content and assert rejection without a published target or changed source bytes. The body reports successful negative controls with final validation temporarily removed. (src/infra/sqlite-snapshot.test.ts:534, eaee973bf7f1)
  • Real worker measurements and remaining qualification: The captured body reports 12 production-worker outputs from paired trials on 131.24 MiB of synthetic databases, with preserved source hashes and verified output content. Candidate-snapshot median wall time improved 14.81%; backup timing did not establish a speedup. It explicitly leaves the published 2026.9.7 first-hop and combined full-update result outstanding. (f5fe1efa8296)
  • Applicable update proof requirement: The fully read root policy requires published-driver × candidate proof for update changes. The PR documents that published 2026.9.7 uses its own snapshot worker, limiting first-hop benefit. No schema, configuration, retention, or serialized-format change is introduced. (AGENTS.md, eaee973bf7f1)

Likely related people:

  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • 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.

  • Add a redacted published 2026.9.7 updater × candidate transcript showing completed upgrade and preserved operator state; terminal output or logs are sufficient. Update the PR body to trigger re-review, or ask a maintainer for @clawsweeper re-review if needed.

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 (2 earlier review cycles)
  • reviewed 2026-10-01T21:08:48.580Z sha f5fe1ef :: needs changes before merge. :: none
  • reviewed 2026-10-01T23:05:35.993Z sha f5fe1ef :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review October 1, 2026 22:59
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 1, 2026
Apply the existing fixture correction from dd2a7ba (#162869). The picker can be visible while its controls still await catalog hydration; assert readiness before interacting.

Co-authored-by: Vincent Koc <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Oct 2, 2026
@steipete
steipete merged commit 4da115e into main Oct 2, 2026
136 checks passed
@steipete
steipete deleted the codex/updater-snapshot-cost branch October 2, 2026 02:30
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
* perf(update): avoid duplicate snapshot integrity scans

* test(ui): inherit model picker readiness fix

Apply the existing fixture correction from 9ba56c1 (openclaw#162869). The picker can be visible while its controls still await catalog hydration; assert readiness before interacting.

Co-authored-by: Vincent Koc <[email protected]>

---------

Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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