FAILURE MAP
← Case archive

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

Conflict marker resolution: a longer rule of equals signs ends the ours section · case 01

A heading underline inside our side splits the conflict in the wrong place.

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

ROOT CAUSE

The separator test accepts any line that starts with seven equals signs.

VERIFIED REPAIR

Only a line of exactly seven equals signs separates the sides.

Unsuccessful approach: Stripping whitespace first still treats an indented separator-like line as the separator.

Case contract

Scan lines for conflict blocks. A marker is exactly seven marker characters, alone or followed by a space and a label: "<" opens, "|" starts the optional base section, a line of exactly seven "=" separates, ">" closes. Each closed block is replaced by ours, theirs, ours followed by theirs (union, no dedupe) or base. An unclosed block yields {"error": "unterminated conflict"}. Return the lines and the number of conflicts.

Why this case matters

Merge drivers and editors resolve conflict blocks by parsing marker lines that must not be confused with file content.

1 / The failure

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

N = 1
observations = []
def solve(lines, strategy):
    out = []
    state = None
    o, b, t = [], [], []
    count = 0
    def marker(line, ch):
        return line == ch * 7 or line.startswith(ch * 7 + ' ')
    for line in lines:
        if state is None:
            if marker(line, '<'):
                state = 'o'
                o, b, t = [], [], []
            else:
                out.append(line)
        elif state == 'o' and marker(line, '|'):
            state = 'b'
        elif state in ('o', 'b') and line.startswith('=' * 7):
            state = 't'
        elif state == 't' and marker(line, '>'):
            count += 1
            out.extend({'ours': o, 'theirs': t, 'union': o + t, 'base': b}[strategy])
            state = None
        else:
            {'o': o, 'b': b, 't': t}[state].append(line)
    if state is not None:
        return {'error': 'unterminated conflict', 'conflicts': count}
    return {'lines': out, 'conflicts': count}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z1', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z1'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b1', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b1'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4'], 'conflicts': 2})],
    2: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z2', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z2'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b2', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b2'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4'], 'conflicts': 3})],
    3: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z3', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z3'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b3', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b3'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4', '4'], 'conflicts': 4})],
    4: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z4', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z4'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b4', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b4'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4', '4', '4'], 'conflicts': 5})],
    5: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z5', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z5'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b5', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b5'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4', '4', '4', '4'], 'conflicts': 6})],
}[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
take ours{'conflicts': 1, 'lines': ['h', 'o1', 'z']}{'conflicts': 1, 'lines': ['h', 'o1', 'z']}Passed
take theirs with base section{'conflicts': 1, 'lines': ['h', 't1', 't2']}{'conflicts': 1, 'lines': ['h', 't1', 't2']}Passed
union keeps both in order{'conflicts': 1, 'lines': ['x', 'y', 'y', 'z1']}{'conflicts': 1, 'lines': ['x', 'y', 'y', 'z1']}Passed
base strategy{'conflicts': 1, 'lines': ['b1']}{'conflicts': 1, 'lines': ['b1']}Passed
long marker-like content lines{'conflicts': 1, 'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>']}{'conflicts': 1, 'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>']}Passed
marker prefix glued to text{'conflicts': 1, 'lines': ['<<<<<<<x', 'b']}{'conflicts': 1, 'lines': ['<<<<<<<x', 'b']}Passed
setext underline inside ours{'conflicts': 1, 'lines': ['Title']}{'conflicts': 1, 'lines': ['Title', '========']}Failed
indented separator-like line{'conflicts': 1, 'lines': [' =======', 'k', 't']}{'conflicts': 1, 'lines': [' =======', 'k', 't']}Passed
unterminated conflict is an error{'conflicts': 0, 'error': 'unterminated conflict'}{'conflicts': 0, 'error': 'unterminated conflict'}Passed
two conflicts{'conflicts': 2, 'lines': ['2', 'mid', '4']}{'conflicts': 2, 'lines': ['2', 'mid', '4']}Passed

SHA-256 / 69cb6388543a1eefb86a14a25dedac264a7c400ae2b4c60087ebf0c5190f754b

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(lines, strategy):
    out = []
    state = None
    o, b, t = [], [], []
    count = 0
    def marker(line, ch):
        return line == ch * 7 or line.startswith(ch * 7 + ' ')
    for line in lines:
        if state is None:
            if marker(line, '<'):
                state = 'o'
                o, b, t = [], [], []
            else:
                out.append(line)
        elif state == 'o' and marker(line, '|'):
            state = 'b'
        elif state in ('o', 'b') and line.strip() == '=' * 7:
            state = 't'
        elif state == 't' and marker(line, '>'):
            count += 1
            out.extend({'ours': o, 'theirs': t, 'union': o + t, 'base': b}[strategy])
            state = None
        else:
            {'o': o, 'b': b, 't': t}[state].append(line)
    if state is not None:
        return {'error': 'unterminated conflict', 'conflicts': count}
    return {'lines': out, 'conflicts': count}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z1', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z1'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b1', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b1'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4'], 'conflicts': 2})],
    2: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z2', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z2'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b2', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b2'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4'], 'conflicts': 3})],
    3: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z3', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z3'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b3', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b3'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4', '4'], 'conflicts': 4})],
    4: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z4', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z4'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b4', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b4'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4', '4', '4'], 'conflicts': 5})],
    5: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z5', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z5'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b5', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b5'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4', '4', '4', '4'], 'conflicts': 6})],
}[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
take ours{'conflicts': 1, 'lines': ['h', 'o1', 'z']}{'conflicts': 1, 'lines': ['h', 'o1', 'z']}Passed
take theirs with base section{'conflicts': 1, 'lines': ['h', 't1', 't2']}{'conflicts': 1, 'lines': ['h', 't1', 't2']}Passed
union keeps both in order{'conflicts': 1, 'lines': ['x', 'y', 'y', 'z1']}{'conflicts': 1, 'lines': ['x', 'y', 'y', 'z1']}Passed
base strategy{'conflicts': 1, 'lines': ['b1']}{'conflicts': 1, 'lines': ['b1']}Passed
long marker-like content lines{'conflicts': 1, 'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>']}{'conflicts': 1, 'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>']}Passed
marker prefix glued to text{'conflicts': 1, 'lines': ['<<<<<<<x', 'b']}{'conflicts': 1, 'lines': ['<<<<<<<x', 'b']}Passed
setext underline inside ours{'conflicts': 1, 'lines': ['Title', '========']}{'conflicts': 1, 'lines': ['Title', '========']}Passed
indented separator-like line{'conflicts': 1, 'lines': ['k', '=======', 't']}{'conflicts': 1, 'lines': [' =======', 'k', 't']}Failed
unterminated conflict is an error{'conflicts': 0, 'error': 'unterminated conflict'}{'conflicts': 0, 'error': 'unterminated conflict'}Passed
two conflicts{'conflicts': 2, 'lines': ['2', 'mid', '4']}{'conflicts': 2, 'lines': ['2', 'mid', '4']}Passed

SHA-256 / c12656f32fbc58c2c360d70cd7cd4b906c257394dddc675a2d0d89c25a50d4d1

3 / The verified repair

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

N = 1
observations = []
def solve(lines, strategy):
    out = []
    state = None
    o, b, t = [], [], []
    count = 0
    def marker(line, ch):
        return line == ch * 7 or line.startswith(ch * 7 + ' ')
    for line in lines:
        if state is None:
            if marker(line, '<'):
                state = 'o'
                o, b, t = [], [], []
            else:
                out.append(line)
        elif state == 'o' and marker(line, '|'):
            state = 'b'
        elif state in ('o', 'b') and line == '=' * 7:
            state = 't'
        elif state == 't' and marker(line, '>'):
            count += 1
            out.extend({'ours': o, 'theirs': t, 'union': o + t, 'base': b}[strategy])
            state = None
        else:
            {'o': o, 'b': b, 't': t}[state].append(line)
    if state is not None:
        return {'error': 'unterminated conflict', 'conflicts': count}
    return {'lines': out, 'conflicts': count}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z1', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z1'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b1', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b1'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4'], 'conflicts': 2})],
    2: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z2', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z2'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b2', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b2'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4'], 'conflicts': 3})],
    3: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z3', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z3'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b3', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b3'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4', '4'], 'conflicts': 4})],
    4: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z4', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z4'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b4', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b4'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4', '4', '4'], 'conflicts': 5})],
    5: [('take ours', [['h', '<<<<<<< ours', 'o1', '=======', 't1', '>>>>>>> theirs', 'z'], 'ours'], {'lines': ['h', 'o1', 'z'], 'conflicts': 1}), ('take theirs with base section', [['h', '<<<<<<< ours', 'o1', '||||||| base', 'b1', '=======', 't1', 't2', '>>>>>>> theirs'], 'theirs'], {'lines': ['h', 't1', 't2'], 'conflicts': 1}), ('union keeps both in order', [['<<<<<<< ours', 'x', 'y', '=======', 'y', 'z5', '>>>>>>> theirs'], 'union'], {'lines': ['x', 'y', 'y', 'z5'], 'conflicts': 1}), ('base strategy', [['<<<<<<<', 'o', '|||||||', 'b5', '=======', 't', '>>>>>>>'], 'base'], {'lines': ['b5'], 'conflicts': 1}), ('long marker-like content lines', [['<<<<<<<<<< banner', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs', '>>>>>>>>'], 'ours'], {'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>'], 'conflicts': 1}), ('marker prefix glued to text', [['<<<<<<<x', '<<<<<<< ours', 'a', '=======', 'b', '>>>>>>> theirs'], 'theirs'], {'lines': ['<<<<<<<x', 'b'], 'conflicts': 1}), ('setext underline inside ours', [['<<<<<<< ours', 'Title', '========', '=======', 'T', '>>>>>>> theirs'], 'ours'], {'lines': ['Title', '========'], 'conflicts': 1}), ('indented separator-like line', [['<<<<<<< ours', '  =======', 'k', '=======', 't', '>>>>>>> theirs'], 'union'], {'lines': ['  =======', 'k', 't'], 'conflicts': 1}), ('unterminated conflict is an error', [['a', '<<<<<<< ours', 'o', '=======', 't'], 'ours'], {'error': 'unterminated conflict', 'conflicts': 0}), ('two conflicts', [['<<<<<<< ours', '1', '=======', '2', '>>>>>>> theirs', 'mid', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs', '<<<<<<< ours', '3', '||||||| base', 'b', '=======', '4', '>>>>>>> theirs'], 'theirs'], {'lines': ['2', 'mid', '4', '4', '4', '4', '4'], 'conflicts': 6})],
}[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
take ours{'conflicts': 1, 'lines': ['h', 'o1', 'z']}{'conflicts': 1, 'lines': ['h', 'o1', 'z']}Passed
take theirs with base section{'conflicts': 1, 'lines': ['h', 't1', 't2']}{'conflicts': 1, 'lines': ['h', 't1', 't2']}Passed
union keeps both in order{'conflicts': 1, 'lines': ['x', 'y', 'y', 'z1']}{'conflicts': 1, 'lines': ['x', 'y', 'y', 'z1']}Passed
base strategy{'conflicts': 1, 'lines': ['b1']}{'conflicts': 1, 'lines': ['b1']}Passed
long marker-like content lines{'conflicts': 1, 'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>']}{'conflicts': 1, 'lines': ['<<<<<<<<<< banner', 'a', '>>>>>>>>']}Passed
marker prefix glued to text{'conflicts': 1, 'lines': ['<<<<<<<x', 'b']}{'conflicts': 1, 'lines': ['<<<<<<<x', 'b']}Passed
setext underline inside ours{'conflicts': 1, 'lines': ['Title', '========']}{'conflicts': 1, 'lines': ['Title', '========']}Passed
indented separator-like line{'conflicts': 1, 'lines': [' =======', 'k', 't']}{'conflicts': 1, 'lines': [' =======', 'k', 't']}Passed
unterminated conflict is an error{'conflicts': 0, 'error': 'unterminated conflict'}{'conflicts': 0, 'error': 'unterminated conflict'}Passed
two conflicts{'conflicts': 2, 'lines': ['2', 'mid', '4']}{'conflicts': 2, 'lines': ['2', 'mid', '4']}Passed

SHA-256 / 272d15778f4f1be1a425432da1c61043bb5fa4b9e954f6cb50c73a7260c1648a

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

Case digest / 5f55129fcae0a44035add463844336d6ba52862a121e6e08c0dfc5dbd168dae7