FAILURE MAP
← Case archive

FA-75141 / CRDT convergence / Open access

Formatting mark spans: the range end is treated as inclusive · case 01

Formatting bleeds onto the character just after the selected range.

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

ROOT CAUSE

The covered range includes the end offset, although ranges are half-open.

VERIFIED REPAIR

Cover characters from the clamped start up to but excluding the end offset.

Unsuccessful approach: Clamping to length minus one fixes interior ranges but drops the final character of marks that reach the end of the text.

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 + 1, 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], [5, 7]][[0, 2], [4, 6]]Failed
arrival order does not matter[[0, 2], [5, 7]][[0, 2], [4, 6]]Failed
equal counters break by replica[[1, 6]][[1, 5]]Failed
equal counters other arrival[[1, 6]][[1, 5]]Failed
mark reaching the end of text[[6, 9]][[6, 9]]Passed
range end is exclusive[[2, 4], [5, 7]][[2, 3], [5, 6]]Failed
adjacent ranges join[[0, 5]][[0, 4]]Failed
one-character gap stays split[[0, 6]][[0, 2], [3, 5]]Failed
range starting before the text is clamped[[0, 3]][[0, 2]]Failed
range past the end is clamped[[8, 9]][[8, 9]]Passed

SHA-256 / e04419624598cc78e3d736d1552aa0e77b6719de031f1ee3f33fed8792c2fb83

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 - 1)):
            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, 8]][[6, 9]]Failed
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]]Failed

SHA-256 / 67fcec52acf2bb778219c29e6ca87c4361d01d879bb6abc896a64f07a8ce6eef

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

Case digest / f26a20f7e3edb6ae403eda26a2751c6cb5d8d3c2aefb853f95f9aa2985ec2457