Repository navigation
fix: preserve MEMORY.md when Doctor merges fail - #190497
Conversation
Keep the pre-merge canonical memory beside the legacy archive and publish through the existing atomic writer without its destructive copy fallback. Use a unique repair directory so later repairs cannot overwrite recovery copies. Preserve workspace aliases and modes and leave completed merges unchanged on subsequent Doctor runs. The 129-line test allocation covers failed publication, alias and mode preservation, and the backup collision/idempotency regression. Co-authored-by: Syxscott <[email protected]> Co-authored-by: steipete <[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: blocked before merge. What this changesDoctor preserves canonical memory before atomically publishing a legacy-memory merge and allocates unique recovery directories. Example: Doctor merges MEMORY.md containing "# Canonical\n" with memory.md containing "# Legacy\n" and publication encounters ENOSPC.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it repairs a concrete canonical-memory corruption path still present on main, and no actionable patch defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor receives configured workspace paths and repair confirmation, archives legacy memory, publishes the merged canonical file, and reports the result. flowchart TD
A[Doctor CLI] --> B[Memory health checks]
B --> C[Workspace memory repair]
C --> D[Unique recovery directory]
D --> E[Legacy archive and canonical backup]
C --> F[Existing atomic writer]
F --> G[Canonical MEMORY.md]
C --> H[Doctor result note]
Technical reviewBest possible solution: Use the existing atomic-publication owner with independent recovery copies and unique archive directories. Do we have a high-confidence way to reproduce the issue? Current-main source establishes truncate-in-place publication, and supplied CLI evidence demonstrates real filesystem failures; this read-only review executed no target code. Is this the best way to solve the issue? This is a focused repair at the existing migration owner: it preserves archive ordering and merge semantics while replacing destructive publication with the established atomic writer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e0ccab26a1b5. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +23, Tests +129, Docs +2, Other +2. Total +156 across 4 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label 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 November 1, 2026, 11:26 AM ET / 16:26 UTC. |
|
Merged via squash.
|
Keep the pre-merge canonical memory beside the legacy archive and publish through the existing atomic writer without its destructive copy fallback. Use a unique repair directory so later repairs cannot overwrite recovery copies. Preserve workspace aliases and modes and leave completed merges unchanged on subsequent Doctor runs. The 129-line test allocation covers failed publication, alias and mode preservation, and the backup collision/idempotency regression. Co-authored-by: Syxscott <[email protected]> Co-authored-by: steipete <[email protected]>
Keep the pre-merge canonical memory beside the legacy archive and publish through the existing atomic writer without its destructive copy fallback. Use a unique repair directory so later repairs cannot overwrite recovery copies. Preserve workspace aliases and modes and leave completed merges unchanged on subsequent Doctor runs. Adapt the regression fixtures to the stable branch while preserving its bounded-read and UTF-8 repairs. Inject torn direct writes for the real Doctor entry-point red proof; cover atomic publication failures, workspace aliases/modes, and unique backups/idempotency without a dependency change. Co-authored-by: Syxscott <[email protected]> Co-authored-by: steipete <[email protected]> (cherry picked from commit 1b92282) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit bf293d0942920e55eefb2a4b594d7397e9442e33)
Backport scoped #190497 from 1b92282. Co-authored-by: Syxscott <[email protected]> Co-authored-by: steipete <[email protected]> Co-authored-by: RomneyDa <[email protected]>
Related: #187291 by @syxscott.
What Problem This Solves
Doctor can truncate or tear
MEMORY.mdwhen a legacy root-memory merge write fails. The existing repair archives onlymemory.md, leaving the original canonical memory without a recovery copy.User Impact
Failed writes preserve the live canonical memory, and each merge keeps
MEMORY.md.pre-mergebeside the legacy archive. Earlier backups remain intact and a second Doctor run after a completed merge leaves the file unchanged. Workspace directory aliases and existing file/directory permissions remain supported.Why This Change Was Made
This takes over #187291 with Syxscott's atomic publication fix and one small correction: allocate a unique repair directory with
mkdtemp, because timestamp-only recursive mkdir can reuse a directory and overwrite its backups. Publication uses the existing atomic writer with the actual directory mode, preserved file mode, synced temporary file/parent, and its permission-error copy fallback disabled. Doctor documentation includes the backup location and recovery step.Syxscott is retained as the source commit author and co-author; Peter Steinberger receives the requested co-author credit. No new abstraction or compatibility path is introduced. Production source grows by 23 lines and tests by 129 lines; the separate test-line allocation covers publication failures, aliases/modes, and the backup collision/idempotency regression.
Evidence
doctor-workspace.test.ts,doctor-memory-recall.test.ts, anddoctor-memory-search.test.ts, with source hashes matching this commit. Command wall time 51.49 s including compilation (Vitest 46.20 s); workspace test bodies take under 0.2 s. This focused pre-PR proof uses the contributor checkout's frozen dependency set; exact-head PR CI supplies current-main dependency, lint, and type proof.git diff --checkpass. Local lint could not start without this worktree's dependencies; no local installation or broad suite was run.