{"abstract":"Patches touching a last line without newline are reported as truncated.","category":"Text diff and three-way merge","checks":8,"contract":"Parse \"@@ -a[,b] +c[,d] @@\" hunks (omitted counts are 1) and consume body lines until both remaining counts reach zero: \" \" (or a completely empty line) counts for both sides, \"-\" for old, \"+\" for new, \"\\\\\" marker lines are skipped and not counted, anything else ends the body. Remaining counts other than zero yield {\"error\": \"hunk k truncated\"}. Return [a, b, c, d, body_lines] per hunk.","evaluation_group":"w2-text-diff-merge-unified-hunk-parser","failed_approach":"Skipping markers but counting them in the body length misreports the hunk size.","family":"w2-text-diff-merge-unified-hunk-parser-marker-lines","id":"FA-75751","implementations":{"attempt":{"sha256":"b06d8855db56c5f90895db189af3ba172cab6227d76cd1759f04ef56527f4d7c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport re\nN = 1\nobservations = []\ndef solve(lines):\n    hdr = re.compile(r'^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@')\n    hunks = []\n    i = 0\n    while i < len(lines):\n        m = hdr.match(lines[i])\n        if not m:\n            i += 1\n            continue\n        os_ = int(m.group(1))\n        ol = int(m.group(2)) if m.group(2) is not None else 1\n        ns = int(m.group(3))\n        nl = int(m.group(4)) if m.group(4) is not None else 1\n        need_o, need_n, body = ol, nl, 0\n        i += 1\n        while (need_o > 0 or need_n > 0) and i < len(lines):\n            ln = lines[i]\n            if ln.startswith('\\\\'):\n                i += 1\n                body += 1\n                continue\n            t = ln[:1] if ln else ' '\n            if t == ' ':\n                need_o -= 1\n                need_n -= 1\n            elif t == '-':\n                need_o -= 1\n            elif t == '+':\n                need_n -= 1\n            else:\n                break\n            body += 1\n            i += 1\n        if need_o != 0 or need_n != 0:\n            return {'error': 'hunk %d truncated' % len(hunks)}\n        hunks.append([os_, ol, ns, nl, body])\n    return {'hunks': hunks}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {\n    1: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,1 @@', '+n']], {'hunks': [[0, 0, 1, 1, 1]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,3 @@', ' a', '-b', '+x', '+x']], {'hunks': [[2, 2, 2, 3, 4]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    2: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,2 @@', '+n', '+n']], {'hunks': [[0, 0, 1, 2, 2]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,4 @@', ' a', '-b', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 4, 5]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    3: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,3 @@', '+n', '+n', '+n']], {'hunks': [[0, 0, 1, 3, 3]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,5 @@', ' a', '-b', '+x', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 5, 6]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    4: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,4 @@', '+n', '+n', '+n', '+n']], {'hunks': [[0, 0, 1, 4, 4]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,6 @@', ' a', '-b', '+x', '+x', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 6, 7]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    5: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,5 @@', '+n', '+n', '+n', '+n', '+n']], {'hunks': [[0, 0, 1, 5, 5]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,7 @@', ' a', '-b', '+x', '+x', '+x', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 7, 8]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\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":"5faf733c08a1fe88b1d6796745b52e13bc8d3353edb9c01d608ac645a69cb3fd","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport re\nN = 1\nobservations = []\ndef solve(lines):\n    hdr = re.compile(r'^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@')\n    hunks = []\n    i = 0\n    while i < len(lines):\n        m = hdr.match(lines[i])\n        if not m:\n            i += 1\n            continue\n        os_ = int(m.group(1))\n        ol = int(m.group(2)) if m.group(2) is not None else 1\n        ns = int(m.group(3))\n        nl = int(m.group(4)) if m.group(4) is not None else 1\n        need_o, need_n, body = ol, nl, 0\n        i += 1\n        while (need_o > 0 or need_n > 0) and i < len(lines):\n            ln = lines[i]\n            t = ln[:1] if ln else ' '\n            if t == ' ':\n                need_o -= 1\n                need_n -= 1\n            elif t == '-':\n                need_o -= 1\n            elif t == '+':\n                need_n -= 1\n            else:\n                break\n            body += 1\n            i += 1\n        if need_o != 0 or need_n != 0:\n            return {'error': 'hunk %d truncated' % len(hunks)}\n        hunks.append([os_, ol, ns, nl, body])\n    return {'hunks': hunks}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {\n    1: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,1 @@', '+n']], {'hunks': [[0, 0, 1, 1, 1]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,3 @@', ' a', '-b', '+x', '+x']], {'hunks': [[2, 2, 2, 3, 4]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    2: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,2 @@', '+n', '+n']], {'hunks': [[0, 0, 1, 2, 2]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,4 @@', ' a', '-b', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 4, 5]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    3: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,3 @@', '+n', '+n', '+n']], {'hunks': [[0, 0, 1, 3, 3]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,5 @@', ' a', '-b', '+x', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 5, 6]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    4: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,4 @@', '+n', '+n', '+n', '+n']], {'hunks': [[0, 0, 1, 4, 4]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,6 @@', ' a', '-b', '+x', '+x', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 6, 7]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    5: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,5 @@', '+n', '+n', '+n', '+n', '+n']], {'hunks': [[0, 0, 1, 5, 5]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,7 @@', ' a', '-b', '+x', '+x', '+x', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 7, 8]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\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":"f7cb408150ea004796feeba53038e7c0c49b22f204a4db846dd0fc151220bea6","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport re\nN = 1\nobservations = []\ndef solve(lines):\n    hdr = re.compile(r'^@@ -(\\d+)(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@')\n    hunks = []\n    i = 0\n    while i < len(lines):\n        m = hdr.match(lines[i])\n        if not m:\n            i += 1\n            continue\n        os_ = int(m.group(1))\n        ol = int(m.group(2)) if m.group(2) is not None else 1\n        ns = int(m.group(3))\n        nl = int(m.group(4)) if m.group(4) is not None else 1\n        need_o, need_n, body = ol, nl, 0\n        i += 1\n        while (need_o > 0 or need_n > 0) and i < len(lines):\n            ln = lines[i]\n            if ln.startswith('\\\\'):\n                i += 1\n                continue\n            t = ln[:1] if ln else ' '\n            if t == ' ':\n                need_o -= 1\n                need_n -= 1\n            elif t == '-':\n                need_o -= 1\n            elif t == '+':\n                need_n -= 1\n            else:\n                break\n            body += 1\n            i += 1\n        if need_o != 0 or need_n != 0:\n            return {'error': 'hunk %d truncated' % len(hunks)}\n        hunks.append([os_, ol, ns, nl, body])\n    return {'hunks': hunks}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = {\n    1: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,1 @@', '+n']], {'hunks': [[0, 0, 1, 1, 1]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,3 @@', ' a', '-b', '+x', '+x']], {'hunks': [[2, 2, 2, 3, 4]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    2: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,2 @@', '+n', '+n']], {'hunks': [[0, 0, 1, 2, 2]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,4 @@', ' a', '-b', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 4, 5]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    3: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,3 @@', '+n', '+n', '+n']], {'hunks': [[0, 0, 1, 3, 3]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,5 @@', ' a', '-b', '+x', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 5, 6]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    4: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,4 @@', '+n', '+n', '+n', '+n']], {'hunks': [[0, 0, 1, 4, 4]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,6 @@', ' a', '-b', '+x', '+x', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 6, 7]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\n    5: [('well-formed hunk', [['--- a/f', '+++ b/f', '@@ -1,3 +1,3 @@', ' a', '-b', '+B', ' c']], {'hunks': [[1, 3, 1, 3, 4]]}), ('omitted counts mean one', [['@@ -4 +4 @@', '-x', '+y']], {'hunks': [[4, 1, 4, 1, 2]]}), ('explicit zero count', [['@@ -0,0 +1,5 @@', '+n', '+n', '+n', '+n', '+n']], {'hunks': [[0, 0, 1, 5, 5]]}), ('no-newline marker is not a body line', [['@@ -1 +1 @@', '-old', '\\\\ No newline at end of file', '+new', '\\\\ No newline at end of file']], {'hunks': [[1, 1, 1, 1, 2]]}), ('empty line tolerated as context', [['@@ -1,3 +1,3 @@', ' a', '', ' c']], {'hunks': [[1, 3, 1, 3, 3]]}), ('truncated hunk', [['@@ -1,3 +1,4 @@', ' a', '+b', ' c']], {'error': 'hunk 0 truncated'}), ('trailing additions after old side is exhausted', [['@@ -2,2 +2,7 @@', ' a', '-b', '+x', '+x', '+x', '+x', '+x', '+x']], {'hunks': [[2, 2, 2, 7, 8]]}), ('two hunks', [['@@ -1,2 +1,1 @@', ' a', '-b', '@@ -9 +8,2 @@', ' z', '+w']], {'hunks': [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]})],\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-unified-hunk-parser-marker-lines","generated_at":"2026-09-29T14:49:09.706795+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Patch tools must validate hunk bodies against their headers before applying anything.","repair":"Skip \"\\\\\" marker lines without counting them.","root_cause":"Marker lines are not skipped, so they fall into the \"anything else\" branch and stop the body.","sha256":"c40ba733472727774295cee365fb38042a5c2c1462f4758e9dc0ec75ec16fc86","title":"Unified hunk parser: no-newline markers end the hunk body · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":38.741,"exit_code":1,"observations":[{"actual":{"hunks":[[1,3,1,3,4]]},"check":"well-formed hunk","expected":{"hunks":[[1,3,1,3,4]]},"passed":true},{"actual":{"hunks":[[4,1,4,1,2]]},"check":"omitted counts mean one","expected":{"hunks":[[4,1,4,1,2]]},"passed":true},{"actual":{"hunks":[[0,0,1,1,1]]},"check":"explicit zero count","expected":{"hunks":[[0,0,1,1,1]]},"passed":true},{"actual":{"hunks":[[1,1,1,1,3]]},"check":"no-newline marker is not a body line","expected":{"hunks":[[1,1,1,1,2]]},"passed":false},{"actual":{"hunks":[[1,3,1,3,3]]},"check":"empty line tolerated as context","expected":{"hunks":[[1,3,1,3,3]]},"passed":true},{"actual":{"error":"hunk 0 truncated"},"check":"truncated hunk","expected":{"error":"hunk 0 truncated"},"passed":true},{"actual":{"hunks":[[2,2,2,3,4]]},"check":"trailing additions after old side is exhausted","expected":{"hunks":[[2,2,2,3,4]]},"passed":true},{"actual":{"hunks":[[1,2,1,1,2],[9,1,8,2,2]]},"check":"two hunks","expected":{"hunks":[[1,2,1,1,2],[9,1,8,2,2]]},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"well-formed hunk\", \"actual\": {\"hunks\": [[1, 3, 1, 3, 4]]}, \"expected\": {\"hunks\": [[1, 3, 1, 3, 4]]}, \"passed\": true}, {\"check\": \"omitted counts mean one\", \"actual\": {\"hunks\": [[4, 1, 4, 1, 2]]}, \"expected\": {\"hunks\": [[4, 1, 4, 1, 2]]}, \"passed\": true}, {\"check\": \"explicit zero count\", \"actual\": {\"hunks\": [[0, 0, 1, 1, 1]]}, \"expected\": {\"hunks\": [[0, 0, 1, 1, 1]]}, \"passed\": true}, {\"check\": \"no-newline marker is not a body line\", \"actual\": {\"hunks\": [[1, 1, 1, 1, 3]]}, \"expected\": {\"hunks\": [[1, 1, 1, 1, 2]]}, \"passed\": false}, {\"check\": \"empty line tolerated as context\", \"actual\": {\"hunks\": [[1, 3, 1, 3, 3]]}, \"expected\": {\"hunks\": [[1, 3, 1, 3, 3]]}, \"passed\": true}, {\"check\": \"truncated hunk\", \"actual\": {\"error\": \"hunk 0 truncated\"}, \"expected\": {\"error\": \"hunk 0 truncated\"}, \"passed\": true}, {\"check\": \"trailing additions after old side is exhausted\", \"actual\": {\"hunks\": [[2, 2, 2, 3, 4]]}, \"expected\": {\"hunks\": [[2, 2, 2, 3, 4]]}, \"passed\": true}, {\"check\": \"two hunks\", \"actual\": {\"hunks\": [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]}, \"expected\": {\"hunks\": [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.129,"exit_code":1,"observations":[{"actual":{"hunks":[[1,3,1,3,4]]},"check":"well-formed hunk","expected":{"hunks":[[1,3,1,3,4]]},"passed":true},{"actual":{"hunks":[[4,1,4,1,2]]},"check":"omitted counts mean one","expected":{"hunks":[[4,1,4,1,2]]},"passed":true},{"actual":{"hunks":[[0,0,1,1,1]]},"check":"explicit zero count","expected":{"hunks":[[0,0,1,1,1]]},"passed":true},{"actual":{"error":"hunk 0 truncated"},"check":"no-newline marker is not a body line","expected":{"hunks":[[1,1,1,1,2]]},"passed":false},{"actual":{"hunks":[[1,3,1,3,3]]},"check":"empty line tolerated as context","expected":{"hunks":[[1,3,1,3,3]]},"passed":true},{"actual":{"error":"hunk 0 truncated"},"check":"truncated hunk","expected":{"error":"hunk 0 truncated"},"passed":true},{"actual":{"hunks":[[2,2,2,3,4]]},"check":"trailing additions after old side is exhausted","expected":{"hunks":[[2,2,2,3,4]]},"passed":true},{"actual":{"hunks":[[1,2,1,1,2],[9,1,8,2,2]]},"check":"two hunks","expected":{"hunks":[[1,2,1,1,2],[9,1,8,2,2]]},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"well-formed hunk\", \"actual\": {\"hunks\": [[1, 3, 1, 3, 4]]}, \"expected\": {\"hunks\": [[1, 3, 1, 3, 4]]}, \"passed\": true}, {\"check\": \"omitted counts mean one\", \"actual\": {\"hunks\": [[4, 1, 4, 1, 2]]}, \"expected\": {\"hunks\": [[4, 1, 4, 1, 2]]}, \"passed\": true}, {\"check\": \"explicit zero count\", \"actual\": {\"hunks\": [[0, 0, 1, 1, 1]]}, \"expected\": {\"hunks\": [[0, 0, 1, 1, 1]]}, \"passed\": true}, {\"check\": \"no-newline marker is not a body line\", \"actual\": {\"error\": \"hunk 0 truncated\"}, \"expected\": {\"hunks\": [[1, 1, 1, 1, 2]]}, \"passed\": false}, {\"check\": \"empty line tolerated as context\", \"actual\": {\"hunks\": [[1, 3, 1, 3, 3]]}, \"expected\": {\"hunks\": [[1, 3, 1, 3, 3]]}, \"passed\": true}, {\"check\": \"truncated hunk\", \"actual\": {\"error\": \"hunk 0 truncated\"}, \"expected\": {\"error\": \"hunk 0 truncated\"}, \"passed\": true}, {\"check\": \"trailing additions after old side is exhausted\", \"actual\": {\"hunks\": [[2, 2, 2, 3, 4]]}, \"expected\": {\"hunks\": [[2, 2, 2, 3, 4]]}, \"passed\": true}, {\"check\": \"two hunks\", \"actual\": {\"hunks\": [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]}, \"expected\": {\"hunks\": [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]}, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.289,"exit_code":0,"observations":[{"actual":{"hunks":[[1,3,1,3,4]]},"check":"well-formed hunk","expected":{"hunks":[[1,3,1,3,4]]},"passed":true},{"actual":{"hunks":[[4,1,4,1,2]]},"check":"omitted counts mean one","expected":{"hunks":[[4,1,4,1,2]]},"passed":true},{"actual":{"hunks":[[0,0,1,1,1]]},"check":"explicit zero count","expected":{"hunks":[[0,0,1,1,1]]},"passed":true},{"actual":{"hunks":[[1,1,1,1,2]]},"check":"no-newline marker is not a body line","expected":{"hunks":[[1,1,1,1,2]]},"passed":true},{"actual":{"hunks":[[1,3,1,3,3]]},"check":"empty line tolerated as context","expected":{"hunks":[[1,3,1,3,3]]},"passed":true},{"actual":{"error":"hunk 0 truncated"},"check":"truncated hunk","expected":{"error":"hunk 0 truncated"},"passed":true},{"actual":{"hunks":[[2,2,2,3,4]]},"check":"trailing additions after old side is exhausted","expected":{"hunks":[[2,2,2,3,4]]},"passed":true},{"actual":{"hunks":[[1,2,1,1,2],[9,1,8,2,2]]},"check":"two hunks","expected":{"hunks":[[1,2,1,1,2],[9,1,8,2,2]]},"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"well-formed hunk\", \"actual\": {\"hunks\": [[1, 3, 1, 3, 4]]}, \"expected\": {\"hunks\": [[1, 3, 1, 3, 4]]}, \"passed\": true}, {\"check\": \"omitted counts mean one\", \"actual\": {\"hunks\": [[4, 1, 4, 1, 2]]}, \"expected\": {\"hunks\": [[4, 1, 4, 1, 2]]}, \"passed\": true}, {\"check\": \"explicit zero count\", \"actual\": {\"hunks\": [[0, 0, 1, 1, 1]]}, \"expected\": {\"hunks\": [[0, 0, 1, 1, 1]]}, \"passed\": true}, {\"check\": \"no-newline marker is not a body line\", \"actual\": {\"hunks\": [[1, 1, 1, 1, 2]]}, \"expected\": {\"hunks\": [[1, 1, 1, 1, 2]]}, \"passed\": true}, {\"check\": \"empty line tolerated as context\", \"actual\": {\"hunks\": [[1, 3, 1, 3, 3]]}, \"expected\": {\"hunks\": [[1, 3, 1, 3, 3]]}, \"passed\": true}, {\"check\": \"truncated hunk\", \"actual\": {\"error\": \"hunk 0 truncated\"}, \"expected\": {\"error\": \"hunk 0 truncated\"}, \"passed\": true}, {\"check\": \"trailing additions after old side is exhausted\", \"actual\": {\"hunks\": [[2, 2, 2, 3, 4]]}, \"expected\": {\"hunks\": [[2, 2, 2, 3, 4]]}, \"passed\": true}, {\"check\": \"two hunks\", \"actual\": {\"hunks\": [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]}, \"expected\": {\"hunks\": [[1, 2, 1, 1, 2], [9, 1, 8, 2, 2]]}, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}