Skip to content

perf(update): reuse verification for owned recovery images - #175359

Merged
steipete merged 4 commits into
mainfrom
dbasync/upgradetime
Oct 17, 2026
Merged

steipete merged 4 commits into
mainfrom
dbasync/upgradetime

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Candidate-side Doctor repeatedly hashes the same large SQLite database while retaining its original state. On the synthetic 43 GB agent database, original-state capture took 588 seconds; APFS clone operations were negligible. The baseline recorded eighteen whole-agent digest passes across source generations, private acquisition, and publication. The change removes redundant source-generation and owned-image publication passes.

Manual original-state capture now uses the existing maintenance owner's exclusive SQLite custody. Automatic rollback backups and PostgreSQL retain their generation checks. Owned hardlink publication retains its digest until the final published-byte comparison, and moving that verified image into the capture payload does not hash the rename again. WAL recovery, refusal of absent databases with retained journals, image integrity, publication durability, and restore-time digest/authority checks remain.

Canonical index repair verifies each rebuilt table and its indexes after DDL instead of repeating a whole-database scan. Source integrity admission, --full-integrity-check, transactional rollback, and migration finalizer data/foreign-key checks remain.

The installed updater runs first under its own version. These changes affect only candidate-side Doctor, capture, and schema preparation. There is no schema, retention, or public API change.

Completed measurements

Three alternating shared-harness v3 pairs used frozen base 8c4ea360522c290cada727b04a09408457b44393 and candidate 05b79326574952d6472cae42822e7060ba65c474 (M1,C1,M2,C2,M3,C3). The interrupted original M2 is excluded and was replaced. All six completed runs have complete causal coverage, zero recorded SQL errors, and clean fixture-process shutdown. Counts below are median [min–max]; warmed statistics pool the 30 actual turns per head, rather than treating per-run averages as medians.

Warmed turn metric Base Candidate
Causal all-thread statements 62 [62–63] 62 [62–63]
Causal requests 17 [17–18] 17 [17–18]
Causal MAIN statements 0 [0–0] 0 [0–0]
Raw-window all-thread statements 68 [68–103] 68 [68–89]
Raw-window requests 18 [18–23] 18 [18–22]
Raw-window MAIN statements 0 [0–13] 0 [0–9]
Whole workload Base Candidate
Statements 3,632 [3,620–3,634] 3,596 [3,591–3,633]
Requests 919 [913–922] 918 [916–920]
MAIN 149 [148–149] 149 [148–149]

No ordinary-turn or whole-workload SQL saving is credited to this upgrade-only change. Raw windows include separately attributed background work; the causal warmed-turn counts do not regress. Every raw warmed-window MAIN statement is a background state_leases expiry SELECT in plugin lifecycle lease checks (no-turn-context): 13 in each base run, 13 across the first two windows of C2, and none in C1/C3. Busy-host scheduling moves this maintenance across phase boundaries; it is not a removed check or a SQL saving from this change.

Phase Base statements / requests / MAIN Candidate statements / requests / MAIN
Boot 329 [328–329] / 88 [88–88] / 64 [64–64] 329 [329–329] / 88 [88–90] / 64 [64–64]
Connect + first turn 582 [570–588] / 128 [121–128] / 0 [0–0] 610 [574–615] / 127 [124–132] / 13 [0–13]
Ten warmed windows 720 [718–720] / 188 [186–188] / 13 [13–13] 688 [687–721] / 185 [184–188] / 0 [0–13]
Second session + spawn 519 [515–519] / 133 [132–134] / 0 [0–0] 519 [518–521] / 133 [133–134] / 0 [0–0]
Control plane 7 [7–7] / 1 [1–1] / 0 [0–0] 7 [7–8] / 1 [1–1] / 0 [0–0]
Cron 256 [256–257] / 70 [70–70] / 0 [0–0] 256 [256–257] / 70 [70–70] / 0 [0–0]
Compaction 249 [249–249] / 38 [38–38] / 0 [0–0] 249 [247–249] / 38 [38–38] / 0 [0–0]
Idle settle 140 [139–141] / 20 [20–20] / 0 [0–0] 140 [139–141] / 20 [20–20] / 0 [0–0]
Connected idle 146 [144–146] / 49 [49–50] / 0 [0–0] 146 [144–146] / 49 [49–49] / 0 [0–0]
Shutdown 24 [24–24] / 6 [6–6] / 7 [7–7] 24 [24–24] / 6 [6–6] / 7 [7–7]
Restart boot 342 [335–344] / 103 [103–106] / 58 [57–58] 335 [334–335] / 103 [102–103] / 58 [57–58]
Restart connect + first turn 295 [293–302] / 89 [88–90] / 0 [0–0] 269 [269–302] / 90 [89–91] / 0 [0–0]
Restart shutdown 24 [24–25] / 7 [6–7] / 7 [7–7] 24 [24–24] / 6 [6–6] / 7 [7–7]

Owner attribution is unchanged in every run: sqlite-index-schema executes eight worker statements during compaction and eight during connected idle; sqlite-readonly-location-cleanup executes ten child-process statements at boot and ten at restart. These owners contribute zero MAIN statements and no request-origin matches. This absence of owner-tagged transport requests is not a claim that the entire flow makes zero requests.

44 GB upgrade cell

One busy-host pair exercised public candidate-side doctor --fix --non-interactive in default quick-check mode on derived agent27/state25 images, cloned from the retained native agent28/state26 source including WAL. It covers candidate Doctor, migrations, original-state capture, ordinary Doctor contributions, and fresh readiness; it excludes updater download/install and service activation. The installed updater runs first, so these changes only improve candidate-side work.

Observed duration/count Base Candidate
Candidate Doctor (seconds) 1,371.128 804.418
Original-state capture (seconds) 588.249 130.337
Fresh readiness (milliseconds) 30.812 27.998
Whole-agent digest passes during capture 18 2
Capture integrity PRAGMAs 4 4
Whole-flow integrity PRAGMAs 59 59

Complete row counts for transcript identities, transcript events, memory origins, and session heads matched before/after migration. Ordered 100-row sample hashes for transcript payloads, memory origins, and session heads also matched. These are sampled payload hashes plus complete counts, not proof of equality of every payload. The retained source database/WAL metadata remained unchanged.

The observed candidate Doctor duration is still above the five-minute aim. This was one busy-host scale pair, not a controlled latency benchmark; nested Doctor steps and child work overlap and must not be added or subtracted as independent wall-time contributions. The native28/26 explicit-full comparison and stable24 historical-backfill measurement are separate follow-ups.

Compact evidence: comparison.json, warm-count-audit.json, warm-main-attribution.json, base-scale-summary.json, candidate1-scale-summary.json, doctor-check-costs.json, and per-arm cleanup receipts.

Area inventoried T1 calls remain 0→0. The measured production bodies are identical to final PR head 1f519280c06d153f81eb223d3b1694ce244761cb; subsequent changes integrated main and repaired test consumers. The scale fixture already had canonical indexes, so the scoped index repair has forced-repair regression coverage but no claimed share of the scale timing difference.

Removed checks and accepted edges

  • Manual original-state generation sweeps: an unsupported out-of-owner write during exclusive capture can leave an earlier manual recovery image; the capture grants no automatic restore authority.
  • Intermediate digest after an explicit owned hardlink transfer: a private-image mutation is detected by the retained final publication comparison.
  • Digest after no-replace payload rename: the rename transfers the verified inode; later corruption is refused by restore's digest check.
  • Unreachable post-publication identity guard: both successful publication branches supply a required identity; publication errors still throw.
  • Whole-database post-index-DDL scan: unrelated corruption arising after source admission waits for the next whole-file check; index-only DDL does not mutate unrelated tables.

Validation and size

Passed: changed-file formatting, native type-aware lint, and diff whitespace. Both Codex review rounds are scoped-clean. Focused owner proof passed: eight suites, 154 tests passed and two skipped, covering capture/WAL/publication/restore/generations/index repair. The seven additional Doctor/rollback test consumers now use the same async entry point; their basic formatting/lint passed. CI confirmed both later fixture repairs: 28 backup tests and 42 settlement tests passed before the main-integration run superseded that workflow. The published-driver × candidate update cell passed (workflow 39019006593, job 117360580775). Final-head CI passed all production/test types, type-aware lint, source contracts, Madge, T1 (182→182; compatibility 10→10), and the dialect ratchet (0/0/3 unchanged). All nine revised or affected consumer suites passed in CI, 116 tests. The final canonical Knip scan completed with 16 findings, all identical to observed main CI 39021393912, dependencies job 117363945442 at 1225e95d82d9; flagged files and scanner/configuration blobs match main/base/head. There are no candidate-only export findings; Knip itself is not green. Existing active-handle WAL and corruption/rollback regressions remain.

Authored diff against integrated main: production +60/−49 (net +11), tests +225/−50 (net +175), documentation +19/−3 (net +16). The old parent generation helper is removed; the small capture-purpose receipt keeps the manual-evidence decision in the existing backup owner.

Final CI reported seven UI cases in five untouched files. A focused replay on this PR's main base 342875ae60f8 reproduced six with matching signatures; candidate replay reproduced four and passed two, which is not a claim that the intermittent cases were fixed. The seventh parameterized composer case was not selected by its original full-name filter, but its exact failure (expected 3 to be less than or equal to 1, line825) is recorded in completed main CI39021393912/job117363944654; that file is byte-identical at main/base/head. All seven failures therefore have main or base evidence. No extra UI replay is needed. Both PostgreSQL conformance jobs and all code/static/security jobs passed on the final head. The four failed UI jobs contain only the seven inherited cases above. The aggregate failure report was settling at the pre-merge read; landing uses the authorized inherited-failure route. Frozen SQL measurements completed after merge under the campaign proof policy; all six arms passed.

The separate npm 12 package-acceptance job failed its installed-file budget (48,196 versus 47,500); installation completed and the required Docker update cell passed. The independent package-size repair subsequently landed on main. No all-green workflow claim is made.

@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 complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T09:47:03.282610Z 1f51928 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M cli CLI command changes commands Command implementations labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
Remove the export left unused by manual capture cleanup. Exercise generation refusal and preservation through the retained physical-generation entry point.
Move Doctor and rollback test consumers to the retained physical generation reader after the synchronous helper became private. Keep the existing generation and restoration assertions.
Restore the backup namespace spy and declare the settlement fixtures as SQLite so physical generation reads preserve their no-native-process contract.
@steipete
steipete force-pushed the dbasync/upgradetime branch from 2e27c79 to 1f51928 Compare October 17, 2026 09:43
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment 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 reuses verified SQLite images during manual recovery capture and checks only rebuilt tables after canonical index repair.

Example: Candidate Doctor captures the synthetic 43 GB agent database before repair.

  • Before: The reported capture performed eighteen whole-agent digest passes.
  • After: The reported capture performs two passes while preserving payload hashes and row counts.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused implementation with reported production-path capture evidence and verified upgrade-job execution; final-head CI is not established as passing.
Proof confidence 🐚 platinum hermit (4/6) Maintainer-authored PR outside the ordinary contributor proof gate; the body reports candidate Doctor capture with preserved hashes and rows, and the linked published-driver upgrade job succeeded for the measured candidate.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Doctor retains original database state slowly because it repeatedly reads the same large SQLite payload.
Reason: The maintainer-directed optimization addresses measured maintenance work without adding configuration, a competing owner, or a new persisted format.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR provides a useful, maintainer-directed reduction in database capture work, with no concrete introduced defect found; unresolved CI still prevents a merge-ready verdict.

Priority: P2
Reviewed head: 1f519280c06d153f81eb223d3b1694ce244761cb

Before merge

None.

Findings

None.

Agent review details

How this fits together

Doctor and update maintenance pass database inventories through isolated snapshot workers, which produce verified recovery images and manifests consumed by separate restoration owners.

flowchart TD
  A[Doctor maintenance custody] --> B[Original state capture]
  B --> C[Database backup worker]
  C --> D[Verified SQLite image]
  D --> E[Final publication comparison]
  E --> F[Manual recovery manifest]
  F --> G[Restore validation]
Loading

Technical review

Best possible solution:

Retain this focused optimization and land it after the required checks for the reviewed head are resolved.

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

Current-main source shows repeated generation and publication digest work, supported by the body's large-database observations; no target code was executed during this review.

Is this the best way to solve the issue?

The change removes repeated work within existing owners while preserving WAL recovery, final-byte comparison, transactional index repair, and separate automatic rollback admission.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Manual original-state capture changes intended behavior with a stated reason (e47d0ce: Preserve original configuration and databases before update or Doctor mutations; later capture work reduced process overhead while retaining manual recovery evidence.)
  • Owned snapshot publication keeps the original intent (c77a055: Transfer an already-owned private image without another full copy while preserving independent snapshots for public callers and verified publication.)
  • Post-index-repair integrity changes intended behavior with a stated reason (dae099a: Use efficient migration integrity coverage while fully checking rebuilt tables; this PR explains removing the remaining repeated whole-file scan.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit bf3f5dc adds src/infra/sqlite-snapshot.ts:438 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bf3f5dc532f0; files: src/infra/sqlite-snapshot.ts)
  • Jason (Json): Raw commit c77a055 adds src/infra/sqlite-snapshot.ts:381 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c77a055f0864; files: src/infra/sqlite-snapshot.ts)

PR surface

Source +11, Tests +175, Docs +16. Total +202 across 17 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 60 49 +11
Tests 11 225 50 +175
Docs 1 19 3 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 304 102 +202

Labels

Label changes:

  • add P2: Redundant full-image reads prolong maintenance on large databases, with a bounded performance improvement and no demonstrated urgent regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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: Redundant full-image reads prolong maintenance on large databases, with a bounded performance improvement and no demonstrated urgent regression.
  • 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.

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 17, 2026, 5:59 AM ET / 09:59 UTC.

@steipete
steipete merged commit 2411716 into main Oct 17, 2026
157 of 166 checks passed
@steipete
steipete deleted the dbasync/upgradetime branch October 17, 2026 10:08
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…175359)

Reduce candidate-side Doctor recovery capture work by reusing exclusive maintenance custody for manual original-state SQLite captures and retaining verified digests across owned inode transfers. Automatic rollback, PostgreSQL generations, WAL recovery, final publication checks, and restore validation remain unchanged.

After canonical index repair, verify rebuilt tables instead of repeating a whole-database scan; preserve source admission and finalizer checks. The installed updater still runs first under its own version.

Release-note context: reduce redundant full-database reads during candidate updates of large SQLite stores.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. 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