FAILURE MAP
← Case archive

FA-80791 / Bidirectional text layout / Open access

Visual run list for shaping: run length accumulation · case 01

Runs report lengths one short, dropping their last glyph.

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

ROOT CAUSE

The run length is recomputed from the start index without counting the current character.

VERIFIED REPAIR

Increment the run length for each character appended.

Unsuccessful approach: Storing the absolute index as the length is wrong for runs not at the line start.

Case contract

Input resolved levels of a line. Group maximal equal-level runs [logical start, length, level]; reorder whole runs from the highest level down to the lowest odd level by reversing sequences of runs at or above the level. Return [[start, length, "rtl"|"ltr"]] in visual order.

Why this case matters

Mixed right-to-left and left-to-right text must resolve levels and visual order exactly, or words, numbers and carets land in the wrong place.

1 / The failure

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

N = 1
observations = []
def solve(x):
    levels = x
    n = len(levels)
    runs = []
    for i in range(n):
        if runs and runs[-1][2] == levels[i]:
            runs[-1][1] = i - runs[-1][0]
        else:
            runs.append([i, 1, levels[i]])
    if not runs:
        return []
    odd = [r[2] for r in runs if r[2] % 2]
    if odd:
        for lev in range(max(r[2] for r in runs), min(odd) - 1, -1):
            out, i = [], 0
            while i < len(runs):
                if runs[i][2] >= lev:
                    j = i
                    while j < len(runs) and runs[j][2] >= lev:
                        j += 1
                    out.extend(runs[i:j][::-1])
                    i = j
                else:
                    out.append(runs[i])
                    i += 1
            runs = out
    return [[s, ln, 'rtl' if lv % 2 else 'ltr'] for s, ln, lv in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1, 0, 0, 0], [[2, 5, 'rtl'], [0, 2, 'ltr'], [7, 3, 'ltr']]), ('regression: run length accumulation', [4, 3, 3, 2, 2, 4], [[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 2, 'ltr'], [5, 1, 'ltr']]), ('regression: run length accumulation', [1, 1, 2, 4, 4, 4, 2, 2, 2, 2, 4, 4], [[2, 1, 'ltr'], [3, 3, 'ltr'], [6, 4, 'ltr'], [10, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']])], [('regression: run length accumulation', [2, 2, 2, 3, 3, 3, 3, 2], [[0, 3, 'ltr'], [3, 4, 'rtl'], [7, 1, 'ltr']]), ('regression: run length accumulation', [2, 2, 1], [[2, 1, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [1, 1, 1, 1, 1, 1, 1], [[0, 7, 'rtl']]), ('regression: run length accumulation', [0, 0, 0], [[0, 3, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [1], [[0, 1, 'rtl']]), ('control layout', [3], [[0, 1, 'rtl']])], [('regression: run length accumulation', [1, 1], [[0, 2, 'rtl']]), ('regression: run length accumulation', [1, 1, 3, 1, 1, 1, 1, 2, 2], [[7, 2, 'ltr'], [3, 4, 'rtl'], [2, 1, 'rtl'], [0, 2, 'rtl']]), ('regression: run length accumulation', [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [[0, 6, 'ltr'], [6, 4, 'rtl']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1], [[4, 2, 'rtl'], [0, 4, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2, 3], [[0, 1, 'ltr'], [1, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']])], [('regression: run length accumulation', [3, 3, 3, 0, 0, 0, 0, 0, 0], [[0, 3, 'rtl'], [3, 6, 'ltr']]), ('regression: run length accumulation', [1, 1, 1], [[0, 3, 'rtl']]), ('regression: run length accumulation', [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1], [[0, 2, 'ltr'], [3, 8, 'rtl'], [2, 1, 'rtl']]), ('regression: run length accumulation', [2, 2, 0, 0, 0, 0, 1, 1, 0], [[0, 2, 'ltr'], [2, 4, 'ltr'], [6, 2, 'rtl'], [8, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']]), ('control layout', [1], [[0, 1, 'rtl']])], [('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1], [[2, 5, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 1, 2], [[11, 1, 'ltr'], [10, 1, 'rtl'], [8, 2, 'rtl'], [4, 4, 'rtl'], [0, 4, 'ltr']]), ('regression: run length accumulation', [1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [[1, 2, 'rtl'], [0, 1, 'rtl'], [3, 9, 'ltr']]), ('regression: run length accumulation', [2, 4, 4, 1, 1, 1, 1, 2], [[7, 1, 'ltr'], [3, 4, 'rtl'], [0, 1, 'ltr'], [1, 2, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']])]]
for label, args, expected in fixtures[N - 1]:
    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
LTR number inside RTL[[4, 1, 'rtl'], [2, 1, 'ltr'], [0, 1, 'rtl']][[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]Failed
regression: run length accumulation[[2, 4, 'rtl'], [0, 1, 'ltr'], [7, 2, 'ltr']][[2, 5, 'rtl'], [0, 2, 'ltr'], [7, 3, 'ltr']]Failed
regression: run length accumulation[[1, 1, 'rtl'], [0, 1, 'ltr'], [3, 1, 'ltr'], [5, 1, 'ltr']][[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 2, 'ltr'], [5, 1, 'ltr']]Failed
regression: run length accumulation[[2, 1, 'ltr'], [3, 2, 'ltr'], [6, 3, 'ltr'], [10, 1, 'ltr'], [0, 1, 'rtl']][[2, 1, 'ltr'], [3, 3, 'ltr'], [6, 4, 'ltr'], [10, 2, 'ltr'], [0, 2, 'rtl']]Failed
lowest odd is three[[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']][[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]Passed
control layout[[0, 1, 'rtl']][[0, 1, 'rtl']]Passed
control layout[[0, 1, 'ltr']][[0, 1, 'ltr']]Passed
control layout[[0, 1, 'ltr']][[0, 1, 'ltr']]Passed

SHA-256 / 9935ace46057cbbd32598677aba2a8d1fd284a430e47ffa1b800fe3dfe0094d9

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    levels = x
    n = len(levels)
    runs = []
    for i in range(n):
        if runs and runs[-1][2] == levels[i]:
            runs[-1][1] = i
        else:
            runs.append([i, 1, levels[i]])
    if not runs:
        return []
    odd = [r[2] for r in runs if r[2] % 2]
    if odd:
        for lev in range(max(r[2] for r in runs), min(odd) - 1, -1):
            out, i = [], 0
            while i < len(runs):
                if runs[i][2] >= lev:
                    j = i
                    while j < len(runs) and runs[j][2] >= lev:
                        j += 1
                    out.extend(runs[i:j][::-1])
                    i = j
                else:
                    out.append(runs[i])
                    i += 1
            runs = out
    return [[s, ln, 'rtl' if lv % 2 else 'ltr'] for s, ln, lv in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1, 0, 0, 0], [[2, 5, 'rtl'], [0, 2, 'ltr'], [7, 3, 'ltr']]), ('regression: run length accumulation', [4, 3, 3, 2, 2, 4], [[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 2, 'ltr'], [5, 1, 'ltr']]), ('regression: run length accumulation', [1, 1, 2, 4, 4, 4, 2, 2, 2, 2, 4, 4], [[2, 1, 'ltr'], [3, 3, 'ltr'], [6, 4, 'ltr'], [10, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']])], [('regression: run length accumulation', [2, 2, 2, 3, 3, 3, 3, 2], [[0, 3, 'ltr'], [3, 4, 'rtl'], [7, 1, 'ltr']]), ('regression: run length accumulation', [2, 2, 1], [[2, 1, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [1, 1, 1, 1, 1, 1, 1], [[0, 7, 'rtl']]), ('regression: run length accumulation', [0, 0, 0], [[0, 3, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [1], [[0, 1, 'rtl']]), ('control layout', [3], [[0, 1, 'rtl']])], [('regression: run length accumulation', [1, 1], [[0, 2, 'rtl']]), ('regression: run length accumulation', [1, 1, 3, 1, 1, 1, 1, 2, 2], [[7, 2, 'ltr'], [3, 4, 'rtl'], [2, 1, 'rtl'], [0, 2, 'rtl']]), ('regression: run length accumulation', [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [[0, 6, 'ltr'], [6, 4, 'rtl']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1], [[4, 2, 'rtl'], [0, 4, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2, 3], [[0, 1, 'ltr'], [1, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']])], [('regression: run length accumulation', [3, 3, 3, 0, 0, 0, 0, 0, 0], [[0, 3, 'rtl'], [3, 6, 'ltr']]), ('regression: run length accumulation', [1, 1, 1], [[0, 3, 'rtl']]), ('regression: run length accumulation', [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1], [[0, 2, 'ltr'], [3, 8, 'rtl'], [2, 1, 'rtl']]), ('regression: run length accumulation', [2, 2, 0, 0, 0, 0, 1, 1, 0], [[0, 2, 'ltr'], [2, 4, 'ltr'], [6, 2, 'rtl'], [8, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']]), ('control layout', [1], [[0, 1, 'rtl']])], [('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1], [[2, 5, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 1, 2], [[11, 1, 'ltr'], [10, 1, 'rtl'], [8, 2, 'rtl'], [4, 4, 'rtl'], [0, 4, 'ltr']]), ('regression: run length accumulation', [1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [[1, 2, 'rtl'], [0, 1, 'rtl'], [3, 9, 'ltr']]), ('regression: run length accumulation', [2, 4, 4, 1, 1, 1, 1, 2], [[7, 1, 'ltr'], [3, 4, 'rtl'], [0, 1, 'ltr'], [1, 2, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']])]]
for label, args, expected in fixtures[N - 1]:
    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
LTR number inside RTL[[4, 1, 'rtl'], [2, 3, 'ltr'], [0, 1, 'rtl']][[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]Failed
regression: run length accumulation[[2, 6, 'rtl'], [0, 1, 'ltr'], [7, 9, 'ltr']][[2, 5, 'rtl'], [0, 2, 'ltr'], [7, 3, 'ltr']]Failed
regression: run length accumulation[[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 4, 'ltr'], [5, 1, 'ltr']][[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 2, 'ltr'], [5, 1, 'ltr']]Failed
regression: run length accumulation[[2, 1, 'ltr'], [3, 5, 'ltr'], [6, 9, 'ltr'], [10, 11, 'ltr'], [0, 1, 'rtl']][[2, 1, 'ltr'], [3, 3, 'ltr'], [6, 4, 'ltr'], [10, 2, 'ltr'], [0, 2, 'rtl']]Failed
lowest odd is three[[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']][[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]Passed
control layout[[0, 1, 'rtl']][[0, 1, 'rtl']]Passed
control layout[[0, 1, 'ltr']][[0, 1, 'ltr']]Passed
control layout[[0, 1, 'ltr']][[0, 1, 'ltr']]Passed

SHA-256 / f2888e1a75153ed53e9909dcde776b8c9eb1c619ad785b8d2308aff28610cc8f

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    levels = x
    n = len(levels)
    runs = []
    for i in range(n):
        if runs and runs[-1][2] == levels[i]:
            runs[-1][1] += 1
        else:
            runs.append([i, 1, levels[i]])
    if not runs:
        return []
    odd = [r[2] for r in runs if r[2] % 2]
    if odd:
        for lev in range(max(r[2] for r in runs), min(odd) - 1, -1):
            out, i = [], 0
            while i < len(runs):
                if runs[i][2] >= lev:
                    j = i
                    while j < len(runs) and runs[j][2] >= lev:
                        j += 1
                    out.extend(runs[i:j][::-1])
                    i = j
                else:
                    out.append(runs[i])
                    i += 1
            runs = out
    return [[s, ln, 'rtl' if lv % 2 else 'ltr'] for s, ln, lv in runs]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1, 0, 0, 0], [[2, 5, 'rtl'], [0, 2, 'ltr'], [7, 3, 'ltr']]), ('regression: run length accumulation', [4, 3, 3, 2, 2, 4], [[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 2, 'ltr'], [5, 1, 'ltr']]), ('regression: run length accumulation', [1, 1, 2, 4, 4, 4, 2, 2, 2, 2, 4, 4], [[2, 1, 'ltr'], [3, 3, 'ltr'], [6, 4, 'ltr'], [10, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']])], [('regression: run length accumulation', [2, 2, 2, 3, 3, 3, 3, 2], [[0, 3, 'ltr'], [3, 4, 'rtl'], [7, 1, 'ltr']]), ('regression: run length accumulation', [2, 2, 1], [[2, 1, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [1, 1, 1, 1, 1, 1, 1], [[0, 7, 'rtl']]), ('regression: run length accumulation', [0, 0, 0], [[0, 3, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [1], [[0, 1, 'rtl']]), ('control layout', [3], [[0, 1, 'rtl']])], [('regression: run length accumulation', [1, 1], [[0, 2, 'rtl']]), ('regression: run length accumulation', [1, 1, 3, 1, 1, 1, 1, 2, 2], [[7, 2, 'ltr'], [3, 4, 'rtl'], [2, 1, 'rtl'], [0, 2, 'rtl']]), ('regression: run length accumulation', [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [[0, 6, 'ltr'], [6, 4, 'rtl']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1], [[4, 2, 'rtl'], [0, 4, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2, 3], [[0, 1, 'ltr'], [1, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']])], [('regression: run length accumulation', [3, 3, 3, 0, 0, 0, 0, 0, 0], [[0, 3, 'rtl'], [3, 6, 'ltr']]), ('regression: run length accumulation', [1, 1, 1], [[0, 3, 'rtl']]), ('regression: run length accumulation', [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1], [[0, 2, 'ltr'], [3, 8, 'rtl'], [2, 1, 'rtl']]), ('regression: run length accumulation', [2, 2, 0, 0, 0, 0, 1, 1, 0], [[0, 2, 'ltr'], [2, 4, 'ltr'], [6, 2, 'rtl'], [8, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']]), ('control layout', [1], [[0, 1, 'rtl']])], [('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1], [[2, 5, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 1, 2], [[11, 1, 'ltr'], [10, 1, 'rtl'], [8, 2, 'rtl'], [4, 4, 'rtl'], [0, 4, 'ltr']]), ('regression: run length accumulation', [1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [[1, 2, 'rtl'], [0, 1, 'rtl'], [3, 9, 'ltr']]), ('regression: run length accumulation', [2, 4, 4, 1, 1, 1, 1, 2], [[7, 1, 'ltr'], [3, 4, 'rtl'], [0, 1, 'ltr'], [1, 2, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']])]]
for label, args, expected in fixtures[N - 1]:
    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
LTR number inside RTL[[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']][[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]Passed
regression: run length accumulation[[2, 5, 'rtl'], [0, 2, 'ltr'], [7, 3, 'ltr']][[2, 5, 'rtl'], [0, 2, 'ltr'], [7, 3, 'ltr']]Passed
regression: run length accumulation[[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 2, 'ltr'], [5, 1, 'ltr']][[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 2, 'ltr'], [5, 1, 'ltr']]Passed
regression: run length accumulation[[2, 1, 'ltr'], [3, 3, 'ltr'], [6, 4, 'ltr'], [10, 2, 'ltr'], [0, 2, 'rtl']][[2, 1, 'ltr'], [3, 3, 'ltr'], [6, 4, 'ltr'], [10, 2, 'ltr'], [0, 2, 'rtl']]Passed
lowest odd is three[[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']][[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]Passed
control layout[[0, 1, 'rtl']][[0, 1, 'rtl']]Passed
control layout[[0, 1, 'ltr']][[0, 1, 'ltr']]Passed
control layout[[0, 1, 'ltr']][[0, 1, 'ltr']]Passed

SHA-256 / a0cac67c287f9b2f7db28fa80651cd25410fdfe66d479f813e1de51f981f7290

Verification & scope

A deterministic toy bidi model over stipulated class labels and integer levels; it is inspired by, but does not claim conformance to, any published algorithm. 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:57.096746+00:00.

Case digest / a95ecb64be3ce41779f1d7fd2db74a63823ffa49240d679ede37682cb12ca63e