Repository navigation
fix(doctor): retire deferred receipts and track migration backups - #162771
Conversation
|
🦞👀 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 October 1, 2026, 5:48 PM ET / 21:48 UTC (Revision 13). ClawSweeper reviewWhat this changesDoctor retires verified completed plugin-import receipts, explains skipped new history, and records migration backups for guarded update cleanup. Merge readiness✅ Ready for maintainer review The fixes remain useful and absent from current main. The updated current-head regression resolves the earlier replacement-database compatibility blocker; no actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherDoctor migrates legacy session files into OpenClaw’s SQLite databases while preserving recovery originals. Update cleanup consumes Doctor’s recorded evidence to identify originals that operators can safely retire. flowchart TD
A[Legacy session files] --> B[Doctor import and recovery]
C[Plugin migration obligations] --> B
B --> D[Verified SQLite history]
B --> E[Recovery receipts and backups]
E --> F[Completion and later update checks]
F --> G[Confirmed guarded cleanup]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +391, Tests +448, Docs +19. Total +858 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep receipt retirement and backup eligibility with their existing Doctor owners, preserving canonical history and explicit, fenced cleanup of rollback originals. Do we have a high-confidence way to reproduce the issue? Yes, source inspection supports both reported mechanisms: completed receipts remain active on main, and migration backups lack cleanup registration. This read-only review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes, the patch extends the existing receipt, backup, readiness, and disposal owners rather than creating parallel cleanup behavior; the corrected regression now validates the intended importable conversation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3ee29f3b82c3. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
d5a3028 to
2391df9
Compare
Retire completed or disabled plugin session import obligations after verified source archival, and explain retained inputs without moving newly supplied transcripts. Register startup migration backups with recovery cleanup, protect groups until verified migration completion and a later successful update, and retain unrecorded originals.
Reuse the recovery dependency walk for backup groups, combine duplicate target validation and completion scans, and remove redundant receipt predicates and an unused return value while preserving transaction rechecks.
Preserve the migration fences while placing receipt retirement in its sibling, legacy index publication in the archive owner, and backup completion in readiness. Move receipt regression cases without changing their inputs or assertions.
All retirement entrypoints are Doctor one-shots. Reuse the retained-source command owner, remove the extra infra module, and preserve the write transaction and source-verification guards without changing the SQLite inventory policy.
a2d6384 to
a49da13
Compare
|
Landed (squash |
… backups (openclaw#162771) Doctor left verified session-SQLite migration receipts and migration backups behind forever: every later Doctor or update run re-verified retired sources, and backup directories were never inventoried for protected cleanup. Doctor now retires a receipt only after re-checking receipt equality, pending obligations, source/index absence and archive/database verification inside one synchronous transaction, preserves history written after a database replacement, and registers migration backups so cleanup can only remove them after a recorded completion plus a later successful update. Refs openclaw#161949
…s test plan (openclaw#163071) openclaw#162771 added src/commands/doctor-session-sqlite.receipt-retirement.test.ts without extending the commands test plan expectation; main hourly 36935459406 was red on the owner count. Refs openclaw#162771
…generation The earlier reconciliation refreshed whichever file occupied a recorded path, so a valid database that replaced the recorded destination before the rewrite was adopted and cleanup could then retire the original against the wrong generation. Bind each refresh to the rewrite's pre-exchange dev/ino: an artifact must still match its recorded identity and carry the recorded size and sha256, and a destination must still be the generation whose migration was verified. Mismatches stay protected and are reported, preserving PR openclaw#162771's destination binding. Fixes the P1 review finding on openclaw#169893.
…169893) * fix(doctor): keep recovery originals retirable across a NOCOW rewrite Doctor's btrfs NOCOW repair copies every store file into a fresh directory, so the inode and mtime recorded in the migration manifest no longer match the live file. `update cleanup` then classifies a verified recovery original as blocked/artifact-metadata-changed, and its destination-database check rejects the rewritten database, permanently disabling a documented retirement path for operators who followed the NOCOW guidance. After a successful directory exchange the rewrite now re-records the relocated identity of the recovery originals and destination databases it exchanged, only after proving the copy still carries the recorded content (size and sha256). Anything that cannot be proven keeps its original record and stays protected, so no cleanup safeguard is weakened. Fixes #169674 * fix(doctor): refresh NOCOW recovery identities only for the recorded generation The earlier reconciliation refreshed whichever file occupied a recorded path, so a valid database that replaced the recorded destination before the rewrite was adopted and cleanup could then retire the original against the wrong generation. Bind each refresh to the rewrite's pre-exchange dev/ino: an artifact must still match its recorded identity and carry the recorded size and sha256, and a destination must still be the generation whose migration was verified. Mismatches stay protected and are reported, preserving PR #162771's destination binding. Fixes the P1 review finding on #169893. * fix(doctor): preserve exact recovery identity across NOCOW rewrites Consolidate the verified rewrite identity handoff and preserve the pre-copy metadata check. Exercise actual cleanup and refusal for replaced destinations, originals, metadata, and changed bytes. Co-authored-by: xydigitLybnnnn <[email protected]> * test(doctor): allow cleanup ownership workers in NOCOW fixture --------- Co-authored-by: xydigitLybnnnn <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…penclaw#169893) * fix(doctor): keep recovery originals retirable across a NOCOW rewrite Doctor's btrfs NOCOW repair copies every store file into a fresh directory, so the inode and mtime recorded in the migration manifest no longer match the live file. `update cleanup` then classifies a verified recovery original as blocked/artifact-metadata-changed, and its destination-database check rejects the rewritten database, permanently disabling a documented retirement path for operators who followed the NOCOW guidance. After a successful directory exchange the rewrite now re-records the relocated identity of the recovery originals and destination databases it exchanged, only after proving the copy still carries the recorded content (size and sha256). Anything that cannot be proven keeps its original record and stays protected, so no cleanup safeguard is weakened. Fixes openclaw#169674 * fix(doctor): refresh NOCOW recovery identities only for the recorded generation The earlier reconciliation refreshed whichever file occupied a recorded path, so a valid database that replaced the recorded destination before the rewrite was adopted and cleanup could then retire the original against the wrong generation. Bind each refresh to the rewrite's pre-exchange dev/ino: an artifact must still match its recorded identity and carry the recorded size and sha256, and a destination must still be the generation whose migration was verified. Mismatches stay protected and are reported, preserving PR openclaw#162771's destination binding. Fixes the P1 review finding on openclaw#169893. * fix(doctor): preserve exact recovery identity across NOCOW rewrites Consolidate the verified rewrite identity handoff and preserve the pre-copy metadata check. Exercise actual cleanup and refusal for replaced destinations, originals, metadata, and changed bytes. Co-authored-by: xydigitLybnnnn <[email protected]> * test(doctor): allow cleanup ownership workers in NOCOW fixture --------- Co-authored-by: xydigitLybnnnn <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
…penclaw#169893) * fix(doctor): keep recovery originals retirable across a NOCOW rewrite Doctor's btrfs NOCOW repair copies every store file into a fresh directory, so the inode and mtime recorded in the migration manifest no longer match the live file. `update cleanup` then classifies a verified recovery original as blocked/artifact-metadata-changed, and its destination-database check rejects the rewritten database, permanently disabling a documented retirement path for operators who followed the NOCOW guidance. After a successful directory exchange the rewrite now re-records the relocated identity of the recovery originals and destination databases it exchanged, only after proving the copy still carries the recorded content (size and sha256). Anything that cannot be proven keeps its original record and stays protected, so no cleanup safeguard is weakened. Fixes openclaw#169674 * fix(doctor): refresh NOCOW recovery identities only for the recorded generation The earlier reconciliation refreshed whichever file occupied a recorded path, so a valid database that replaced the recorded destination before the rewrite was adopted and cleanup could then retire the original against the wrong generation. Bind each refresh to the rewrite's pre-exchange dev/ino: an artifact must still match its recorded identity and carry the recorded size and sha256, and a destination must still be the generation whose migration was verified. Mismatches stay protected and are reported, preserving PR openclaw#162771's destination binding. Fixes the P1 review finding on openclaw#169893. * fix(doctor): preserve exact recovery identity across NOCOW rewrites Consolidate the verified rewrite identity handoff and preserve the pre-copy metadata check. Exercise actual cleanup and refusal for replaced destinations, originals, metadata, and changed bytes. Co-authored-by: xydigitLybnnnn <[email protected]> * test(doctor): allow cleanup ownership workers in NOCOW fixture --------- Co-authored-by: xydigitLybnnnn <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 29fb33a) Co-authored-by: RomneyDa <[email protected]>
Closes #162525
Closes #162622
What Problem This Solves
Doctor could retain a completed deferred plugin import receipt indefinitely and silently skip later legacy history. Its pre-startup-migration SQLite backups were also absent from update cleanup.
User Impact
Doctor retires completed or explicitly disabled/uninstalled plugin obligations after verified archival. An active receipt preserves new input and reports the receipt, plugin, and next command. Canonical SQLite edits and deletions remain authoritative. After receipt recovery and retirement, new history imports in the same pass.
Update cleanup lists migration backups. Recorded groups stay protected until Doctor verifies migration completion and a subsequent update succeeds. Existing confirmation and offline ownership checks then permit retirement; unrecorded historical backups stay protected. Keep these files with your pre-upgrade backups while the matching rollback generation is needed.
Why This Change Was Made
The receipt owner had no retirement path, and the backup producer never registered its artifacts with cleanup. Doctor's retained-source owner now uses the existing removed-source state, pending-generation check, receipt equality, and strict archive/database verification. Original sources and the index must be absent before and inside the retirement transaction. Receipt rebuilding finishes before retirement; diagnostic callbacks and cached verification cannot authorize it.
The backup producer records exact artifacts in the existing recovery manifest. Doctor's readiness owner records completion, excluding refused databases; cleanup reuses its dependency protection and fenced disposal. The rebase preserves main's asynchronous zero-byte transcript recovery and scalar-state migration/maintenance authority. A successful-rebuild notice is informational, so it does not suppress discovery of eligible new history. The regression requires same-pass import of a complete conversation after receipt rebinding and retirement.
The compression pass removed 24 net lines of duplicated lifecycle plumbing, plus three lines by reusing existing content comparison and manifest handling. Final LOC: production +557/−166 (+391 net); tests +451/−3 (+448 net); docs +21/−2. Remaining production growth supplies receipt retirement/diagnostics and backup registration/completion/inventory facts, with guarded data preservation. Existing archival publication moved to its existing owner to meet line caps. There is one cleanup/disposal implementation and no final baseline changes.
No SQLite schema, dependency, configuration option, or CLI option changes. Candidate Doctor consumes existing operator state; recoverable failures preserve originals and produce warnings. Release-note context is in this description. Thanks to @shadow-enthusiast and @islandpreneur007 for the reports.
Evidence
Pushed head:
253d558337db012cc5b19aaab502210d17fa0682. Rebased onto750b253a246e667e759caf926947042c2ea7077eafter actual conflicts appeared in the shared Doctor owners. The PR is ready for review, auto-merge off; no landing is requested.The own CI failure on
250dca44f9f59d93a8b1c4db38570390c9cff95awas reproduced with the maintainer-authorized exact local command:Root cause was the replacement-database test fixture: its later JSONL contained only a session header. The existing primary-transcript reader intentionally requires at least one message for unregistered history. The fixture now supplies a complete header and user message, with stable timestamps and working directory. Assertions still require one imported session, now both events, exact persisted history, preserved canonical metadata/history, receipt retirement, and an idempotent second import. No production code changed for this correction. The earlier interpretation of this header-only input as lost conversation history was incorrect.
The failing rebinding case now passes in 2.533 s; the slowest case in the local file took 5.181 s. Shared compilation/setup accounts for the remainder of wall time. No assertion, timeout, retry, or skip was weakened or added.
Checker gap on this head: the one authorized fresh Blacksmith lease
tbx_01m3wnwfh6fs4fch1b62f7rqf4remained queued without an IP or workflow run URL for 10m 41s (2026-10-01 21:28:18–21:38:59 UTC). It was stopped through the native lifecycle, verifiedcompleted, and its temporary SSH credentials were removed. No remote fetch/install/checker ran. No additional lease or provider fallback was used. The maintainer explicitly allowed pushing with this gap after ten minutes.The prepared but unrun command was:
The local eight-test result above is current-head evidence; earlier remote results below retain their original head attribution.
Fresh direct-route Codex P1 review covered the complete rebased candidate, discovery/compression delta, and the latest fixture-only correction. Findings about archive identity, recreated indexes, and permissive diagnostic callbacks were fixed before the clean reviews.
Earlier heavy proof used isolated Blacksmith Testboxes fetching pinned commits with frozen installs, without local-tree synchronization. The maintainer authorized only the exact receipt-retirement file as a local exception for this CI repair. Local formatting and
git diff --checkpass.Completed proof
a49da13e72b7cd85921ae8f09fd9f6df4760e444, nine affected suites passed all 111 tests. Core production types passed in 41 s; Doctor test types passed in 33 s. Leasetbx_01m3wj58xeve786zehpxtg2q7c, run. This includes newly introduced scalar-state and retained-runtime callers found by comparing the caller inventory; an unrelated cron filename substring was verified not to import a changed owner.deferred-plugin-session-sources.ts. No other lint error appeared. The final delta removes three source lines without changing limits or baselines; final-head checker confirmation is still required.614ebbdbb769f5a98fcd33c20a8a670c287f58cbfailed for all three intended reasons: missing/changed archives incorrectly retired their receipt, and database replacement hit the stale identity check before rebinding. Wall 31 s; test time 6.941 s.6df4acd1e4416149e5366d0051105afdac0aa840: 103 files passed, one platform-skipped; 1,447 tests passed, five skipped, in 1,187.19 s wall including shared compiler preparation. Leasetbx_01m3wa5wpbefxmbq8bjcs03n3z, run. Earlier caller batches had 1,194 passing tests, 14 skips, and the inherited config-capture failure below.d5a3028b7a33ea2928bae691689ec443587383bc, all five touched suites passed three times: 68 tests per run, 204 executions. Before-fix controls ond5e94ecc0939907f18e5980ac6d7613c140387ddfailed because the receipt-specific skip warning was absent and cleanup listed zero migration backups instead of two.2026.9.7updated to the pinned candidate, exited zero, recordedstatus: succeeded/phase: finished, restarted, returned/readyz=200, and verified the running build. Update time 308.258 s; full cell including package build 17m21s. This is prior-head update proof.On intermediate
32065aaa7e8879166c7d4cc85d8be392fe30d496,check-changedpassed its first 18 steps, then failed an inherited core graph budget:agents-other: 724 test roots exceeds the advisory 720 limit. The unchanged base4e6eb74beb7681e2787e2077503b13e7c35ab5d0reproduced the same count. All 15 remaining commands were run: 13 passed, including 27 core test-type shards in 1,038.540 s compiler time; two found a stale import subsequently removed. The correcteda2d6384b8e57257fa08de86a651aeb0a038d00afpassed production types and changed-core lint (zero warnings/errors). Leasestbx_01m3wcmsngz93d2yxxdcgrvg16(run) andtbx_01m3wejqwh83am030ak660z977(run). These results do not establish the final head's checker status.Measured affected-suite costs on the rebased parent
Measured with
pnpm test <file> --maxWorkers=1. No case exceeded 30 s or file exceeded 120 s of test time; the largest case was 11.723 s. Real receipt, SQLite, archival, and cleanup boundaries are required here: the runtime regression caught behavior that the earlier source review missed.doctor-session-sqlite.receipt-recovery.test.tsdoctor-session-sqlite.retained-source-verification.test.tsdoctor-session-sqlite.shared-orphan.test.tsdoctor-session-sqlite.deferred-plugin.test.tsdoctor-session-entry-state.test.tsdoctor-session-transcripts.sqlite.test.tsdoctor-migration-backup.test.tsdoctor-config-preflight.container-upgrade.test.tsdoctor-retained-runtime.settlement.test.tsWaived fixtures and inherited failures
The maintainer explicitly waived the slow-test STOP for these five pre-existing fixture follow-ups. All listed slow cases passed. The uncommitted planner-fixture optimization was dropped; none of these fixtures was changed, and no timeout, retry, skip, or weaker assertion was added.
ci-changed-node-test-plan.source-owners.test.tsdoctor-health.test.tsdoctor-health.managed-admission.test.tsdoctor-health.managed-settlement.test.tsdoctor-health.managed-approvals.test.tsdoctor-health.fleet-preflight.test.ts→preserves original config bytes before Doctor relocates and repairs legacy statefailed withOriginal configuration was not capturedfor legacy.clawdbot/openclaw.json. It reproduced on untouched parentd5e94ecc0939907f18e5980ac6d7613c140387dd(14.27 s Vitest, 34.09 s wrapper). The maintainer ruled it inherited and directed leaving it untouched.doctor-health.nocow.test.ts:112→joins Doctor's inspection child and database handles before rewriting both storesexpectedtools.exchanges2 and got 0. It reproduced on untouched base4e6eb74beb7681e2787e2077503b13e7c35ab5d0(24.87 s Vitest, 26.44 s wrapper). It was left untouched; no passing replay is claimed as a fix.GitHub Actions checks are attached to the final pushed head. Final hosted suite completion/timing is not claimed, and no CI wait or merge was requested.