gabriel / muse public
fix main #69 / 100

fix: detect file-level move+edit as a single PatchOp

When a file is renamed *and* its content changes simultaneously, the diff engine previously emitted a disconnected all-delete PatchOp for the old path and an all-insert PatchOp for the new path — losing the relationship between them entirely.

The fix adds `_detect_file_move_edits` in `symbol_diff.py` which scores (removed_path, added_path) pairs by body_hash overlap and greedily collapses those with ≥50% overlap into a single `PatchOp` carrying `from_address` (old path) and `address` (new path), with `child_ops` being the actual symbol diff between the two trees.

`PatchOp` in `domain.py` gains `from_address: NotRequired[DomainAddress]` to carry this metadata cleanly without a new op type.

`diff.py` detects `from_address` and renders the file header in cyan as `R old_path → new_path`, matching the existing colour semantics (cyan = same content, different location — now extended to same-origin, different content+location).

Three regression tests in `TestFileMoveAndEdit` cover: collapse to single PatchOp, correct child op types, and no false positives for unrelated files.

G Gabriel Cardona <gabriel@tellurstori.com> · 3d ago Mar 21, 2026 · 1afd410c · parent 589ae017
4
files changed
343
files in snapshot

0 comments

No comments yet. Be the first to start the discussion.