gabriel / muse public
fix BREAKING fix/92-comment-only-independence-merge #1 / 1
AI Agent gabriel · 1 day ago · Oct 21, 2026 · Diff

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]>

sha256:2084d8cc66f5923f35d286b4c8bc7217c01011a4d2690240b554ef18e99c9ab5 sha
+12 ~2 symbols
2 changed · 1215 in snapshot files
sha256:2fb1212037682156861e518bd23e566c37996a7012fbe8b475e09c3c4849fb44 snapshot
+12
symbols added
~2
symbols modified
2
files changed
1215
files in snapshot
0
dead code introduced
Semantic Changes 14 symbols
+ _ALICE_CALC variable variable _ALICE_CALC L59–65
+ _BASE_CALC variable variable _BASE_CALC L51–57
+ _BOB_CALC variable variable _BOB_CALC L67–73
+ _run function function _run L42–48
+ CliRunner import import CliRunner L37–37
+ InvokeResult import import InvokeResult L37–37
+ annotations import import annotations L31–31
+ json import import json L33–33
+ os import import os L34–34
+ pathlib import import pathlib L35–35
+ runner variable variable runner L39–39
+ test_trailing_comments_on_different_functions_merge_cleanly function function test_trailing_comments_on_different_functions_merge_cleanly L76–127
~ muse/plugins/code/plugin.py .py 2 symbols modified
Files Changed
+1 ~1
1215 in snapshot
← Older Oldest on fix/92-comment-only-independence-merge
All commits
Newer → Latest on fix/92-comment-only-independence-merge

0 comments

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

To add a comment, use the Muse CLI: muse hub commit comment sha256:2084d8cc66f5923f35d286b4c8bc7217c01011a4d2690240b554ef18e99c9ab5 --body "your comment"