FAILURE MAP
← Case archive

FA-80416 / Bidirectional text layout / Open access

Neutral run resolution: numbers as right-to-left context · case 01

Neutrals between Hebrew text and a number fall back to the embedding direction.

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

ROOT CAUSE

European numbers are not mapped to R when used as neutral context.

VERIFIED REPAIR

Treat EN and AN as R for neutral resolution.

Unsuccessful approach: Mapping EN to L is the opposite error.

Case contract

Input [resolved weak classes, sos, eos, embedding level]. A maximal run of neutrals (ON, WS, B, S) takes the direction of its surrounding strong types when both sides agree (EN and AN count as R; sos/eos at the edges); otherwise the embedding direction (L for even level, R for odd). Return classes.

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, sos, eos, level = x
    t = list(types)
    n = len(t)
    NI = ('ON', 'WS', 'B', 'S')
    e = 'L' if level % 2 == 0 else 'R'
    def strong(c):
        return 'R' if c in ('R', 'AN') else c
    i = 0
    while i < n:
        if t[i] in NI:
            j = i
            while j < n and t[j] in NI:
                j += 1
            before = sos if i == 0 else strong(t[i - 1])
            after = eos if j == n else strong(t[j])
            fill = before if before == after else e
            for k in range(i, j):
                t[k] = fill
            i = j
        else:
            i += 1
    return t
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('regression: numbers as right-to-left context', [['AN', 'ON', 'EN', 'R', 'L', 'S', 'AN', 'AN', 'AN', 'ON', 'L'], 'R', 'L', 0], ['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']), ('partial-repair probe', [['AN', 'EN', 'WS', 'L', 'R', 'WS', 'ON', 'AN', 'WS'], 'L', 'L', 1], ['AN', 'EN', 'R', 'L', 'R', 'R', 'R', 'AN', 'R']), ('regression: numbers as right-to-left context', [['R', 'WS', 'EN', 'EN', 'L', 'WS', 'ON'], 'R', 'R', 2], ['R', 'R', 'EN', 'EN', 'L', 'L', 'L']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['S', 'WS', 'WS', 'EN', 'AN', 'AN', 'EN'], 'L', 'L', 2], ['L', 'L', 'L', 'EN', 'AN', 'AN', 'EN']), ('control layout', [['AN', 'ON', 'B', 'WS', 'WS', 'L', 'R', 'EN', 'L'], 'R', 'R', 0], ['AN', 'L', 'L', 'L', 'L', 'L', 'R', 'EN', 'L'])], [('regression: numbers as right-to-left context', [['R', 'R', 'AN', 'WS', 'EN', 'R', 'EN', 'WS'], 'L', 'L', 0], ['R', 'R', 'AN', 'R', 'EN', 'R', 'EN', 'L']), ('regression: numbers as right-to-left context', [['AN', 'WS', 'ON', 'R', 'ON', 'EN', 'ON', 'L', 'S', 'R', 'AN'], 'L', 'L', 0], ['AN', 'R', 'R', 'R', 'R', 'EN', 'L', 'L', 'L', 'R', 'AN']), ('regression: numbers as right-to-left context', [['R', 'ON', 'ON', 'WS', 'WS', 'WS', 'R', 'ON', 'EN', 'WS', 'ON'], 'R', 'R', 2], ['R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'EN', 'R', 'R']), ('regression: numbers as right-to-left context', [['R', 'AN', 'ON', 'EN', 'L', 'ON', 'EN'], 'R', 'R', 0], ['R', 'AN', 'R', 'EN', 'L', 'L', 'EN']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['S', 'WS', 'R', 'S', 'WS', 'ON', 'L', 'R'], 'R', 'L', 1], ['R', 'R', 'R', 'R', 'R', 'R', 'L', 'R']), ('control layout', [['S', 'L', 'ON', 'ON'], 'L', 'R', 0], ['L', 'L', 'L', 'L'])], [('regression: numbers as right-to-left context', [['AN', 'R', 'ON', 'B', 'EN', 'EN', 'EN', 'R', 'ON', 'L'], 'R', 'R', 0], ['AN', 'R', 'R', 'R', 'EN', 'EN', 'EN', 'R', 'L', 'L']), ('regression: numbers as right-to-left context', [['ON', 'R', 'R', 'ON', 'EN', 'ON', 'WS', 'WS', 'WS', 'EN', 'ON'], 'L', 'R', 2], ['L', 'R', 'R', 'R', 'EN', 'R', 'R', 'R', 'R', 'EN', 'R']), ('regression: numbers as right-to-left context', [['AN', 'B', 'EN', 'R', 'EN', 'EN', 'ON', 'AN', 'EN'], 'L', 'L', 2], ['AN', 'R', 'EN', 'R', 'EN', 'EN', 'R', 'AN', 'EN']), ('partial-repair probe', [['L', 'ON', 'ON', 'EN', 'EN', 'L', 'R', 'S', 'WS', 'WS', 'EN'], 'R', 'L', 3], ['L', 'R', 'R', 'EN', 'EN', 'L', 'R', 'R', 'R', 'R', 'EN']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('control layout', [['AN', 'ON', 'R', 'ON', 'AN', 'S', 'R'], 'L', 'L', 1], ['AN', 'R', 'R', 'R', 'AN', 'R', 'R']), ('control layout', [['WS', 'ON', 'L', 'WS', 'L', 'WS', 'S', 'ON', 'R', 'WS', 'S'], 'R', 'L', 2], ['L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'R', 'L', 'L'])], [('regression: numbers as right-to-left context', [['R', 'WS', 'EN', 'EN', 'L', 'WS', 'ON'], 'R', 'R', 2], ['R', 'R', 'EN', 'EN', 'L', 'L', 'L']), ('regression: numbers as right-to-left context', [['R', 'EN', 'WS', 'R', 'AN', 'WS', 'WS', 'ON', 'R', 'AN'], 'R', 'R', 2], ['R', 'EN', 'R', 'R', 'AN', 'R', 'R', 'R', 'R', 'AN']), ('regression: numbers as right-to-left context', [['R', 'ON', 'R', 'WS', 'EN', 'AN', 'AN', 'ON', 'B', 'WS', 'R'], 'R', 'L', 2], ['R', 'R', 'R', 'R', 'EN', 'AN', 'AN', 'R', 'R', 'R', 'R']), ('regression: numbers as right-to-left context', [['AN', 'B', 'EN', 'R', 'EN', 'EN', 'ON', 'AN', 'EN'], 'L', 'L', 2], ['AN', 'R', 'EN', 'R', 'EN', 'EN', 'R', 'AN', 'EN']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('control layout', [['WS', 'S', 'L', 'S', 'EN', 'R', 'S', 'AN', 'AN'], 'R', 'R', 2], ['L', 'L', 'L', 'L', 'EN', 'R', 'R', 'AN', 'AN']), ('control layout', [['WS', 'R', 'ON', 'S', 'L', 'WS', 'ON', 'WS', 'R'], 'R', 'L', 0], ['R', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'R'])], [('regression: numbers as right-to-left context', [['L', 'EN', 'WS', 'R', 'ON', 'R', 'EN', 'L', 'B', 'B'], 'L', 'L', 2], ['L', 'EN', 'R', 'R', 'R', 'R', 'EN', 'L', 'L', 'L']), ('regression: numbers as right-to-left context', [['AN', 'ON', 'EN', 'R', 'L', 'S', 'AN', 'AN', 'AN', 'ON', 'L'], 'R', 'L', 0], ['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']), ('regression: numbers as right-to-left context', [['ON', 'WS', 'R', 'ON', 'EN', 'R', 'WS', 'S'], 'R', 'L', 2], ['R', 'R', 'R', 'R', 'EN', 'R', 'L', 'L']), ('partial-repair probe', [['EN', 'EN', 'ON', 'L', 'ON', 'L', 'WS', 'L'], 'L', 'L', 3], ['EN', 'EN', 'R', 'L', 'L', 'L', 'L', 'L']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['ON', 'R', 'ON', 'L'], 'R', 'R', 1], ['R', 'R', 'R', 'L']), ('control layout', [['WS', 'L', 'L', 'R', 'EN', 'EN', 'WS', 'ON', 'L'], 'R', 'L', 0], ['L', 'L', 'L', 'R', 'EN', 'EN', 'L', 'L', 'L'])]]
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
neutral between numbers and R['R', 'L', 'EN']['R', 'R', 'EN']Failed
regression: numbers as right-to-left context['AN', 'L', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']Failed
partial-repair probe['AN', 'EN', 'R', 'L', 'R', 'R', 'R', 'AN', 'R']['AN', 'EN', 'R', 'L', 'R', 'R', 'R', 'AN', 'R']Passed
regression: numbers as right-to-left context['R', 'L', 'EN', 'EN', 'L', 'L', 'L']['R', 'R', 'EN', 'EN', 'L', 'L', 'L']Failed
mixed neutral run['R', 'R', 'R', 'R', 'R']['R', 'R', 'R', 'R', 'R']Passed
trailing neutral uses eos['L', 'L']['L', 'L']Passed
control layout['L', 'L', 'L', 'EN', 'AN', 'AN', 'EN']['L', 'L', 'L', 'EN', 'AN', 'AN', 'EN']Passed
control layout['AN', 'L', 'L', 'L', 'L', 'L', 'R', 'EN', 'L']['AN', 'L', 'L', 'L', 'L', 'L', 'R', 'EN', 'L']Passed

SHA-256 / e4b86900096ad83dce76f4070561c76d709ed8b97f57f06393fae077b2bb04a5

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    types, sos, eos, level = x
    t = list(types)
    n = len(t)
    NI = ('ON', 'WS', 'B', 'S')
    e = 'L' if level % 2 == 0 else 'R'
    def strong(c):
        return 'L' if c == 'EN' else ('R' if c in ('R', 'AN') else c)
    i = 0
    while i < n:
        if t[i] in NI:
            j = i
            while j < n and t[j] in NI:
                j += 1
            before = sos if i == 0 else strong(t[i - 1])
            after = eos if j == n else strong(t[j])
            fill = before if before == after else e
            for k in range(i, j):
                t[k] = fill
            i = j
        else:
            i += 1
    return t
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('regression: numbers as right-to-left context', [['AN', 'ON', 'EN', 'R', 'L', 'S', 'AN', 'AN', 'AN', 'ON', 'L'], 'R', 'L', 0], ['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']), ('partial-repair probe', [['AN', 'EN', 'WS', 'L', 'R', 'WS', 'ON', 'AN', 'WS'], 'L', 'L', 1], ['AN', 'EN', 'R', 'L', 'R', 'R', 'R', 'AN', 'R']), ('regression: numbers as right-to-left context', [['R', 'WS', 'EN', 'EN', 'L', 'WS', 'ON'], 'R', 'R', 2], ['R', 'R', 'EN', 'EN', 'L', 'L', 'L']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['S', 'WS', 'WS', 'EN', 'AN', 'AN', 'EN'], 'L', 'L', 2], ['L', 'L', 'L', 'EN', 'AN', 'AN', 'EN']), ('control layout', [['AN', 'ON', 'B', 'WS', 'WS', 'L', 'R', 'EN', 'L'], 'R', 'R', 0], ['AN', 'L', 'L', 'L', 'L', 'L', 'R', 'EN', 'L'])], [('regression: numbers as right-to-left context', [['R', 'R', 'AN', 'WS', 'EN', 'R', 'EN', 'WS'], 'L', 'L', 0], ['R', 'R', 'AN', 'R', 'EN', 'R', 'EN', 'L']), ('regression: numbers as right-to-left context', [['AN', 'WS', 'ON', 'R', 'ON', 'EN', 'ON', 'L', 'S', 'R', 'AN'], 'L', 'L', 0], ['AN', 'R', 'R', 'R', 'R', 'EN', 'L', 'L', 'L', 'R', 'AN']), ('regression: numbers as right-to-left context', [['R', 'ON', 'ON', 'WS', 'WS', 'WS', 'R', 'ON', 'EN', 'WS', 'ON'], 'R', 'R', 2], ['R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'EN', 'R', 'R']), ('regression: numbers as right-to-left context', [['R', 'AN', 'ON', 'EN', 'L', 'ON', 'EN'], 'R', 'R', 0], ['R', 'AN', 'R', 'EN', 'L', 'L', 'EN']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['S', 'WS', 'R', 'S', 'WS', 'ON', 'L', 'R'], 'R', 'L', 1], ['R', 'R', 'R', 'R', 'R', 'R', 'L', 'R']), ('control layout', [['S', 'L', 'ON', 'ON'], 'L', 'R', 0], ['L', 'L', 'L', 'L'])], [('regression: numbers as right-to-left context', [['AN', 'R', 'ON', 'B', 'EN', 'EN', 'EN', 'R', 'ON', 'L'], 'R', 'R', 0], ['AN', 'R', 'R', 'R', 'EN', 'EN', 'EN', 'R', 'L', 'L']), ('regression: numbers as right-to-left context', [['ON', 'R', 'R', 'ON', 'EN', 'ON', 'WS', 'WS', 'WS', 'EN', 'ON'], 'L', 'R', 2], ['L', 'R', 'R', 'R', 'EN', 'R', 'R', 'R', 'R', 'EN', 'R']), ('regression: numbers as right-to-left context', [['AN', 'B', 'EN', 'R', 'EN', 'EN', 'ON', 'AN', 'EN'], 'L', 'L', 2], ['AN', 'R', 'EN', 'R', 'EN', 'EN', 'R', 'AN', 'EN']), ('partial-repair probe', [['L', 'ON', 'ON', 'EN', 'EN', 'L', 'R', 'S', 'WS', 'WS', 'EN'], 'R', 'L', 3], ['L', 'R', 'R', 'EN', 'EN', 'L', 'R', 'R', 'R', 'R', 'EN']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('control layout', [['AN', 'ON', 'R', 'ON', 'AN', 'S', 'R'], 'L', 'L', 1], ['AN', 'R', 'R', 'R', 'AN', 'R', 'R']), ('control layout', [['WS', 'ON', 'L', 'WS', 'L', 'WS', 'S', 'ON', 'R', 'WS', 'S'], 'R', 'L', 2], ['L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'R', 'L', 'L'])], [('regression: numbers as right-to-left context', [['R', 'WS', 'EN', 'EN', 'L', 'WS', 'ON'], 'R', 'R', 2], ['R', 'R', 'EN', 'EN', 'L', 'L', 'L']), ('regression: numbers as right-to-left context', [['R', 'EN', 'WS', 'R', 'AN', 'WS', 'WS', 'ON', 'R', 'AN'], 'R', 'R', 2], ['R', 'EN', 'R', 'R', 'AN', 'R', 'R', 'R', 'R', 'AN']), ('regression: numbers as right-to-left context', [['R', 'ON', 'R', 'WS', 'EN', 'AN', 'AN', 'ON', 'B', 'WS', 'R'], 'R', 'L', 2], ['R', 'R', 'R', 'R', 'EN', 'AN', 'AN', 'R', 'R', 'R', 'R']), ('regression: numbers as right-to-left context', [['AN', 'B', 'EN', 'R', 'EN', 'EN', 'ON', 'AN', 'EN'], 'L', 'L', 2], ['AN', 'R', 'EN', 'R', 'EN', 'EN', 'R', 'AN', 'EN']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('control layout', [['WS', 'S', 'L', 'S', 'EN', 'R', 'S', 'AN', 'AN'], 'R', 'R', 2], ['L', 'L', 'L', 'L', 'EN', 'R', 'R', 'AN', 'AN']), ('control layout', [['WS', 'R', 'ON', 'S', 'L', 'WS', 'ON', 'WS', 'R'], 'R', 'L', 0], ['R', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'R'])], [('regression: numbers as right-to-left context', [['L', 'EN', 'WS', 'R', 'ON', 'R', 'EN', 'L', 'B', 'B'], 'L', 'L', 2], ['L', 'EN', 'R', 'R', 'R', 'R', 'EN', 'L', 'L', 'L']), ('regression: numbers as right-to-left context', [['AN', 'ON', 'EN', 'R', 'L', 'S', 'AN', 'AN', 'AN', 'ON', 'L'], 'R', 'L', 0], ['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']), ('regression: numbers as right-to-left context', [['ON', 'WS', 'R', 'ON', 'EN', 'R', 'WS', 'S'], 'R', 'L', 2], ['R', 'R', 'R', 'R', 'EN', 'R', 'L', 'L']), ('partial-repair probe', [['EN', 'EN', 'ON', 'L', 'ON', 'L', 'WS', 'L'], 'L', 'L', 3], ['EN', 'EN', 'R', 'L', 'L', 'L', 'L', 'L']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['ON', 'R', 'ON', 'L'], 'R', 'R', 1], ['R', 'R', 'R', 'L']), ('control layout', [['WS', 'L', 'L', 'R', 'EN', 'EN', 'WS', 'ON', 'L'], 'R', 'L', 0], ['L', 'L', 'L', 'R', 'EN', 'EN', 'L', 'L', 'L'])]]
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
neutral between numbers and R['R', 'L', 'EN']['R', 'R', 'EN']Failed
regression: numbers as right-to-left context['AN', 'L', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']Failed
partial-repair probe['AN', 'EN', 'L', 'L', 'R', 'R', 'R', 'AN', 'R']['AN', 'EN', 'R', 'L', 'R', 'R', 'R', 'AN', 'R']Failed
regression: numbers as right-to-left context['R', 'L', 'EN', 'EN', 'L', 'L', 'L']['R', 'R', 'EN', 'EN', 'L', 'L', 'L']Failed
mixed neutral run['R', 'R', 'R', 'R', 'R']['R', 'R', 'R', 'R', 'R']Passed
trailing neutral uses eos['L', 'L']['L', 'L']Passed
control layout['L', 'L', 'L', 'EN', 'AN', 'AN', 'EN']['L', 'L', 'L', 'EN', 'AN', 'AN', 'EN']Passed
control layout['AN', 'L', 'L', 'L', 'L', 'L', 'R', 'EN', 'L']['AN', 'L', 'L', 'L', 'L', 'L', 'R', 'EN', 'L']Passed

SHA-256 / fb592f8b79508dc139a5cdf551f8f03816fad817d863509916be61ed0280fa1f

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    types, sos, eos, level = x
    t = list(types)
    n = len(t)
    NI = ('ON', 'WS', 'B', 'S')
    e = 'L' if level % 2 == 0 else 'R'
    def strong(c):
        return 'R' if c in ('R', 'EN', 'AN') else c
    i = 0
    while i < n:
        if t[i] in NI:
            j = i
            while j < n and t[j] in NI:
                j += 1
            before = sos if i == 0 else strong(t[i - 1])
            after = eos if j == n else strong(t[j])
            fill = before if before == after else e
            for k in range(i, j):
                t[k] = fill
            i = j
        else:
            i += 1
    return t
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('regression: numbers as right-to-left context', [['AN', 'ON', 'EN', 'R', 'L', 'S', 'AN', 'AN', 'AN', 'ON', 'L'], 'R', 'L', 0], ['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']), ('partial-repair probe', [['AN', 'EN', 'WS', 'L', 'R', 'WS', 'ON', 'AN', 'WS'], 'L', 'L', 1], ['AN', 'EN', 'R', 'L', 'R', 'R', 'R', 'AN', 'R']), ('regression: numbers as right-to-left context', [['R', 'WS', 'EN', 'EN', 'L', 'WS', 'ON'], 'R', 'R', 2], ['R', 'R', 'EN', 'EN', 'L', 'L', 'L']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['S', 'WS', 'WS', 'EN', 'AN', 'AN', 'EN'], 'L', 'L', 2], ['L', 'L', 'L', 'EN', 'AN', 'AN', 'EN']), ('control layout', [['AN', 'ON', 'B', 'WS', 'WS', 'L', 'R', 'EN', 'L'], 'R', 'R', 0], ['AN', 'L', 'L', 'L', 'L', 'L', 'R', 'EN', 'L'])], [('regression: numbers as right-to-left context', [['R', 'R', 'AN', 'WS', 'EN', 'R', 'EN', 'WS'], 'L', 'L', 0], ['R', 'R', 'AN', 'R', 'EN', 'R', 'EN', 'L']), ('regression: numbers as right-to-left context', [['AN', 'WS', 'ON', 'R', 'ON', 'EN', 'ON', 'L', 'S', 'R', 'AN'], 'L', 'L', 0], ['AN', 'R', 'R', 'R', 'R', 'EN', 'L', 'L', 'L', 'R', 'AN']), ('regression: numbers as right-to-left context', [['R', 'ON', 'ON', 'WS', 'WS', 'WS', 'R', 'ON', 'EN', 'WS', 'ON'], 'R', 'R', 2], ['R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'EN', 'R', 'R']), ('regression: numbers as right-to-left context', [['R', 'AN', 'ON', 'EN', 'L', 'ON', 'EN'], 'R', 'R', 0], ['R', 'AN', 'R', 'EN', 'L', 'L', 'EN']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['S', 'WS', 'R', 'S', 'WS', 'ON', 'L', 'R'], 'R', 'L', 1], ['R', 'R', 'R', 'R', 'R', 'R', 'L', 'R']), ('control layout', [['S', 'L', 'ON', 'ON'], 'L', 'R', 0], ['L', 'L', 'L', 'L'])], [('regression: numbers as right-to-left context', [['AN', 'R', 'ON', 'B', 'EN', 'EN', 'EN', 'R', 'ON', 'L'], 'R', 'R', 0], ['AN', 'R', 'R', 'R', 'EN', 'EN', 'EN', 'R', 'L', 'L']), ('regression: numbers as right-to-left context', [['ON', 'R', 'R', 'ON', 'EN', 'ON', 'WS', 'WS', 'WS', 'EN', 'ON'], 'L', 'R', 2], ['L', 'R', 'R', 'R', 'EN', 'R', 'R', 'R', 'R', 'EN', 'R']), ('regression: numbers as right-to-left context', [['AN', 'B', 'EN', 'R', 'EN', 'EN', 'ON', 'AN', 'EN'], 'L', 'L', 2], ['AN', 'R', 'EN', 'R', 'EN', 'EN', 'R', 'AN', 'EN']), ('partial-repair probe', [['L', 'ON', 'ON', 'EN', 'EN', 'L', 'R', 'S', 'WS', 'WS', 'EN'], 'R', 'L', 3], ['L', 'R', 'R', 'EN', 'EN', 'L', 'R', 'R', 'R', 'R', 'EN']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('control layout', [['AN', 'ON', 'R', 'ON', 'AN', 'S', 'R'], 'L', 'L', 1], ['AN', 'R', 'R', 'R', 'AN', 'R', 'R']), ('control layout', [['WS', 'ON', 'L', 'WS', 'L', 'WS', 'S', 'ON', 'R', 'WS', 'S'], 'R', 'L', 2], ['L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'R', 'L', 'L'])], [('regression: numbers as right-to-left context', [['R', 'WS', 'EN', 'EN', 'L', 'WS', 'ON'], 'R', 'R', 2], ['R', 'R', 'EN', 'EN', 'L', 'L', 'L']), ('regression: numbers as right-to-left context', [['R', 'EN', 'WS', 'R', 'AN', 'WS', 'WS', 'ON', 'R', 'AN'], 'R', 'R', 2], ['R', 'EN', 'R', 'R', 'AN', 'R', 'R', 'R', 'R', 'AN']), ('regression: numbers as right-to-left context', [['R', 'ON', 'R', 'WS', 'EN', 'AN', 'AN', 'ON', 'B', 'WS', 'R'], 'R', 'L', 2], ['R', 'R', 'R', 'R', 'EN', 'AN', 'AN', 'R', 'R', 'R', 'R']), ('regression: numbers as right-to-left context', [['AN', 'B', 'EN', 'R', 'EN', 'EN', 'ON', 'AN', 'EN'], 'L', 'L', 2], ['AN', 'R', 'EN', 'R', 'EN', 'EN', 'R', 'AN', 'EN']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('control layout', [['WS', 'S', 'L', 'S', 'EN', 'R', 'S', 'AN', 'AN'], 'R', 'R', 2], ['L', 'L', 'L', 'L', 'EN', 'R', 'R', 'AN', 'AN']), ('control layout', [['WS', 'R', 'ON', 'S', 'L', 'WS', 'ON', 'WS', 'R'], 'R', 'L', 0], ['R', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'R'])], [('regression: numbers as right-to-left context', [['L', 'EN', 'WS', 'R', 'ON', 'R', 'EN', 'L', 'B', 'B'], 'L', 'L', 2], ['L', 'EN', 'R', 'R', 'R', 'R', 'EN', 'L', 'L', 'L']), ('regression: numbers as right-to-left context', [['AN', 'ON', 'EN', 'R', 'L', 'S', 'AN', 'AN', 'AN', 'ON', 'L'], 'R', 'L', 0], ['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']), ('regression: numbers as right-to-left context', [['ON', 'WS', 'R', 'ON', 'EN', 'R', 'WS', 'S'], 'R', 'L', 2], ['R', 'R', 'R', 'R', 'EN', 'R', 'L', 'L']), ('partial-repair probe', [['EN', 'EN', 'ON', 'L', 'ON', 'L', 'WS', 'L'], 'L', 'L', 3], ['EN', 'EN', 'R', 'L', 'L', 'L', 'L', 'L']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['ON', 'R', 'ON', 'L'], 'R', 'R', 1], ['R', 'R', 'R', 'L']), ('control layout', [['WS', 'L', 'L', 'R', 'EN', 'EN', 'WS', 'ON', 'L'], 'R', 'L', 0], ['L', 'L', 'L', 'R', 'EN', 'EN', 'L', 'L', 'L'])]]
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
neutral between numbers and R['R', 'R', 'EN']['R', 'R', 'EN']Passed
regression: numbers as right-to-left context['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']['AN', 'R', 'EN', 'R', 'L', 'L', 'AN', 'AN', 'AN', 'L', 'L']Passed
partial-repair probe['AN', 'EN', 'R', 'L', 'R', 'R', 'R', 'AN', 'R']['AN', 'EN', 'R', 'L', 'R', 'R', 'R', 'AN', 'R']Passed
regression: numbers as right-to-left context['R', 'R', 'EN', 'EN', 'L', 'L', 'L']['R', 'R', 'EN', 'EN', 'L', 'L', 'L']Passed
mixed neutral run['R', 'R', 'R', 'R', 'R']['R', 'R', 'R', 'R', 'R']Passed
trailing neutral uses eos['L', 'L']['L', 'L']Passed
control layout['L', 'L', 'L', 'EN', 'AN', 'AN', 'EN']['L', 'L', 'L', 'EN', 'AN', 'AN', 'EN']Passed
control layout['AN', 'L', 'L', 'L', 'L', 'L', 'R', 'EN', 'L']['AN', 'L', 'L', 'L', 'L', 'L', 'R', 'EN', 'L']Passed

SHA-256 / 0a7c6a279dd7cb7d70690967bb9e408f9418d1c3ed6caacf39bbab1d245a7d1e

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

Case digest / 79e2be9c8795f2842de7aa18213ac236eade66448ddf620959c3ad8707aa8d77