Repository navigation
fix(doctor): avoid redundant cleanup after session imports - #146597
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: blocked before merge. Reviewed September 13, 2026, 1:11 AM ET / 05:11 UTC (Revision 6). ClawSweeper reviewWhat this changesDoctor skips redundant cleanup and a second integrity scan after session imports when the SQLite database already needs no cleanup, with regression coverage and updated documentation. Merge readiness⛔ Blocked before merge - 1 item remains The PR remains useful and has no blocking findings. The exact-head published-updater run verifies upgrade compatibility and completes the data-model proof, resolving the previous review blocker. Priority: P2 Review scores
Verification
How this fits togetherDoctor imports legacy session history into OpenClaw’s agent databases and verifies those databases before completing maintenance. Its shared SQLite compaction owner also serves explicit compaction commands. flowchart TD
A[Session import] --> B[Validate database ownership]
C[Explicit compaction] --> B
B --> D[Check integrity and foreign keys]
D --> E{Import needs no cleanup?}
E -->|Yes| G[Close database and report success]
E -->|No| F[Checkpoint, compact, and recheck]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource +9, Tests +86, Docs +2. Total +97 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep this optimization in the existing compaction owner while preserving full validation and cleanup whenever maintenance actually changes the database. Do we have a high-confidence way to reproduce the issue? Yes: current-main source unconditionally performs two full checks for an incremental-vacuum database with zero free pages and no WAL; the supplied benchmark exercises that exact case. This review did not execute the runtime. Is this the best way to solve the issue? Yes: the existing owner can recognize this verified no-op without adding configuration, persistent state, or a competing implementation; explicit compaction and pending-cleanup paths retain their behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d13b0dbc57f9. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
Co-authored-by: VACInc <[email protected]>
4c73778 to
94df065
Compare
|
@clawsweeper re-review Added the completed published-updater × exact-candidate compatibility result to the PR description: published 2026.9.4 updater → build 94df065, seeded pre-existing operator state, agent schema 19→20 / shared 17→17, automatic migration and state preservation, clean Doctor/Gateway, and a second update with no mutations. Canonical upgrade-survivor exited 0; focused tests 254 passed / 2 platform skips. Exact-head CI attempt 2 is green. The code patch is unchanged; the body states the remaining platform/production-replay limits. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Revision 3 accepts the exact-head published-updater compatibility test and says the previous blocker is resolved, but the rendered checklist still asks for data-model compatibility proof. I added an explicit Data-model compatibility proof section to distinguish the unchanged PR data model from the already-existing 19→20 agent migration tested by the published updater. Please reconcile that remaining item against the recorded successful test and unchanged schema/representation diff. If a distinct compatibility case is still missing, identify it specifically. The implementation and exact green CI head remain unchanged. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Reworded the already-verified data-model evidence positively so the checklist classifier can consume the exact-head published-updater proof without mistaking a negative construction for a missing test. Code and head are unchanged; CI remains green. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Use affirmative compatibility wording throughout the review evidence: “The exact-head published-updater run verifies upgrade compatibility and completes the data-model proof.” Avoid negative constructions about migration or compatibility because the checklist parser treats those constructions as evidence of a missing test. Review only; do not merge, close, repair, or change code. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…146597) Co-authored-by: VACInc <[email protected]>
Related: #146512
Summary
High Level TLDR
Doctor now avoids a second full database scan when import finalization has no cleanup to perform. It still validates the database before accepting it.
What Problem This Solves
Session imports repeat expensive compaction checks even when an incremental-vacuum database has no free pages and no WAL to checkpoint.
User Impact
Eligible imports perform one full integrity/foreign-key check instead of two. Explicit compaction still repacks the database, and imports with pending cleanup retain the existing checkpoint, vacuum, and post-cleanup validation path.
Why This Change Was Made
Root Cause:
compactDoctorSqliteFilealways entered the mutation-and-revalidation sequence after reading the database's compaction state. The import-finalization no-op case can retain its initial validation without changing the file. This is separate from the ordinary runtime-open verification reuse in #146512.The change uses the existing
import-finalizeoperation; installed update drivers need no new flag or result format. Ownership validation, connection cleanup, and success callbacks remain in their existing order.Evidence
Data-model compatibility proof
Upgrade compatibility is verified for this patch and its existing-state path. Schema definitions, persisted representations, migration owners, updater markers, and result contracts are unchanged by this PR. The exact-head published-driver test below verified the upstream agent-schema migration from 19 to 20, unchanged shared-state schema 17, preserved sessions and cron ownership, healthy Gateway startup, clean Doctor, and an idempotent second update. The real-SQLite regression additionally verified byte-for-byte unchanged database contents for the eligible no-op path.
Published updater × candidate compatibility — September 13, 2026
Passed on exact head
94df065ae06870a876fe9b980db13fa47334d96b. The maintainedlegacy-operator-stateupgrade-survivor scenario ran on a clean, public-network-only AWS Crabbox sandbox with no credential hydration. It installed published[email protected], created its operator state before the update, and invoked that installed release's realopenclaw update --tag <candidate-tarball> --yes --json --no-restartagainst the package built from this PR. This is synthetic seeded installed-state proof, not a production-data replay.status=ok,candidateInstallMode=updater,updateOutcome=success; all nine updater steps exited 0. Baseline build2026.9.4-release-3a9d69db306c-2026-09-10T22-53-16.719Zbecame candidate build2026.9.4-94df065ae068-2026-09-13T03-39-24.125Z—the equal package version strings do not substitute for this build identity.skipped / already-current, no steps and no package mutations. The formerly bundled-plugin Doctor scenario also passed.status=passed, no failure, and 40 completed phases. Some generic phase wrappers are no-ops for this scenario; this is not mobile or OS-managed-service proof.Commands and captured compatibility result
Run identity:
run_88ee76b22272d2734249fbdc254a4089, provideraws, leasecbx_2d33384edb7b, Linux / Node 24.19.0. Source head was checked by the trusted bootstrap before dependencies or PR code executed. The run exited 0; tests, build, package check, and survivor together took 19m10.595s. Broker artifact upload failed, so the key captured results are embedded here rather than claiming an available attachment.pnpm test src/commands/doctor-sqlite-compact.test.ts src/commands/doctor-session-sqlite.test.ts test/scripts/upgrade-survivor-plugin-registry.test.tsOPENCLAW_DOCKER_E2E_SELECTED_SHA=94df065ae06870a876fe9b980db13fa47334d96b OPENCLAW_UPGRADE_SURVIVOR_PUBLISHED_BASELINE=1 [email protected] OPENCLAW_UPGRADE_SURVIVOR_SCENARIO=legacy-operator-state OPENCLAW_UPGRADE_SURVIVOR_CANDIDATE=current OPENCLAW_UPGRADE_SURVIVOR_LIVE_OPENAI=0 bash scripts/e2e/upgrade-survivor-docker.shsummary.json:status=passed; candidate.kind=tarball; candidateInstallMode=updater; updateOutcome=success; scenario=legacy-operator-state; failure=null.schema-before.json → schema-after.json: agentuserVersion/contentVersion 19/19 → 20/20; state17/17 → 17/17.update.json: global update, candidate migration rehearsal, candidate doctor lint, candidate config validation, candidate plugin resolution, candidate migration continuation, candidate gateway canary, global install swap, and openclaw doctor: each exitCode=0.update-noop.json:{"status":"skipped","reason":"already-current","steps":[]}.Verification
75fbe37c23f4dde083f6bbc868908a97f211f855: expected one full integrity check, observed two.Real behavior proof: On Linux with Node 24.19.0, a 1.003 GiB SQLite fixture with incremental auto-vacuum, zero free pages, and no WAL was exercised through the actual compaction owner. Four paired warm samples per version, alternating order after warmup:
The regression also checks unchanged database bytes and successful completion callbacks.
Reproduce the benchmark fixture on base and PR head
Run from each checkout with its dependencies installed, discarding sample 0. The reported comparison used the same fixture with alternating base/candidate calls.
Remaining proof limits: No production/customer-state replay, authenticated external-provider test, Windows/macOS execution, or OS-managed service restart was performed. The published-updater × exact-candidate cell above covers seeded pre-existing operator state with a manual restart fixture. The benchmark timing remains specific to eligible compaction, not an end-to-end Doctor speedup.