FAILURE MAP
← Case archive

FA-75151 / CRDT convergence / Open access

Formatting mark spans: contiguous bold characters are reported one by one · case 01

A single bold word is reported as many one-character spans.

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

ROOT CAUSE

Span output never extends the previous span when the next character is contiguous.

VERIFIED REPAIR

Extend the previous span when the current character starts exactly where it ends.

Unsuccessful approach: Also joining across a one-character gap reports a non-bold character as bold.

Case contract

A text of `length` characters receives ["bold"|"unbold", start, end, stamp] operations over half-open ranges clamped to the text. Each character takes the operation with the largest stamp (counter, replica) covering it; it is bold when that operation is "bold". Return maximal bold spans as [start, end) pairs in order.

Why this case matters

Rich-text CRDTs must resolve overlapping formatting operations identically regardless of arrival order.

1 / The failure

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

N = 1
observations = []
def solve(length, ops):
    best = [None] * length
    for kind, start, end, stamp in ops:
        st = tuple(stamp)
        for i in range(max(start, 0), min(end, length)):
            if best[i] is None or st > best[i][0]:
                best[i] = (st, kind)
    spans = []
    for i, b in enumerate(best):
        if b is not None and b[1] == 'bold':
            if False:
                spans[-1][1] = i + 1
            else:
                spans.append([i, i + 1])
    return spans
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('later unbold wins inside a bold range', [9, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [9, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [9, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [9, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [9, [['bold', 6, 9, [1, 'a']]]], [[6, 9]]), ('range end is exclusive', [9, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [9, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [9, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [9, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [9, [['bold', 8, 10, [1, 'a']], ['unbold', -1, 1, [2, 'a']]]], [[8, 9]])],
    2: [('later unbold wins inside a bold range', [10, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [10, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [10, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [10, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [10, [['bold', 7, 10, [1, 'a']]]], [[7, 10]]), ('range end is exclusive', [10, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [10, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [10, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [10, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [10, [['bold', 9, 12, [1, 'a']], ['unbold', -2, 1, [2, 'a']]]], [[9, 10]])],
    3: [('later unbold wins inside a bold range', [11, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [11, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [11, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [11, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [11, [['bold', 8, 11, [1, 'a']]]], [[8, 11]]), ('range end is exclusive', [11, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [11, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [11, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [11, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [11, [['bold', 10, 14, [1, 'a']], ['unbold', -3, 1, [2, 'a']]]], [[10, 11]])],
    4: [('later unbold wins inside a bold range', [12, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [12, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [12, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [12, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [12, [['bold', 9, 12, [1, 'a']]]], [[9, 12]]), ('range end is exclusive', [12, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [12, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [12, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [12, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [12, [['bold', 11, 16, [1, 'a']], ['unbold', -4, 1, [2, 'a']]]], [[11, 12]])],
    5: [('later unbold wins inside a bold range', [13, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [13, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [13, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [13, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [13, [['bold', 10, 13, [1, 'a']]]], [[10, 13]]), ('range end is exclusive', [13, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [13, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [13, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [13, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [13, [['bold', 12, 18, [1, 'a']], ['unbold', -5, 1, [2, 'a']]]], [[12, 13]])],
}[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
later unbold wins inside a bold range[[0, 1], [1, 2], [4, 5], [5, 6]][[0, 2], [4, 6]]Failed
arrival order does not matter[[0, 1], [1, 2], [4, 5], [5, 6]][[0, 2], [4, 6]]Failed
equal counters break by replica[[1, 2], [2, 3], [3, 4], [4, 5]][[1, 5]]Failed
equal counters other arrival[[1, 2], [2, 3], [3, 4], [4, 5]][[1, 5]]Failed
mark reaching the end of text[[6, 7], [7, 8], [8, 9]][[6, 9]]Failed
range end is exclusive[[2, 3], [5, 6]][[2, 3], [5, 6]]Passed
adjacent ranges join[[0, 1], [1, 2], [2, 3], [3, 4]][[0, 4]]Failed
one-character gap stays split[[0, 1], [1, 2], [3, 4], [4, 5]][[0, 2], [3, 5]]Failed
range starting before the text is clamped[[0, 1], [1, 2]][[0, 2]]Failed
range past the end is clamped[[8, 9]][[8, 9]]Passed

SHA-256 / 8cb9aec544c53e9414378cff11034052e6811c38da3b4631ed1543af55c996a5

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(length, ops):
    best = [None] * length
    for kind, start, end, stamp in ops:
        st = tuple(stamp)
        for i in range(max(start, 0), min(end, length)):
            if best[i] is None or st > best[i][0]:
                best[i] = (st, kind)
    spans = []
    for i, b in enumerate(best):
        if b is not None and b[1] == 'bold':
            if spans and spans[-1][1] >= i - 1:
                spans[-1][1] = i + 1
            else:
                spans.append([i, i + 1])
    return spans
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('later unbold wins inside a bold range', [9, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [9, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [9, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [9, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [9, [['bold', 6, 9, [1, 'a']]]], [[6, 9]]), ('range end is exclusive', [9, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [9, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [9, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [9, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [9, [['bold', 8, 10, [1, 'a']], ['unbold', -1, 1, [2, 'a']]]], [[8, 9]])],
    2: [('later unbold wins inside a bold range', [10, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [10, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [10, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [10, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [10, [['bold', 7, 10, [1, 'a']]]], [[7, 10]]), ('range end is exclusive', [10, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [10, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [10, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [10, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [10, [['bold', 9, 12, [1, 'a']], ['unbold', -2, 1, [2, 'a']]]], [[9, 10]])],
    3: [('later unbold wins inside a bold range', [11, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [11, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [11, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [11, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [11, [['bold', 8, 11, [1, 'a']]]], [[8, 11]]), ('range end is exclusive', [11, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [11, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [11, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [11, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [11, [['bold', 10, 14, [1, 'a']], ['unbold', -3, 1, [2, 'a']]]], [[10, 11]])],
    4: [('later unbold wins inside a bold range', [12, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [12, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [12, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [12, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [12, [['bold', 9, 12, [1, 'a']]]], [[9, 12]]), ('range end is exclusive', [12, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [12, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [12, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [12, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [12, [['bold', 11, 16, [1, 'a']], ['unbold', -4, 1, [2, 'a']]]], [[11, 12]])],
    5: [('later unbold wins inside a bold range', [13, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [13, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [13, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [13, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [13, [['bold', 10, 13, [1, 'a']]]], [[10, 13]]), ('range end is exclusive', [13, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [13, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [13, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [13, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [13, [['bold', 12, 18, [1, 'a']], ['unbold', -5, 1, [2, 'a']]]], [[12, 13]])],
}[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
later unbold wins inside a bold range[[0, 2], [4, 6]][[0, 2], [4, 6]]Passed
arrival order does not matter[[0, 2], [4, 6]][[0, 2], [4, 6]]Passed
equal counters break by replica[[1, 5]][[1, 5]]Passed
equal counters other arrival[[1, 5]][[1, 5]]Passed
mark reaching the end of text[[6, 9]][[6, 9]]Passed
range end is exclusive[[2, 3], [5, 6]][[2, 3], [5, 6]]Passed
adjacent ranges join[[0, 4]][[0, 4]]Passed
one-character gap stays split[[0, 5]][[0, 2], [3, 5]]Failed
range starting before the text is clamped[[0, 2]][[0, 2]]Passed
range past the end is clamped[[8, 9]][[8, 9]]Passed

SHA-256 / d90d0144b41eccc840e4b22da3142a1d21d1e4a86d67fecc3c66ea04a9b1de6d

3 / The verified repair

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

N = 1
observations = []
def solve(length, ops):
    best = [None] * length
    for kind, start, end, stamp in ops:
        st = tuple(stamp)
        for i in range(max(start, 0), min(end, length)):
            if best[i] is None or st > best[i][0]:
                best[i] = (st, kind)
    spans = []
    for i, b in enumerate(best):
        if b is not None and b[1] == 'bold':
            if spans and spans[-1][1] == i:
                spans[-1][1] = i + 1
            else:
                spans.append([i, i + 1])
    return spans
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = {
    1: [('later unbold wins inside a bold range', [9, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [9, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [9, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [9, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [9, [['bold', 6, 9, [1, 'a']]]], [[6, 9]]), ('range end is exclusive', [9, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [9, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [9, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [9, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [9, [['bold', 8, 10, [1, 'a']], ['unbold', -1, 1, [2, 'a']]]], [[8, 9]])],
    2: [('later unbold wins inside a bold range', [10, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [10, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [10, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [10, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [10, [['bold', 7, 10, [1, 'a']]]], [[7, 10]]), ('range end is exclusive', [10, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [10, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [10, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [10, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [10, [['bold', 9, 12, [1, 'a']], ['unbold', -2, 1, [2, 'a']]]], [[9, 10]])],
    3: [('later unbold wins inside a bold range', [11, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [11, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [11, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [11, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [11, [['bold', 8, 11, [1, 'a']]]], [[8, 11]]), ('range end is exclusive', [11, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [11, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [11, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [11, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [11, [['bold', 10, 14, [1, 'a']], ['unbold', -3, 1, [2, 'a']]]], [[10, 11]])],
    4: [('later unbold wins inside a bold range', [12, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [12, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [12, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [12, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [12, [['bold', 9, 12, [1, 'a']]]], [[9, 12]]), ('range end is exclusive', [12, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [12, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [12, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [12, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [12, [['bold', 11, 16, [1, 'a']], ['unbold', -4, 1, [2, 'a']]]], [[11, 12]])],
    5: [('later unbold wins inside a bold range', [13, [['bold', 0, 6, [1, 'a']], ['unbold', 2, 4, [2, 'b']]]], [[0, 2], [4, 6]]), ('arrival order does not matter', [13, [['unbold', 2, 4, [2, 'b']], ['bold', 0, 6, [1, 'a']]]], [[0, 2], [4, 6]]), ('equal counters break by replica', [13, [['bold', 1, 5, [3, 'b']], ['unbold', 3, 7, [3, 'a']]]], [[1, 5]]), ('equal counters other arrival', [13, [['unbold', 3, 7, [3, 'a']], ['bold', 1, 5, [3, 'b']]]], [[1, 5]]), ('mark reaching the end of text', [13, [['bold', 10, 13, [1, 'a']]]], [[10, 13]]), ('range end is exclusive', [13, [['bold', 2, 3, [1, 'a']], ['bold', 5, 6, [2, 'a']]]], [[2, 3], [5, 6]]), ('adjacent ranges join', [13, [['bold', 0, 2, [1, 'a']], ['bold', 2, 4, [1, 'b']]]], [[0, 4]]), ('one-character gap stays split', [13, [['bold', 0, 2, [1, 'a']], ['bold', 3, 5, [1, 'b']]]], [[0, 2], [3, 5]]), ('range starting before the text is clamped', [13, [['bold', -2, 2, [1, 'a']]]], [[0, 2]]), ('range past the end is clamped', [13, [['bold', 12, 18, [1, 'a']], ['unbold', -5, 1, [2, 'a']]]], [[12, 13]])],
}[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
later unbold wins inside a bold range[[0, 2], [4, 6]][[0, 2], [4, 6]]Passed
arrival order does not matter[[0, 2], [4, 6]][[0, 2], [4, 6]]Passed
equal counters break by replica[[1, 5]][[1, 5]]Passed
equal counters other arrival[[1, 5]][[1, 5]]Passed
mark reaching the end of text[[6, 9]][[6, 9]]Passed
range end is exclusive[[2, 3], [5, 6]][[2, 3], [5, 6]]Passed
adjacent ranges join[[0, 4]][[0, 4]]Passed
one-character gap stays split[[0, 2], [3, 5]][[0, 2], [3, 5]]Passed
range starting before the text is clamped[[0, 2]][[0, 2]]Passed
range past the end is clamped[[8, 9]][[8, 9]]Passed

SHA-256 / 21c8eaa45830efc45a72b6b5b3a268b3a1405e8bbf2c11fe819a0647666b0375

Verification & scope

A deterministic, bounded teaching model of one replicated data type with stipulated operation and merge rules; it is not a production CRDT library and makes no claim of conformance to any specific published design. 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:03.593415+00:00.

Case digest / 4b20ebc2065708ad0864d0a84b2bcf5acd614c37f8e246634c69fabf36131861