extradoc: keep exact-text pre-pins immovable in table-flank pinning - #77
Open
cassus wants to merge 1 commit into
Open
extradoc: keep exact-text pre-pins immovable in table-flank pinning#77cassus wants to merge 1 commit into
cassus wants to merge 1 commit into
Conversation
_pin_table_flanks rebuilt its anchor set from matched-table ±1 flanks with no awareness of the exact-text / API-uncreatable pre-pins established by _pre_pin_stable_anchors. When a table's neighbour shifts (e.g. a new heading inserted adjacent to the table), a flank pin could land on a base index already pinned by an unambiguous exact-text match elsewhere and clobber it: the original heading got word-diffed into the new adjacent one and the real match re-inserted as a duplicate downstream. Thread pre_pins into _pin_table_flanks and seed them into the anchor set at top priority; the existing conflict-resolution loop only ever drops a contributing table pair, never a pre-pin. Two prior tests asserted the old flank-override behaviour and are updated to the correct exact-text match; adds a regression test for the clobber case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #75.
What
_pin_table_flanks(diffmerge/content_align.py) rebuilds its anchor set fromeach matched table's ±1 flanking positions with no awareness of the exact-text
pre-pins already established by
_pre_pin_stable_anchors. A pre-pin is aproven unique correspondence; a flank pin is only a heuristic. When a table's
neighbour shifts (e.g. a new heading inserted adjacent to the table), a flank
pin can land on a
baseindex already held by a correct exact-text pre-pin andsilently overwrite it — so a low-confidence heuristic overrides a
high-confidence anchor, and the displaced paragraph gets duplicated/garbled.
See #75 for the full root-cause and the
align_content()pipeline ordering.Changes
diffmerge/content_align.py— threadpre_pinsinto_pin_table_flanksandseed them into the anchor set at top priority; the existing conflict-
resolution loop now only ever drops a flank pin, never a pre-pin.
tests/diffmerge/test_table_flank_pinning.py— two prior tests that assertedthe old flank-override behaviour updated to the correct exact-text match;
adds
test_flank_pin_never_overrides_exact_text_pre_pin(fails before thefix, passes after).
Verification
duplicate, mangled into the new heading's text, with spurious deletes; fix
restored → heading untouched, no spurious deletes.
verify_accepted.py: 227/227 paragraphs clean on twoindependent copies.