Repository navigation
fix(doctor): continue repairs after legacy agent directory collisions - #146092
Conversation
Merge legacy agent subdirectories recursively, preserve differing source files in one quarantine, and record recoverable collision receipts so later repairs continue. Reuse the canonical agent-directory resolver for SDK fallbacks, validation, and migration, and report old quarantine artifacts without deleting them. Reported by a Discord user (Aristotelianism). Fixes #146043
|
🦞👀 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 13, 2026, 3:14 AM ET / 07:14 UTC (Revision 26). ClawSweeper reviewWhat this changesDoctor preserves legacy directory conflicts, defers SQLite relocation, continues independent repairs, and keeps standalone SDK sessions and tools using the appropriate directory. Merge readiness✅ Ready for maintainer review This remains a useful fix absent from current main. Earlier code findings are resolved, and the matching captured PR body explicitly records acceptance of the updater qualification exception. No actionable patch defects remain. Priority: P1 Review scores
Verification
How this fits togetherDoctor repairs older OpenClaw installation state during maintenance and updates. Its directory decisions also affect where standalone SDK sessions find databases, settings, models, and managed tools. flowchart TD
A[Configuration and directory overrides] --> B[Shared installation resolver]
C[Legacy files and database owners] --> B
B --> D[Doctor migration]
D --> E[Merge files and preserve conflicts]
D --> F[Leave SQLite families in place]
E --> G[Report warnings and continue repairs]
F --> G
B --> H[SDK sessions and tool lookup]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +632, Tests +1391, Docs +12. Total +2035 across 31 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Doctor should complete independent repairs while keeping existing SDK state usable; database relocation and ownership transfer should remain separately approved work. Do we have a high-confidence way to reproduce the issue? Yes, from source: a legacy entry colliding with its destination produces an unclassified warning on current main, which the migration runner treats as a refusal. This read-only review did not execute the reproduction. Is this the best way to solve the issue? Yes. The patch repairs the existing migration owner, shares directory resolution, and avoids unsafe SQLite movement; the remaining published-updater qualification limit has an explicit recorded acceptance. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3f849337ee97. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (25 earlier review cycles; latest 8 shown)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* commit '2acbeee461474b6ba41f5186ae1a4e0e80f4087a': (117 commits) fix(ui): import the shared deferred helper in sidebar scope tests (#146862) fix(ui): copy chat content from its context menu (#146679) perf(memory): defer legacy sidecar writer imports (#146815) fix(e2e): accept expected Kitchen Sink worker rejection (#146681) fix(ui): distinguish absolute and relative file links (#146572) feat(ui): keep file previews in tabs and render HTML (#146672) refactor: reuse shared deferred promises in UI tests (#146670) fix: gateway stop/restart refuses a healthy gateway when the Windows process snapshot misses (#146387) improve(crabbox): keep healthy cloud desktops warm on resume (#146816) fix: report blocked SQLite WAL checkpoints in status and doctor (#146775) feat: share browser dashboards with agents (#146702) fix(doctor): continue repairs after legacy agent directory collisions (#146092) feat(agents): retry cyber-refused embedded turns on Daybreak (#145291) fix: restore media uploads through protected egress (#144902) refactor(qa): share capture filter rendering (#146696) fix(cli): keep running stream jobs visible as running (#146793) refactor(parallels): share gateway readiness loop (#146694) fix(sessions): avoid rewriting already-consumed input on release (#146795) fix: preserve scheduled conversation delivery after Doctor (#146794) perf(ui): avoid redundant session-row provenance work (#146797) ...
…openclaw#146092) Doctor continues after legacy agent-directory collisions: non-database files merge recursively and conflicts are quarantined once, with a completion receipt. SQLite database families remain in place with a deferred receipt and a Doctor warning; moving them requires a separate persistence design. SDK and Doctor share one install-directory resolver carrying the directory, recorded owner, and migration state. Environment overrides take precedence; malformed config produces one warning without writes. Sessions keep their existing store when the configured owner differs, and system search tools and shell PATH remain usable without an ambient owner. Validation includes failing-before/passing-after regressions, SDK/Doctor boundary suites, changed-file checks, a clean P1 review, and successful exact-head CI. Published-updater installation qualification remains a documented, maintainer-accepted limitation. Fixes openclaw#146043 Reported by @steipete (openclaw#146043).
Fixes #146043
Additional instructions
Maintainer edits are welcome.
What Problem This Solves
Doctor stopped before later repairs when legacy
~/.openclaw/agent/contents collided with the current agent directory. Whole destination subdirectories were skipped, and repeated runs accumulated quarantine directories. Standalone SDK state could also become unreachable when its selected directory or database owner disagreed with Doctor.Reported by @steipete (#146043). The issue also credits the original community report.
Why This Change Was Made
One install resolver supplies the selected directory, recorded database owner, and migration state to the SDK and Doctor. Explicit environment directory selection precedes config inspection; other lookups use the shared tolerant, read-only config loader. Missing, unreadable, or invalid config records one warning and preserves default/legacy access without writing config, changing the process environment, or starting migration. Doctor retains its separate config-admission gate.
The compatibility source is the shipped SDK location,
homedir()/.openclaw/agent, independent of state/home overrides. Nonempty legacy state remains selected until a matching completed migration receipt exists. Existing legacy sessions retain their recordedmainowner even when configuration selectsworker. An owner mismatch leaves the source in place and records both owners and the path.SQLite families are deferred, never moved or quarantined by this directory migration. The planner reserves each database and its WAL, SHM, and rollback-journal files before merging ordinary entries. Each family appears once in the repair receipt with
outcome=deferred,reason=sqlite-family, its source paths, and its planned destination. The warning names those paths and explains that the store keeps being used from its current location; a later release moves it. No completion marker is written for a deferred source. The SQLite family move and rollback path introduced during this repair has been removed.An otherwise eligible deferred source retains its ancillary files so the SDK can still use installed tools, model definitions, and settings. Missing non-database destination entries are copied; identical files need no work, and conflicts remain at their existing source and destination paths with a warning. No new quarantine is created for that deferred source. Sources without SQLite families retain recursive move-and-quarantine behavior, including existing
bin/directories. Differing files preserve the destination and quarantine the source under the resolved state root; repeated runs without new conflicts create no new artifact. Quarantines older than 30 days receive a cleanup hint and are never automatically deleted.Deferred warnings reach Doctor and update reporting while independent repairs continue. Explicitly selected directories are never drained, and copied-state plans cannot move unbound SDK home payloads.
User Impact
Doctor continues other repairs while leaving every legacy SQLite family intact and usable at its current location. SDK sessions keep their recorded owner and existing database; tools, models, and settings remain available. Eligible non-database files still merge, and collisions are reported without repeated quarantine copies for a deferred store.
Whole-store ownership transfer and atomic SQLite-family movement or recovery artifacts remain separate maintainer design decisions, pending Peter's approval. This PR implements neither. Operators can keep using the existing store until a later release provides that migration.
Release-note context: Doctor preserves legacy SQLite families in place, reports their deferred migration, merges eligible ordinary files, and continues later repairs.
Evidence
The updated regression uses two real SQLite families with committed WAL-only rows. A database-only copy cannot read the row. It injects a later ordinary-file failure and blocks database, WAL, or SHM restoration to prove those family operations are never attempted. Both families stay at source, the receipt lists both exactly once with planned destinations, ordinary-file merging makes progress, and opening each original database recovers its WAL rows. Repeating Doctor preserves the same facts without a quarantine artifact.
node scripts/run-vitest.mjs src/infra/state-migrations.recoverable-legacy-state.test.ts src/infra/state-migrations.caller-mode.storage.test.ts src/agents/sessions/sdk.auth-migration.test.ts -t 'leaves SQLite families|deferred main SQLite family|preserves existing standalone sessions'Against the preceding head
f9b91e0aa49bb4e9d5dc05455903a52a067e4b51:The failures show database-family movement/quarantine, unsafe rollback, or SDK/Doctor cutover instead of the required deferral. After the repair, all five focused suites passed:
Test names:
leaves SQLite families in place while merging files ($relativeDatabase, destination: $destination, blocked restore: $blockedRestore)shares the install directory between SDK and Doctor: $testCase.name (malformed: $malformed)— includes deferred SQLite state with valid and malformed config.preserves existing standalone sessions (configured owner: $configuredOwner, Doctor: $doctor)— both same-owner and different-owner Doctor runs retain the original main-owned store, sessions, tools, and model discovery.keeps standalone state after an incomplete migration, including a source-carried receipt (companion: %s).The full proof command includes the required 21 files, both Doctor flows, registration boundary, and recovery suites:
The full proof passed: 904 tests across 26 files, with two existing skips. The final focused rerun passed 84 tests across five files.
node scripts/check-changed.mjspassed both TypeScript lanes, all unused-export scans, lint, storage guards, and zero runtime import cycles. A fresh independent P1 review of the final source found no actionable findings.pnpm buildpassed on committed headb21a10567f9beecb5069458a4c12365166dabadbin 7m 9s, including declarations, native Doctor loading checks, and the Control UI.Round 12 numstat relative to
f9b91e0aa49bb4e9d5dc05455903a52a067e4b51: production +108/-153 (net -45); tests +207/-203 (net +4); docs +4/-2. No new configuration options, dependencies, schemas, recovery stores, retention policy, or changelog changes.Previously reviewed head:
b21a10567f9beecb5069458a4c12365166dabadb. Exact-head CI run 34740729898 passed on attempt 1: 118 successful jobs, 14 skipped, zero failures. No failed-job rerun was used. The bounded watcher exitedGREEN:CI per job
Known limits: SQLite-family movement and whole-store ownership transfer are intentionally deferred pending their separate accepted persistence designs. The published-updater × candidate installation was not rerun this round.
ClawSweeper review
The completed review of
1d88ebf8fe3c8c1a3d8567136df43b8c0d959ac6found no actionable code defects and confirms that the system-tool finding is resolved. SQLite families remain in place, preserving rollback dependencies and external cold transcripts. Optional managed-bin lookup permits systemfd/rgand shell PATH access without an ambient owner while SDK admission remains strict.The maintainer approved landing this exact head on the documented regression, SDK/Doctor boundary, build, and CI evidence, accepting the remaining qualification limit: published-updater × candidate installation was not rerun. SQLite relocation and whole-store ownership transfer remain deferred to separate accepted persistence designs.
Ownerless-tool regression
With a valid explicit
alpha/betaroster, no ambient owner, no directory override, and no legacy payload, this command failed on the preceding head:node scripts/run-vitest.mjs src/agents/utils/tools-manager.test.ts -t 'without an ambient agent owner'After the fix, all five selected suites passed, including the three new cases, missing-tool/no-download behavior, strict SDK admission, and unchanged filesystem contents:
Fixup head:
1d88ebf8fe3c8c1a3d8567136df43b8c0d959ac6. Fresh Codex autoreview of this fixup is scoped-clean at P1. Changed-file formatting, production/test typechecking, unused-export scans, lint, storage guards, and runtime-cycle checks all passed:Exact-head CI run 34742453855 completed successfully on attempt 2. Attempt 1 had one runner-side cancellation with zero executed steps in
checks-node-compact-large-7; the aggregate gate failed because of it. One authorized failed/cancelled-job rerun passed, and the exact-head watcher returnedGREEN. The earlier CI run above applies to the preceding head.