Skip to content

fix: preserve recovery sources and readmit state after update Doctor - #175300

Merged
steipete merged 1 commit into
mainfrom
fix8/doctor-admission-regressions
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
fix8/doctor-admission-regressions

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

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 and pnpm test <files> --maxWorkers=1.

Core tsgo, targeted type-aware lint, formatting, both edited docs' MDX checks, and git diff --check pass. 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 main 8324bae8896e. 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. Landed 90e9222398af reconnects 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:

Tested revision Result
Current main 8c4ea360522c 7/7 pass
Unchanged PR head 0a76e07bc43d 7/7 pass
CI's main parent 8324bae8896e All three hosted assertion signatures reproduce; 4 failed / 3 passed overall, with the same missed insertion also affecting the result-cap case

The 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.

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.
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T07:38:03.100360Z 0a76e07 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes commands Command implementations size: XS labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Canonical-path discovery can proceed without reading the unavailable recovery registry and allow source migration.
  • After: Doctor refuses before target preparation and tells the operator to restore the matching database while preserving its sidecars.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The narrow implementation has no identified code defect and changes no persisted format; confidence is bounded by owner-harness evidence and unresolved exact-head CI.
Proof confidence 🦐 gold shrimp (3/6) The supplied maintainer-authored classification exempts ordinary contributor proof; reported owner tests cover source preservation and child schema changes, but provide no shipped-entry-point demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor can migrate recovery sources without available shared-state history, and an updater can reuse a handle admitted before Doctor changed its schema.
Reason: The maintainer-authored direction restores documented source-preservation and schema-compatibility guarantees through existing owners without adding configuration or storage formats.

Regression provenance

Possible 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
Reviewed head: 0a76e07bc43df3a564506aa6fd522311fe2a63cf

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not show a shipped update CLI crossing the Doctor handoff or a shipped Doctor invocation refusing orphaned shared-state sidecars.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Doctor child settlement keeps the original intent (b2e11a2: The existing finally block revoked schema admission after foreign Doctor writes while retaining process-custody cleanup.)
  • Warm shared-state admission keeps the original intent (8d89449: Remove duplicate warm schema checks while retaining first admission and explicit maintenance lifecycle boundaries.)
  • Canonical session-store discovery keeps the original intent (64495be: Canonical per-agent paths identify their owner without waiting for an unnecessary shared-state registry read.)
  • Doctor target preparation keeps the original intent (e25e244: Prepare physical targets and repair legacy session scalars under the existing maintenance owner before canonical consumers run.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 1232d3f adds src/cli/update-cli/update-command-doctor-child.ts:157 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 1232d3f13ec0; files: src/cli/update-cli/update-command-doctor-child.ts)

PR surface

Source +17, Docs +11. Total +28 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 21 4 +17
Tests 0 0 0 0
Docs 2 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 32 4 +28

Labels

Label changes:

  • add P2: The repair protects recovery sources and schema admission in specific database-loss and update-handoff cases, without evidence of a widespread current outage.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The repair protects recovery sources and schema admission in specific database-loss and update-handoff cases, without evidence of a widespread current outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 17, 2026, 3:49 AM ET / 07:49 UTC.

@steipete
steipete merged commit e72e9a5 into main Oct 17, 2026
153 of 159 checks passed
@steipete
steipete deleted the fix8/doctor-admission-regressions branch October 17, 2026 08:12
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant