Repository navigation
improve: avoid redundant schema repair during Doctor preflight - #155446
Conversation
|
🦞👀 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: needs maintainer review before merge. Reviewed September 22, 2026, 3:22 AM ET / 07:22 UTC (Revision 3). ClawSweeper reviewWhat this changesDoctor skips redundant early database repair when fresh schema and integrity checks pass, preserves its recovery paths, and reuses prepared workers in CLI tests. Merge readiness✅ Ready for maintainer review Keep open as useful work with no blocking findings. The published-updater evidence resolves the previous compatibility concern, and the optimization remains absent from fetched main. Priority: P2 Review scores
Verification
How this fits togetherDoctor prepares OpenClaw’s shared SQLite state before plugin preparation and later migration steps. This change checks whether early repair is necessary while retaining the later full repair. flowchart TD
A[Doctor preflight] --> B[Current ownership admission]
B --> C{Schema, integrity and quarantine checks}
C -->|Healthy| D[Plugin preparation]
C -->|Repair needed| E[Existing full repair]
E --> D
D --> F[Later full Doctor repair]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +26, Tests +237. Total +263 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep schema readiness checks within the existing database owner, preserving fresh integrity checks, recovery behavior, and the independent later repair. Do we have a high-confidence way to reproduce the issue? Yes: current-main source shows both early preparation and the later Doctor migration selecting full repair; execution and timing evidence come from the supplied remote validation, not a local run. Is this the best way to solve the issue? Yes: extending the existing readiness and repair owner avoids a competing implementation while preserving automatic callers and historical recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d17eccf2e435. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Merged via squash auto-merge.
|
…law#155446) * perf: avoid redundant early Doctor schema repairs * test: follow the current Doctor schema contract * test: reuse prepared workers in pristine Doctor CLI fixtures
…ds nothing (#206694) * fix(doctor): skip the state schema repair when its read-only plan finds nothing Doctor's shared-state schema repair ran on every doctor --fix (doctor mode repairs unconditionally since #155446): a write-mode open of the state, credential and quarantine stores, the schema lease, write transactions and a clean-close seal invalidation, even on a healthy install where it changes nothing. planOpenClawStateDatabaseDoctorRepair enumerates every condition the doctor-scope repair acts on at the current schema version, each decided at its owner from the rows or catalog entries that step writes (delivery queue compaction and pruning, cron job projection, subagent payloads, approval references, ACP accounting, credential receipt, canonical catalog, indexes, integrity and the rest). It reads the live stores through the #206485 guard, so a store nobody holds is undecidable. The repair runs exactly as before unless every condition answers none. The config-flow pending check now records this plan as its first input and stays at work while the agent database and plugin obligation inputs have no predicate. * fix(doctor): include quarantine clearing in the state schema plan and fall back on plan errors * test(doctor): add guard fixtures for the remaining state schema plan conditions * fix(doctor): read the schema version predicate through Kysely and record the guard test lines * fix(doctor): load the state schema plan only for Doctor and list it in the PR wrapper inventory * refactor(doctor): trace config-flow inputs through the startup helper * fix(doctor): give the config-flow pending tracer one exported spelling
…ds nothing (openclaw#206694) * fix(doctor): skip the state schema repair when its read-only plan finds nothing Doctor's shared-state schema repair ran on every doctor --fix (doctor mode repairs unconditionally since openclaw#155446): a write-mode open of the state, credential and quarantine stores, the schema lease, write transactions and a clean-close seal invalidation, even on a healthy install where it changes nothing. planOpenClawStateDatabaseDoctorRepair enumerates every condition the doctor-scope repair acts on at the current schema version, each decided at its owner from the rows or catalog entries that step writes (delivery queue compaction and pruning, cron job projection, subagent payloads, approval references, ACP accounting, credential receipt, canonical catalog, indexes, integrity and the rest). It reads the live stores through the openclaw#206485 guard, so a store nobody holds is undecidable. The repair runs exactly as before unless every condition answers none. The config-flow pending check now records this plan as its first input and stays at work while the agent database and plugin obligation inputs have no predicate. * fix(doctor): include quarantine clearing in the state schema plan and fall back on plan errors * test(doctor): add guard fixtures for the remaining state schema plan conditions * fix(doctor): read the schema version predicate through Kysely and record the guard test lines * fix(doctor): load the state schema plan only for Doctor and list it in the PR wrapper inventory * refactor(doctor): trace config-flow inputs through the startup helper * fix(doctor): give the config-flow pending tracer one exported spelling
What Problem This Solves
Doctor preflight performs a full shared-state repair before plugin preparation even when the database is healthy and current, then performs the full repair again later.
User Impact
Healthy current databases avoid redundant early repair work. Doctor retains fresh integrity checks, historical upgrades, canonical-index repair, quarantine recovery, orphan delivery recovery, and its later full repair. This changes no schema version or stored format and requires no operator action.
Why This Change Was Made
Early preparation only needs to make shared state ready for dependent readers and plugin-obligation writers. The existing schema owner now checks current shape and fresh physical integrity under current ownership admission. Historical shape, failed integrity, or quarantine still invokes the existing full Doctor repair. The later normal migration remains unconditional; no integrity result or database-generation receipt is reused.
Evidence
Seven native SQLite cases pass on Blacksmith Testbox: healthy current schema, a historical release fixture, a missing canonical index, quarantine and orphan delivery recovery, and unrecoverable same-version corruption before early convergence or later repair. They preserve later full repair and already committed plugin obligations. Negative controls demonstrate the unnecessary repair in the original path and the recovery failures of a shape-only shortcut.
After rebasing onto current main, all 63 tests pass across the new file and the existing state-migration, container-upgrade, and update-schema-guard suites (78.16 seconds wall). They cover awaited convergence, lease loss, backup identity, rollback refusal, and database replacement. The new seven-case file takes 21.12 seconds through the repository test wrapper with one worker, including startup; its seven cases also pass hosted CI after main’s schema 18 update, with 26.79 seconds of combined execution under the shared worker load. Fresh independent review found no actionable P0–P2 findings.
On one remote host, a synthetic 17.7 MiB shared-state database with 512 rows measured 16.91 ms median preparation versus 46.12 ms for full repair: 63.3% less time in this phase. The comparison alternated paths for eight measured samples each after warmup. Both retained fresh integrity checks; these figures do not measure whole-Doctor or production-scale latency.
Full changed-file checks pass: formatting, line-cap gate, core and core-test type checks, lint, dead exports, import cycles, and storage/other repository guards.
The published-updater acceptance run passed: the released OpenClaw 2026.9.5 updater installed the tarball built from
3b715571a934, verified automatic migration, completed Doctor, preserved seeded state and unavailable-plugin configuration, and passed Gateway readiness/health checks. Subsequent changes are test-only; the tested production code is unchanged.The existing pristine CLI process fixture initially timed out in hosted CI while its child processes compiled the source worker graph. The complete ordered file passed on an unloaded Testbox in 92.46 seconds, so the CI timeout was not reproduced there. The fixture now keeps the real source CLI and existing RPC hook while using the prepared real child workers and private fixture package assets. The same five cases pass in 50.57 seconds; the existing-state child decreased from 28.89 to 10.70 seconds. No assertions, deadlines, cases, or production behavior changed. Fresh independent P2 review is clean. The repaired Doctor/pristine process shard passed in the final hosted run, and all 147 checks passed, including the required CI gate (run 35698591709). The unrelated Slack fixture failure is addressed by main’s canonical fix
99f7055b3391, now incorporated.