Repository navigation
fix: preserve recovery sources and readmit state after update Doctor - #175300
Conversation
Drain retained parent shared-state handles after the Doctor child settles, including unsuccessful exits, before revoking schema admission. The next parent access must admit the resulting database schema again. This keeps updates from silently reusing admission from before Doctor migrated it, without restoring per-read schema probes removed in #175077. Refuse destructive Doctor session migration before target preparation when the shared-state database is absent but its SQLite sidecars survive. Keep legacy source and WAL bytes intact and tell the operator to restore the matching database. Canonical-path recovery retains #175129's registry-read optimization; source preservation no longer depends on that incidental read. The existing regressions reproduced on origin/main cec76b0: both Doctor exit-code cases and shared-state orphan-WAL preservation failed. After the fix all 11 cases in the two owning files pass unchanged. Core types, targeted lint, formatting, docs MDX and whitespace checks pass. Independent P2 review found no actionable P0-P2 findings. Sibling proof: 65/65 pass across Doctor authority/delegation and session recovery/restore; 186.85 s command wall. No tests or assertions changed. OAuth's same-hourly failure is covered by active PR #175069 and untouched.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves legacy session sources when shared-state recovery history is unavailable and closes parent database handles after update Doctor finishes. Example: Doctor imports legacy sessions while state/openclaw.sqlite is missing and openclaw.sqlite-wal remains.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep open: this focused recovery-safety repair remains necessary on main, and no actionable introduced code defect was found; exact-head CI still needs resolution. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe update CLI delegates migrations to a Doctor child, then resumes shared-state access; Doctor target preparation controls admission before legacy session imports and archival. flowchart TD
A[Update CLI] --> B[Doctor child]
B --> C[Shared state database]
B --> D[Session target preparation]
D --> E[Legacy session sources]
A --> F[Drain parent handles]
F --> G[Fresh schema admission]
Technical reviewBest possible solution: Retain these two repairs in the existing Doctor preparation and shared-state lifecycle owners while preserving the intentional read optimizations. Do we have a high-confidence way to reproduce the issue? Existing owning tests provide concrete reproductions for orphaned shared-state WAL and both Doctor exit outcomes; source inspection confirms the paths, but no tests were executed during this read-only review. Is this the best way to solve the issue? The patch repairs admission at the owning boundaries using existing sidecar detection and asynchronous database closure, avoiding repeated schema probes or a competing recovery mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7de7f398b4e9. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +17, Docs +11. Total +28 across 4 files. Added test files: 0. 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 17, 2026, 3:49 AM ET / 07:49 UTC. |
…#175300) Drain retained parent shared-state handles after the Doctor child settles, including unsuccessful exits, before revoking schema admission. The next parent access must admit the resulting database schema again. This keeps updates from silently reusing admission from before Doctor migrated it, without restoring per-read schema probes removed in openclaw#175077. Refuse destructive Doctor session migration before target preparation when the shared-state database is absent but its SQLite sidecars survive. Keep legacy source and WAL bytes intact and tell the operator to restore the matching database. Canonical-path recovery retains openclaw#175129's registry-read optimization; source preservation no longer depends on that incidental read. The existing regressions reproduced on origin/main 65bc05f: both Doctor exit-code cases and shared-state orphan-WAL preservation failed. After the fix all 11 cases in the two owning files pass unchanged. Core types, targeted lint, formatting, docs MDX and whitespace checks pass. Independent P2 review found no actionable P0-P2 findings. Sibling proof: 65/65 pass across Doctor authority/delegation and session recovery/restore; 186.85 s command wall. No tests or assertions changed. OAuth's same-hourly failure is covered by active PR openclaw#175069 and untouched.
What Problem This Solves
Doctor could move legacy session sources despite unavailable shared-state recovery history, and an updater could reuse stale schema admission after its Doctor child migrated the database.
User Impact
Destructive Doctor session migrations now refuse before importing or archiving legacy sources when the shared-state database is missing but its SQLite sidecars remain. The error asks operators to restore the matching database and preserve the sidecars. After an update Doctor child settles, including a failed exit, the next parent access admits the resulting schema again and refuses unsupported newer versions.
Why This Change Was Made
The canonical-path optimization in #175129 removed a registry read that had incidentally blocked the unsafe migration. Put the explicit orphan-sidecar refusal in Doctor's existing target-preparation owner, before source mutations, and retain the optimization.
The warm-cache simplification in #175077 left existing parent handles usable after admission revocation. Drain the affected handles through the existing path-scoped asynchronous lifecycle owner before revoking admission and releasing process custody. No per-read schema probes, new state, or new migration machinery are introduced. Both contracts are documented.
Evidence
On main
cec76b0b41d2, both Doctor-child exit-code cases and the shared-state orphan-WAL case reproduced. All existing assertions remain unchanged, including exact legacy-source and WAL byte preservation. The fix passes all 11 cases in the two owning files and 65 sibling cases covering delegated authority, child settlement, recovery, and restore paths, using native Node 24 andpnpm test <files> --maxWorkers=1.Core tsgo, targeted type-aware lint, formatting, both edited docs' MDX checks, and
git diff --checkpass. Independent P2 autoreview is scoped-clean with no actionable P0–P2 findings. The simplified change adds only the missing lifecycle close and the explicit destructive-migration admission guard: production +21/-4 lines, docs +11/-0; no tests changed.The OAuth invalid_grant failure in the same hourly is separately covered by the active non-draft diff of #175069 and is not changed or claimed fixed here. Current-main and open-PR duplicate checks found no other fix for these two cases. No CI dispatch or rerun was requested; PR CI supplies broad proof.
PostgreSQL failure attribution after PR CI
Job 117343061337 tested merge
bdcc9301dd58, combining this PR with main8324bae8896e. That main revision contains #175157's migration of local file observation into a worker, while this PR's own base predates it. The existing PostgreSQL test's in-process filesystem mock no longer receives worker observations. Landed90e9222398afreconnects that fixture without weakening its product assertions.Using the native conformance runner, Node 24,
--maxWorkers=1, and the same pinned PostgreSQL 17/pgvector image as CI:8c4ea360522c0a76e07bc43d8324bae8896eThe historical-main comparison explicitly selected that revision's source plugin tree after an initial attempt encountered a stale local built plugin export; that initial attempt is excluded from the matching evidence. The qualified run reproduced the old cobalt snippet, old vector snippet/0.56 score, and missing boundedmarker snippet exactly. These failures are inherited and the narrow fixture repair is already on main. No source changes or branch push were needed; the existing P2 review remains applicable. No CI was dispatched or rerun.