Repository navigation
perf(update): shorten stopped database capture and Doctor work - #170087
Conversation
Clone checkpointed databases in the native stopped-owner path and hash each image once while preserving the existing restore receipt. Keep coherent snapshot and write-generation checks for mutable update and standalone Doctor captures. Defer current-schema media maintenance during updates and avoid a writable canonical-key open when the stored key already matches. Retain pending migration, corruption, and explicit Doctor repair behavior.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR speeds stopped-update database capture and skips unnecessary Doctor work on unchanged agent databases. Example: A native update encounters a checkpointed 3.01 GiB agent database with a current schema.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this useful, maintainer-directed performance PR open; the revised patch has no definite introduced correctness finding. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe native migration command acquires stopped-Gateway ownership, captures database and configuration preimages, runs candidate Doctor, and retains recovery receipts for restoration or cleanup. flowchart TD
A[Native supervisor] --> B[Stopped migration command]
B --> C[Database backup owner]
C --> D[SQLite snapshot owner]
D --> E[Recovery receipt]
B --> F[Doctor maintenance]
E --> G[Database restore owner]
F --> H[Candidate activation]
Technical reviewBest possible solution: Retain the stopped-capture optimization within the existing snapshot owner while preserving coherent live capture, required Doctor repairs, and verified rollback. Do we have a high-confidence way to reproduce the issue? Current main unconditionally performs verified capture and media maintenance and opens canonical-key contracts for writing; the body reports comparable Linux component measurements, and this read-only review executed no target code. Is this the best way to solve the issue? The patch reuses the guarded filesystem copy and snapshot owners, preserves the mutable capture path, and limits maintenance deferral to current schemas without pending repair or recorded corruption. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5168930e11e2. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +118, Tests +125, Docs +17. Total +260 across 10 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 12, 2026, 3:06 PM ET / 19:06 UTC (Revision 2). |
|
Addressed the SQL-ownership checks in For recovery compatibility, the candidate-owned A complete v2026.10.2 binary-to-candidate upgrade/rollback campaign was not run. It remains a stated proof limit, rather than a claimed result. There is no stored-shape change or identified introduced compatibility defect to justify expanding this performance lane into release validation. The requested validation scope is focused local checks plus full PR CI, and the component benchmark does not claim end-to-end update timing. |
|
Landing under the lane's authorized inherited/unrelated-CI exception for head
The baseline failure sources are also unchanged between that main revision and CI's main parent Using the explicitly authorized exact-head REST fallback: this lane's |
…law#170087) * perf(update): reduce stopped database capture and Doctor work Clone checkpointed databases in the native stopped-owner path and hash each image once while preserving the existing restore receipt. Keep coherent snapshot and write-generation checks for mutable update and standalone Doctor captures. Defer current-schema media maintenance during updates and avoid a writable canonical-key open when the stored key already matches. Retain pending migration, corruption, and explicit Doctor repair behavior. * refactor(update): keep stopped capture in SQLite snapshot owner
What Problem This Solves
Native update migration spends minutes backing up and rechecking unchanged multi-GiB agent databases during a shared-state-only schema upgrade. The recovery capture performs multiple full-file passes, and Doctor invalidates existing integrity evidence and opens a writer even when there is nothing to change.
User Impact
Shorter stopped time during native updates. Every discovered database remains backed up, including unchanged agent schemas, because Doctor can still write bookkeeping. Existing receipt fields, SHA-256 verification during restore, row identities, and rollback ownership remain unchanged. No schema or configuration changes.
Why This Change Was Made
The native migration entrypoint already owns a stopped Gateway. Its checkpointed files now use the existing native filesystem clone/byte-copy owner, inspect the cloned SQLite header/schema, hash the final image once, and check source identity and mutation metadata. Retained WAL/journal families keep the coherent verified-snapshot path. Native rollback uses the supervisor fence, so capture no longer calculates live-writer generations twice; the mutable updater and standalone Doctor recovery captures retain those checks.
During update, current agent schemas with no pending repair or recorded corruption defer media body/archive maintenance to explicit Doctor and keep their clean-close evidence. Canonical-session repair reads the stored main key before opening a writer; actual changes still use the existing setter and admission checks. Startup integrity validation remains owned by startup, including the independent clean-close seal work.
Production LOC: +118 (155 added, 37 removed; tests/docs excluded). The increase is intentional: the existing live-writer/coherent-snapshot contract cannot be replaced by stopped-file capture. This adds the narrower stopped capture and removes its unnecessary full-file work without weakening the live path or changing persisted recovery metadata.
Evidence
Linux/Node 26 on a task-owned btrfs loopback, 3.01 GiB synthetic agent database plus a small shared-state database. One before/after pair per inode policy, measuring the production backup owner plus update-time media maintenance:
Shared btrfs extents independently confirm the clone path. These component timings exclude Gateway startup/readiness and the shared schema migration itself. No production state or services were changed, and no Testbox/Crabbox leases were allocated.
Focused proof: changed-file oxfmt and core oxlint passed; three independent P0–P2 reviews were clean, including the final snapshot-owner extraction. Doctor focused files passed 23 tests (352.89 s wrapper wall time including cold worker compilation). The backup and native migration/rollback files passed another 31 tests (374.38 s wrapper wall time; 145.90 s and 196.37 s Vitest durations, including cold preparation for backup). All 54 focused tests passed across four files; the new backup cases each ran under 0.6 s. The first attempt stopped before testing because a source edit invalidated worker compilation; the frozen retry passed. After CI caught misplaced raw SQL in the coordinator, capture moved into the existing snapshot owner and reused journal-policy normalization, without guard exceptions or baseline changes. Follow-up focused proof passed 36 backup/snapshot/native-migration tests (428.43 s wrapper) and 45 snapshot/journal tests (7 platform skips; 95.45 s wrapper). Full validation belongs to exact-head PR CI.
Limitations: a retained SHA-256 digest still requires one full read, and native cloning depends on the filesystem/inode flags. A byte copy remains available when reflink is unsupported. The 40-GiB end-to-end outage target has not been directly measured. A complete-command trial on the source rig encountered missing Control UI assets and began a build, so it was stopped and excluded rather than treated as installed-update timing. Startup validation remains separate from this change (related: #169649).
CI failure attribution
The first CI run exposed two lane-owned SQL ownership violations. Those are fixed by keeping stopped capture in the existing SQLite snapshot owner and sharing journal normalization through its existing PRAGMA owner; no guard allowlists or baselines were relaxed.
The remaining historical-transcript failure reproduces on unchanged main
8656a687160dbfdd95fd16ae1682e033747d2a07:src/commands/doctor-config-preflight.test.ts→ “leaves historical transcript bytes at startup and normalizes them in later plain Doctor.” A single-test baseline run failed with the identical expectedHistorical answerversus actual[[reply_to_current]] Historical answerand missingopenclawDeliverymetadata (92.81 s). Baseline command:node scripts/run-vitest.mjs run --config test/vitest/vitest.commands.config.ts --project commands src/commands/doctor-config-preflight.test.ts --maxWorkers=1 -t 'leaves historical transcript bytes at startup and normalizes them in later plain Doctor'. The explicit project selects this focused source test without building runtime assets; existing workspace dependency directories were reused. No tracked baseline files changed.This preflight does not reach either changed Doctor path. Source inspection traces the separate regression to historical migration opening a new unadmitted SQLite handle before transcript payload preparation, which now requires admitted schema facts. This lane does not change that migration.
The new-head
checks-node-changed-compact-large-2failure also reproduces on the same unchanged main:src/state/openclaw-agent-worker-store.test.ts→ “pooled agent publication owner (captured source) > retains exact canonical lease cleanup after failure and releases it on retry.” It expects an aggregate containingcontrolled worker lease cleanup failurebut receives that same ordinary Error. Baseline command:pnpm test src/state/openclaw-agent-worker-store.test.ts --maxWorkers=1 -t 'retains exact canonical lease cleanup after failure and releases it on retry'(54.42 s wrapper; 24.88 s Vitest; identical failure). The worker cleanup owner and test are unchanged by this PR.Final CI: run 38293502498, attempt 1 tested head
b3210bac376723086f7c48fd9aad449a559143d9through merge03fa034d6d77d25ec967fed0afd4199808cf0d88. Architecture, baseline ratchets, export/closure guards, lint, production types, builds, all seven UI E2E shards, and the other changed-code shards passed. The two test failures are the unchanged-main reproductions above.check-test-types-core-3was marked cancelled at its 15-minute job limit during post-job cleanup: its log records successful completion of all six selected core graphs and the root-scripts graph (7/7, each exitCode 0), followed by the completed-step receipt before cleanup. No type error was reported. The CI aggregate remains red; no reruns were requested.Review proof limit: the native production-entry tests cover successful migration, injected candidate failure, restoration of settings/includes and database contents, retry, and future-schema refusal. A complete v2026.10.2 binary-to-candidate upgrade/rollback campaign was not run.