Skip to content

perf(doctor): retain full integrity admission through migrations - #175402

Merged
steipete merged 8 commits into
mainfrom
dbasync/upgradetime-receipt
Oct 17, 2026
Merged

steipete merged 8 commits into
mainfrom
dbasync/upgradetime-receipt

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

An explicit full-integrity standalone Doctor upgrade verifies the live agent database before its declared version migration, then discards that verification during the version/additive phases. Later runtime admission in the same Doctor process scans the same database again.

Move invalidation before the version prelude's live-source check and retain the resulting full-verification receipt through that owner's committed version and additive phases. The schema owner publishes admission from the still-open handle. This also fixes inline quick migration publishing completed runtime validation without full-integrity proof: quick checks no longer satisfy runtime's full-check requirement. Separate Doctor invocations continue to inspect current bytes.

Updater full backups check private images, not the live database, and supply no reusable live-source receipt. Their migration and rollback phases are unchanged. The installed updater executes first under its own version; these are candidate-side changes. No schema version, retention, dependency or public API change.

Evidence

Three alternating shared-v3 harness pairs are complete on base 884a96d134f420793d880fbbbae28ef61f671c9d and candidate 89cf41ed1c5f168e31ceaa207889a57b17496a7f. The matched explicit-full comparison is also complete on the retained synthetic 43.06 GB agent / 0.557 GB state fixture (native agent28/state26, not stable24/state20). No saving is claimed for default quick-integrity upgrades or separate-process readiness. A newly required full check after inline quick migration is a correctness cost, not an optimization claim.

Measurement Base Candidate
Standalone full live-source verification passes 2 1
Live-agent table-scoped finalizer checks 5 5
Live-agent foreign-key checks 3 2
All observed integrity-family PRAGMAs 38 36
Explicit-full candidate Doctor, seconds 728.476 523.313
Original-state capture, seconds 160.350 125.247
Fresh sealed readiness, milliseconds 30.771 39.258
Attributed warmed all-thread SQL, median [min–max] 61 [61–62] 61 [61–62]
Attributed warmed requests, median [min–max] 16 [16–17] 16 [16–17]
Attributed warmed MAIN SQL 0 [0–0] 0 [0–0]
Raw warmed all-thread SQL, median [min–max] 67.5 [67–87] 67 [67–100]
Raw warmed requests, median [min–max] 17 [17–21] 17 [17–23]
Raw warmed MAIN SQL 0 [0–9] 0 [0–13]
Whole-workload SQL, median [min–max] 3515 [3515–3550] 3516 [3516–3526]
Whole-workload requests, median [min–max] 893 [892–897] 894 [894–899]
Whole-workload MAIN SQL 149 [149–150] 150 [149–150]
Area inventoried T1 calls 0 0

Warmed figures pool 30 turns per side. The touched Doctor migration owners emitted no captured SQL or requests in this runtime harness; it establishes warm non-regression, not Doctor savings. The one-statement/one-request whole-workload median increase is not attributed to this change. Raw warm windows include background maintenance; the attributed turn counts are identical. No wall-time or whole-workload saving is claimed.

The large pair is one busy-host observation. Baseline Doctor time includes a recorded 16.197-second suspension while recovering its orphaned runner; the same surviving baseline was resumed, not replayed. One-minute host load was 52.04→39.79 for baseline and 27.57→34.69 for candidate. The first required live-agent full scan varied from 241.967 to 156.389 seconds; that variation and the capture difference are not credited to this PR. The attributable result is removal of the baseline’s second full scan (34.968 seconds in that arm) and its associated foreign-key check. Same-inode observation confirms the comparison; separate physical recovery images retain their checks. Both arms preserved complete row counts and ordered 100-row payload/origin/head sample hashes, and the retained source DB/WAL metadata stayed unchanged. This is sampled data preservation, not a whole-corpus equality or 44 GB restore claim. The five-minute aim remains unmet.

The shared-read audit found no matching warmed SQL/requests/MAIN in exact-entry facts, actor hydration, entry-cache snapshots, row facts or watermarks on either head. Whole-workload row facts stayed at 3 statements / 2 requests / 0 MAIN per arm; the other four families had no matches. Request IDs were fully attributed. Zero matches do not imply absence of in-memory work.

Removed checks and accepted edges

  • Repeated invalidation of freshly verified source facts between phases under one maintenance owner: unsupported external file mutation during exclusive maintenance is outside the custody contract; corruption present before this Doctor invocation must still be refused.
  • Repeated same-process full verification after a successfully verified migration: process-lifetime physical integrity proof remains valid across owner-controlled writes; migration finalizers retain their data checks.
  • Re-reading agent identity and schema after each awaited integrity check: the maintenance owner retains custody; unsupported external writes during that custody are outside the contract. Lease-loss refusal and entry/finalizer checks remain.

Proof and size

The focused migration suite passed all 10 cases, including standalone/updater × quick/full admission, retained data, corruption refusal despite earlier proof, and group rollback. Both independent Codex review rounds found no actionable P0–P2 issues. Earlier head efbc9c9581eb84271e1883dc5488af87e0d4ceaf passed 87 tests across 11 relevant owner files, production types, all other test type shards, lint, source contracts, Madge, both PostgreSQL jobs, and T1/dialect ratchets. Its published-driver × candidate update workflow 39023237985 succeeded, including job117372355902; later changes only integrate main and repair test/tooling coverage.

Current head 89cf41ed1c5f168e31ceaa207889a57b17496a7f integrates main 884a96d134f and fixes the two CI defects: the test passes a pathname to the SQLite receipt API, and the PR wrapper inventory includes the extracted admission module. Current-head local type-aware lint, the Doctor type shard, all 10 migration tests, and 22 wrapper/import-closure cases pass. Canonical Knip completed with 17 unused-export findings: the original 16 exactly match completed main CI39021393912/job117363945442; the additional process-respawn constant matches the completed production scan on clean main d00f7932b2757066be00604a3a372e60894813b7. Flagged source and rule inputs were compared; none of these files is changed by this PR. Knip is inherited, not green. Repaired-head CI 39025731368 completed with the aggregate openclaw/ci-gate passing on exact head 89cf41ed1c5f168e31ceaa207889a57b17496a7f: both PostgreSQL jobs, types, lint, contracts, Madge, ratchets, all 87 owner tests and 19 import-closure tests passed. No failed or running check remained at the final observation. No third review round was added. The prior T1 inventory is 182→182 (compatibility10→10), changed-owner0→0; dialect0/1/11 unchanged and Madge0. Exact-head CI confirms the integrated static gates; the separately run canonical Knip result remains inherited as detailed above.

Against integrated main: 7 files, +211/−37; production +59/−29, tests +142/−7, docs +9/−1, wrapper inventory +1. The small shared schema-admission function replaces the inline publication path and serves both migration phases.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: M labels Oct 17, 2026
@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-17T10:42:05.598532Z 89cf41e 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.

Base automatically changed from dbasync/upgradetime to main October 17, 2026 10:08
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: L and removed size: M labels Oct 17, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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: blocked before merge.

What this changes

Preserve full SQLite verification across Doctor migration phases while preventing quick checks from satisfying full runtime admission.

Example: Standalone Doctor migrates an agent database from schema 26 with --full-integrity-check.

  • Before: Migration phases discard verification, so same-process runtime admission repeats the full scan.
  • After: Runtime admission reuses the full verification; quick migration still requires a later full check.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused design and migration harness are useful, but a confirmed wrapper dependency defect and unfinished upgrade compatibility prevent a pass.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor repeats expensive full database scans and can publish completed runtime validation after only quick migration checks.
Reason: The maintainer-authored direction restores the documented distinction between quick migration coverage and full runtime verification while reducing redundant maintenance work.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this PR open: the maintainer-owned migration fix has clear value, but its new module breaks trusted PR wrapper extraction.

Priority: P2
Reviewed head: efbc9c9581eb84271e1883dc5488af87e0d4ceaf

Before merge

  • Include the new admission module in the PR wrapper inventory (P2) - This import adds a transitive runtime dependency to sources extracted by the trusted PR wrapper, but scripts/pr-lib/wrapper-components.txt omits src/state/openclaw-agent-db-schema-admission.ts. The extracted tree therefore cannot resolve this import. Exact-head CI confirms both the missing inventory entry and the unresolved extracted-context import. Add the module to the inventory so wrapper execution remains closed over its runtime dependencies.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Include the new admission module in the PR wrapper inventory — src/state/openclaw-agent-db-schema.ts:70

Tests

  • Missing end-to-end proof: Complete a latest-stable published-driver upgrade with retained settings and data, and show standalone full-check reuse plus quick-check runtime verification; no base-failing execution of the new regression was supplied.
Agent review details

How this fits together

Doctor admits and backs up existing databases, runs schema migrations under maintenance custody, and publishes verified schema facts for subsequent runtime opens.

flowchart TD
  A[Doctor command] --> B[Maintenance custody]
  B --> C[Source verification and backup]
  C --> D[Version migration]
  D --> E[Additive schema preparation]
  E --> F[Admission publication]
  F --> G[Runtime database open]
Loading

Technical review

Best possible solution:

Retain the focused admission fix, include its new module in wrapper extraction, and establish upgrade compatibility before landing.

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

Source inspection establishes the discarded verification and ungated validation paths on main; exact-head CI independently demonstrates the introduced wrapper failure, without running target code locally.

Is this the best way to solve the issue?

The existing schema owner is the right place to publish full admission, and moving invalidation before verification preserves explicit inspection without introducing another cache owner.

Full review comments:

  • [P2] Include the new admission module in the PR wrapper inventory — src/state/openclaw-agent-db-schema.ts:70
    This import adds a transitive runtime dependency to sources extracted by the trusted PR wrapper, but scripts/pr-lib/wrapper-components.txt omits src/state/openclaw-agent-db-schema-admission.ts. The extracted tree therefore cannot resolve this import. Exact-head CI confirms both the missing inventory entry and the unresolved extracted-context import. Add the module to the inventory so wrapper execution remains closed over its runtime dependencies.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Explicit maintenance invalidation changes intended behavior with a stated reason (bb7d32e: Shared physical admission must not prevent explicit Doctor maintenance from inspecting current bytes.)
  • Post-migration admitted-handle registration keeps the original intent (497b0af: Preserve verified schema admission through registration and identify the physical file through its open handle.)
  • Quick versus full migration verification keeps the original intent (dae099a: Quick migration checks reduce unrelated index work but must never publish full-verification facts.)
  • Recovery-image and index-repair optimizations keeps the original intent (perf(update): reuse verification for owned recovery images #175359: Reuse exclusive custody and verified owned images while preserving automatic rollback generation checks.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test test/scripts/pr-wrapper-source-closure.test.ts test/scripts/eager-import-closure.test.ts
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 497b0af adds src/state/openclaw-agent-db-schema.ts:638 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 497b0afb3706; files: src/state/openclaw-agent-db-schema.ts)

PR surface

Source +41, Tests +310, Docs +24. Total +375 across 22 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 119 78 +41
Tests 12 367 57 +310
Docs 1 28 4 +24
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 514 139 +375

Review metrics

Metric Value Why it matters
Focused migration change Production +59/−29; tests +142/−7 The final migration commits extract shared admission publication and add quick/full × standalone/updater coverage; earlier recovery-image work is already on main.

Labels

Label changes:

  • add P2: This addresses repeated maintenance scans and incorrect integrity admission, with a focused wrapper integration defect blocking merge.
  • add merge-risk: 🚨 automation: The added runtime import is absent from the trusted PR wrapper inventory, and exact-head closure checks demonstrate the resulting extraction failure.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This addresses repeated maintenance scans and incorrect integrity admission, with a focused wrapper integration defect blocking merge.
  • merge-risk: 🚨 automation: The added runtime import is absent from the trusted PR wrapper inventory, and exact-head closure checks demonstrate the resulting extraction failure.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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, 6:21 AM ET / 10:21 UTC.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M and removed cli CLI command changes size: L labels Oct 17, 2026
@steipete
steipete merged commit 2e20625 into main Oct 17, 2026
161 of 163 checks passed
@steipete
steipete deleted the dbasync/upgradetime-receipt branch October 17, 2026 11:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…penclaw#175402)

Preserve a verified live-source full-integrity receipt through standalone Doctor version and additive migrations, so later same-process admission can reuse it. Publish completed runtime validation only when a real full receipt exists; a quick check never satisfies full-integrity admission.

Updater backup checks stay private-image checks and do not become live-source proof. Keep corruption refusals, maintenance authority, finalizer data checks, and rollback behavior. The installed updater runs first under its own version; these are candidate-side changes.

Release-note context: avoid redundant full-agent verification after a successful explicit-full standalone Doctor migration.
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: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant