{"abstract":"A line duplicated in the new file anchors to its last copy and misaligns the diff.","category":"Text diff and three-way merge","checks":8,"contract":"Candidates are lines occurring exactly once in the old side and exactly once in the new side, as (old index, new index) pairs in old order. Keep the longest chain with increasing new index, found with patience piles (bisect on pile tops by new index, back pointers to the previous pile top) and reconstructed from the top of the last pile. Return the anchor pairs.","contract_signature":"a, b","evaluation_group":"w2-text-diff-merge-patience-anchors","failed_approach":"Requiring uniqueness only in the new side admits lines repeated in the old side.","family":"w2-text-diff-merge-patience-anchors-uniqueness-both-sides","id":"FA-75506","implementations":{"attempt":{"sha256":"d4c8255e277d46b105f5bebdf23e715b42e4d570f7b27d5caae2d309a041bff6","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport bisect\nimport collections\nN = 1\nobservations = []\ndef solve(a, b):\n    ca = collections.Counter(a)\n    cb = collections.Counter(b)\n    posb = {x: j for j, x in enumerate(b)}\n    cand = [(i, posb[x]) for i, x in enumerate(a) if cb.get(x, 0) == 1]\n    tails = []\n    back = {}\n    for idx, (i, j) in enumerate(cand):\n        lo = bisect.bisect_left([cand[t][1] for t in tails], j)\n        if lo == len(tails):\n            tails.append(idx)\n        else:\n            tails[lo] = idx\n        back[idx] = tails[lo - 1] if lo > 0 else None\n    res = []\n    t = tails[-1] if tails else None\n    while t is not None:\n        res.append(list(cand[t]))\n        t = back[t]\n    return res[::-1]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {\n    1: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['v', 'w', 'p', 'u']], [[1, 0], [2, 1], [3, 2]]), ('later short chain', [['m0', 'm1', 'm2', 'k'], ['k', 'm0', 'm1', 'm2']], [[0, 1], [1, 2], [2, 3]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n    2: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['u', 'v', 'w', 'p']], [[0, 0], [1, 1], [2, 2], [3, 3]]), ('later short chain', [['m0', 'm1', 'm2', 'm3', 'k'], ['k', 'm0', 'm1', 'm2', 'm3']], [[0, 1], [1, 2], [2, 3], [3, 4]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n    3: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['v', 'w', 'p', 'u']], [[1, 0], [2, 1], [3, 2]]), ('later short chain', [['m0', 'm1', 'm2', 'm3', 'm4', 'k'], ['k', 'm0', 'm1', 'm2', 'm3', 'm4']], [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n    4: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['u', 'v', 'w', 'p']], [[0, 0], [1, 1], [2, 2], [3, 3]]), ('later short chain', [['m0', 'm1', 'm2', 'm3', 'm4', 'm5', 'k'], ['k', 'm0', 'm1', 'm2', 'm3', 'm4', 'm5']], [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n    5: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['v', 'w', 'p', 'u']], [[1, 0], [2, 1], [3, 2]]), ('later short chain', [['m0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'k'], ['k', 'm0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6']], [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n}[N]\nfor label, args, expected in cases:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"71ccc77f62652bcac3468b7915523534b824c82a8b62791a032a2402e70d8ccf","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport bisect\nimport collections\nN = 1\nobservations = []\ndef solve(a, b):\n    ca = collections.Counter(a)\n    cb = collections.Counter(b)\n    posb = {x: j for j, x in enumerate(b)}\n    cand = [(i, posb[x]) for i, x in enumerate(a) if ca[x] == 1 and x in cb]\n    tails = []\n    back = {}\n    for idx, (i, j) in enumerate(cand):\n        lo = bisect.bisect_left([cand[t][1] for t in tails], j)\n        if lo == len(tails):\n            tails.append(idx)\n        else:\n            tails[lo] = idx\n        back[idx] = tails[lo - 1] if lo > 0 else None\n    res = []\n    t = tails[-1] if tails else None\n    while t is not None:\n        res.append(list(cand[t]))\n        t = back[t]\n    return res[::-1]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {\n    1: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['v', 'w', 'p', 'u']], [[1, 0], [2, 1], [3, 2]]), ('later short chain', [['m0', 'm1', 'm2', 'k'], ['k', 'm0', 'm1', 'm2']], [[0, 1], [1, 2], [2, 3]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n    2: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['u', 'v', 'w', 'p']], [[0, 0], [1, 1], [2, 2], [3, 3]]), ('later short chain', [['m0', 'm1', 'm2', 'm3', 'k'], ['k', 'm0', 'm1', 'm2', 'm3']], [[0, 1], [1, 2], [2, 3], [3, 4]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n    3: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['v', 'w', 'p', 'u']], [[1, 0], [2, 1], [3, 2]]), ('later short chain', [['m0', 'm1', 'm2', 'm3', 'm4', 'k'], ['k', 'm0', 'm1', 'm2', 'm3', 'm4']], [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n    4: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['u', 'v', 'w', 'p']], [[0, 0], [1, 1], [2, 2], [3, 3]]), ('later short chain', [['m0', 'm1', 'm2', 'm3', 'm4', 'm5', 'k'], ['k', 'm0', 'm1', 'm2', 'm3', 'm4', 'm5']], [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n    5: [('unique lines in order', [['a', 'b', 'c', 'd'], ['a', 'x', 'c', 'd']], [[0, 0], [2, 2], [3, 3]]), ('crossing unique lines keep the longest chain', [['f1', 'f2', 'f3', 'g'], ['f2', 'f3', 'f1', 'g']], [[1, 0], [2, 1], [3, 3]]), ('duplicated in new side are not anchors', [['x', 'y', 'z'], ['y', 'x', 'y', 'z']], [[0, 1], [2, 3]]), ('duplicated in old side are not anchors', [['}', 'a', '}', 'b'], ['}', 'b', 'a']], [[3, 1]]), ('no unique common lines', [['r', 'r'], ['s', 's']], []), ('chain ends before the last candidate', [['u', 'v', 'w', 'p'], ['v', 'w', 'p', 'u']], [[1, 0], [2, 1], [3, 2]]), ('later short chain', [['m0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'k'], ['k', 'm0', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6']], [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]), ('single candidate', [['q', 'z'], ['z', 'q', 'q']], [[1, 0]])],\n}[N]\nfor label, args, expected in cases:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"A deterministic, bounded teaching model of one diff, patch or merge rule with stipulated conventions; it is not a production diff or version-control implementation and makes no claim of conformance to any specific tool. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-text-diff-merge-patience-anchors-uniqueness-both-sides","generated_at":"2026-09-29T14:49:07.358301+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Patience diff anchors on unique lines to produce readable diffs of code with many repeated braces and blank lines.","root_cause":"Candidates require uniqueness only in the old side.","sha256":"46f9080a3590a55cce22ce76d89081d3b3fcae7293561875ae6feab97a36a235","title":"Patience diff anchors: lines repeated in the new side become anchors · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":47.015,"exit_code":1,"observations":[{"actual":[[0,0],[2,2],[3,3]],"check":"unique lines in order","expected":[[0,0],[2,2],[3,3]],"passed":true},{"actual":[[1,0],[2,1],[3,3]],"check":"crossing unique lines keep the longest chain","expected":[[1,0],[2,1],[3,3]],"passed":true},{"actual":[[0,1],[2,3]],"check":"duplicated in new side are not anchors","expected":[[0,1],[2,3]],"passed":true},{"actual":[[2,0],[3,1]],"check":"duplicated in old side are not anchors","expected":[[3,1]],"passed":false},{"actual":[],"check":"no unique common lines","expected":[],"passed":true},{"actual":[[1,0],[2,1],[3,2]],"check":"chain ends before the last candidate","expected":[[1,0],[2,1],[3,2]],"passed":true},{"actual":[[0,1],[1,2],[2,3]],"check":"later short chain","expected":[[0,1],[1,2],[2,3]],"passed":true},{"actual":[[1,0]],"check":"single candidate","expected":[[1,0]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"unique lines in order\", \"actual\": [[0, 0], [2, 2], [3, 3]], \"expected\": [[0, 0], [2, 2], [3, 3]], \"passed\": true}, {\"check\": \"crossing unique lines keep the longest chain\", \"actual\": [[1, 0], [2, 1], [3, 3]], \"expected\": [[1, 0], [2, 1], [3, 3]], \"passed\": true}, {\"check\": \"duplicated in new side are not anchors\", \"actual\": [[0, 1], [2, 3]], \"expected\": [[0, 1], [2, 3]], \"passed\": true}, {\"check\": \"duplicated in old side are not anchors\", \"actual\": [[2, 0], [3, 1]], \"expected\": [[3, 1]], \"passed\": false}, {\"check\": \"no unique common lines\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"chain ends before the last candidate\", \"actual\": [[1, 0], [2, 1], [3, 2]], \"expected\": [[1, 0], [2, 1], [3, 2]], \"passed\": true}, {\"check\": \"later short chain\", \"actual\": [[0, 1], [1, 2], [2, 3]], \"expected\": [[0, 1], [1, 2], [2, 3]], \"passed\": true}, {\"check\": \"single candidate\", \"actual\": [[1, 0]], \"expected\": [[1, 0]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.943,"exit_code":1,"observations":[{"actual":[[0,0],[2,2],[3,3]],"check":"unique lines in order","expected":[[0,0],[2,2],[3,3]],"passed":true},{"actual":[[1,0],[2,1],[3,3]],"check":"crossing unique lines keep the longest chain","expected":[[1,0],[2,1],[3,3]],"passed":true},{"actual":[[0,1],[1,2],[2,3]],"check":"duplicated in new side are not anchors","expected":[[0,1],[2,3]],"passed":false},{"actual":[[3,1]],"check":"duplicated in old side are not anchors","expected":[[3,1]],"passed":true},{"actual":[],"check":"no unique common lines","expected":[],"passed":true},{"actual":[[1,0],[2,1],[3,2]],"check":"chain ends before the last candidate","expected":[[1,0],[2,1],[3,2]],"passed":true},{"actual":[[0,1],[1,2],[2,3]],"check":"later short chain","expected":[[0,1],[1,2],[2,3]],"passed":true},{"actual":[[1,0]],"check":"single candidate","expected":[[1,0]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"unique lines in order\", \"actual\": [[0, 0], [2, 2], [3, 3]], \"expected\": [[0, 0], [2, 2], [3, 3]], \"passed\": true}, {\"check\": \"crossing unique lines keep the longest chain\", \"actual\": [[1, 0], [2, 1], [3, 3]], \"expected\": [[1, 0], [2, 1], [3, 3]], \"passed\": true}, {\"check\": \"duplicated in new side are not anchors\", \"actual\": [[0, 1], [1, 2], [2, 3]], \"expected\": [[0, 1], [2, 3]], \"passed\": false}, {\"check\": \"duplicated in old side are not anchors\", \"actual\": [[3, 1]], \"expected\": [[3, 1]], \"passed\": true}, {\"check\": \"no unique common lines\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"chain ends before the last candidate\", \"actual\": [[1, 0], [2, 1], [3, 2]], \"expected\": [[1, 0], [2, 1], [3, 2]], \"passed\": true}, {\"check\": \"later short chain\", \"actual\": [[0, 1], [1, 2], [2, 3]], \"expected\": [[0, 1], [1, 2], [2, 3]], \"passed\": true}, {\"check\": \"single candidate\", \"actual\": [[1, 0]], \"expected\": [[1, 0]], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}