Repository navigation
fix(doctor): converge empty legacy state roots - #114678
Conversation
|
Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 1:37 AM ET / 05:37 UTC. ClawSweeper reviewWhat this changesThe PR replaces an empty legacy Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open: the exact PR head fixes a current-main startup refusal for an empty legacy state root, with no introduced correctness finding. It remains compatibility-sensitive because it replaces a persisted legacy path with a link; exact-head CI is still running. Priority: P1 Review scores
Verification
How this fits togetherDoctor migrations run before Gateway readiness and reconcile legacy state locations with the canonical state root. Their warnings feed the startup checkpoint, which otherwise refuses to mark the Gateway ready. flowchart LR
A[Legacy state root] --> C[Doctor state migration]
B[Canonical state root] --> C
C --> D{Legacy root empty?}
D -->|Yes| E[Link legacy path to canonical root]
D -->|No| F[Blocking migration warning]
E --> G[Startup checkpoint]
F --> G
G --> H[Gateway readiness]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +19, Tests +41. Total +60 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the owner-boundary convergence only after exact-head validation confirms that empty legacy residue links cleanly while non-empty and failed-mutation paths remain startup-blocking. Do we have a high-confidence way to reproduce the issue? Yes: current main’s state-directory owner emits the blocking target-exists warning for this shape, while the PR’s focused test and supplied two-boot Gateway evidence exercise the repaired path. Is this the best way to solve the issue? Yes: repair belongs in the state-directory migration owner, where it can converge a proven empty residue and preserve the existing warning path for non-empty state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 77e54ad04fa0. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (31 earlier review cycles; latest 8 shown)
|
37fa145 to
d229b08
Compare
d229b08 to
6db6c39
Compare
6db6c39 to
109f95b
Compare
109f95b to
88e61a7
Compare
|
Addressed the P1 finding on the current branch head (also rebased onto current main; the test-file conflict is resolved). Keep unresolved state-directory conflicts blocking (P1) — done. The classifier no longer keys on Supporting hardenings that shaped the marker choice:
Regression test encoding fail-open — reverted; main's "warns when target exists and legacy state is not a safe mirror" suite is restored verbatim. Requested coverage — added: bare-target + populated-legacy stays a blocking warning; auto-created runtime dirs don't count as markers; the preflight warnings-block test now carries the exact uninitialized-target skip message; and a new The residual product decision is intentionally narrow: an initialized |
f1cb87c to
ff3743f
Compare
4230b35 to
24f5933
Compare
24f5933 to
5bfd7f2
Compare
The startup migration checkpoint refuses gateway readiness on any migration warning and only records success afterward, so a warning that restarting can never clear wedges every boot permanently. autoMigrateLegacyStateDir emitted its deterministic skip decisions as warnings; after upgrading to 2026.7.x a leftover legacy state dir next to an existing ~/.openclaw locked the gateway out with no doctor repair path. Classify skips by whether a usable canonical target dir exists: when ~/.openclaw exists it wins state-dir resolution and the skipped legacy path is inert residue, so the skip is a non-blocking Doctor notice; without a canonical target the legacy path is the active state root and broken shapes there stay blocking warnings. Real migration failures (rename failed, rollback, split state) are unchanged. Closes openclaw#112395
isInitializedStateRoot used existsSync, so a DIRECTORY named openclaw.json or clawdbot.json satisfied the marker. That flips an unresolved legacy-state conflict from a startup-blocking warning to a non-blocking notice, and preflight then records its checkpoint and starts the gateway against a stray directory while the real state is still unmigrated. The comment above the predicate already said only a config FILE proves ownership; the code did not. Add isFilePath as the fail-closed twin of isDirPath — an unreadable marker (EACCES) returns false and keeps the warning blocking, rather than a permission error silently downgrading it. Two regressions cover both accepted marker names as directories, since either one alone satisfies the predicate. Reported by ClawSweeper on openclaw#114678 [P1].
Rebase-onto-main fixups (main moved ~2544 commits since this branch was last synced, largely via openclaw#120959's startup-migration-checkpoint rework): - withTempDir -> withTestDir (helper renamed in src/test-helpers/temp-dir.ts). - makeTempRoot -> makeDoctorStateDir (the actual tracked-tempdir helper this test file uses elsewhere; makeTempRoot never existed here). - Mock ../config/io.js's readConfigFileSnapshotWithPluginMetadata and ../infra/startup-migration-checkpoint.js's needsStateMigrationCheckpoint / recordSuccessfulStateMigrations / acquireStartupMigrationLeaseWithWait, all added/renamed by openclaw#120959's checkpoint-identity rework. - needsStateMigrationCheckpoint now mirrors needsStartupMigrationCheckpoint by default (openclaw#120959 decoupled the two), and the plugin migration fingerprint is pinned non-null so the pre/post-convergence identity check doesn't spuriously refuse readiness in this suite. ClawSweeper P3 fix (confidence 0.98): the two "no-copy" fixtures in doctor-config-preflight.legacy-config.test.ts never created a bare .openclaw directory, so config/paths.ts's resolveStateDir fell through to the legacy dir as the resolved state dir instead of ~/.openclaw. That made targetsDefaultStateRoot false, so the canonical-root guard this PR added was never actually exercised — the assertions passed vacuously because the copy target itself became ~/.clawdbot. Creating a bare ~/.openclaw in both fixtures makes it the resolved target and forces the guard to run.
The preflight now calls migrateLegacyConfigMachineState, which this suite's doctor-state-migrations mock did not export, so every legacy config case failed on the missing mock rather than on behavior.
…suite state-migration.test.ts crossed the 1000-line test cap once this PR's cases landed on top of main's growth. The five gateway-readiness cases move to their own file behind the existing shared test-helpers module; no case text changed and the suite total is unchanged at 68.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Maintainer repair is land-ready at
Proof:
The CI run has one unrelated timeout in |
|
Thanks @harjothkhara! Proof: A real 2026.6.11 upgrade with an initialized
Merged in e5d0e60 |
What Problem This Solves
Refs #112395.
OpenClaw 2026.7.1 added a startup migration checkpoint. A leftover empty
~/.clawdbotdirectory beside an initialized~/.openclawroot now produces a Doctor warning. Every startup migration warning blocks Gateway readiness, so the Gateway exits before listening. Restarting repeats the same warning because the empty legacy directory never converges.Why This Change Was Made
The migration owner now removes only a proven empty legacy directory and replaces it with a symlink to the existing canonical root. This preserves the old-path compatibility contract and prevents older clients from recreating split state.
The startup owner remains fail-closed. A legacy directory with any file, a broken link, an outside-root link, or another unresolved shape still produces a blocking warning. The earlier config-file marker approach was removed because historical Doctor versions could copy a config file without proving that legacy user state was already migrated.
User Impact
~/.clawdbotto~/.openclawand reaches Gateway readiness.openclaw doctor --fixguidance.Evidence
Real upgrade red/green
Both runs used the real
[email protected]config command, defaultHOMEpath resolution, andopenclaw gateway run --forcetwice.68c3818f7096State dir migration skipped: target already existsandrefusing to report the gateway ready.fe2b921d6d70[gateway] ready;.clawdbotresolved to.openclaw; the second boot had no target-exists warning.Regression proof
The new owner-boundary test failed against unmodified main production code with
migrated: falseand the target-exists warning: https://github.com/openclaw/openclaw/actions/runs/33471907503The built-CLI Gateway test failed on main with the exact startup refusal, then passed on the final
ab88e45a267tree through two readiness cycles:Formatting, core Oxlint, conflict-marker, max-lines, assertion-safety, database-first, and
git diff --checkgates pass. Type checks remain delegated to CI under the repository host-safety rule.Production LOC: +22/-3 (net +19) | Tests: +45/-4 (net +41). The production growth owns empty-directory retirement, the compatibility link, and failure reporting at the migration boundary.
Original contribution and investigation by @harjothkhara. Maintainer repair preserves that credit.
This contribution is AI-assisted and maintainer-verified.