Skip to content

fix(updates): avoid repeated private snapshot integrity scans - #174928

Merged
vincentkoc merged 2 commits into
mainfrom
fix/sqlite-snapshot-integrity-once-20261017
Oct 17, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/sqlite-snapshot-integrity-once-20261017

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes repeated full integrity scans while preparing private SQLite update snapshots, including stopped captures with committed WAL data.

User Impact

Eligible private snapshots perform one integrity and foreign-key pass instead of two. FULL auto-vacuum databases, transforms, compaction, caller validators, and native online backups retain their existing checks. No migration, configuration, or operator action is required.

Why This Change Was Made

The snapshot owner already checks the final private image before publication. It can defer the earlier check when the input is privately owned, row IDs are preserved, no transform or validator runs, and SQLite reports NONE or INCREMENTAL auto-vacuum.

FULL auto-vacuum stays excluded: switching journal mode can commit an auto-vacuum operation that removes a malformed freelist. Its early check must reject that corruption before normalization can erase the evidence. Native admission, source-generation/SHM guards, content hashes, publication checks, and cleanup remain unchanged.

The dialect ratchet now recognizes the existing snapshot module as the native SQLite artifact owner. Its PRAGMAs admit and normalize SQLite files; update backup callers attach PostgreSQL exports through a separate owner. No PostgreSQL query, schema, or migration contract changes. Only engine-maintenance constructs receive this scoped classification; consumer PRAGMAs and mechanical/design growth still fail, as four added ratchet cases verify.

Evidence

  • Native Blacksmith Testbox allocation run: 64 passed, 2 existing platform skips, across the new integrity tests and existing snapshot/transfer suites. The outer Actions allocation was cancelled during the queue/stop race; the already-running test command completed, and the wrapper returned exit 0 with a settled completion receipt for source tree eb4a1585fed6e9bb61a95564c7351605d7e8fb0c.
  • All 14 new real-SQLite cases passed before naming/comment-only lint corrections; runtime bytes and test behavior are unchanged: three acquisition routes; NONE/INCREMENTAL/FULL work counts; preserved row IDs and WAL contents; source artifact preservation; index, foreign-key, and catalog corruption refusal; callback admission ordering; and a FULL-auto-vacuum control that demonstrates corruption disappearing during journal normalization.
  • Runtime: Linux, Node 24.19.0, pnpm 12.11.1, Vitest 5.0.3, fs-safe 0.26.6. This is not production Bun/Btrfs performance proof; no elapsed-time or physical-I/O improvement is claimed.
  • Independent source/dependency review and full-candidate autoreview (all priorities P0–P3) are clear. Autoreview covered the owner classification before the final disposal-binding renames and receiver-preservation lint comment; those mechanical changes received independent review. The earlier native tree receipt is not an exact final-tree receipt. Formatting and git diff --check pass.
  • Exact-head CI attempt for 517c862a1cdfd8da281c8b894a4108d727a8118e is terminal: 41 passed, 27 skipped, 2 failed. All admitted changed-node tests, production/test types, lint, and security-fast passed; the SQLite dialect subcheck also passed. The workflow is failed, not green.
  • The remaining baseline failure is the mock-export guard at src/cli/update-cli/update-command-service-maintenance-native.test-support.ts:52; the second failure is its aggregate gate. Main commit e849b9252142 changed that closed mock without updating its export-preservation/isolation contract. The fixture, mocked target, scanner, guard, resolver, baseline and dependency inputs are byte-identical between tested merge b1049a4cdd662c044a0062898be820d77877f2ef and its main parent 8919729f0484e743af1a956f20f880bdba79a185. This requires native inherited-failure admission; it is not a passing-CI claim or a reason to alter snapshot behavior.
  • ClawSweeper exact-head review reports zero findings and no before-merge actions. Its noted proof limit remains explicit: these are native snapshot-owner tests, not a shipped updater or production performance run.
Scope and remaining work

Runtime delta: +15/-3, net +12 lines. The growth is the native auto-vacuum admission guard that allows removing a duplicate integrity/FK pass without losing corruption refusal. Tooling adds two lines to classify that existing engine owner; tests add 245 lines. No new cache or alternate acquisition path.

Separate follow-ups remain: active-WAL generation observations still perform their existing family hashes; live/non-stopped backups still acquire before-generation, backup, and after-generation images. Those costs are distinct from the stopped snapshot path fixed here. Doctor's first migration-backup registration also rehashes an owner-created snapshot; carrying the snapshot's content evidence into that registration needs its own lifecycle proof.

@vincentkoc vincentkoc self-assigned this Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@vincentkoc
vincentkoc marked this pull request as ready for review October 17, 2026 01:25
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 17, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR skips duplicate integrity scans for eligible private SQLite snapshots while retaining final verification and early checks before potentially destructive work.

Example: Capture a WAL-backed database with auto_vacuum=NONE, user_version=7, and records at row IDs 71 and 81.

  • Before: The private image receives two integrity and foreign-key passes.
  • After: The private image receives one pass before publication, preserving committed WAL contents, row IDs, and version 7.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, apparently correct optimization with meaningful real-SQLite boundary coverage; supplied execution evidence is narrower than a shipped update flow.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its supporting evidence exercises the production snapshot owner with real SQLite rather than a shipped updater, and the linked run's logs could not be inspected through the host allowlist.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Updates preparing large private database snapshots repeat integrity work over an image that has no intervening data rewrite.
Reason: The maintainer-authored direction matches the repository's instruction to remove repeated integrity work and keeps the change within the existing snapshot owner.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR provides a useful optimization that current main still lacks, with no introduced correctness or security defect identified.

Priority: P2
Reviewed head: 517c862a1cdfd8da281c8b894a4108d727a8118e

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not demonstrate a shipped updater run or a base-failing execution of the new scan-count regression.
Agent review details

How this fits together

Update and backup callers pass SQLite files to the shared snapshot owner, which acquires a private image, normalizes journaling, verifies it, and publishes a standalone snapshot with content evidence.

flowchart TD
  A[Update and backup callers] --> B[Private SQLite acquisition]
  B --> C[Eligibility and early checks]
  C --> D[Journal normalization]
  D --> E[Final integrity and foreign keys]
  E --> F[Verified snapshot publication]
Loading

Technical review

Best possible solution:

Retain the narrow eligibility guard and final publication verification, then complete the existing exact-head CI gate.

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

Current-main source shows eligible private images receiving both source and final integrity passes; this review did not execute target code.

Is this the best way to solve the issue?

The change removes redundant work in the existing owner while preserving early admission wherever callbacks, compaction, or FULL auto-vacuum could change the evidence being checked.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Source and final snapshot verification changes intended behavior with a stated reason (dae099a: The prior change carried migration-selected integrity coverage through source and final verification while preserving full checks for backups and transformed recovery archives.)
  • SQLite dialect primitive-owner classification keeps the original intent (89f8764: Native SQLite artifact owners may contain engine-maintenance primitives; the added classification follows that boundary while tests retain mechanical and design ratchets.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit ef196b6 adds src/infra/sqlite-snapshot.ts:194 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ef196b68b48d; files: src/infra/sqlite-snapshot.ts)
  • Peter Steinberger: Raw commit a095b72 adds src/infra/sqlite-snapshot.ts:539 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a095b72fbf48; files: src/infra/sqlite-snapshot.ts)
  • Jason (Json): Raw commit 9a01463 adds src/infra/sqlite-snapshot.ts:609 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 9a0146355c02; files: src/infra/sqlite-snapshot.ts)

PR surface

Source +12, Tests +245, Other +2. Total +259 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 15 3 +12
Tests 2 245 0 +245
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 4 262 3 +259

Review metrics

Metric Value Why it matters
Production versus test growth Production/tooling +17/-3; tests +245/-0 The small runtime guard supports removing a duplicate scan while the tests exercise preservation and corruption refusal.

Labels

Label changes:

  • add P2: Avoidable database scans increase update preparation work, with limited blast radius and no demonstrated outage or data loss.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Avoidable database scans increase update preparation work, with limited blast radius and no demonstrated outage or data loss.
  • 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.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 16, 2026, 9:46 PM ET / October 17, 2026, 01:46 UTC.

@vincentkoc
vincentkoc merged commit 022e167 into main Oct 17, 2026
152 of 155 checks passed
@vincentkoc
vincentkoc deleted the fix/sqlite-snapshot-integrity-once-20261017 branch October 17, 2026 02:57
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…aw#174928)

* fix(updates): avoid repeated private snapshot integrity scans

* fix(ci): classify native SQLite snapshot maintenance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts 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