FA-75801 / Text diff and three-way merge / Open access
Hunk function context: underscore and dollar headings are ignored · case 01
Hunks inside labels or macros that start with "_" or "$" show an older heading.
ROOT CAUSE
The predicate accepts only alphabetic first characters.
VERIFIED REPAIR
Also accept "_" and "$" as heading starts.
Unsuccessful approach: Adding only the underscore still ignores "$" headings.
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[:1].isalpha():
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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 | ['int main(void)', 'int main(void)'] | ['$macro', '_private:'] | Failed |
| 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 / 59c5073ff4557b3302dc7f48c73c075380ef9a90988c302e4305cf92e1ebc786
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].isalpha() or ln[:1] == '_':
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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 | ['int main(void)', '_private:'] | ['$macro', '_private:'] | Failed |
| 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 / 5524544a41146205b9097c80e58933c40c8ceadd0eca111e1b02ee1107a5500c
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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.267505+00:00.
Case digest / c5efb8f24f2b7b99450a1f5b02c058dc69f66d6cfa6cb552dbf40bf7ae7da53c