Repository navigation
Conversation
Doctor's auth-profile migration backup copied the SQLite anchor file and checked it for the planned auth rows, but PostgreSQL owners keep those rows in PostgreSQL, so every `doctor --fix` failed with "Auth profile backup differs from the planned source". PostgreSQL owners now get the exact PostgreSQL capture Doctor uses before schema migrations, with the planned rows checked against the live store between two fingerprints. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🦞👀 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 changesDoctor backs up PostgreSQL auth-profile stores through the PostgreSQL backup owner before migrating their credentials. Example: A PostgreSQL auth store contains the legacy profile claude-cli:work.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain This PR addresses a current PostgreSQL Doctor failure that can block service startup, while preserving the existing migration safeguards. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor reads shared and per-agent credential stores, plans normalization, verifies a pre-migration backup, and commits through the existing auth-store transaction owners. flowchart TD
A[Doctor CLI] --> B[Auth migration plan]
B --> C[Engine selection]
C --> D[SQLite snapshot]
C --> E[Exact PostgreSQL capture]
D --> F[Source and owner revalidation]
E --> F
F --> G[Existing auth migration transactions]
Technical reviewBest possible solution: Retain the engine-aware backup repair under the existing Doctor migration and backup owners. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the anchor-versus-PostgreSQL mismatch, and the contributor records matching CLI failure and recovery; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch fixes the backup boundary rather than bypassing verification, preserves SQLite behavior, and leaves credential normalization, receipts, ownership checks, and writes with their existing owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c18dd0e81f40. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +92, Tests +126. Total +218 across 3 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 31, 2026, 1:38 PM ET / 17:38 UTC. |
|
Thanks, @ceckert, for the report, initial fix, and PostgreSQL reproduction. I confirmed the SQLite-anchor mismatch still exists on main and carried the fix into #189639, with backend selection and captured-row verification handled by the database backup owner. The replacement also registers the PostgreSQL regressions in conformance CI and retains your co-author credit alongside steipete's. Closing this PR in favor of that replacement; its CI and landing are being tracked there. |
What Problem This Solves
Fixes:
openclaw doctor --fixalways exits 1 with "SQLite database cannot be snapshotted safely: … Auth profile backup differs from the planned source; retry Doctor." when a PostgreSQL-backed state or agent store holds auth profiles that Doctor needs to migrate, such as a legacyclaude-cli:alias.User Impact
User impact: Doctor can migrate stored auth profiles on PostgreSQL installations, saving a verified PostgreSQL backup first, instead of failing on every run. Retrying never helps today, so any service or container that runs Doctor before startup cannot start.
Why This Change Was Made
Before rewriting stored auth profiles, Doctor saves a verified backup and checks that it holds exactly the rows it planned from. Both checks assumed SQLite. On PostgreSQL the
.sqlitefile at that path is only the store's anchor: planning reads the rows from PostgreSQL, but the backup copied the anchor file, which holds no auth rows, so the check could never pass.For PostgreSQL owners, the backup now uses the same exact capture as Doctor's pre-migration PostgreSQL backups (
<db>.auth-profile-migration-<id>.postgres.bak). The planned rows are checked against the live store between two fingerprints of it, and Doctor refuses if anything changed during the capture. SQLite owners keep the existing snapshot and check. The step moves into its own module, sodoctor-auth-flat-profiles.tsgets shorter.Evidence
Shipped CLI against disposable PostgreSQL 16 with synthetic credentials. The state store is on PostgreSQL. After an initializing
doctor --fix, the shared auth store row is set to a legacyclaude-cli:workAPI-key profile, the shape an older release leaves behind, and config references that profile. Thenopenclaw doctor --fix --non-interactiveruns.main(OpenClaw 2026.10.9 (4a95b4e))OpenClaw 2026.10.9 (b11c4d6))doctor --fixexitSQLite database cannot be snapshotted safely: <root>/state/state/openclaw.sqlite. Auth profile backup differs from the planned source; retry Doctor.Saved auth profile migration backup: …andMigrated stored auth profile aliases in …claude-cli:workanthropic:work, same synthetic key<root>/state/state/openclaw.sqlite.auth-profile-migration-<id>.postgres.bak:anchor.sqlite,database.sqlite,manifest.json, still holding theclaude-cli:workrowThe same failure took down a production gateway: every pre-start Doctor exited 1 on this step.
src/commands/doctor/auth-alias-migration.postgres.test.tscovers both the shared state store and an agent store on real PostgreSQL. Each migrates the alias and leaves a completed backup that still holds the pre-migration row. If the rows change mid-capture, Doctor refuses and leaves the store unmigrated. The migrate cases failed onmainwith the exact error above.auth-alias-migration,auth-alias-preservation,doctor-auth-flat-profilesanddoctor-health-contributions.pnpm check:changedpasses, except the dead-export scan, which reportssrc/tts/directive-facts.tsonmainalready.