FAILURE MAP
← Case archive

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

LCS edit script: ties emit the insertion before the deletion · case 01

A replaced line is shown as the new line followed by the removed one.

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

ROOT CAUSE

The walk uses a strict comparison, so equal table values choose insertion first.

THE FAILURE

The walk uses a strict comparison, so equal table values choose insertion first.

Unsuccessful approach: Breaking ties by comparing the line texts makes the order depend on content.

Case contract

Given old and new line lists, fill a suffix LCS table L[i][j] for a[i:], b[j:], then walk from the start: equal lines are kept, otherwise delete when L[i+1][j] >= L[i][j+1] and insert otherwise; flush remaining old lines as deletions and new lines as insertions. Return [tag, line] ops with tags " ", "-", "+".

Why this case matters

Line diffs are built from a longest-common-subsequence table; the walk decides how edits are ordered and presented.

1 / The failure

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

N = 1
observations = []
def solve(a, b):
    n, m = len(a), len(b)
    T = [[0] * (m + 1) for _ in range(n + 1)]
    for i in range(n - 1, -1, -1):
        for j in range(m - 1, -1, -1):
            if a[i] == b[j]:
                T[i][j] = T[i + 1][j + 1] + 1
            else:
                T[i][j] = max(T[i + 1][j], T[i][j + 1])
    out = []
    i = j = 0
    while i < n and j < m:
        if a[i] == b[j]:
            out.append([' ', a[i]])
            i += 1
            j += 1
        elif T[i + 1][j] > T[i][j + 1]:
            out.append(['-', a[i]])
            i += 1
        else:
            out.append(['+', b[j]])
            j += 1
    out.extend(['-', x] for x in a[i:])
    out.extend(['+', x] for x in b[j:])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0']], [[' ', 'a'], [' ', 'b'], ['+', 'n0']]), ('deletion at the end', [['a', 'b', 'c', 't1', 't2'], ['a', 'b', 'c']], [[' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same'], ['same']], [[' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0']], [['+', 'k0']]), ('repeated line after a replaced one', [['r1', 'r1'], ['q', 'r1']], [['-', 'r1'], ['+', 'q'], [' ', 'r1']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
    2: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0', 'n1']], [[' ', 'a'], [' ', 'b'], ['+', 'n0'], ['+', 'n1']]), ('deletion at the end', [['a', 'b', 'c', 'd', 't1', 't2'], ['a', 'b', 'c', 'd']], [[' ', 'a'], [' ', 'b'], [' ', 'c'], [' ', 'd'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same', 'same'], ['same', 'same']], [[' ', 'same'], [' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0', 'k1']], [['+', 'k0'], ['+', 'k1']]), ('repeated line after a replaced one', [['r2', 'r2'], ['q', 'r2']], [['-', 'r2'], ['+', 'q'], [' ', 'r2']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
    3: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0', 'n1', 'n2']], [[' ', 'a'], [' ', 'b'], ['+', 'n0'], ['+', 'n1'], ['+', 'n2']]), ('deletion at the end', [['a', 'b', 't1', 't2'], ['a', 'b']], [[' ', 'a'], [' ', 'b'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same', 'same', 'same'], ['same', 'same', 'same']], [[' ', 'same'], [' ', 'same'], [' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0', 'k1', 'k2']], [['+', 'k0'], ['+', 'k1'], ['+', 'k2']]), ('repeated line after a replaced one', [['r3', 'r3'], ['q', 'r3']], [['-', 'r3'], ['+', 'q'], [' ', 'r3']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
    4: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0', 'n1', 'n2', 'n3']], [[' ', 'a'], [' ', 'b'], ['+', 'n0'], ['+', 'n1'], ['+', 'n2'], ['+', 'n3']]), ('deletion at the end', [['a', 'b', 'c', 't1', 't2'], ['a', 'b', 'c']], [[' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same', 'same', 'same', 'same'], ['same', 'same', 'same', 'same']], [[' ', 'same'], [' ', 'same'], [' ', 'same'], [' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0', 'k1', 'k2', 'k3']], [['+', 'k0'], ['+', 'k1'], ['+', 'k2'], ['+', 'k3']]), ('repeated line after a replaced one', [['r4', 'r4'], ['q', 'r4']], [['-', 'r4'], ['+', 'q'], [' ', 'r4']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
    5: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0', 'n1', 'n2', 'n3', 'n4']], [[' ', 'a'], [' ', 'b'], ['+', 'n0'], ['+', 'n1'], ['+', 'n2'], ['+', 'n3'], ['+', 'n4']]), ('deletion at the end', [['a', 'b', 'c', 'd', 't1', 't2'], ['a', 'b', 'c', 'd']], [[' ', 'a'], [' ', 'b'], [' ', 'c'], [' ', 'd'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same', 'same', 'same', 'same', 'same'], ['same', 'same', 'same', 'same', 'same']], [[' ', 'same'], [' ', 'same'], [' ', 'same'], [' ', 'same'], [' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0', 'k1', 'k2', 'k3', 'k4']], [['+', 'k0'], ['+', 'k1'], ['+', 'k2'], ['+', 'k3'], ['+', 'k4']]), ('repeated line after a replaced one', [['r5', 'r5'], ['q', 'r5']], [['-', 'r5'], ['+', 'q'], [' ', 'r5']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
}[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
single replaced line[[' ', 'a'], ['+', 'x'], ['-', 'b'], [' ', 'c']][[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]Failed
insertion at the end[[' ', 'a'], [' ', 'b'], ['+', 'n0']][[' ', 'a'], [' ', 'b'], ['+', 'n0']]Passed
deletion at the end[[' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 't1'], ['-', 't2']][[' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 't1'], ['-', 't2']]Passed
tie prefers deletion first[['+', 'q'], [' ', 'p'], ['-', 'q']][['-', 'p'], [' ', 'q'], ['+', 'p']]Failed
moved block[[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']][[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]Passed
identical sequences[[' ', 'same']][[' ', 'same']]Passed
first lines differ[['+', 'B'], ['-', 'A'], [' ', 'b'], [' ', 'c'], [' ', 'd']][['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]Failed
empty old side[['+', 'k0']][['+', 'k0']]Passed
repeated line after a replaced one[['+', 'q'], [' ', 'r1'], ['-', 'r1']][['-', 'r1'], ['+', 'q'], [' ', 'r1']]Failed
lcs longer than greedy[['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['+', 'd'], ['-', 'x'], ['-', 'y']][['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']]Failed

SHA-256 / 8eb9637e8956463c9d28149cebb2b71ded2f118961a787452614f6bc039d566a

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(a, b):
    n, m = len(a), len(b)
    T = [[0] * (m + 1) for _ in range(n + 1)]
    for i in range(n - 1, -1, -1):
        for j in range(m - 1, -1, -1):
            if a[i] == b[j]:
                T[i][j] = T[i + 1][j + 1] + 1
            else:
                T[i][j] = max(T[i + 1][j], T[i][j + 1])
    out = []
    i = j = 0
    while i < n and j < m:
        if a[i] == b[j]:
            out.append([' ', a[i]])
            i += 1
            j += 1
        elif T[i + 1][j] > T[i][j + 1] or a[i] < b[j]:
            out.append(['-', a[i]])
            i += 1
        else:
            out.append(['+', b[j]])
            j += 1
    out.extend(['-', x] for x in a[i:])
    out.extend(['+', x] for x in b[j:])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0']], [[' ', 'a'], [' ', 'b'], ['+', 'n0']]), ('deletion at the end', [['a', 'b', 'c', 't1', 't2'], ['a', 'b', 'c']], [[' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same'], ['same']], [[' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0']], [['+', 'k0']]), ('repeated line after a replaced one', [['r1', 'r1'], ['q', 'r1']], [['-', 'r1'], ['+', 'q'], [' ', 'r1']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
    2: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0', 'n1']], [[' ', 'a'], [' ', 'b'], ['+', 'n0'], ['+', 'n1']]), ('deletion at the end', [['a', 'b', 'c', 'd', 't1', 't2'], ['a', 'b', 'c', 'd']], [[' ', 'a'], [' ', 'b'], [' ', 'c'], [' ', 'd'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same', 'same'], ['same', 'same']], [[' ', 'same'], [' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0', 'k1']], [['+', 'k0'], ['+', 'k1']]), ('repeated line after a replaced one', [['r2', 'r2'], ['q', 'r2']], [['-', 'r2'], ['+', 'q'], [' ', 'r2']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
    3: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0', 'n1', 'n2']], [[' ', 'a'], [' ', 'b'], ['+', 'n0'], ['+', 'n1'], ['+', 'n2']]), ('deletion at the end', [['a', 'b', 't1', 't2'], ['a', 'b']], [[' ', 'a'], [' ', 'b'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same', 'same', 'same'], ['same', 'same', 'same']], [[' ', 'same'], [' ', 'same'], [' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0', 'k1', 'k2']], [['+', 'k0'], ['+', 'k1'], ['+', 'k2']]), ('repeated line after a replaced one', [['r3', 'r3'], ['q', 'r3']], [['-', 'r3'], ['+', 'q'], [' ', 'r3']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
    4: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0', 'n1', 'n2', 'n3']], [[' ', 'a'], [' ', 'b'], ['+', 'n0'], ['+', 'n1'], ['+', 'n2'], ['+', 'n3']]), ('deletion at the end', [['a', 'b', 'c', 't1', 't2'], ['a', 'b', 'c']], [[' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same', 'same', 'same', 'same'], ['same', 'same', 'same', 'same']], [[' ', 'same'], [' ', 'same'], [' ', 'same'], [' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0', 'k1', 'k2', 'k3']], [['+', 'k0'], ['+', 'k1'], ['+', 'k2'], ['+', 'k3']]), ('repeated line after a replaced one', [['r4', 'r4'], ['q', 'r4']], [['-', 'r4'], ['+', 'q'], [' ', 'r4']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
    5: [('single replaced line', [['a', 'b', 'c'], ['a', 'x', 'c']], [[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]), ('insertion at the end', [['a', 'b'], ['a', 'b', 'n0', 'n1', 'n2', 'n3', 'n4']], [[' ', 'a'], [' ', 'b'], ['+', 'n0'], ['+', 'n1'], ['+', 'n2'], ['+', 'n3'], ['+', 'n4']]), ('deletion at the end', [['a', 'b', 'c', 'd', 't1', 't2'], ['a', 'b', 'c', 'd']], [[' ', 'a'], [' ', 'b'], [' ', 'c'], [' ', 'd'], ['-', 't1'], ['-', 't2']]), ('tie prefers deletion first', [['p', 'q'], ['q', 'p']], [['-', 'p'], [' ', 'q'], ['+', 'p']]), ('moved block', [['h', 'x', 'y', 'z', 't'], ['h', 'z', 'x', 'y', 't']], [[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]), ('identical sequences', [['same', 'same', 'same', 'same', 'same'], ['same', 'same', 'same', 'same', 'same']], [[' ', 'same'], [' ', 'same'], [' ', 'same'], [' ', 'same'], [' ', 'same']]), ('first lines differ', [['A', 'b', 'c', 'd'], ['B', 'b', 'c', 'd']], [['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]), ('empty old side', [[], ['k0', 'k1', 'k2', 'k3', 'k4']], [['+', 'k0'], ['+', 'k1'], ['+', 'k2'], ['+', 'k3'], ['+', 'k4']]), ('repeated line after a replaced one', [['r5', 'r5'], ['q', 'r5']], [['-', 'r5'], ['+', 'q'], [' ', 'r5']]), ('lcs longer than greedy', [['a', 'b', 'c', 'x', 'y'], ['x', 'y', 'a', 'b', 'c', 'd']], [['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']])],
}[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
single replaced line[[' ', 'a'], ['-', 'b'], ['-', 'c'], ['+', 'x'], ['+', 'c']][[' ', 'a'], ['-', 'b'], ['+', 'x'], [' ', 'c']]Failed
insertion at the end[[' ', 'a'], [' ', 'b'], ['+', 'n0']][[' ', 'a'], [' ', 'b'], ['+', 'n0']]Passed
deletion at the end[[' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 't1'], ['-', 't2']][[' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 't1'], ['-', 't2']]Passed
tie prefers deletion first[['-', 'p'], [' ', 'q'], ['+', 'p']][['-', 'p'], [' ', 'q'], ['+', 'p']]Passed
moved block[[' ', 'h'], ['-', 'x'], ['-', 'y'], [' ', 'z'], ['-', 't'], ['+', 'x'], ['+', 'y'], ['+', 't']][[' ', 'h'], ['+', 'z'], [' ', 'x'], [' ', 'y'], ['-', 'z'], [' ', 't']]Failed
identical sequences[[' ', 'same']][[' ', 'same']]Passed
first lines differ[['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']][['-', 'A'], ['+', 'B'], [' ', 'b'], [' ', 'c'], [' ', 'd']]Passed
empty old side[['+', 'k0']][['+', 'k0']]Passed
repeated line after a replaced one[['+', 'q'], [' ', 'r1'], ['-', 'r1']][['-', 'r1'], ['+', 'q'], [' ', 'r1']]Failed
lcs longer than greedy[['-', 'a'], ['-', 'b'], ['-', 'c'], [' ', 'x'], [' ', 'y'], ['+', 'a'], ['+', 'b'], ['+', 'c'], ['+', 'd']][['+', 'x'], ['+', 'y'], [' ', 'a'], [' ', 'b'], [' ', 'c'], ['-', 'x'], ['-', 'y'], ['+', 'd']]Failed

SHA-256 / 3fe31f738490420e49d21d55679800b503de7c3a0476011679bccd9a97de60dc

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 10 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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:05.775196+00:00.

Case digest / 64618b320d71d0340024651c52aac55373d6ea9c86923dc08056294b969e9513