Repository navigation
fix(doctor): settle byte-identical duplicate session import archives - #155194
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: blocked before merge. Reviewed September 22, 2026, 3:04 AM ET / 07:04 UTC (Revision 10). ClawSweeper reviewWhat this changesDoctor consolidates verified identical session archives, redirects recovery manifests to a surviving original, and reports settlement results during recovery and updates. Merge readiness⛔ Blocked before merge - 3 items remain Still needed: current main and the latest release retain the duplicate-archive refusal. The prior recovery-target defect remains unchanged and blocks merge; the recorded archive-settlement proof remains useful. Priority: P1 Review scores
Verification
How this fits togetherDoctor migrates legacy conversation files into agent SQLite databases. Its retained archives and migration manifests preserve originals for recovery and determine whether update-time session repair can finish. flowchart TD
A[Legacy archives and manifests] --> B[Doctor target selection]
B --> C[Verify ownership and bytes]
C --> D{Identical original copies?}
D -->|Yes| E[Keep survivor and redirect manifests]
D -->|No| F[Preserve originals and warn]
E --> G[Import or recover selected agent]
F --> H[Doctor and update report]
G --> H
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +334, Tests +604, Docs +10, Other +1. Total +949 across 18 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. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep settlement within the existing recovery journal and carry the complete prepared agent, store, and database target through historical import. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the remaining defect: recover historical archives for a non-default agent sharing a fixed session.store; the recursive import drops its prepared database and agent selection. No runtime reproduction was executed here. Is this the best way to solve the issue? The journal-based settlement is appropriate, but the recovery handoff must preserve its already-resolved target instead of resolving it again from an incomplete selector. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5c42f636bb9b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
Coalesce trusted identical archive claims through the recovery journal, redirect retained migration manifests without losing import acknowledgments, and preserve session warnings through Doctor and the installed updater. Recover uses the same settlement for historical-only stores. Fixes #155095. Related: #154413. Thanks @fozzels-assistant for the detailed report.
fb11b1e to
24b9ea9
Compare
…penclaw#155194) * fix(doctor): settle byte-identical duplicate session import archives Coalesce trusted identical archive claims through the recovery journal, redirect retained migration manifests without losing import acknowledgments, and preserve session warnings through Doctor and the installed updater. Recover uses the same settlement for historical-only stores. Fixes openclaw#155095. Related: openclaw#154413. Thanks @fozzels-assistant for the detailed report. * fix(ci): register session archive recovery owner
Closes #155095. Related: #154413. Thanks @fozzels-assistant for the detailed archive analysis and recovery report.
What Problem This Solves
Repeated session imports can leave byte-identical primary archives that Doctor treats as conflicting history. Repair keeps deferring them, and older update flows can strand the installation while waiting for session repair.
User Impact
Doctor automatically keeps one verified original for identical archive claims and redirects every migration manifest to it. Import and recover use the same settlement, including interrupted runs. Genuinely different copies remain preserved and named in warnings; historical-only warnings allow post-session plugin repair to finish.
No new flags, configuration, dependencies, or SQLite schema changes. The existing archive journal preserves retryable disposal and rollback mappings. The historical-only source-index refusal was already addressed by #153097; this change fixes duplicate settlement and the missing durable warning that an archive-only early return exposed.
Why This Change Was Made
One verified surviving original must satisfy every retained run's rollback claim. Merely deleting duplicates or marking their references disposed breaks failed-run recovery. Coalescing also preserves completed import acknowledgments, so it cannot resurrect history that a user deliberately deleted.
doctor-session-sqlite-retirement.ts:64)doctor-session-sqlite-migration-coalesce.ts:15, with migration-run keys)doctor-session-sqlite-discovery.ts:76,355)doctor-session-sqlite.ts:170,369, target/recovery/type owners,doctor-session-transcripts.ts:528, registered flow runner atdoctor-health-contribution-runners.state.ts:163)The target-selection and manifest-coalescing functions are in coherent sibling modules because the existing files had no line-growth allowance. They retain the same owners and add no alternate scanner, import receipt, or disposal implementation.
Evidence
Head:
24b9ea9eb0dbe865ffeb4e784a6cb69b09e34f65. The branch is rebased onto main06ce6c415dd293f139181085c9518abe5d47ce36, which includes the final #155138 lifecycle fix at2fe69089d79. The old embedded prerequisite is removed completely. All lifecycle/pool files and their test helpers exactly match main.The original settlement delta is unchanged: every added and removed line in its 16 files matches the r1-reviewed patch relative to its original base. The only new edits register
doctor-session-sqlite-recovery-inventory.test.tsin the existing SQLite recovery CI owner and add it to the matching strict ownership assertion. This fixes its accidental generic-Doctor placement without changing runner allocation or product test assertions.fb11b1e6cbfsrc/config/sessions/session-transcript-reconcile-pool.ts(+29/−0 removed);src/config/sessions/session-transcript-reconcile.ts(+42/−27 removed)session-transcript-reconcile-pool.test.ts,session-transcript-reconcile.lifecycle.test.ts,openclaw-test-state.test.ts(+173/−19 removed)scripts/lib/ci-command-test-plan.mts+1;test/scripts/ci-node-test-plan.commands.test.ts+1[1,1]; 27.04 s Vitest wall; no drainage errorscheck:changedTestbox:
tbx_01m334yb1jas7vvkpp0g03aabr(run). The lease was stopped after the successful command; terminal state independently verified. The ordering probe inherits the canonical runtime-config owner and uses ignored proof-only sequencing/reporting to verify lease-before-handoff and the same worker. Its first reporter used the wrong Vitest property after all 19 product tests passed; the observer was corrected todiagnostic().workerId, then strict order/worker verification passed. No product/test assertions, retries, timeouts, or committed isolation settings changed. The Doctor suite run had not started before that observer correction.The previous unmodified published 2026.9.5 updater → candidate proof on head
fb11b1e6cbfb8704f48056c4e4779a777a94e60cpassed in 106 s with 13 agents and two real imports. Actual update stdout named 1,307 settled copies and all four differing IDs. Standalone Doctor, recover and dry-run exited 0; all eight differing originals stayed byte-identical; all 13,154 retained manifest references resolved with no retired-path references or ENOENT. That prior-head live proof is retained as historical evidence, not relabeled as a new-head package run. This refresh uses the scoped Testbox gates above, as requested.Earlier regression controls fail for the intended contracts: identical-claim eligibility, retained warning persistence, and distinct-original-path protection. Disabling manifest redirection leaves a retained reference to a physically absent retired file in both interrupted recovery cases; restoring exact bytes passes both cases. No safe recovery recipe was verified for unpatched 2026.9.5; preserve archives and migration manifests rather than moving files independently.
Current split: runtime production +597/−263 (net +334); tooling +1/−0; tests +688/−84 (net +604); docs +10/−0. No new configuration/CLI options, dependencies, schemas, suppressions, or baseline edits.
The final test stages total 444 passed / 2 skipped / zero product failures. No file exceeded 120 s of test time. The existing public bounded-heap proof took 31.445 s total, with 28.362 s of measured import/verification for 25,000 events.