{"abstract":"The reversed hunk shows new lines before old lines inside each change.","category":"Text diff and three-way merge","checks":8,"contract":"Reverse one unified hunk: swap the old and new ranges in the header, keeping each range's count omitted if it was omitted and keeping any trailing header text; swap \"-\" and \"+\" on body lines; within each run of changed lines emit the (new) removed lines before the (new) added lines; a \"\\\" marker line stays attached to the line it follows.","evaluation_group":"w2-text-diff-merge-patch-reversal","failed_approach":"Sorting the run by text interleaves removals and additions arbitrarily.","family":"w2-text-diff-merge-patch-reversal-block-order","id":"FA-75716","implementations":{"attempt":{"sha256":"d8ba69ef8d949f4682696e02b676d28c68f5833ac655f15d13d46bee94378b91","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport re\nN = 1\nobservations = []\ndef solve(lines):\n    m = re.match(r'@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(.*)$', lines[0])\n    a, an, c, cn, tail = m.groups()\n    def fmt(s, cnt):\n        return s if cnt is None else s + ',' + cnt\n    out = ['@@ -%s +%s @@%s' % (fmt(c, cn), fmt(a, an), tail)]\n    units = []\n    for ln in lines[1:]:\n        if ln.startswith('\\\\') and units:\n            units[-1].append(ln)\n        else:\n            units.append([ln])\n    dels, adds = [], []\n    def flush():\n        for u in sorted(dels + adds):\n            out.extend(u)\n        dels.clear()\n        adds.clear()\n    for u in units:\n        tag = u[0][:1]\n        if tag == '+':\n            dels.append(['-' + u[0][1:]] + u[1:])\n        elif tag == '-':\n            adds.append(['+' + u[0][1:]] + u[1:])\n        else:\n            flush()\n            out.extend(u)\n    flush()\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {\n    1: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,1 @@', '+n0']], ['@@ -1,1 +0,0 @@', '-n0']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,3 @@', ' u', '-v', ' w', '+x0']], ['@@ -7,3 +7,3 @@', ' u', '+v', ' w', '-x0'])],\n    2: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,2 @@', '+n0', '+n1']], ['@@ -1,2 +0,0 @@', '-n0', '-n1']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,4 @@', ' u', '-v', ' w', '+x0', '+x1']], ['@@ -7,4 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1'])],\n    3: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,3 @@', '+n0', '+n1', '+n2']], ['@@ -1,3 +0,0 @@', '-n0', '-n1', '-n2']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,5 @@', ' u', '-v', ' w', '+x0', '+x1', '+x2']], ['@@ -7,5 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1', '-x2'])],\n    4: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,4 @@', '+n0', '+n1', '+n2', '+n3']], ['@@ -1,4 +0,0 @@', '-n0', '-n1', '-n2', '-n3']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,6 @@', ' u', '-v', ' w', '+x0', '+x1', '+x2', '+x3']], ['@@ -7,6 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1', '-x2', '-x3'])],\n    5: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,5 @@', '+n0', '+n1', '+n2', '+n3', '+n4']], ['@@ -1,5 +0,0 @@', '-n0', '-n1', '-n2', '-n3', '-n4']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,7 @@', ' u', '-v', ' w', '+x0', '+x1', '+x2', '+x3', '+x4']], ['@@ -7,7 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1', '-x2', '-x3', '-x4'])],\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":"4ee9ec1b6a0254a91c6fe1e9d764d692fbfee9c1e16da655053aab807ef13df7","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport re\nN = 1\nobservations = []\ndef solve(lines):\n    m = re.match(r'@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(.*)$', lines[0])\n    a, an, c, cn, tail = m.groups()\n    def fmt(s, cnt):\n        return s if cnt is None else s + ',' + cnt\n    out = ['@@ -%s +%s @@%s' % (fmt(c, cn), fmt(a, an), tail)]\n    units = []\n    for ln in lines[1:]:\n        if ln.startswith('\\\\') and units:\n            units[-1].append(ln)\n        else:\n            units.append([ln])\n    dels, adds = [], []\n    def flush():\n        for u in adds + dels:\n            out.extend(u)\n        dels.clear()\n        adds.clear()\n    for u in units:\n        tag = u[0][:1]\n        if tag == '+':\n            dels.append(['-' + u[0][1:]] + u[1:])\n        elif tag == '-':\n            adds.append(['+' + u[0][1:]] + u[1:])\n        else:\n            flush()\n            out.extend(u)\n    flush()\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {\n    1: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,1 @@', '+n0']], ['@@ -1,1 +0,0 @@', '-n0']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,3 @@', ' u', '-v', ' w', '+x0']], ['@@ -7,3 +7,3 @@', ' u', '+v', ' w', '-x0'])],\n    2: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,2 @@', '+n0', '+n1']], ['@@ -1,2 +0,0 @@', '-n0', '-n1']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,4 @@', ' u', '-v', ' w', '+x0', '+x1']], ['@@ -7,4 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1'])],\n    3: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,3 @@', '+n0', '+n1', '+n2']], ['@@ -1,3 +0,0 @@', '-n0', '-n1', '-n2']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,5 @@', ' u', '-v', ' w', '+x0', '+x1', '+x2']], ['@@ -7,5 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1', '-x2'])],\n    4: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,4 @@', '+n0', '+n1', '+n2', '+n3']], ['@@ -1,4 +0,0 @@', '-n0', '-n1', '-n2', '-n3']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,6 @@', ' u', '-v', ' w', '+x0', '+x1', '+x2', '+x3']], ['@@ -7,6 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1', '-x2', '-x3'])],\n    5: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,5 @@', '+n0', '+n1', '+n2', '+n3', '+n4']], ['@@ -1,5 +0,0 @@', '-n0', '-n1', '-n2', '-n3', '-n4']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,7 @@', ' u', '-v', ' w', '+x0', '+x1', '+x2', '+x3', '+x4']], ['@@ -7,7 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1', '-x2', '-x3', '-x4'])],\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"},"fixed":{"sha256":"60005a6c39c3bb955d488ae11ca4bc7ac154f68e83ecf2270785580f27d1e4a7","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport re\nN = 1\nobservations = []\ndef solve(lines):\n    m = re.match(r'@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@(.*)$', lines[0])\n    a, an, c, cn, tail = m.groups()\n    def fmt(s, cnt):\n        return s if cnt is None else s + ',' + cnt\n    out = ['@@ -%s +%s @@%s' % (fmt(c, cn), fmt(a, an), tail)]\n    units = []\n    for ln in lines[1:]:\n        if ln.startswith('\\\\') and units:\n            units[-1].append(ln)\n        else:\n            units.append([ln])\n    dels, adds = [], []\n    def flush():\n        for u in dels + adds:\n            out.extend(u)\n        dels.clear()\n        adds.clear()\n    for u in units:\n        tag = u[0][:1]\n        if tag == '+':\n            dels.append(['-' + u[0][1:]] + u[1:])\n        elif tag == '-':\n            adds.append(['+' + u[0][1:]] + u[1:])\n        else:\n            flush()\n            out.extend(u)\n    flush()\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {\n    1: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,1 @@', '+n0']], ['@@ -1,1 +0,0 @@', '-n0']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,3 @@', ' u', '-v', ' w', '+x0']], ['@@ -7,3 +7,3 @@', ' u', '+v', ' w', '-x0'])],\n    2: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,2 @@', '+n0', '+n1']], ['@@ -1,2 +0,0 @@', '-n0', '-n1']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,4 @@', ' u', '-v', ' w', '+x0', '+x1']], ['@@ -7,4 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1'])],\n    3: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,3 @@', '+n0', '+n1', '+n2']], ['@@ -1,3 +0,0 @@', '-n0', '-n1', '-n2']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,5 @@', ' u', '-v', ' w', '+x0', '+x1', '+x2']], ['@@ -7,5 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1', '-x2'])],\n    4: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,4 @@', '+n0', '+n1', '+n2', '+n3']], ['@@ -1,4 +0,0 @@', '-n0', '-n1', '-n2', '-n3']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,6 @@', ' u', '-v', ' w', '+x0', '+x1', '+x2', '+x3']], ['@@ -7,6 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1', '-x2', '-x3'])],\n    5: [('replacement block', [['@@ -3,2 +3,2 @@ def f():', ' a', '-b', '+B', ' c']], ['@@ -3,2 +3,2 @@ def f():', ' a', '-B', '+b', ' c']), ('omitted counts stay omitted', [['@@ -5 +5 @@', '-x', '+y']], ['@@ -5 +5 @@', '-y', '+x']), ('explicit zero count', [['@@ -0,0 +1,5 @@', '+n0', '+n1', '+n2', '+n3', '+n4']], ['@@ -1,5 +0,0 @@', '-n0', '-n1', '-n2', '-n3', '-n4']), ('no-newline marker follows its line', [['@@ -1,2 +1,2 @@', ' k', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], ['@@ -1,2 +1,2 @@', ' k', '-new', '\\\\ No newline at end of file', '+old', '\\\\ No newline at end of file']), ('several blocks', [['@@ -1,6 +1,5 @@', '-a', ' b', '+c', '+d', ' e', '-f', '-g', '+h', ' i']], ['@@ -1,5 +1,6 @@', '+a', ' b', '-c', '-d', ' e', '-h', '+f', '+g', ' i']), ('insertion only', [['@@ -2,1 +2,3 @@', ' p', '+q', '+r']], ['@@ -2,3 +2,1 @@', ' p', '-q', '-r']), ('marker after the new side only', [['@@ -4,1 +4,1 @@', '-z', '+z2', '\\\\ No newline at end of file']], ['@@ -4,1 +4,1 @@', '-z2', '\\\\ No newline at end of file', '+z']), ('header without trailing text', [['@@ -7,3 +7,7 @@', ' u', '-v', ' w', '+x0', '+x1', '+x2', '+x3', '+x4']], ['@@ -7,7 +7,3 @@', ' u', '+v', ' w', '-x0', '-x1', '-x2', '-x3', '-x4'])],\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-patch-reversal-block-order","generated_at":"2026-09-29T14:49:09.568715+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Reverting a change applies the reversed patch, which must still be a valid, conventionally ordered hunk.","repair":"Within each run, write removed lines first, then added lines.","root_cause":"The flush writes the added lines before the removed lines.","sha256":"f06e9d76c8312c204f0f986bf594880e2f71ab12e5323442f45270df6981433c","title":"Patch reversal: reversed blocks list additions before removals · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.341,"exit_code":1,"observations":[{"actual":["@@ -3,2 +3,2 @@ def f():"," a","+b","-B"," c"],"check":"replacement block","expected":["@@ -3,2 +3,2 @@ def f():"," a","-B","+b"," c"],"passed":false},{"actual":["@@ -5 +5 @@","+x","-y"],"check":"omitted counts stay omitted","expected":["@@ -5 +5 @@","-y","+x"],"passed":false},{"actual":["@@ -1,1 +0,0 @@","-n0"],"check":"explicit zero count","expected":["@@ -1,1 +0,0 @@","-n0"],"passed":true},{"actual":["@@ -1,2 +1,2 @@"," k","+old","\\ No newline at end of file","-new","\\ No newline at end of file"],"check":"no-newline marker follows its line","expected":["@@ -1,2 +1,2 @@"," k","-new","\\ No newline at end of file","+old","\\ No newline at end of file"],"passed":false},{"actual":["@@ -1,5 +1,6 @@","+a"," b","-c","-d"," e","+f","+g","-h"," i"],"check":"several blocks","expected":["@@ -1,5 +1,6 @@","+a"," b","-c","-d"," e","-h","+f","+g"," i"],"passed":false},{"actual":["@@ -2,3 +2,1 @@"," p","-q","-r"],"check":"insertion only","expected":["@@ -2,3 +2,1 @@"," p","-q","-r"],"passed":true},{"actual":["@@ -4,1 +4,1 @@","+z","-z2","\\ No newline at end of file"],"check":"marker after the new side only","expected":["@@ -4,1 +4,1 @@","-z2","\\ No newline at end of file","+z"],"passed":false},{"actual":["@@ -7,3 +7,3 @@"," u","+v"," w","-x0"],"check":"header without trailing text","expected":["@@ -7,3 +7,3 @@"," u","+v"," w","-x0"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"replacement block\", \"actual\": [\"@@ -3,2 +3,2 @@ def f():\", \" a\", \"+b\", \"-B\", \" c\"], \"expected\": [\"@@ -3,2 +3,2 @@ def f():\", \" a\", \"-B\", \"+b\", \" c\"], \"passed\": false}, {\"check\": \"omitted counts stay omitted\", \"actual\": [\"@@ -5 +5 @@\", \"+x\", \"-y\"], \"expected\": [\"@@ -5 +5 @@\", \"-y\", \"+x\"], \"passed\": false}, {\"check\": \"explicit zero count\", \"actual\": [\"@@ -1,1 +0,0 @@\", \"-n0\"], \"expected\": [\"@@ -1,1 +0,0 @@\", \"-n0\"], \"passed\": true}, {\"check\": \"no-newline marker follows its line\", \"actual\": [\"@@ -1,2 +1,2 @@\", \" k\", \"+old\", \"\\\\ No newline at end of file\", \"-new\", \"\\\\ No newline at end of file\"], \"expected\": [\"@@ -1,2 +1,2 @@\", \" k\", \"-new\", \"\\\\ No newline at end of file\", \"+old\", \"\\\\ No newline at end of file\"], \"passed\": false}, {\"check\": \"several blocks\", \"actual\": [\"@@ -1,5 +1,6 @@\", \"+a\", \" b\", \"-c\", \"-d\", \" e\", \"+f\", \"+g\", \"-h\", \" i\"], \"expected\": [\"@@ -1,5 +1,6 @@\", \"+a\", \" b\", \"-c\", \"-d\", \" e\", \"-h\", \"+f\", \"+g\", \" i\"], \"passed\": false}, {\"check\": \"insertion only\", \"actual\": [\"@@ -2,3 +2,1 @@\", \" p\", \"-q\", \"-r\"], \"expected\": [\"@@ -2,3 +2,1 @@\", \" p\", \"-q\", \"-r\"], \"passed\": true}, {\"check\": \"marker after the new side only\", \"actual\": [\"@@ -4,1 +4,1 @@\", \"+z\", \"-z2\", \"\\\\ No newline at end of file\"], \"expected\": [\"@@ -4,1 +4,1 @@\", \"-z2\", \"\\\\ No newline at end of file\", \"+z\"], \"passed\": false}, {\"check\": \"header without trailing text\", \"actual\": [\"@@ -7,3 +7,3 @@\", \" u\", \"+v\", \" w\", \"-x0\"], \"expected\": [\"@@ -7,3 +7,3 @@\", \" u\", \"+v\", \" w\", \"-x0\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.808,"exit_code":1,"observations":[{"actual":["@@ -3,2 +3,2 @@ def f():"," a","+b","-B"," c"],"check":"replacement block","expected":["@@ -3,2 +3,2 @@ def f():"," a","-B","+b"," c"],"passed":false},{"actual":["@@ -5 +5 @@","+x","-y"],"check":"omitted counts stay omitted","expected":["@@ -5 +5 @@","-y","+x"],"passed":false},{"actual":["@@ -1,1 +0,0 @@","-n0"],"check":"explicit zero count","expected":["@@ -1,1 +0,0 @@","-n0"],"passed":true},{"actual":["@@ -1,2 +1,2 @@"," k","+old","\\ No newline at end of file","-new","\\ No newline at end of file"],"check":"no-newline marker follows its line","expected":["@@ -1,2 +1,2 @@"," k","-new","\\ No newline at end of file","+old","\\ No newline at end of file"],"passed":false},{"actual":["@@ -1,5 +1,6 @@","+a"," b","-c","-d"," e","+f","+g","-h"," i"],"check":"several blocks","expected":["@@ -1,5 +1,6 @@","+a"," b","-c","-d"," e","-h","+f","+g"," i"],"passed":false},{"actual":["@@ -2,3 +2,1 @@"," p","-q","-r"],"check":"insertion only","expected":["@@ -2,3 +2,1 @@"," p","-q","-r"],"passed":true},{"actual":["@@ -4,1 +4,1 @@","+z","-z2","\\ No newline at end of file"],"check":"marker after the new side only","expected":["@@ -4,1 +4,1 @@","-z2","\\ No newline at end of file","+z"],"passed":false},{"actual":["@@ -7,3 +7,3 @@"," u","+v"," w","-x0"],"check":"header without trailing text","expected":["@@ -7,3 +7,3 @@"," u","+v"," w","-x0"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"replacement block\", \"actual\": [\"@@ -3,2 +3,2 @@ def f():\", \" a\", \"+b\", \"-B\", \" c\"], \"expected\": [\"@@ -3,2 +3,2 @@ def f():\", \" a\", \"-B\", \"+b\", \" c\"], \"passed\": false}, {\"check\": \"omitted counts stay omitted\", \"actual\": [\"@@ -5 +5 @@\", \"+x\", \"-y\"], \"expected\": [\"@@ -5 +5 @@\", \"-y\", \"+x\"], \"passed\": false}, {\"check\": \"explicit zero count\", \"actual\": [\"@@ -1,1 +0,0 @@\", \"-n0\"], \"expected\": [\"@@ -1,1 +0,0 @@\", \"-n0\"], \"passed\": true}, {\"check\": \"no-newline marker follows its line\", \"actual\": [\"@@ -1,2 +1,2 @@\", \" k\", \"+old\", \"\\\\ No newline at end of file\", \"-new\", \"\\\\ No newline at end of file\"], \"expected\": [\"@@ -1,2 +1,2 @@\", \" k\", \"-new\", \"\\\\ No newline at end of file\", \"+old\", \"\\\\ No newline at end of file\"], \"passed\": false}, {\"check\": \"several blocks\", \"actual\": [\"@@ -1,5 +1,6 @@\", \"+a\", \" b\", \"-c\", \"-d\", \" e\", \"+f\", \"+g\", \"-h\", \" i\"], \"expected\": [\"@@ -1,5 +1,6 @@\", \"+a\", \" b\", \"-c\", \"-d\", \" e\", \"-h\", \"+f\", \"+g\", \" i\"], \"passed\": false}, {\"check\": \"insertion only\", \"actual\": [\"@@ -2,3 +2,1 @@\", \" p\", \"-q\", \"-r\"], \"expected\": [\"@@ -2,3 +2,1 @@\", \" p\", \"-q\", \"-r\"], \"passed\": true}, {\"check\": \"marker after the new side only\", \"actual\": [\"@@ -4,1 +4,1 @@\", \"+z\", \"-z2\", \"\\\\ No newline at end of file\"], \"expected\": [\"@@ -4,1 +4,1 @@\", \"-z2\", \"\\\\ No newline at end of file\", \"+z\"], \"passed\": false}, {\"check\": \"header without trailing text\", \"actual\": [\"@@ -7,3 +7,3 @@\", \" u\", \"+v\", \" w\", \"-x0\"], \"expected\": [\"@@ -7,3 +7,3 @@\", \" u\", \"+v\", \" w\", \"-x0\"], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":40.275,"exit_code":0,"observations":[{"actual":["@@ -3,2 +3,2 @@ def f():"," a","-B","+b"," c"],"check":"replacement block","expected":["@@ -3,2 +3,2 @@ def f():"," a","-B","+b"," c"],"passed":true},{"actual":["@@ -5 +5 @@","-y","+x"],"check":"omitted counts stay omitted","expected":["@@ -5 +5 @@","-y","+x"],"passed":true},{"actual":["@@ -1,1 +0,0 @@","-n0"],"check":"explicit zero count","expected":["@@ -1,1 +0,0 @@","-n0"],"passed":true},{"actual":["@@ -1,2 +1,2 @@"," k","-new","\\ No newline at end of file","+old","\\ No newline at end of file"],"check":"no-newline marker follows its line","expected":["@@ -1,2 +1,2 @@"," k","-new","\\ No newline at end of file","+old","\\ No newline at end of file"],"passed":true},{"actual":["@@ -1,5 +1,6 @@","+a"," b","-c","-d"," e","-h","+f","+g"," i"],"check":"several blocks","expected":["@@ -1,5 +1,6 @@","+a"," b","-c","-d"," e","-h","+f","+g"," i"],"passed":true},{"actual":["@@ -2,3 +2,1 @@"," p","-q","-r"],"check":"insertion only","expected":["@@ -2,3 +2,1 @@"," p","-q","-r"],"passed":true},{"actual":["@@ -4,1 +4,1 @@","-z2","\\ No newline at end of file","+z"],"check":"marker after the new side only","expected":["@@ -4,1 +4,1 @@","-z2","\\ No newline at end of file","+z"],"passed":true},{"actual":["@@ -7,3 +7,3 @@"," u","+v"," w","-x0"],"check":"header without trailing text","expected":["@@ -7,3 +7,3 @@"," u","+v"," w","-x0"],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"replacement block\", \"actual\": [\"@@ -3,2 +3,2 @@ def f():\", \" a\", \"-B\", \"+b\", \" c\"], \"expected\": [\"@@ -3,2 +3,2 @@ def f():\", \" a\", \"-B\", \"+b\", \" c\"], \"passed\": true}, {\"check\": \"omitted counts stay omitted\", \"actual\": [\"@@ -5 +5 @@\", \"-y\", \"+x\"], \"expected\": [\"@@ -5 +5 @@\", \"-y\", \"+x\"], \"passed\": true}, {\"check\": \"explicit zero count\", \"actual\": [\"@@ -1,1 +0,0 @@\", \"-n0\"], \"expected\": [\"@@ -1,1 +0,0 @@\", \"-n0\"], \"passed\": true}, {\"check\": \"no-newline marker follows its line\", \"actual\": [\"@@ -1,2 +1,2 @@\", \" k\", \"-new\", \"\\\\ No newline at end of file\", \"+old\", \"\\\\ No newline at end of file\"], \"expected\": [\"@@ -1,2 +1,2 @@\", \" k\", \"-new\", \"\\\\ No newline at end of file\", \"+old\", \"\\\\ No newline at end of file\"], \"passed\": true}, {\"check\": \"several blocks\", \"actual\": [\"@@ -1,5 +1,6 @@\", \"+a\", \" b\", \"-c\", \"-d\", \" e\", \"-h\", \"+f\", \"+g\", \" i\"], \"expected\": [\"@@ -1,5 +1,6 @@\", \"+a\", \" b\", \"-c\", \"-d\", \" e\", \"-h\", \"+f\", \"+g\", \" i\"], \"passed\": true}, {\"check\": \"insertion only\", \"actual\": [\"@@ -2,3 +2,1 @@\", \" p\", \"-q\", \"-r\"], \"expected\": [\"@@ -2,3 +2,1 @@\", \" p\", \"-q\", \"-r\"], \"passed\": true}, {\"check\": \"marker after the new side only\", \"actual\": [\"@@ -4,1 +4,1 @@\", \"-z2\", \"\\\\ No newline at end of file\", \"+z\"], \"expected\": [\"@@ -4,1 +4,1 @@\", \"-z2\", \"\\\\ No newline at end of file\", \"+z\"], \"passed\": true}, {\"check\": \"header without trailing text\", \"actual\": [\"@@ -7,3 +7,3 @@\", \" u\", \"+v\", \" w\", \"-x0\"], \"expected\": [\"@@ -7,3 +7,3 @@\", \" u\", \"+v\", \" w\", \"-x0\"], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}