fix: comment-only edits to different functions in same file no longer conflict (muse#92)
Root cause: content_id (symbol identity, muse/plugins/code/ast_parser.py) is computed via ast.unparse(), which strips comments by design -- this is intentional, documented behavior relied on broadly (diff/log/rename/ muse code stable), so it must not change. A trailing-comment-only edit is therefore AST-identical to base, build_diff_ops() finds no changed child_ops, and falls back to a whole-file ReplaceOp labeled "reformatted -- no semantic change" instead of a symbol-addressed PatchOp.
When two branches each comment a DIFFERENT function in the same file, merge_ops()'s Step 1.5 (independence-aware blob reconstruction) had no PatchOp on either side to compare, so it just `continue`d -- no reconstruction was attempted at all, and Step 2's coarse OT check flagged the two competing file-level ReplaceOps as a hard conflict even though the edits never overlap.
Fix has two parts, both in CodePlugin.merge_ops():
1. When symbol-level patch info isn't available for a candidate changed path, attempt a direct three-way LINE merge on the raw base/ours/ theirs blob bytes via cohen_transform.three_way_merge_lines() -- the same primitive _independence_merge_blob() already uses. This is unconditionally safe: a clean (non-overlapping) line-level merge is correct regardless of symbol knowledge or file type. Use the result only when the merge reports no conflict; any real overlap still falls through to the existing conflict path.
2. A second bug surfaced while verifying (1) live: Step 2's OT check independently re-flags the path as conflicting from the two file-level ReplaceOps, and conflict_addresses was never filtered against independence_resolved before Step 3 built the final conflict list -- so a path resolved cleanly by (1) still ended up in all_conflicts_final. Filter conflict_addresses against independence_resolved's keys immediately after Step 2.
Verified live via muse-dev against a disposable /tmp sandbox: two branches each add a trailing comment to a different function in calc.py; merge now reports status=merged with zero conflicts, and the committed file contains both comments.
New regression test (tests/test_comment_only_independence_merge.py) reproduces the exact scenario through the real CLI. Confirmed genuine RED (reverted the fix, test failed with the pre-fix conflict) before GREEN with the fix restored.
Targeted regression suite -- test_core_merge_engine, test_cmd_merge, test_code_harmony_plugin, test_phase1_merge_engine, test_phase5_phantom_guard, test_phase6_unified_merge_engine, test_op_merge, test_octopus_merge, test_harmony_merge_commit_integrity, test_code_plugin, test_code_plugin_attributes, test_phase2_or_set_symbol_independence, plus the new test -- all pass (636 passed, 19 skipped), zero regressions.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Semantic Changes
14 symbols
Files Changed
+1
~1
1215 in snapshot
0 comments
muse hub commit comment sha256:2084d8cc66f5923f35d286b4c8bc7217c01011a4d2690240b554ef18e99c9ab5 --body "your comment"
No comments yet. Be the first to start the discussion.