FA-80421 / Bidirectional text layout / Open access
Neutral run resolution: embedding direction parity · case 01
Unresolvable neutrals take the opposite of the embedding direction.
ROOT CAUSE
Even levels are mapped to R.
VERIFIED REPAIR
Even embedding levels are left-to-right.
Unsuccessful approach: Treating only level 0 as LTR breaks level 2 embeddings.
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 == 1 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: embedding direction parity', [['R', 'ON', 'L', 'WS', 'WS', 'R', 'L', 'L', 'WS'], 'R', 'L', 0], ['R', 'L', 'L', 'L', 'L', 'R', 'L', 'L', 'L']), ('regression: embedding direction parity', [['EN', 'L', 'AN', 'ON', 'L', 'L', 'ON'], 'R', 'R', 0], ['EN', 'L', 'AN', 'L', 'L', 'L', 'L']), ('regression: embedding direction parity', [['EN', 'R', 'ON', 'ON', 'WS', 'ON', 'WS', 'L', 'WS'], 'L', 'R', 2], ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'L']), ('regression: embedding direction parity', [['ON', 'L', 'R', 'WS', 'AN', 'ON', 'WS', 'L', 'AN'], 'R', 'R', 2], ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN']), ('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', [['R', 'L'], 'R', 'R', 3], ['R', 'L']), ('control layout', [['EN', 'R', 'EN', 'R'], 'L', 'L', 3], ['EN', 'R', 'EN', 'R'])], [('regression: embedding direction parity', [['EN', 'EN', 'ON', 'L', 'S', 'L', 'WS', 'R', 'R', 'ON', 'L'], 'R', 'R', 3], ['EN', 'EN', 'R', 'L', 'L', 'L', 'R', 'R', 'R', 'R', 'L']), ('regression: embedding direction parity', [['S', 'S', 'R', 'R', 'R', 'ON', 'AN', 'L', 'S'], 'L', 'L', 3], ['R', 'R', 'R', 'R', 'R', 'R', 'AN', 'L', 'L']), ('regression: embedding direction parity', [['R', 'ON', 'AN', 'ON', 'S', 'AN', 'WS', 'L', 'AN'], 'R', 'L', 2], ['R', 'R', 'AN', 'R', 'R', 'AN', 'L', 'L', 'AN']), ('regression: embedding direction parity', [['ON', 'L', 'R', 'WS', 'AN', 'ON', 'WS', 'L', 'AN'], 'R', 'R', 2], ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN']), ('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', [['L', 'L'], 'L', 'R', 0], ['L', 'L']), ('control layout', [['ON', 'WS', 'EN', 'L', 'R', 'L', 'R', 'ON', 'AN', 'L'], 'R', 'R', 3], ['R', 'R', 'EN', 'L', 'R', 'L', 'R', 'R', 'AN', 'L'])], [('regression: embedding direction parity', [['WS', 'EN', 'L', 'WS', 'ON', 'WS'], 'L', 'R', 3], ['R', 'EN', 'L', 'R', 'R', 'R']), ('regression: embedding direction parity', [['EN', 'AN', 'WS', 'L', 'ON', 'R'], 'L', 'L', 1], ['EN', 'AN', 'R', 'L', 'R', 'R']), ('regression: embedding direction parity', [['ON', 'AN', 'R', 'R'], 'L', 'L', 2], ['L', 'AN', 'R', 'R']), ('regression: embedding direction parity', [['WS', 'R'], 'L', 'L', 2], ['L', 'R']), ('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', [['AN', 'AN', 'ON', 'R'], 'L', 'L', 1], ['AN', 'AN', 'R', 'R']), ('control layout', [['ON', 'WS', 'B', 'ON', 'L', 'R', 'AN', 'L', 'EN', 'WS'], 'L', 'R', 1], ['L', 'L', 'L', 'L', 'L', 'R', 'AN', 'L', 'EN', 'R'])], [('regression: embedding direction parity', [['AN', 'R', 'ON', 'B', 'EN', 'EN', 'EN', 'R', 'ON', 'L'], 'R', 'R', 0], ['AN', 'R', 'R', 'R', 'EN', 'EN', 'EN', 'R', 'L', 'L']), ('regression: embedding direction parity', [['L', 'L', 'WS', 'WS', 'S', 'R', 'R', 'WS', 'AN', 'WS', 'L'], 'R', 'L', 2], ['L', 'L', 'L', 'L', 'L', 'R', 'R', 'R', 'AN', 'L', 'L']), ('regression: embedding direction parity', [['AN', 'B', 'S'], 'R', 'L', 2], ['AN', 'L', 'L']), ('regression: embedding direction parity', [['WS', 'WS', 'B', 'R', 'R', 'EN', 'S', 'EN'], 'L', 'R', 2], ['L', 'L', 'L', 'R', 'R', 'EN', 'R', 'EN']), ('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', [['ON', 'WS', 'EN'], 'R', 'R', 1], ['R', 'R', 'EN']), ('control layout', [['AN', 'L'], 'L', 'R', 1], ['AN', 'L'])], [('regression: embedding direction parity', [['B', 'R', 'ON', 'L', 'AN', 'AN', 'WS'], 'L', 'R', 1], ['R', 'R', 'R', 'L', 'AN', 'AN', 'R']), ('regression: embedding direction parity', [['WS', 'EN', 'R', 'WS', 'L', 'EN', 'R'], 'L', 'L', 2], ['L', 'EN', 'R', 'L', 'L', 'EN', 'R']), ('regression: embedding direction parity', [['B', 'L', 'ON', 'ON', 'AN', 'AN', 'EN'], 'L', 'R', 2], ['L', 'L', 'L', 'L', 'AN', 'AN', 'EN']), ('regression: embedding direction parity', [['EN', 'R', 'ON', 'ON', 'WS', 'ON', 'WS', 'L', 'WS'], 'L', 'R', 2], ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', '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', [['R', 'L', 'ON', 'WS', 'L', 'L', 'R', 'WS', 'WS'], 'L', 'R', 2], ['R', 'L', 'L', 'L', 'L', 'L', 'R', 'R', 'R']), ('control layout', [['R', 'EN', 'ON', 'AN'], 'L', 'L', 3], ['R', 'EN', 'R', 'AN'])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: embedding direction parity | ['R', 'R', 'L', 'R', 'R', 'R', 'L', 'L', 'L'] | ['R', 'L', 'L', 'L', 'L', 'R', 'L', 'L', 'L'] | Failed |
| regression: embedding direction parity | ['EN', 'L', 'AN', 'R', 'L', 'L', 'R'] | ['EN', 'L', 'AN', 'L', 'L', 'L', 'L'] | Failed |
| regression: embedding direction parity | ['EN', 'R', 'R', 'R', 'R', 'R', 'R', 'L', 'R'] | ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'L'] | Failed |
| regression: embedding direction parity | ['R', 'L', 'R', 'R', 'AN', 'R', 'R', 'L', 'AN'] | ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN'] | 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 | ['R', 'L'] | ['R', 'L'] | Passed |
| control layout | ['EN', 'R', 'EN', 'R'] | ['EN', 'R', 'EN', 'R'] | Passed |
SHA-256 / e7c23fac6280faf34d13d70ea16ab723705ec1b687e0770edeedf87db3b904b4
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 == 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: embedding direction parity', [['R', 'ON', 'L', 'WS', 'WS', 'R', 'L', 'L', 'WS'], 'R', 'L', 0], ['R', 'L', 'L', 'L', 'L', 'R', 'L', 'L', 'L']), ('regression: embedding direction parity', [['EN', 'L', 'AN', 'ON', 'L', 'L', 'ON'], 'R', 'R', 0], ['EN', 'L', 'AN', 'L', 'L', 'L', 'L']), ('regression: embedding direction parity', [['EN', 'R', 'ON', 'ON', 'WS', 'ON', 'WS', 'L', 'WS'], 'L', 'R', 2], ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'L']), ('regression: embedding direction parity', [['ON', 'L', 'R', 'WS', 'AN', 'ON', 'WS', 'L', 'AN'], 'R', 'R', 2], ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN']), ('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', [['R', 'L'], 'R', 'R', 3], ['R', 'L']), ('control layout', [['EN', 'R', 'EN', 'R'], 'L', 'L', 3], ['EN', 'R', 'EN', 'R'])], [('regression: embedding direction parity', [['EN', 'EN', 'ON', 'L', 'S', 'L', 'WS', 'R', 'R', 'ON', 'L'], 'R', 'R', 3], ['EN', 'EN', 'R', 'L', 'L', 'L', 'R', 'R', 'R', 'R', 'L']), ('regression: embedding direction parity', [['S', 'S', 'R', 'R', 'R', 'ON', 'AN', 'L', 'S'], 'L', 'L', 3], ['R', 'R', 'R', 'R', 'R', 'R', 'AN', 'L', 'L']), ('regression: embedding direction parity', [['R', 'ON', 'AN', 'ON', 'S', 'AN', 'WS', 'L', 'AN'], 'R', 'L', 2], ['R', 'R', 'AN', 'R', 'R', 'AN', 'L', 'L', 'AN']), ('regression: embedding direction parity', [['ON', 'L', 'R', 'WS', 'AN', 'ON', 'WS', 'L', 'AN'], 'R', 'R', 2], ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN']), ('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', [['L', 'L'], 'L', 'R', 0], ['L', 'L']), ('control layout', [['ON', 'WS', 'EN', 'L', 'R', 'L', 'R', 'ON', 'AN', 'L'], 'R', 'R', 3], ['R', 'R', 'EN', 'L', 'R', 'L', 'R', 'R', 'AN', 'L'])], [('regression: embedding direction parity', [['WS', 'EN', 'L', 'WS', 'ON', 'WS'], 'L', 'R', 3], ['R', 'EN', 'L', 'R', 'R', 'R']), ('regression: embedding direction parity', [['EN', 'AN', 'WS', 'L', 'ON', 'R'], 'L', 'L', 1], ['EN', 'AN', 'R', 'L', 'R', 'R']), ('regression: embedding direction parity', [['ON', 'AN', 'R', 'R'], 'L', 'L', 2], ['L', 'AN', 'R', 'R']), ('regression: embedding direction parity', [['WS', 'R'], 'L', 'L', 2], ['L', 'R']), ('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', [['AN', 'AN', 'ON', 'R'], 'L', 'L', 1], ['AN', 'AN', 'R', 'R']), ('control layout', [['ON', 'WS', 'B', 'ON', 'L', 'R', 'AN', 'L', 'EN', 'WS'], 'L', 'R', 1], ['L', 'L', 'L', 'L', 'L', 'R', 'AN', 'L', 'EN', 'R'])], [('regression: embedding direction parity', [['AN', 'R', 'ON', 'B', 'EN', 'EN', 'EN', 'R', 'ON', 'L'], 'R', 'R', 0], ['AN', 'R', 'R', 'R', 'EN', 'EN', 'EN', 'R', 'L', 'L']), ('regression: embedding direction parity', [['L', 'L', 'WS', 'WS', 'S', 'R', 'R', 'WS', 'AN', 'WS', 'L'], 'R', 'L', 2], ['L', 'L', 'L', 'L', 'L', 'R', 'R', 'R', 'AN', 'L', 'L']), ('regression: embedding direction parity', [['AN', 'B', 'S'], 'R', 'L', 2], ['AN', 'L', 'L']), ('regression: embedding direction parity', [['WS', 'WS', 'B', 'R', 'R', 'EN', 'S', 'EN'], 'L', 'R', 2], ['L', 'L', 'L', 'R', 'R', 'EN', 'R', 'EN']), ('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', [['ON', 'WS', 'EN'], 'R', 'R', 1], ['R', 'R', 'EN']), ('control layout', [['AN', 'L'], 'L', 'R', 1], ['AN', 'L'])], [('regression: embedding direction parity', [['B', 'R', 'ON', 'L', 'AN', 'AN', 'WS'], 'L', 'R', 1], ['R', 'R', 'R', 'L', 'AN', 'AN', 'R']), ('regression: embedding direction parity', [['WS', 'EN', 'R', 'WS', 'L', 'EN', 'R'], 'L', 'L', 2], ['L', 'EN', 'R', 'L', 'L', 'EN', 'R']), ('regression: embedding direction parity', [['B', 'L', 'ON', 'ON', 'AN', 'AN', 'EN'], 'L', 'R', 2], ['L', 'L', 'L', 'L', 'AN', 'AN', 'EN']), ('regression: embedding direction parity', [['EN', 'R', 'ON', 'ON', 'WS', 'ON', 'WS', 'L', 'WS'], 'L', 'R', 2], ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', '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', [['R', 'L', 'ON', 'WS', 'L', 'L', 'R', 'WS', 'WS'], 'L', 'R', 2], ['R', 'L', 'L', 'L', 'L', 'L', 'R', 'R', 'R']), ('control layout', [['R', 'EN', 'ON', 'AN'], 'L', 'L', 3], ['R', 'EN', 'R', 'AN'])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: embedding direction parity | ['R', 'L', 'L', 'L', 'L', 'R', 'L', 'L', 'L'] | ['R', 'L', 'L', 'L', 'L', 'R', 'L', 'L', 'L'] | Passed |
| regression: embedding direction parity | ['EN', 'L', 'AN', 'L', 'L', 'L', 'L'] | ['EN', 'L', 'AN', 'L', 'L', 'L', 'L'] | Passed |
| regression: embedding direction parity | ['EN', 'R', 'R', 'R', 'R', 'R', 'R', 'L', 'R'] | ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'L'] | Failed |
| regression: embedding direction parity | ['R', 'L', 'R', 'R', 'AN', 'R', 'R', 'L', 'AN'] | ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN'] | 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 | ['R', 'L'] | ['R', 'L'] | Passed |
| control layout | ['EN', 'R', 'EN', 'R'] | ['EN', 'R', 'EN', 'R'] | Passed |
SHA-256 / 1acb4e04951f4e20b451379785cbe15ef7eb37a6e614899c946fb66766d009fc
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: embedding direction parity', [['R', 'ON', 'L', 'WS', 'WS', 'R', 'L', 'L', 'WS'], 'R', 'L', 0], ['R', 'L', 'L', 'L', 'L', 'R', 'L', 'L', 'L']), ('regression: embedding direction parity', [['EN', 'L', 'AN', 'ON', 'L', 'L', 'ON'], 'R', 'R', 0], ['EN', 'L', 'AN', 'L', 'L', 'L', 'L']), ('regression: embedding direction parity', [['EN', 'R', 'ON', 'ON', 'WS', 'ON', 'WS', 'L', 'WS'], 'L', 'R', 2], ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'L']), ('regression: embedding direction parity', [['ON', 'L', 'R', 'WS', 'AN', 'ON', 'WS', 'L', 'AN'], 'R', 'R', 2], ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN']), ('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', [['R', 'L'], 'R', 'R', 3], ['R', 'L']), ('control layout', [['EN', 'R', 'EN', 'R'], 'L', 'L', 3], ['EN', 'R', 'EN', 'R'])], [('regression: embedding direction parity', [['EN', 'EN', 'ON', 'L', 'S', 'L', 'WS', 'R', 'R', 'ON', 'L'], 'R', 'R', 3], ['EN', 'EN', 'R', 'L', 'L', 'L', 'R', 'R', 'R', 'R', 'L']), ('regression: embedding direction parity', [['S', 'S', 'R', 'R', 'R', 'ON', 'AN', 'L', 'S'], 'L', 'L', 3], ['R', 'R', 'R', 'R', 'R', 'R', 'AN', 'L', 'L']), ('regression: embedding direction parity', [['R', 'ON', 'AN', 'ON', 'S', 'AN', 'WS', 'L', 'AN'], 'R', 'L', 2], ['R', 'R', 'AN', 'R', 'R', 'AN', 'L', 'L', 'AN']), ('regression: embedding direction parity', [['ON', 'L', 'R', 'WS', 'AN', 'ON', 'WS', 'L', 'AN'], 'R', 'R', 2], ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN']), ('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', [['L', 'L'], 'L', 'R', 0], ['L', 'L']), ('control layout', [['ON', 'WS', 'EN', 'L', 'R', 'L', 'R', 'ON', 'AN', 'L'], 'R', 'R', 3], ['R', 'R', 'EN', 'L', 'R', 'L', 'R', 'R', 'AN', 'L'])], [('regression: embedding direction parity', [['WS', 'EN', 'L', 'WS', 'ON', 'WS'], 'L', 'R', 3], ['R', 'EN', 'L', 'R', 'R', 'R']), ('regression: embedding direction parity', [['EN', 'AN', 'WS', 'L', 'ON', 'R'], 'L', 'L', 1], ['EN', 'AN', 'R', 'L', 'R', 'R']), ('regression: embedding direction parity', [['ON', 'AN', 'R', 'R'], 'L', 'L', 2], ['L', 'AN', 'R', 'R']), ('regression: embedding direction parity', [['WS', 'R'], 'L', 'L', 2], ['L', 'R']), ('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', [['AN', 'AN', 'ON', 'R'], 'L', 'L', 1], ['AN', 'AN', 'R', 'R']), ('control layout', [['ON', 'WS', 'B', 'ON', 'L', 'R', 'AN', 'L', 'EN', 'WS'], 'L', 'R', 1], ['L', 'L', 'L', 'L', 'L', 'R', 'AN', 'L', 'EN', 'R'])], [('regression: embedding direction parity', [['AN', 'R', 'ON', 'B', 'EN', 'EN', 'EN', 'R', 'ON', 'L'], 'R', 'R', 0], ['AN', 'R', 'R', 'R', 'EN', 'EN', 'EN', 'R', 'L', 'L']), ('regression: embedding direction parity', [['L', 'L', 'WS', 'WS', 'S', 'R', 'R', 'WS', 'AN', 'WS', 'L'], 'R', 'L', 2], ['L', 'L', 'L', 'L', 'L', 'R', 'R', 'R', 'AN', 'L', 'L']), ('regression: embedding direction parity', [['AN', 'B', 'S'], 'R', 'L', 2], ['AN', 'L', 'L']), ('regression: embedding direction parity', [['WS', 'WS', 'B', 'R', 'R', 'EN', 'S', 'EN'], 'L', 'R', 2], ['L', 'L', 'L', 'R', 'R', 'EN', 'R', 'EN']), ('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', [['ON', 'WS', 'EN'], 'R', 'R', 1], ['R', 'R', 'EN']), ('control layout', [['AN', 'L'], 'L', 'R', 1], ['AN', 'L'])], [('regression: embedding direction parity', [['B', 'R', 'ON', 'L', 'AN', 'AN', 'WS'], 'L', 'R', 1], ['R', 'R', 'R', 'L', 'AN', 'AN', 'R']), ('regression: embedding direction parity', [['WS', 'EN', 'R', 'WS', 'L', 'EN', 'R'], 'L', 'L', 2], ['L', 'EN', 'R', 'L', 'L', 'EN', 'R']), ('regression: embedding direction parity', [['B', 'L', 'ON', 'ON', 'AN', 'AN', 'EN'], 'L', 'R', 2], ['L', 'L', 'L', 'L', 'AN', 'AN', 'EN']), ('regression: embedding direction parity', [['EN', 'R', 'ON', 'ON', 'WS', 'ON', 'WS', 'L', 'WS'], 'L', 'R', 2], ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', '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', [['R', 'L', 'ON', 'WS', 'L', 'L', 'R', 'WS', 'WS'], 'L', 'R', 2], ['R', 'L', 'L', 'L', 'L', 'L', 'R', 'R', 'R']), ('control layout', [['R', 'EN', 'ON', 'AN'], 'L', 'L', 3], ['R', 'EN', 'R', 'AN'])]]
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: embedding direction parity | ['R', 'L', 'L', 'L', 'L', 'R', 'L', 'L', 'L'] | ['R', 'L', 'L', 'L', 'L', 'R', 'L', 'L', 'L'] | Passed |
| regression: embedding direction parity | ['EN', 'L', 'AN', 'L', 'L', 'L', 'L'] | ['EN', 'L', 'AN', 'L', 'L', 'L', 'L'] | Passed |
| regression: embedding direction parity | ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'L'] | ['EN', 'R', 'L', 'L', 'L', 'L', 'L', 'L', 'L'] | Passed |
| regression: embedding direction parity | ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN'] | ['L', 'L', 'R', 'R', 'AN', 'L', 'L', 'L', 'AN'] | 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 | ['R', 'L'] | ['R', 'L'] | Passed |
| control layout | ['EN', 'R', 'EN', 'R'] | ['EN', 'R', 'EN', 'R'] | Passed |
SHA-256 / 6f203b93dc1711a1aa2d934b4ac4f9dc3b838ec4b95b3f8a6f63477644fa2fa3
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.572409+00:00.
Case digest / 853260f1afc855c87544d0892bc3ebd79c8bf92ba80e3451c7c7317c06e455b7