FAILURE MAP
← Case archive

FA-80461 / Bidirectional text layout / Open access

Implicit level runs: run end bookkeeping · case 01

Level runs report ends one short.

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

ROOT CAUSE

Extending a run stores the current index instead of one past it.

THE FAILURE

Extending a run stores the current index instead of one past it.

Unsuccessful approach: Storing i + 2 overshoots.

Case contract

Input [resolved classes L/R/EN/AN, embedding levels]. At even levels R goes up one and AN/EN up two; at odd levels L, EN and AN go up one. Return level runs [start, end exclusive, level] of equal final levels.

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):
    types, levels = x
    out = []
    for c, lv in zip(types, levels):
        if lv % 2 == 0:
            if c == 'R':
                out.append(lv + 1)
            elif c in ('AN', 'EN'):
                out.append(lv + 2)
            else:
                out.append(lv)
        else:
            if c in ('L', 'EN', 'AN'):
                out.append(lv + 1)
            else:
                out.append(lv)
    runs = []
    for i, lv in enumerate(out):
        if runs and runs[-1][2] == lv:
            runs[-1][1] = i
        else:
            runs.append([i, i + 1, lv])
    return runs
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: run end bookkeeping', [['AN', 'EN', 'AN', 'EN', 'L', 'EN', 'EN', 'EN', 'R', 'EN', 'L'], [3, 3, 4, 4, 4, 1, 1, 1, 1, 2, 2]], [[0, 2, 4], [2, 4, 6], [4, 5, 4], [5, 8, 2], [8, 9, 1], [9, 10, 4], [10, 11, 2]]), ('regression: run end bookkeeping', [['L', 'EN', 'R', 'L', 'L', 'EN', 'EN', 'EN', 'L', 'AN', 'L'], [3, 3, 3, 0, 0, 0, 3, 1, 1, 1, 1]], [[0, 2, 4], [2, 3, 3], [3, 5, 0], [5, 6, 2], [6, 7, 4], [7, 11, 2]]), ('regression: run end bookkeeping', [['EN', 'L', 'AN', 'L', 'EN', 'EN', 'L'], [1, 1, 1, 2, 2, 4, 4]], [[0, 4, 2], [4, 5, 4], [5, 6, 6], [6, 7, 4]]), ('regression: run end bookkeeping', [['L', 'L', 'EN', 'R', 'EN'], [3, 3, 1, 2, 2]], [[0, 2, 4], [2, 3, 2], [3, 4, 3], [4, 5, 4]]), ('number in RTL text', [['R', 'AN', 'R'], [1, 1, 1]], [[0, 1, 1], [1, 2, 2], [2, 3, 1]]), ('level two embedding', [['R', 'L'], [2, 2]], [[0, 1, 3], [1, 2, 2]]), ('control layout', [['R'], [3]], [[0, 1, 3]]), ('control layout', [['L', 'EN'], [1, 4]], [[0, 1, 2], [1, 2, 6]])], [('regression: run end bookkeeping', [['R', 'AN', 'EN', 'EN'], [1, 1, 1, 1]], [[0, 1, 1], [1, 4, 2]]), ('regression: run end bookkeeping', [['L', 'R', 'R', 'AN'], [2, 3, 3, 3]], [[0, 1, 2], [1, 3, 3], [3, 4, 4]]), ('regression: run end bookkeeping', [['EN', 'EN', 'R', 'AN', 'R', 'R', 'R', 'EN', 'R', 'L'], [2, 0, 0, 0, 3, 3, 3, 3, 2, 2]], [[0, 1, 4], [1, 2, 2], [2, 3, 1], [3, 4, 2], [4, 7, 3], [7, 8, 4], [8, 9, 3], [9, 10, 2]]), ('regression: run end bookkeeping', [['EN', 'L', 'L', 'AN', 'L', 'R', 'EN', 'L'], [0, 0, 0, 1, 1, 1, 1, 0]], [[0, 1, 2], [1, 3, 0], [3, 5, 2], [5, 6, 1], [6, 7, 2], [7, 8, 0]]), ('number in LTR text', [['L', 'EN', 'L'], [0, 0, 0]], [[0, 1, 0], [1, 2, 2], [2, 3, 0]]), ('level two embedding', [['R', 'L'], [2, 2]], [[0, 1, 3], [1, 2, 2]]), ('control layout', [['AN', 'R'], [1, 1]], [[0, 1, 2], [1, 2, 1]]), ('control layout', [['R'], [4]], [[0, 1, 5]])], [('regression: run end bookkeeping', [['AN', 'L', 'R', 'EN', 'AN', 'AN', 'EN', 'AN', 'R'], [2, 2, 2, 2, 0, 0, 1, 2, 0]], [[0, 1, 4], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 7, 2], [7, 8, 4], [8, 9, 1]]), ('regression: run end bookkeeping', [['R', 'EN', 'L', 'EN', 'L', 'L', 'R', 'AN', 'R', 'R', 'EN'], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]], [[0, 1, 3], [1, 2, 4], [2, 3, 2], [3, 4, 4], [4, 6, 2], [6, 7, 3], [7, 8, 4], [8, 10, 3], [10, 11, 2]]), ('regression: run end bookkeeping', [['R', 'AN', 'L', 'R', 'L', 'L', 'AN', 'AN'], [0, 0, 0, 0, 0, 0, 0, 0]], [[0, 1, 1], [1, 2, 2], [2, 3, 0], [3, 4, 1], [4, 6, 0], [6, 8, 2]]), ('regression: run end bookkeeping', [['AN', 'EN', 'AN'], [1, 1, 1]], [[0, 3, 2]]), ('number in LTR text', [['L', 'EN', 'L'], [0, 0, 0]], [[0, 1, 0], [1, 2, 2], [2, 3, 0]]), ('number in RTL text', [['R', 'AN', 'R'], [1, 1, 1]], [[0, 1, 1], [1, 2, 2], [2, 3, 1]]), ('control layout', [['AN', 'EN', 'EN', 'AN', 'AN'], [2, 1, 3, 1, 2]], [[0, 1, 4], [1, 2, 2], [2, 3, 4], [3, 4, 2], [4, 5, 4]]), ('control layout', [['L', 'R'], [2, 2]], [[0, 1, 2], [1, 2, 3]])], [('regression: run end bookkeeping', [['L', 'R', 'L', 'R', 'L', 'EN', 'AN', 'R', 'EN', 'L'], [3, 3, 2, 2, 2, 4, 4, 4, 4, 4]], [[0, 1, 4], [1, 2, 3], [2, 3, 2], [3, 4, 3], [4, 5, 2], [5, 7, 6], [7, 8, 5], [8, 9, 6], [9, 10, 4]]), ('regression: run end bookkeeping', [['R', 'AN', 'L', 'AN', 'EN', 'AN', 'AN', 'L', 'AN', 'L', 'L'], [0, 0, 0, 2, 1, 1, 0, 0, 0, 0, 1]], [[0, 1, 1], [1, 2, 2], [2, 3, 0], [3, 4, 4], [4, 7, 2], [7, 8, 0], [8, 9, 2], [9, 10, 0], [10, 11, 2]]), ('regression: run end bookkeeping', [['L', 'EN', 'L', 'R', 'EN'], [3, 3, 3, 3, 1]], [[0, 3, 4], [3, 4, 3], [4, 5, 2]]), ('regression: run end bookkeeping', [['L', 'R', 'EN', 'L', 'L', 'EN', 'L'], [3, 3, 1, 1, 1, 1, 1]], [[0, 1, 4], [1, 2, 3], [2, 7, 2]]), ('level two embedding', [['R', 'L'], [2, 2]], [[0, 1, 3], [1, 2, 2]]), ('number in LTR text', [['L', 'EN', 'L'], [0, 0, 0]], [[0, 1, 0], [1, 2, 2], [2, 3, 0]]), ('control layout', [['R'], [2]], [[0, 1, 3]]), ('control layout', [['L', 'R'], [2, 1]], [[0, 1, 2], [1, 2, 1]])], [('regression: run end bookkeeping', [['EN', 'L', 'AN', 'L', 'EN', 'EN', 'L'], [1, 1, 1, 2, 2, 4, 4]], [[0, 4, 2], [4, 5, 4], [5, 6, 6], [6, 7, 4]]), ('regression: run end bookkeeping', [['AN', 'AN'], [0, 0]], [[0, 2, 2]]), ('regression: run end bookkeeping', [['L', 'L', 'AN', 'L', 'R', 'AN', 'L', 'AN'], [1, 1, 1, 1, 4, 4, 4, 4]], [[0, 4, 2], [4, 5, 5], [5, 6, 6], [6, 7, 4], [7, 8, 6]]), ('regression: run end bookkeeping', [['L', 'R', 'EN', 'R', 'EN', 'L', 'R', 'R', 'AN', 'EN', 'R', 'R'], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1]], [[0, 1, 2], [1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 6, 2], [6, 8, 1], [8, 9, 2], [9, 10, 4], [10, 12, 1]]), ('level two embedding', [['R', 'L'], [2, 2]], [[0, 1, 3], [1, 2, 2]]), ('number in RTL text', [['R', 'AN', 'R'], [1, 1, 1]], [[0, 1, 1], [1, 2, 2], [2, 3, 1]]), ('control layout', [['R', 'R', 'AN'], [1, 2, 2]], [[0, 1, 1], [1, 2, 3], [2, 3, 4]]), ('control layout', [['AN', 'R'], [2, 2]], [[0, 1, 4], [1, 2, 3]])]]
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
regression: run end bookkeeping[[0, 1, 4], [2, 3, 6], [4, 5, 4], [5, 7, 2], [8, 9, 1], [9, 10, 4], [10, 11, 2]][[0, 2, 4], [2, 4, 6], [4, 5, 4], [5, 8, 2], [8, 9, 1], [9, 10, 4], [10, 11, 2]]Failed
regression: run end bookkeeping[[0, 1, 4], [2, 3, 3], [3, 4, 0], [5, 6, 2], [6, 7, 4], [7, 10, 2]][[0, 2, 4], [2, 3, 3], [3, 5, 0], [5, 6, 2], [6, 7, 4], [7, 11, 2]]Failed
regression: run end bookkeeping[[0, 3, 2], [4, 5, 4], [5, 6, 6], [6, 7, 4]][[0, 4, 2], [4, 5, 4], [5, 6, 6], [6, 7, 4]]Failed
regression: run end bookkeeping[[0, 1, 4], [2, 3, 2], [3, 4, 3], [4, 5, 4]][[0, 2, 4], [2, 3, 2], [3, 4, 3], [4, 5, 4]]Failed
number in RTL text[[0, 1, 1], [1, 2, 2], [2, 3, 1]][[0, 1, 1], [1, 2, 2], [2, 3, 1]]Passed
level two embedding[[0, 1, 3], [1, 2, 2]][[0, 1, 3], [1, 2, 2]]Passed
control layout[[0, 1, 3]][[0, 1, 3]]Passed
control layout[[0, 1, 2], [1, 2, 6]][[0, 1, 2], [1, 2, 6]]Passed

SHA-256 / b5b045f0f51d067da07f0193987d8df6c23e743ccfe932bb9cc719a9fc21632d

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    types, levels = x
    out = []
    for c, lv in zip(types, levels):
        if lv % 2 == 0:
            if c == 'R':
                out.append(lv + 1)
            elif c in ('AN', 'EN'):
                out.append(lv + 2)
            else:
                out.append(lv)
        else:
            if c in ('L', 'EN', 'AN'):
                out.append(lv + 1)
            else:
                out.append(lv)
    runs = []
    for i, lv in enumerate(out):
        if runs and runs[-1][2] == lv:
            runs[-1][1] = i + 2
        else:
            runs.append([i, i + 1, lv])
    return runs
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: run end bookkeeping', [['AN', 'EN', 'AN', 'EN', 'L', 'EN', 'EN', 'EN', 'R', 'EN', 'L'], [3, 3, 4, 4, 4, 1, 1, 1, 1, 2, 2]], [[0, 2, 4], [2, 4, 6], [4, 5, 4], [5, 8, 2], [8, 9, 1], [9, 10, 4], [10, 11, 2]]), ('regression: run end bookkeeping', [['L', 'EN', 'R', 'L', 'L', 'EN', 'EN', 'EN', 'L', 'AN', 'L'], [3, 3, 3, 0, 0, 0, 3, 1, 1, 1, 1]], [[0, 2, 4], [2, 3, 3], [3, 5, 0], [5, 6, 2], [6, 7, 4], [7, 11, 2]]), ('regression: run end bookkeeping', [['EN', 'L', 'AN', 'L', 'EN', 'EN', 'L'], [1, 1, 1, 2, 2, 4, 4]], [[0, 4, 2], [4, 5, 4], [5, 6, 6], [6, 7, 4]]), ('regression: run end bookkeeping', [['L', 'L', 'EN', 'R', 'EN'], [3, 3, 1, 2, 2]], [[0, 2, 4], [2, 3, 2], [3, 4, 3], [4, 5, 4]]), ('number in RTL text', [['R', 'AN', 'R'], [1, 1, 1]], [[0, 1, 1], [1, 2, 2], [2, 3, 1]]), ('level two embedding', [['R', 'L'], [2, 2]], [[0, 1, 3], [1, 2, 2]]), ('control layout', [['R'], [3]], [[0, 1, 3]]), ('control layout', [['L', 'EN'], [1, 4]], [[0, 1, 2], [1, 2, 6]])], [('regression: run end bookkeeping', [['R', 'AN', 'EN', 'EN'], [1, 1, 1, 1]], [[0, 1, 1], [1, 4, 2]]), ('regression: run end bookkeeping', [['L', 'R', 'R', 'AN'], [2, 3, 3, 3]], [[0, 1, 2], [1, 3, 3], [3, 4, 4]]), ('regression: run end bookkeeping', [['EN', 'EN', 'R', 'AN', 'R', 'R', 'R', 'EN', 'R', 'L'], [2, 0, 0, 0, 3, 3, 3, 3, 2, 2]], [[0, 1, 4], [1, 2, 2], [2, 3, 1], [3, 4, 2], [4, 7, 3], [7, 8, 4], [8, 9, 3], [9, 10, 2]]), ('regression: run end bookkeeping', [['EN', 'L', 'L', 'AN', 'L', 'R', 'EN', 'L'], [0, 0, 0, 1, 1, 1, 1, 0]], [[0, 1, 2], [1, 3, 0], [3, 5, 2], [5, 6, 1], [6, 7, 2], [7, 8, 0]]), ('number in LTR text', [['L', 'EN', 'L'], [0, 0, 0]], [[0, 1, 0], [1, 2, 2], [2, 3, 0]]), ('level two embedding', [['R', 'L'], [2, 2]], [[0, 1, 3], [1, 2, 2]]), ('control layout', [['AN', 'R'], [1, 1]], [[0, 1, 2], [1, 2, 1]]), ('control layout', [['R'], [4]], [[0, 1, 5]])], [('regression: run end bookkeeping', [['AN', 'L', 'R', 'EN', 'AN', 'AN', 'EN', 'AN', 'R'], [2, 2, 2, 2, 0, 0, 1, 2, 0]], [[0, 1, 4], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 7, 2], [7, 8, 4], [8, 9, 1]]), ('regression: run end bookkeeping', [['R', 'EN', 'L', 'EN', 'L', 'L', 'R', 'AN', 'R', 'R', 'EN'], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]], [[0, 1, 3], [1, 2, 4], [2, 3, 2], [3, 4, 4], [4, 6, 2], [6, 7, 3], [7, 8, 4], [8, 10, 3], [10, 11, 2]]), ('regression: run end bookkeeping', [['R', 'AN', 'L', 'R', 'L', 'L', 'AN', 'AN'], [0, 0, 0, 0, 0, 0, 0, 0]], [[0, 1, 1], [1, 2, 2], [2, 3, 0], [3, 4, 1], [4, 6, 0], [6, 8, 2]]), ('regression: run end bookkeeping', [['AN', 'EN', 'AN'], [1, 1, 1]], [[0, 3, 2]]), ('number in LTR text', [['L', 'EN', 'L'], [0, 0, 0]], [[0, 1, 0], [1, 2, 2], [2, 3, 0]]), ('number in RTL text', [['R', 'AN', 'R'], [1, 1, 1]], [[0, 1, 1], [1, 2, 2], [2, 3, 1]]), ('control layout', [['AN', 'EN', 'EN', 'AN', 'AN'], [2, 1, 3, 1, 2]], [[0, 1, 4], [1, 2, 2], [2, 3, 4], [3, 4, 2], [4, 5, 4]]), ('control layout', [['L', 'R'], [2, 2]], [[0, 1, 2], [1, 2, 3]])], [('regression: run end bookkeeping', [['L', 'R', 'L', 'R', 'L', 'EN', 'AN', 'R', 'EN', 'L'], [3, 3, 2, 2, 2, 4, 4, 4, 4, 4]], [[0, 1, 4], [1, 2, 3], [2, 3, 2], [3, 4, 3], [4, 5, 2], [5, 7, 6], [7, 8, 5], [8, 9, 6], [9, 10, 4]]), ('regression: run end bookkeeping', [['R', 'AN', 'L', 'AN', 'EN', 'AN', 'AN', 'L', 'AN', 'L', 'L'], [0, 0, 0, 2, 1, 1, 0, 0, 0, 0, 1]], [[0, 1, 1], [1, 2, 2], [2, 3, 0], [3, 4, 4], [4, 7, 2], [7, 8, 0], [8, 9, 2], [9, 10, 0], [10, 11, 2]]), ('regression: run end bookkeeping', [['L', 'EN', 'L', 'R', 'EN'], [3, 3, 3, 3, 1]], [[0, 3, 4], [3, 4, 3], [4, 5, 2]]), ('regression: run end bookkeeping', [['L', 'R', 'EN', 'L', 'L', 'EN', 'L'], [3, 3, 1, 1, 1, 1, 1]], [[0, 1, 4], [1, 2, 3], [2, 7, 2]]), ('level two embedding', [['R', 'L'], [2, 2]], [[0, 1, 3], [1, 2, 2]]), ('number in LTR text', [['L', 'EN', 'L'], [0, 0, 0]], [[0, 1, 0], [1, 2, 2], [2, 3, 0]]), ('control layout', [['R'], [2]], [[0, 1, 3]]), ('control layout', [['L', 'R'], [2, 1]], [[0, 1, 2], [1, 2, 1]])], [('regression: run end bookkeeping', [['EN', 'L', 'AN', 'L', 'EN', 'EN', 'L'], [1, 1, 1, 2, 2, 4, 4]], [[0, 4, 2], [4, 5, 4], [5, 6, 6], [6, 7, 4]]), ('regression: run end bookkeeping', [['AN', 'AN'], [0, 0]], [[0, 2, 2]]), ('regression: run end bookkeeping', [['L', 'L', 'AN', 'L', 'R', 'AN', 'L', 'AN'], [1, 1, 1, 1, 4, 4, 4, 4]], [[0, 4, 2], [4, 5, 5], [5, 6, 6], [6, 7, 4], [7, 8, 6]]), ('regression: run end bookkeeping', [['L', 'R', 'EN', 'R', 'EN', 'L', 'R', 'R', 'AN', 'EN', 'R', 'R'], [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1]], [[0, 1, 2], [1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 6, 2], [6, 8, 1], [8, 9, 2], [9, 10, 4], [10, 12, 1]]), ('level two embedding', [['R', 'L'], [2, 2]], [[0, 1, 3], [1, 2, 2]]), ('number in RTL text', [['R', 'AN', 'R'], [1, 1, 1]], [[0, 1, 1], [1, 2, 2], [2, 3, 1]]), ('control layout', [['R', 'R', 'AN'], [1, 2, 2]], [[0, 1, 1], [1, 2, 3], [2, 3, 4]]), ('control layout', [['AN', 'R'], [2, 2]], [[0, 1, 4], [1, 2, 3]])]]
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
regression: run end bookkeeping[[0, 3, 4], [2, 5, 6], [4, 5, 4], [5, 9, 2], [8, 9, 1], [9, 10, 4], [10, 11, 2]][[0, 2, 4], [2, 4, 6], [4, 5, 4], [5, 8, 2], [8, 9, 1], [9, 10, 4], [10, 11, 2]]Failed
regression: run end bookkeeping[[0, 3, 4], [2, 3, 3], [3, 6, 0], [5, 6, 2], [6, 7, 4], [7, 12, 2]][[0, 2, 4], [2, 3, 3], [3, 5, 0], [5, 6, 2], [6, 7, 4], [7, 11, 2]]Failed
regression: run end bookkeeping[[0, 5, 2], [4, 5, 4], [5, 6, 6], [6, 7, 4]][[0, 4, 2], [4, 5, 4], [5, 6, 6], [6, 7, 4]]Failed
regression: run end bookkeeping[[0, 3, 4], [2, 3, 2], [3, 4, 3], [4, 5, 4]][[0, 2, 4], [2, 3, 2], [3, 4, 3], [4, 5, 4]]Failed
number in RTL text[[0, 1, 1], [1, 2, 2], [2, 3, 1]][[0, 1, 1], [1, 2, 2], [2, 3, 1]]Passed
level two embedding[[0, 1, 3], [1, 2, 2]][[0, 1, 3], [1, 2, 2]]Passed
control layout[[0, 1, 3]][[0, 1, 3]]Passed
control layout[[0, 1, 2], [1, 2, 6]][[0, 1, 2], [1, 2, 6]]Passed

SHA-256 / 339fa242c9a4cda10b3a5b42c8dadc09df70b662eddef0cdef1591a5b37eaae8

HELD IN THE MEMBER ARCHIVE

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

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

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

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

Sign in to the archive ↗

Verification & scope

A deterministic 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:54.138651+00:00.

Case digest / 83846bde730bf0030ebbe0aa675629a28cab4a1fa4026f5ffb9ae00da9ffa6af