Repository navigation
fix(doctor): skip duplicate legacy state scan after settled preflight - #180442
MertBasar0 wants to merge 1 commit into
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 real behavior proof before merge. What this changesThe PR skips legacy-state detection after settled preflight and suppresses repeated detection notices. Example: Run openclaw doctor --fix with unchanged configuration and successful preflight migration receipts.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep open: this PR addresses duplicate Doctor work still present on main, and review found no definite introduced correctness bug. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor preflight detects and migrates legacy state, then hands configuration and migration receipts to ordered health contributions that perform remaining diagnostics and repairs. flowchart TD
A[Doctor CLI] --> B[Config preflight]
B --> C[Legacy migration owner]
C --> D[Config and receipts]
D --> E[Legacy state health]
E --> F[Conditional detection]
E --> G[Remaining cleanup]
Technical reviewBest possible solution: Reuse settled preflight receipts to avoid redundant detection while preserving fallback scans and existing cleanup owners. Do we have a high-confidence way to reproduce the issue? Source establishes detection during preflight and again in the later health contribution; no product execution was performed during this read-only review. Is this the best way to solve the issue? Carrying settlement through the existing configuration handoff is a focused solution, and the patch preserves detection for unsettled or changed configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ad6af54167b9. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -1, Tests +126. Total +125 across 7 files. Added test files: 1. View PR surface stats
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 Reviewed October 22, 2026, 4:33 AM ET / 08:33 UTC. |
) Doctor rescanned legacy state even when the update preflight had already settled the same scan, doubling slow work on large installs. Doctor now reuses settled preflight results when config is unchanged, rescans after pending config writes, plugin inventory changes or metadata invalidation, and keeps independent cleanup. Supersedes #180442, thanks @MertBasar0. Co-authored-by: MertBasar0 <[email protected]>
|
Thanks @MertBasar0. We landed this as #180576 (48fcb8b), with you credited as co-author. Doctor now reuses the settled preflight scan while the config is unchanged. It rescans after pending config writes, plugin inventory changes, or metadata invalidation, and independent cleanup still runs. |
) Doctor rescanned legacy state even when the update preflight had already settled the same scan, doubling slow work on large installs. Doctor now reuses settled preflight results when config is unchanged, rescans after pending config writes, plugin inventory changes or metadata invalidation, and keeps independent cleanup. Supersedes #180442, thanks @MertBasar0. Co-authored-by: MertBasar0 <[email protected]> (cherry picked from commit 48fcb8b) Co-authored-by: RomneyDa <[email protected]>
…claw#180576) Doctor rescanned legacy state even when the update preflight had already settled the same scan, doubling slow work on large installs. Doctor now reuses settled preflight results when config is unchanged, rescans after pending config writes, plugin inventory changes or metadata invalidation, and keeps independent cleanup. Supersedes openclaw#180442, thanks @MertBasar0. Co-authored-by: MertBasar0 <[email protected]>
What Problem This Solves
Fixes:
openclaw doctor --fix/--yesscans legacy state twice and re-prints detection notices and warnings when preflight has already settled all pre-session state migrations on the unchanged config.User Impact
User impact:
openclaw doctor --fix/--yesno longer performs a redundant seconddetectLegacyStateMigrationsscan across the state directory, session stores, SQLite tables, and plugin contracts when preflight already completed cleanly on the same config, and does not print duplicate detection notices or warnings when a second scan is required.Why This Change Was Made
During
loadAndMaybeMigrateDoctorConfig,runDoctorConfigPreflight(src/commands/doctor-config-preflight.ts:340-361) already runsautoMigrateLegacyStatewithdoctorOnlyStateMigrations: shouldRepair, which executesdetectLegacyStateMigrationsand all pre-session migration steps and emits their changes, notices, and warnings. Later in the same health flow,runLegacyStateHealth(src/flows/doctor-health-contributions.ts:238-291) unconditionally calleddetectLegacyStateMigrationsa second time and re-emitted any detection notices and warnings.prepareDoctorConfigMigrationResult(src/commands/doctor/shared/config-migration-result.ts:121-141) now recordspreflightLegacyStateSettled: truewhen the preflight plan was bound (doctorOnlyStateMigrations: true), no config write or plugin inventory change occurred during config flow, no plugin migrations are deferred,params.cfgstill matchespreflight.baseConfig, and every pre-session step receipt completed or was skipped with no warnings.runLegacyStateHealth(src/flows/doctor-health-contributions.ts:238-291) still runscore/doctor/removed-workspaces-stateandrepairObsoleteGeneratedExecApprovals, but skips the redundantdetectLegacyStateMigrationspass whenpreflightLegacyStateSettledholds andctx.cfgstill matchesctx.configResult.cfg. WhendetectLegacyStateMigrationsdoes run (for example in read-onlyopenclaw doctoror after an earlier contribution mutatesctx.cfg), any notices or warnings already recorded on the preflightmigration-detectionreceipt are filtered out before printing.noteimports and manualchanges/notices/warningsloops insrc/flows/doctor-health-contributions.ts,src/flows/doctor-health-contribution-runners.config.ts, andsrc/flows/doctor-health-contribution-runners.state.tsthroughnoteDoctorRepairResult(src/flows/doctor-health-contribution-utils.ts:32-40), keeping production LOC net-1(+77 / -78).Evidence
node scripts/run-vitest.mjs src/flows/doctor-health-contributions.legacy-state.test.ts src/flows/doctor-health-contributions.test.ts src/commands/doctor-config-flow.plugin-session-plan.test.ts(all 87 tests pass, including the newskips duplicate legacy state detection when preflight settled unchanged config and deduplicates prior notes when rerunregression test insrc/flows/doctor-health-contributions.legacy-state.test.ts).npx oxlintandnpx oxfmt --checkon all touched files (0 warnings, 0 errors).