FAILURE MAP
← Case archive

FA-80426 / Bidirectional text layout / Open access

Neutral run resolution: start-of-sequence context · case 01

Leading neutrals ignore the sequence start type.

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

ROOT CAUSE

The embedding direction is used as context at the start instead of sos.

VERIFIED REPAIR

Use sos as the context before the first character.

Unsuccessful approach: Assuming L at the start ignores RTL sequence starts.

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', '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 = e 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 = [[('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('regression: start-of-sequence context', [['B', 'EN', 'WS', 'B', 'R'], 'R', 'L', 0], ['R', 'EN', 'R', 'R', 'R']), ('partial-repair probe', [['S', 'ON'], 'R', 'L', 1], ['R', 'R']), ('regression: start-of-sequence context', [['S', 'WS', 'S', 'WS', 'WS', 'WS', 'AN'], 'R', 'R', 2], ['R', 'R', 'R', 'R', 'R', 'R', 'AN']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['L', 'L', 'EN', 'R', 'R', 'R'], 'R', 'R', 1], ['L', 'L', 'EN', 'R', 'R', 'R']), ('control layout', [['ON', 'WS', 'ON', 'L', 'ON', 'L', 'AN', 'EN'], 'R', 'R', 0], ['L', 'L', 'L', 'L', 'L', 'L', 'AN', 'EN'])], [('regression: start-of-sequence context', [['ON', 'L', 'WS', 'WS'], 'L', 'R', 1], ['L', 'L', 'R', 'R']), ('regression: start-of-sequence context', [['ON', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'ON', 'AN', 'ON'], 'L', 'R', 1], ['L', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'R', 'AN', 'R']), ('regression: start-of-sequence context', [['ON', 'ON', 'AN', 'R', 'ON', 'WS'], 'R', 'R', 2], ['R', 'R', 'AN', 'R', 'R', 'R']), ('regression: start-of-sequence context', [['WS', 'EN', 'AN', 'R', 'R', 'ON'], 'R', 'L', 0], ['R', 'EN', 'AN', 'R', 'R', 'L']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('control layout', [['L', 'AN', 'R', 'L', 'ON', 'R', 'L', 'R', 'R', 'WS', 'L'], 'L', 'R', 0], ['L', 'AN', 'R', 'L', 'L', 'R', 'L', 'R', 'R', 'L', 'L']), ('control layout', [['EN', 'AN', 'L', 'WS', 'S', 'B', 'ON', 'AN'], 'L', 'R', 1], ['EN', 'AN', 'L', 'R', 'R', 'R', 'R', 'AN'])], [('regression: start-of-sequence context', [['WS', 'EN', 'L', 'WS', 'EN', 'B', 'R'], 'R', 'R', 0], ['R', 'EN', 'L', 'L', 'EN', 'R', 'R']), ('regression: start-of-sequence context', [['ON', 'ON', 'R', 'WS', 'WS', 'WS'], 'R', 'R', 0], ['R', 'R', 'R', 'R', 'R', 'R']), ('partial-repair probe', [['ON', 'ON', 'S', 'L', 'WS', 'EN'], 'R', 'R', 3], ['R', 'R', 'R', 'L', 'R', 'EN']), ('regression: start-of-sequence context', [['S', 'WS', 'B', 'R', 'L', 'R', 'AN', 'ON'], 'R', 'R', 0], ['R', 'R', 'R', 'R', 'L', 'R', 'AN', 'R']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('control layout', [['ON', 'R', 'ON', 'L'], 'R', 'R', 1], ['R', 'R', 'R', 'L']), ('control layout', [['R', 'EN', 'B', 'WS', 'WS', 'S'], 'R', 'R', 2], ['R', 'EN', 'R', 'R', 'R', 'R'])], [('regression: start-of-sequence context', [['WS', 'EN', 'R', 'R', 'AN', 'ON', 'L', 'EN', 'R', 'ON'], 'R', 'L', 2], ['R', 'EN', 'R', 'R', 'AN', 'L', 'L', 'EN', 'R', 'L']), ('regression: start-of-sequence context', [['ON', 'R', 'L', 'L', 'ON', 'AN', 'L'], 'R', 'L', 0], ['R', 'R', 'L', 'L', 'L', 'AN', 'L']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('regression: start-of-sequence context', [['WS', 'EN', 'L', 'WS', 'EN', 'B', 'R'], 'R', 'R', 0], ['R', 'EN', 'L', 'L', 'EN', 'R', 'R']), ('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']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('control layout', [['R', 'L', 'B'], 'R', 'R', 3], ['R', 'L', 'R'])], [('regression: start-of-sequence context', [['S', 'WS', 'B', 'R', 'L', 'R', 'AN', 'ON'], 'R', 'R', 0], ['R', 'R', 'R', 'R', 'L', 'R', 'AN', 'R']), ('regression: start-of-sequence context', [['ON', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'ON', 'AN', 'ON'], 'L', 'R', 1], ['L', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'R', 'AN', 'R']), ('partial-repair probe', [['ON', 'L', 'R', 'WS', 'WS', 'WS', 'R', 'EN', 'B', 'S'], 'R', 'R', 3], ['R', 'L', 'R', 'R', 'R', 'R', 'R', 'EN', 'R', 'R']), ('partial-repair probe', [['ON', 'L', 'R', 'B', 'WS', 'R', 'L', 'WS'], 'R', 'L', 1], ['R', 'L', 'R', 'R', 'R', 'R', 'L', 'L']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('control layout', [['ON', 'R', 'R'], 'L', 'L', 2], ['L', 'R', 'R']), ('control layout', [['AN', 'AN', 'EN', 'ON', 'WS', 'WS'], 'R', 'L', 2], ['AN', 'AN', '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
leading neutral uses sos['L', 'R']['R', 'R']Failed
regression: start-of-sequence context['L', 'EN', 'R', 'R', 'R']['R', 'EN', 'R', 'R', 'R']Failed
partial-repair probe['R', 'R']['R', 'R']Passed
regression: start-of-sequence context['L', 'L', 'L', 'L', 'L', 'L', 'AN']['R', 'R', 'R', 'R', 'R', 'R', 'AN']Failed
neutral between numbers and R['R', 'R', 'EN']['R', 'R', 'EN']Passed
trailing neutral uses eos['L', 'L']['L', 'L']Passed
control layout['L', 'L', 'EN', 'R', 'R', 'R']['L', 'L', 'EN', 'R', 'R', 'R']Passed
control layout['L', 'L', 'L', 'L', 'L', 'L', 'AN', 'EN']['L', 'L', 'L', 'L', 'L', 'L', 'AN', 'EN']Passed

SHA-256 / e91ed79940dd0b1b0d441b3b843559fa3d4ec62d051843c098466938ebae1fbd

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 '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 = 'L' 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 = [[('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('regression: start-of-sequence context', [['B', 'EN', 'WS', 'B', 'R'], 'R', 'L', 0], ['R', 'EN', 'R', 'R', 'R']), ('partial-repair probe', [['S', 'ON'], 'R', 'L', 1], ['R', 'R']), ('regression: start-of-sequence context', [['S', 'WS', 'S', 'WS', 'WS', 'WS', 'AN'], 'R', 'R', 2], ['R', 'R', 'R', 'R', 'R', 'R', 'AN']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['L', 'L', 'EN', 'R', 'R', 'R'], 'R', 'R', 1], ['L', 'L', 'EN', 'R', 'R', 'R']), ('control layout', [['ON', 'WS', 'ON', 'L', 'ON', 'L', 'AN', 'EN'], 'R', 'R', 0], ['L', 'L', 'L', 'L', 'L', 'L', 'AN', 'EN'])], [('regression: start-of-sequence context', [['ON', 'L', 'WS', 'WS'], 'L', 'R', 1], ['L', 'L', 'R', 'R']), ('regression: start-of-sequence context', [['ON', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'ON', 'AN', 'ON'], 'L', 'R', 1], ['L', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'R', 'AN', 'R']), ('regression: start-of-sequence context', [['ON', 'ON', 'AN', 'R', 'ON', 'WS'], 'R', 'R', 2], ['R', 'R', 'AN', 'R', 'R', 'R']), ('regression: start-of-sequence context', [['WS', 'EN', 'AN', 'R', 'R', 'ON'], 'R', 'L', 0], ['R', 'EN', 'AN', 'R', 'R', 'L']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('control layout', [['L', 'AN', 'R', 'L', 'ON', 'R', 'L', 'R', 'R', 'WS', 'L'], 'L', 'R', 0], ['L', 'AN', 'R', 'L', 'L', 'R', 'L', 'R', 'R', 'L', 'L']), ('control layout', [['EN', 'AN', 'L', 'WS', 'S', 'B', 'ON', 'AN'], 'L', 'R', 1], ['EN', 'AN', 'L', 'R', 'R', 'R', 'R', 'AN'])], [('regression: start-of-sequence context', [['WS', 'EN', 'L', 'WS', 'EN', 'B', 'R'], 'R', 'R', 0], ['R', 'EN', 'L', 'L', 'EN', 'R', 'R']), ('regression: start-of-sequence context', [['ON', 'ON', 'R', 'WS', 'WS', 'WS'], 'R', 'R', 0], ['R', 'R', 'R', 'R', 'R', 'R']), ('partial-repair probe', [['ON', 'ON', 'S', 'L', 'WS', 'EN'], 'R', 'R', 3], ['R', 'R', 'R', 'L', 'R', 'EN']), ('regression: start-of-sequence context', [['S', 'WS', 'B', 'R', 'L', 'R', 'AN', 'ON'], 'R', 'R', 0], ['R', 'R', 'R', 'R', 'L', 'R', 'AN', 'R']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('control layout', [['ON', 'R', 'ON', 'L'], 'R', 'R', 1], ['R', 'R', 'R', 'L']), ('control layout', [['R', 'EN', 'B', 'WS', 'WS', 'S'], 'R', 'R', 2], ['R', 'EN', 'R', 'R', 'R', 'R'])], [('regression: start-of-sequence context', [['WS', 'EN', 'R', 'R', 'AN', 'ON', 'L', 'EN', 'R', 'ON'], 'R', 'L', 2], ['R', 'EN', 'R', 'R', 'AN', 'L', 'L', 'EN', 'R', 'L']), ('regression: start-of-sequence context', [['ON', 'R', 'L', 'L', 'ON', 'AN', 'L'], 'R', 'L', 0], ['R', 'R', 'L', 'L', 'L', 'AN', 'L']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('regression: start-of-sequence context', [['WS', 'EN', 'L', 'WS', 'EN', 'B', 'R'], 'R', 'R', 0], ['R', 'EN', 'L', 'L', 'EN', 'R', 'R']), ('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']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('control layout', [['R', 'L', 'B'], 'R', 'R', 3], ['R', 'L', 'R'])], [('regression: start-of-sequence context', [['S', 'WS', 'B', 'R', 'L', 'R', 'AN', 'ON'], 'R', 'R', 0], ['R', 'R', 'R', 'R', 'L', 'R', 'AN', 'R']), ('regression: start-of-sequence context', [['ON', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'ON', 'AN', 'ON'], 'L', 'R', 1], ['L', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'R', 'AN', 'R']), ('partial-repair probe', [['ON', 'L', 'R', 'WS', 'WS', 'WS', 'R', 'EN', 'B', 'S'], 'R', 'R', 3], ['R', 'L', 'R', 'R', 'R', 'R', 'R', 'EN', 'R', 'R']), ('partial-repair probe', [['ON', 'L', 'R', 'B', 'WS', 'R', 'L', 'WS'], 'R', 'L', 1], ['R', 'L', 'R', 'R', 'R', 'R', 'L', 'L']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('control layout', [['ON', 'R', 'R'], 'L', 'L', 2], ['L', 'R', 'R']), ('control layout', [['AN', 'AN', 'EN', 'ON', 'WS', 'WS'], 'R', 'L', 2], ['AN', 'AN', '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
leading neutral uses sos['L', 'R']['R', 'R']Failed
regression: start-of-sequence context['L', 'EN', 'R', 'R', 'R']['R', 'EN', 'R', 'R', 'R']Failed
partial-repair probe['L', 'L']['R', 'R']Failed
regression: start-of-sequence context['L', 'L', 'L', 'L', 'L', 'L', 'AN']['R', 'R', 'R', 'R', 'R', 'R', 'AN']Failed
neutral between numbers and R['R', 'R', 'EN']['R', 'R', 'EN']Passed
trailing neutral uses eos['L', 'L']['L', 'L']Passed
control layout['L', 'L', 'EN', 'R', 'R', 'R']['L', 'L', 'EN', 'R', 'R', 'R']Passed
control layout['L', 'L', 'L', 'L', 'L', 'L', 'AN', 'EN']['L', 'L', 'L', 'L', 'L', 'L', 'AN', 'EN']Passed

SHA-256 / 1082b94f93a22ed42258b256af5a3e808108fc9ed4f17b752b0c3065e10620ac

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 = [[('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('regression: start-of-sequence context', [['B', 'EN', 'WS', 'B', 'R'], 'R', 'L', 0], ['R', 'EN', 'R', 'R', 'R']), ('partial-repair probe', [['S', 'ON'], 'R', 'L', 1], ['R', 'R']), ('regression: start-of-sequence context', [['S', 'WS', 'S', 'WS', 'WS', 'WS', 'AN'], 'R', 'R', 2], ['R', 'R', 'R', 'R', 'R', 'R', 'AN']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('control layout', [['L', 'L', 'EN', 'R', 'R', 'R'], 'R', 'R', 1], ['L', 'L', 'EN', 'R', 'R', 'R']), ('control layout', [['ON', 'WS', 'ON', 'L', 'ON', 'L', 'AN', 'EN'], 'R', 'R', 0], ['L', 'L', 'L', 'L', 'L', 'L', 'AN', 'EN'])], [('regression: start-of-sequence context', [['ON', 'L', 'WS', 'WS'], 'L', 'R', 1], ['L', 'L', 'R', 'R']), ('regression: start-of-sequence context', [['ON', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'ON', 'AN', 'ON'], 'L', 'R', 1], ['L', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'R', 'AN', 'R']), ('regression: start-of-sequence context', [['ON', 'ON', 'AN', 'R', 'ON', 'WS'], 'R', 'R', 2], ['R', 'R', 'AN', 'R', 'R', 'R']), ('regression: start-of-sequence context', [['WS', 'EN', 'AN', 'R', 'R', 'ON'], 'R', 'L', 0], ['R', 'EN', 'AN', 'R', 'R', 'L']), ('mixed neutral run', [['R', 'WS', 'ON', 'S', 'R'], 'L', 'L', 0], ['R', 'R', 'R', 'R', 'R']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('control layout', [['L', 'AN', 'R', 'L', 'ON', 'R', 'L', 'R', 'R', 'WS', 'L'], 'L', 'R', 0], ['L', 'AN', 'R', 'L', 'L', 'R', 'L', 'R', 'R', 'L', 'L']), ('control layout', [['EN', 'AN', 'L', 'WS', 'S', 'B', 'ON', 'AN'], 'L', 'R', 1], ['EN', 'AN', 'L', 'R', 'R', 'R', 'R', 'AN'])], [('regression: start-of-sequence context', [['WS', 'EN', 'L', 'WS', 'EN', 'B', 'R'], 'R', 'R', 0], ['R', 'EN', 'L', 'L', 'EN', 'R', 'R']), ('regression: start-of-sequence context', [['ON', 'ON', 'R', 'WS', 'WS', 'WS'], 'R', 'R', 0], ['R', 'R', 'R', 'R', 'R', 'R']), ('partial-repair probe', [['ON', 'ON', 'S', 'L', 'WS', 'EN'], 'R', 'R', 3], ['R', 'R', 'R', 'L', 'R', 'EN']), ('regression: start-of-sequence context', [['S', 'WS', 'B', 'R', 'L', 'R', 'AN', 'ON'], 'R', 'R', 0], ['R', 'R', 'R', 'R', 'L', 'R', 'AN', 'R']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('control layout', [['ON', 'R', 'ON', 'L'], 'R', 'R', 1], ['R', 'R', 'R', 'L']), ('control layout', [['R', 'EN', 'B', 'WS', 'WS', 'S'], 'R', 'R', 2], ['R', 'EN', 'R', 'R', 'R', 'R'])], [('regression: start-of-sequence context', [['WS', 'EN', 'R', 'R', 'AN', 'ON', 'L', 'EN', 'R', 'ON'], 'R', 'L', 2], ['R', 'EN', 'R', 'R', 'AN', 'L', 'L', 'EN', 'R', 'L']), ('regression: start-of-sequence context', [['ON', 'R', 'L', 'L', 'ON', 'AN', 'L'], 'R', 'L', 0], ['R', 'R', 'L', 'L', 'L', 'AN', 'L']), ('leading neutral uses sos', [['WS', 'R'], 'R', 'L', 0], ['R', 'R']), ('regression: start-of-sequence context', [['WS', 'EN', 'L', 'WS', 'EN', 'B', 'R'], 'R', 'R', 0], ['R', 'EN', 'L', 'L', 'EN', 'R', 'R']), ('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']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('control layout', [['R', 'L', 'B'], 'R', 'R', 3], ['R', 'L', 'R'])], [('regression: start-of-sequence context', [['S', 'WS', 'B', 'R', 'L', 'R', 'AN', 'ON'], 'R', 'R', 0], ['R', 'R', 'R', 'R', 'L', 'R', 'AN', 'R']), ('regression: start-of-sequence context', [['ON', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'ON', 'AN', 'ON'], 'L', 'R', 1], ['L', 'L', 'EN', 'L', 'AN', 'R', 'EN', 'EN', 'R', 'AN', 'R']), ('partial-repair probe', [['ON', 'L', 'R', 'WS', 'WS', 'WS', 'R', 'EN', 'B', 'S'], 'R', 'R', 3], ['R', 'L', 'R', 'R', 'R', 'R', 'R', 'EN', 'R', 'R']), ('partial-repair probe', [['ON', 'L', 'R', 'B', 'WS', 'R', 'L', 'WS'], 'R', 'L', 1], ['R', 'L', 'R', 'R', 'R', 'R', 'L', 'L']), ('trailing neutral uses eos', [['L', 'WS'], 'L', 'L', 1], ['L', 'L']), ('neutral between numbers and R', [['R', 'ON', 'EN'], 'L', 'L', 0], ['R', 'R', 'EN']), ('control layout', [['ON', 'R', 'R'], 'L', 'L', 2], ['L', 'R', 'R']), ('control layout', [['AN', 'AN', 'EN', 'ON', 'WS', 'WS'], 'R', 'L', 2], ['AN', 'AN', '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
leading neutral uses sos['R', 'R']['R', 'R']Passed
regression: start-of-sequence context['R', 'EN', 'R', 'R', 'R']['R', 'EN', 'R', 'R', 'R']Passed
partial-repair probe['R', 'R']['R', 'R']Passed
regression: start-of-sequence context['R', 'R', 'R', 'R', 'R', 'R', 'AN']['R', 'R', 'R', 'R', 'R', 'R', 'AN']Passed
neutral between numbers and R['R', 'R', 'EN']['R', 'R', 'EN']Passed
trailing neutral uses eos['L', 'L']['L', 'L']Passed
control layout['L', 'L', 'EN', 'R', 'R', 'R']['L', 'L', 'EN', 'R', 'R', 'R']Passed
control layout['L', 'L', 'L', 'L', 'L', 'L', 'AN', 'EN']['L', 'L', 'L', 'L', 'L', 'L', 'AN', 'EN']Passed

SHA-256 / 64e69ff7e8aa25f6540c27807105a85828ede41b220a2047e2c60c288941ff5e

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

Case digest / e6ffec7058457b6abc15073610e28ca567c500248a0834de6077388e60524101