FA-75681 / Text diff and three-way merge / Open access
Intraline change pairing: removed lines pair with additions after intervening context · case 01
A deletion is highlighted against an unrelated insertion further down.
ROOT CAUSE
Context lines between the removed and added runs are skipped before collecting additions.
VERIFIED REPAIR
Collect additions only when they immediately follow the removed lines.
Unsuccessful approach: Skipping a single context line still pairs across a one-line gap.
Case contract
Within each block of consecutive "-" lines immediately followed by consecutive "+" lines, pair the i-th removed line with the i-th added line (extra lines stay unpaired). For each pair report the common prefix length and the common suffix length, where the suffix may not overlap the prefix. Return [old, new, prefix, suffix] rows.
Why this case matters
Word and character highlighting inside changed lines depends on pairing lines and trimming their shared ends.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import itertools
N = 1
observations = []
def solve(ops):
res = []
i = 0
while i < len(ops):
if ops[i][0] != '-':
i += 1
continue
dels = []
while i < len(ops) and ops[i][0] == '-':
dels.append(ops[i][1])
i += 1
while i < len(ops) and ops[i][0] == ' ':
i += 1
adds = []
while i < len(ops) and ops[i][0] == '+':
adds.append(ops[i][1])
i += 1
for d, a in zip(dels, adds):
p = 0
while p < min(len(d), len(a)) and d[p] == a[p]:
p += 1
s = 0
while s < min(len(d), len(a)) - p and d[-1 - s] == a[-1 - s]:
s += 1
res.append([d, a, p, s])
return res
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
1: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 21']]], [['value = 1', 'value = 21', 8, 1]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'ababab']]], [['abab', 'ababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r1']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
2: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 22']]], [['value = 1', 'value = 22', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'abababab']]], [['abab', 'abababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r2']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
3: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 23']]], [['value = 1', 'value = 23', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'ababababab']]], [['abab', 'ababababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r3']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
4: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 24']]], [['value = 1', 'value = 24', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'abababababab']]], [['abab', 'abababababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r4']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
5: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 25']]], [['value = 1', 'value = 25', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'ababababababab']]], [['abab', 'ababababababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r5']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
}[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 |
|---|---|---|---|
| simple replacement | [['value = 1', 'value = 21', 8, 1]] | [['value = 1', 'value = 21', 8, 1]] | Passed |
| suffix must not overlap prefix | [['aa', 'aaa', 2, 0]] | [['aa', 'aaa', 2, 0]] | Passed |
| overlap with repeated characters | [['abab', 'ababab', 4, 0]] | [['abab', 'ababab', 4, 0]] | Passed |
| pairs do not cross context | [['old', 'new', 0, 0]] | [] | Failed |
| more deletions than insertions | [['x1', 'y1', 0, 1]] | [['x1', 'y1', 0, 1]] | Passed |
| more insertions than deletions | [['p', 'q', 0, 0]] | [['p', 'q', 0, 0]] | Passed |
| pure insertion block | [['d', 'e', 0, 0]] | [['d', 'e', 0, 0]] | Passed |
| two blocks | [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]] | [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]] | Passed |
SHA-256 / d605600c12a4482bfaa5f14d28d948e3b13c714d3b66cced0640248a2765795a
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import itertools
N = 1
observations = []
def solve(ops):
res = []
i = 0
while i < len(ops):
if ops[i][0] != '-':
i += 1
continue
dels = []
while i < len(ops) and ops[i][0] == '-':
dels.append(ops[i][1])
i += 1
if i < len(ops) and ops[i][0] == ' ':
i += 1
adds = []
while i < len(ops) and ops[i][0] == '+':
adds.append(ops[i][1])
i += 1
for d, a in zip(dels, adds):
p = 0
while p < min(len(d), len(a)) and d[p] == a[p]:
p += 1
s = 0
while s < min(len(d), len(a)) - p and d[-1 - s] == a[-1 - s]:
s += 1
res.append([d, a, p, s])
return res
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
1: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 21']]], [['value = 1', 'value = 21', 8, 1]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'ababab']]], [['abab', 'ababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r1']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
2: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 22']]], [['value = 1', 'value = 22', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'abababab']]], [['abab', 'abababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r2']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
3: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 23']]], [['value = 1', 'value = 23', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'ababababab']]], [['abab', 'ababababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r3']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
4: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 24']]], [['value = 1', 'value = 24', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'abababababab']]], [['abab', 'abababababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r4']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
5: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 25']]], [['value = 1', 'value = 25', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'ababababababab']]], [['abab', 'ababababababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r5']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
}[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 |
|---|---|---|---|
| simple replacement | [['value = 1', 'value = 21', 8, 1]] | [['value = 1', 'value = 21', 8, 1]] | Passed |
| suffix must not overlap prefix | [['aa', 'aaa', 2, 0]] | [['aa', 'aaa', 2, 0]] | Passed |
| overlap with repeated characters | [['abab', 'ababab', 4, 0]] | [['abab', 'ababab', 4, 0]] | Passed |
| pairs do not cross context | [['old', 'new', 0, 0]] | [] | Failed |
| more deletions than insertions | [['x1', 'y1', 0, 1]] | [['x1', 'y1', 0, 1]] | Passed |
| more insertions than deletions | [['p', 'q', 0, 0]] | [['p', 'q', 0, 0]] | Passed |
| pure insertion block | [['d', 'e', 0, 0]] | [['d', 'e', 0, 0]] | Passed |
| two blocks | [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]] | [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]] | Passed |
SHA-256 / 20f77cfe047fe176b6bf43b91d9df61d5aaf0d154931d09da6dfbdf45bb6508b
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import itertools
N = 1
observations = []
def solve(ops):
res = []
i = 0
while i < len(ops):
if ops[i][0] != '-':
i += 1
continue
dels = []
while i < len(ops) and ops[i][0] == '-':
dels.append(ops[i][1])
i += 1
adds = []
while i < len(ops) and ops[i][0] == '+':
adds.append(ops[i][1])
i += 1
for d, a in zip(dels, adds):
p = 0
while p < min(len(d), len(a)) and d[p] == a[p]:
p += 1
s = 0
while s < min(len(d), len(a)) - p and d[-1 - s] == a[-1 - s]:
s += 1
res.append([d, a, p, s])
return res
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
1: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 21']]], [['value = 1', 'value = 21', 8, 1]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'ababab']]], [['abab', 'ababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r1']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
2: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 22']]], [['value = 1', 'value = 22', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'abababab']]], [['abab', 'abababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r2']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
3: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 23']]], [['value = 1', 'value = 23', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'ababababab']]], [['abab', 'ababababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r3']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
4: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 24']]], [['value = 1', 'value = 24', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'abababababab']]], [['abab', 'abababababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r4']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
5: [('simple replacement', [[[' ', 'ctx'], ['-', 'value = 1'], ['+', 'value = 25']]], [['value = 1', 'value = 25', 8, 0]]), ('suffix must not overlap prefix', [[['-', 'aa'], ['+', 'aaa']]], [['aa', 'aaa', 2, 0]]), ('overlap with repeated characters', [[['-', 'abab'], ['+', 'ababababababab']]], [['abab', 'ababababababab', 4, 0]]), ('pairs do not cross context', [[['-', 'old'], [' ', 'keep'], ['+', 'new']]], []), ('more deletions than insertions', [[['-', 'x1'], ['-', 'x2'], ['+', 'y1']]], [['x1', 'y1', 0, 1]]), ('more insertions than deletions', [[['-', 'p'], ['+', 'q'], ['+', 'r5']]], [['p', 'q', 0, 0]]), ('pure insertion block', [[['+', 'only'], [' ', 'c'], ['-', 'd'], ['+', 'e']]], [['d', 'e', 0, 0]]), ('two blocks', [[['-', 'foo(a)'], ['+', 'foo(b)'], [' ', 'x'], [' ', 'y'], ['-', 'bar'], ['+', 'baz']]], [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]])],
}[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 |
|---|---|---|---|
| simple replacement | [['value = 1', 'value = 21', 8, 1]] | [['value = 1', 'value = 21', 8, 1]] | Passed |
| suffix must not overlap prefix | [['aa', 'aaa', 2, 0]] | [['aa', 'aaa', 2, 0]] | Passed |
| overlap with repeated characters | [['abab', 'ababab', 4, 0]] | [['abab', 'ababab', 4, 0]] | Passed |
| pairs do not cross context | [] | [] | Passed |
| more deletions than insertions | [['x1', 'y1', 0, 1]] | [['x1', 'y1', 0, 1]] | Passed |
| more insertions than deletions | [['p', 'q', 0, 0]] | [['p', 'q', 0, 0]] | Passed |
| pure insertion block | [['d', 'e', 0, 0]] | [['d', 'e', 0, 0]] | Passed |
| two blocks | [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]] | [['foo(a)', 'foo(b)', 4, 1], ['bar', 'baz', 2, 0]] | Passed |
SHA-256 / 9ab514a32626ced31b0ec0cafb9e2adab1de9e358c2bd2ef432b1066885a5eb3
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:09.074580+00:00.
Case digest / 444405b6b3c9d3a750fb131a12accbf342316ec6700ae7276affc35d1af2b56a