FAILURE MAP
← Case archive

FA-75791 / Text diff and three-way merge / Open access

Hunk function context: indented statements are taken as headings · case 01

The header shows a statement inside the function instead of the function signature.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The predicate strips indentation before testing the first character.

VERIFIED REPAIR

Test the first character of the unstripped line.

Unsuccessful approach: Accepting alphanumerics admits lines that start with digits.

Case contract

For each hunk whose old range starts at 1-based line s, search the old lines strictly before s, nearest first, for a line whose first character is a letter, "_" or "$". The heading is that line with trailing whitespace removed, truncated to limit characters; "" if none.

Why this case matters

The text after the @@ header helps reviewers locate a hunk; choosing the wrong line or including the hunk itself misleads.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(old, starts, limit):
    res = []
    for s in starts:
        found = ''
        for k in range(s - 2, -1, -1):
            ln = old[k]
            if ln.strip()[:1].isalpha() or ln.strip()[:1] in ('_', '$'):
                found = ln.rstrip()[:limit]
                break
        res.append(found)
    return res
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 11], ['def xxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    2: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 12], ['def xxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    3: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 13], ['def xxxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    4: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 14], ['def xxxxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    5: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 15], ['def xxxxxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
}[N]
for label, args, expected in cases:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
nearest preceding definition[' int a;']['int main(void)']Failed
the hunk start line itself is not searched['', 'int main(void)']['', 'int main(void)']Passed
indented lines are not headings[' helper();']['int main(void)']Failed
dollar and underscore headings['$macro', '_private:']['$macro', '_private:']Passed
nothing before the first line['']['']Passed
long heading is truncated[' pass']['def xxxxxxx']Failed
digits do not start a heading['label:']['label:']Passed
trailing whitespace trimmed['text']['text']Passed

SHA-256 / a6d02d700e8a836e53b79e866f12773a51606e13bacbdcb8493a8fbfaffd2520

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(old, starts, limit):
    res = []
    for s in starts:
        found = ''
        for k in range(s - 2, -1, -1):
            ln = old[k]
            if ln[:1].isalnum() or ln[:1] in ('_', '$'):
                found = ln.rstrip()[:limit]
                break
        res.append(found)
    return res
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 11], ['def xxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    2: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 12], ['def xxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    3: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 13], ['def xxxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    4: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 14], ['def xxxxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    5: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 15], ['def xxxxxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
}[N]
for label, args, expected in cases:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
nearest preceding definition['int main(void)']['int main(void)']Passed
the hunk start line itself is not searched['', 'int main(void)']['', 'int main(void)']Passed
indented lines are not headings['int main(void)']['int main(void)']Passed
dollar and underscore headings['$macro', '_private:']['$macro', '_private:']Passed
nothing before the first line['']['']Passed
long heading is truncated['def xxxxxxx']['def xxxxxxx']Passed
digits do not start a heading['42 items']['label:']Failed
trailing whitespace trimmed['text']['text']Passed

SHA-256 / aadf6197d642fae52078573725c01f39ac10b96d0d5a9bb535c8804b7a147a06

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(old, starts, limit):
    res = []
    for s in starts:
        found = ''
        for k in range(s - 2, -1, -1):
            ln = old[k]
            if ln[:1].isalpha() or ln[:1] in ('_', '$'):
                found = ln.rstrip()[:limit]
                break
        res.append(found)
    return res
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 11], ['def xxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    2: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 12], ['def xxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    3: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 13], ['def xxxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    4: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 14], ['def xxxxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
    5: [('nearest preceding definition', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [5], 40], ['int main(void)']), ('the hunk start line itself is not searched', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [2, 3], 40], ['', 'int main(void)']), ('indented lines are not headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [6], 40], ['int main(void)']), ('dollar and underscore headings', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [10, 12], 40], ['$macro', '_private:']), ('nothing before the first line', [['#include <x>', 'int main(void)', '{', '  int a;', '  helper();', '  return 0;', '}', '', '$macro', '  body', '_private:', '  x = 1'], [1], 40], ['']), ('long heading is truncated', [['def xxxxxxxxxxxxxxxxxxxxxxxxx(): ', '    pass', '    pass'], [3], 15], ['def xxxxxxxxxxx']), ('digits do not start a heading', [['label:', '42 items', 'y'], [3], 40], ['label:']), ('trailing whitespace trimmed', [['Section   ', 'text', 'more'], [3], 40], ['text'])],
}[N]
for label, args, expected in cases:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
nearest preceding definition['int main(void)']['int main(void)']Passed
the hunk start line itself is not searched['', 'int main(void)']['', 'int main(void)']Passed
indented lines are not headings['int main(void)']['int main(void)']Passed
dollar and underscore headings['$macro', '_private:']['$macro', '_private:']Passed
nothing before the first line['']['']Passed
long heading is truncated['def xxxxxxx']['def xxxxxxx']Passed
digits do not start a heading['label:']['label:']Passed
trailing whitespace trimmed['text']['text']Passed

SHA-256 / 901da1a275d0f58e8736851aa5793dfd12de27b10320289125820fbedb2270c5

Verification & scope

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.

Observations recorded using Python 3.12.14 at 2026-09-29T14:49:10.241779+00:00.

Case digest / 557c45977d5b36be5e22d98d6f58d3cdfc1495b829fb5cd80fed6ebbb61f7c02