FAILURE MAP
← Case archive

FA-80431 / Bidirectional text layout / Open access

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

Trailing neutrals resolve against the wrong edge.

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

ROOT CAUSE

sos is used after the last character instead of eos.

VERIFIED REPAIR

Use eos as the context after the last character.

Unsuccessful approach: Using the embedding direction ignores eos.

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

SHA-256 / 02b75dff719a77ad903805a4540b809fd45b7c485b9d659bc584b529e43bd0ef

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

SHA-256 / 652ad43800b82444a1e4c9b162f98f296dcdcf04b59876d72a21c1a67615bde2

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

SHA-256 / e3d895139ca5fd50419f0353350f3280bd2913b3ac9427a1e6bcd980e0b59cd7

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

Case digest / 2ebb8f860516442420d09ed4154e70ed905d7e9a293b5e62ddce53cc3c13add7