FA-80371 / Bidirectional text layout / Open access
Weak type resolution: nonspacing mark inheritance · case 01
Combining marks take the sequence start type instead of their base.
ROOT CAUSE
W1 assigns sos to every NSM instead of the preceding type.
VERIFIED REPAIR
Give each NSM the type of the preceding character.
Unsuccessful approach: Using the original class of the previous character copies NSM for mark chains.
Case contract
Input [classes of one isolating run sequence, sos]. W1 NSM takes the previous type (sos at start; ON after LRI/RLI/FSI/PDI). W2 EN after the last strong AL becomes AN. W3 AL->R. W4 a single ES between EN and EN -> EN; a single CS between two numbers of the same type takes that type. W5 a run of ET adjacent to EN -> EN. W6 remaining ES/ET/CS -> ON. W7 EN whose last strong (sos at start) is L -> L. Return resolved 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 = x
t = list(types)
n = len(t)
prev = sos
for i in range(n):
if t[i] == 'NSM':
t[i] = sos
prev = t[i]
last_strong = sos
for i in range(n):
if t[i] in ('L', 'R', 'AL'):
last_strong = t[i]
elif t[i] == 'EN' and last_strong == 'AL':
t[i] = 'AN'
t = ['R' if c == 'AL' else c for c in t]
for i in range(1, n - 1):
if t[i] == 'ES' and t[i - 1] == 'EN' and t[i + 1] == 'EN':
t[i] = 'EN'
elif t[i] == 'CS' and t[i - 1] == t[i + 1] and t[i - 1] in ('EN', 'AN'):
t[i] = t[i - 1]
i = 0
while i < n:
if t[i] == 'ET':
j = i
while j < n and t[j] == 'ET':
j += 1
if (i > 0 and t[i - 1] == 'EN') or (j < n and t[j] == 'EN'):
for k in range(i, j):
t[k] = 'EN'
i = j
else:
i += 1
t = ['ON' if c in ('ES', 'ET', 'CS') else c for c in t]
strong = sos
for i in range(n):
if t[i] in ('L', 'R'):
strong = t[i]
elif t[i] == 'EN' and strong == 'L':
t[i] = 'L'
return t
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('NSM chain after R', [['R', 'NSM', 'NSM', 'EN'], 'L'], ['R', 'R', 'R', 'EN']), ('regression: nonspacing mark inheritance', [['NSM', 'EN', 'LRI', 'ET', 'NSM', 'AN', 'ES', 'ET'], 'L'], ['L', 'L', 'LRI', 'ON', 'ON', 'AN', 'ON', 'ON']), ('regression: nonspacing mark inheritance', [['LRI', 'NSM', 'AN'], 'L'], ['LRI', 'ON', 'AN']), ('partial-repair probe', [['NSM', 'NSM', 'R', 'AL', 'AN', 'CS'], 'R'], ['R', 'R', 'R', 'R', 'AN', 'ON']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('percent after number', [['EN', 'ET', 'ET', 'L'], 'R'], ['EN', 'EN', 'EN', 'L']), ('control layout', [['AN', 'EN'], 'R'], ['AN', 'EN']), ('control layout', [['WS', 'L'], 'L'], ['WS', 'L'])], [('regression: nonspacing mark inheritance', [['L', 'LRI', 'CS', 'WS', 'CS', 'AN', 'NSM', 'CS', 'ON', 'AN', 'CS'], 'L'], ['L', 'LRI', 'ON', 'WS', 'ON', 'AN', 'AN', 'ON', 'ON', 'AN', 'ON']), ('regression: nonspacing mark inheritance', [['EN', 'AL', 'L', 'ES', 'NSM', 'ES', 'AL', 'ES', 'EN', 'AL'], 'R'], ['EN', 'R', 'L', 'ON', 'ON', 'ON', 'R', 'ON', 'AN', 'R']), ('partial-repair probe', [['EN', 'EN', 'NSM', 'NSM', 'EN', 'AN'], 'L'], ['L', 'L', 'L', 'L', 'L', 'AN']), ('partial-repair probe', [['R', 'L', 'NSM', 'NSM', 'AN', 'ES', 'WS', 'EN', 'EN', 'CS'], 'L'], ['R', 'L', 'L', 'L', 'AN', 'ON', 'WS', 'L', 'L', 'ON']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('percent after number', [['EN', 'ET', 'ET', 'L'], 'R'], ['EN', 'EN', 'EN', 'L']), ('control layout', [['WS', 'L', 'ET', 'EN', 'AN', 'R'], 'L'], ['WS', 'L', 'L', 'L', 'AN', 'R']), ('control layout', [['LRI', 'WS', 'ET'], 'R'], ['LRI', 'WS', 'ON'])], [('regression: nonspacing mark inheritance', [['EN', 'AL', 'L', 'ES', 'NSM', 'ES', 'AL', 'ES', 'EN', 'AL'], 'R'], ['EN', 'R', 'L', 'ON', 'ON', 'ON', 'R', 'ON', 'AN', 'R']), ('regression: nonspacing mark inheritance', [['PDI', 'ET', 'NSM', 'NSM', 'ET'], 'R'], ['PDI', 'ON', 'ON', 'ON', 'ON']), ('regression: nonspacing mark inheritance', [['NSM', 'AN', 'AL', 'NSM', 'AL', 'NSM', 'PDI', 'NSM', 'EN'], 'L'], ['L', 'AN', 'R', 'R', 'R', 'R', 'PDI', 'ON', 'AN']), ('partial-repair probe', [['NSM', 'NSM', 'EN', 'CS', 'EN', 'ON', 'WS', 'LRI', 'CS'], 'L'], ['L', 'L', 'L', 'L', 'L', 'ON', 'WS', 'LRI', 'ON']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['AL', 'R', 'ON'], 'R'], ['R', 'R', 'ON']), ('control layout', [['ET', 'EN', 'AN', 'L'], 'L'], ['L', 'L', 'AN', 'L'])], [('regression: nonspacing mark inheritance', [['AN', 'NSM', 'AN', 'EN', 'CS', 'CS', 'EN', 'EN', 'AL'], 'L'], ['AN', 'AN', 'AN', 'L', 'ON', 'ON', 'L', 'L', 'R']), ('regression: nonspacing mark inheritance', [['EN', 'CS', 'NSM', 'LRI'], 'R'], ['EN', 'ON', 'ON', 'LRI']), ('regression: nonspacing mark inheritance', [['ET', 'PDI', 'NSM', 'ON', 'ON', 'NSM', 'NSM', 'EN'], 'L'], ['ON', 'PDI', 'ON', 'ON', 'ON', 'ON', 'ON', 'L']), ('regression: nonspacing mark inheritance', [['ES', 'R', 'L', 'LRI', 'NSM'], 'R'], ['ON', 'R', 'L', 'LRI', 'ON']), ('Arabic number context', [['AL', 'EN', 'CS', 'EN'], 'L'], ['R', 'AN', 'AN', 'AN']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['EN', 'CS', 'R', 'AL', 'ET', 'ES', 'AN', 'R', 'AL', 'AL', 'L'], 'L'], ['L', 'ON', 'R', 'R', 'ON', 'ON', 'AN', 'R', 'R', 'R', 'L']), ('control layout', [['L', 'ES', 'AL', 'LRI'], 'R'], ['L', 'ON', 'R', 'LRI'])], [('regression: nonspacing mark inheritance', [['L', 'L', 'CS', 'ET', 'CS', 'NSM', 'AL', 'LRI', 'PDI', 'L', 'ES'], 'R'], ['L', 'L', 'ON', 'ON', 'ON', 'ON', 'R', 'LRI', 'PDI', 'L', 'ON']), ('regression: nonspacing mark inheritance', [['L', 'CS', 'AL', 'NSM', 'ET', 'CS', 'AN', 'ES', 'EN'], 'R'], ['L', 'ON', 'R', 'R', 'ON', 'ON', 'AN', 'ON', 'AN']), ('partial-repair probe', [['ET', 'PDI', 'EN', 'NSM', 'NSM', 'R', 'L', 'AL'], 'L'], ['ON', 'PDI', 'L', 'L', 'L', 'R', 'L', 'R']), ('regression: nonspacing mark inheritance', [['NSM', 'AN', 'AL', 'NSM', 'AL', 'NSM', 'PDI', 'NSM', 'EN'], 'L'], ['L', 'AN', 'R', 'R', 'R', 'R', 'PDI', 'ON', 'AN']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['NSM', 'LRI', 'EN', 'L', 'WS'], 'L'], ['L', 'LRI', 'L', 'L', 'WS']), ('control layout', [['AN', 'ES', 'ET', 'ON', 'AL'], 'L'], ['AN', 'ON', 'ON', 'ON', '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| NSM chain after R | ['R', 'L', 'L', 'L'] | ['R', 'R', 'R', 'EN'] | Failed |
| regression: nonspacing mark inheritance | ['L', 'L', 'LRI', 'ON', 'L', 'AN', 'ON', 'ON'] | ['L', 'L', 'LRI', 'ON', 'ON', 'AN', 'ON', 'ON'] | Failed |
| regression: nonspacing mark inheritance | ['LRI', 'L', 'AN'] | ['LRI', 'ON', 'AN'] | Failed |
| partial-repair probe | ['R', 'R', 'R', 'R', 'AN', 'ON'] | ['R', 'R', 'R', 'R', 'AN', 'ON'] | Passed |
| NSM after isolate initiator | ['LRI', 'R', 'L', 'PDI'] | ['LRI', 'ON', 'L', 'PDI'] | Failed |
| percent after number | ['EN', 'EN', 'EN', 'L'] | ['EN', 'EN', 'EN', 'L'] | Passed |
| control layout | ['AN', 'EN'] | ['AN', 'EN'] | Passed |
| control layout | ['WS', 'L'] | ['WS', 'L'] | Passed |
SHA-256 / df0b8e7590874a57ab0f5925f9ef8d58a27b1791c7b3d68cb5997ea154c0da7e
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
types, sos = x
t = list(types)
n = len(t)
prev = sos
for i in range(n):
if t[i] == 'NSM':
t[i] = types[i - 1] if i else sos
prev = t[i]
last_strong = sos
for i in range(n):
if t[i] in ('L', 'R', 'AL'):
last_strong = t[i]
elif t[i] == 'EN' and last_strong == 'AL':
t[i] = 'AN'
t = ['R' if c == 'AL' else c for c in t]
for i in range(1, n - 1):
if t[i] == 'ES' and t[i - 1] == 'EN' and t[i + 1] == 'EN':
t[i] = 'EN'
elif t[i] == 'CS' and t[i - 1] == t[i + 1] and t[i - 1] in ('EN', 'AN'):
t[i] = t[i - 1]
i = 0
while i < n:
if t[i] == 'ET':
j = i
while j < n and t[j] == 'ET':
j += 1
if (i > 0 and t[i - 1] == 'EN') or (j < n and t[j] == 'EN'):
for k in range(i, j):
t[k] = 'EN'
i = j
else:
i += 1
t = ['ON' if c in ('ES', 'ET', 'CS') else c for c in t]
strong = sos
for i in range(n):
if t[i] in ('L', 'R'):
strong = t[i]
elif t[i] == 'EN' and strong == 'L':
t[i] = 'L'
return t
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('NSM chain after R', [['R', 'NSM', 'NSM', 'EN'], 'L'], ['R', 'R', 'R', 'EN']), ('regression: nonspacing mark inheritance', [['NSM', 'EN', 'LRI', 'ET', 'NSM', 'AN', 'ES', 'ET'], 'L'], ['L', 'L', 'LRI', 'ON', 'ON', 'AN', 'ON', 'ON']), ('regression: nonspacing mark inheritance', [['LRI', 'NSM', 'AN'], 'L'], ['LRI', 'ON', 'AN']), ('partial-repair probe', [['NSM', 'NSM', 'R', 'AL', 'AN', 'CS'], 'R'], ['R', 'R', 'R', 'R', 'AN', 'ON']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('percent after number', [['EN', 'ET', 'ET', 'L'], 'R'], ['EN', 'EN', 'EN', 'L']), ('control layout', [['AN', 'EN'], 'R'], ['AN', 'EN']), ('control layout', [['WS', 'L'], 'L'], ['WS', 'L'])], [('regression: nonspacing mark inheritance', [['L', 'LRI', 'CS', 'WS', 'CS', 'AN', 'NSM', 'CS', 'ON', 'AN', 'CS'], 'L'], ['L', 'LRI', 'ON', 'WS', 'ON', 'AN', 'AN', 'ON', 'ON', 'AN', 'ON']), ('regression: nonspacing mark inheritance', [['EN', 'AL', 'L', 'ES', 'NSM', 'ES', 'AL', 'ES', 'EN', 'AL'], 'R'], ['EN', 'R', 'L', 'ON', 'ON', 'ON', 'R', 'ON', 'AN', 'R']), ('partial-repair probe', [['EN', 'EN', 'NSM', 'NSM', 'EN', 'AN'], 'L'], ['L', 'L', 'L', 'L', 'L', 'AN']), ('partial-repair probe', [['R', 'L', 'NSM', 'NSM', 'AN', 'ES', 'WS', 'EN', 'EN', 'CS'], 'L'], ['R', 'L', 'L', 'L', 'AN', 'ON', 'WS', 'L', 'L', 'ON']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('percent after number', [['EN', 'ET', 'ET', 'L'], 'R'], ['EN', 'EN', 'EN', 'L']), ('control layout', [['WS', 'L', 'ET', 'EN', 'AN', 'R'], 'L'], ['WS', 'L', 'L', 'L', 'AN', 'R']), ('control layout', [['LRI', 'WS', 'ET'], 'R'], ['LRI', 'WS', 'ON'])], [('regression: nonspacing mark inheritance', [['EN', 'AL', 'L', 'ES', 'NSM', 'ES', 'AL', 'ES', 'EN', 'AL'], 'R'], ['EN', 'R', 'L', 'ON', 'ON', 'ON', 'R', 'ON', 'AN', 'R']), ('regression: nonspacing mark inheritance', [['PDI', 'ET', 'NSM', 'NSM', 'ET'], 'R'], ['PDI', 'ON', 'ON', 'ON', 'ON']), ('regression: nonspacing mark inheritance', [['NSM', 'AN', 'AL', 'NSM', 'AL', 'NSM', 'PDI', 'NSM', 'EN'], 'L'], ['L', 'AN', 'R', 'R', 'R', 'R', 'PDI', 'ON', 'AN']), ('partial-repair probe', [['NSM', 'NSM', 'EN', 'CS', 'EN', 'ON', 'WS', 'LRI', 'CS'], 'L'], ['L', 'L', 'L', 'L', 'L', 'ON', 'WS', 'LRI', 'ON']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['AL', 'R', 'ON'], 'R'], ['R', 'R', 'ON']), ('control layout', [['ET', 'EN', 'AN', 'L'], 'L'], ['L', 'L', 'AN', 'L'])], [('regression: nonspacing mark inheritance', [['AN', 'NSM', 'AN', 'EN', 'CS', 'CS', 'EN', 'EN', 'AL'], 'L'], ['AN', 'AN', 'AN', 'L', 'ON', 'ON', 'L', 'L', 'R']), ('regression: nonspacing mark inheritance', [['EN', 'CS', 'NSM', 'LRI'], 'R'], ['EN', 'ON', 'ON', 'LRI']), ('regression: nonspacing mark inheritance', [['ET', 'PDI', 'NSM', 'ON', 'ON', 'NSM', 'NSM', 'EN'], 'L'], ['ON', 'PDI', 'ON', 'ON', 'ON', 'ON', 'ON', 'L']), ('regression: nonspacing mark inheritance', [['ES', 'R', 'L', 'LRI', 'NSM'], 'R'], ['ON', 'R', 'L', 'LRI', 'ON']), ('Arabic number context', [['AL', 'EN', 'CS', 'EN'], 'L'], ['R', 'AN', 'AN', 'AN']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['EN', 'CS', 'R', 'AL', 'ET', 'ES', 'AN', 'R', 'AL', 'AL', 'L'], 'L'], ['L', 'ON', 'R', 'R', 'ON', 'ON', 'AN', 'R', 'R', 'R', 'L']), ('control layout', [['L', 'ES', 'AL', 'LRI'], 'R'], ['L', 'ON', 'R', 'LRI'])], [('regression: nonspacing mark inheritance', [['L', 'L', 'CS', 'ET', 'CS', 'NSM', 'AL', 'LRI', 'PDI', 'L', 'ES'], 'R'], ['L', 'L', 'ON', 'ON', 'ON', 'ON', 'R', 'LRI', 'PDI', 'L', 'ON']), ('regression: nonspacing mark inheritance', [['L', 'CS', 'AL', 'NSM', 'ET', 'CS', 'AN', 'ES', 'EN'], 'R'], ['L', 'ON', 'R', 'R', 'ON', 'ON', 'AN', 'ON', 'AN']), ('partial-repair probe', [['ET', 'PDI', 'EN', 'NSM', 'NSM', 'R', 'L', 'AL'], 'L'], ['ON', 'PDI', 'L', 'L', 'L', 'R', 'L', 'R']), ('regression: nonspacing mark inheritance', [['NSM', 'AN', 'AL', 'NSM', 'AL', 'NSM', 'PDI', 'NSM', 'EN'], 'L'], ['L', 'AN', 'R', 'R', 'R', 'R', 'PDI', 'ON', 'AN']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['NSM', 'LRI', 'EN', 'L', 'WS'], 'L'], ['L', 'LRI', 'L', 'L', 'WS']), ('control layout', [['AN', 'ES', 'ET', 'ON', 'AL'], 'L'], ['AN', 'ON', 'ON', 'ON', '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| NSM chain after R | ['R', 'R', 'NSM', 'EN'] | ['R', 'R', 'R', 'EN'] | Failed |
| regression: nonspacing mark inheritance | ['L', 'L', 'LRI', 'ON', 'ON', 'AN', 'ON', 'ON'] | ['L', 'L', 'LRI', 'ON', 'ON', 'AN', 'ON', 'ON'] | Passed |
| regression: nonspacing mark inheritance | ['LRI', 'LRI', 'AN'] | ['LRI', 'ON', 'AN'] | Failed |
| partial-repair probe | ['R', 'NSM', 'R', 'R', 'AN', 'ON'] | ['R', 'R', 'R', 'R', 'AN', 'ON'] | Failed |
| NSM after isolate initiator | ['LRI', 'LRI', 'L', 'PDI'] | ['LRI', 'ON', 'L', 'PDI'] | Failed |
| percent after number | ['EN', 'EN', 'EN', 'L'] | ['EN', 'EN', 'EN', 'L'] | Passed |
| control layout | ['AN', 'EN'] | ['AN', 'EN'] | Passed |
| control layout | ['WS', 'L'] | ['WS', 'L'] | Passed |
SHA-256 / 710f1af6737c1f24f9274af2173e12c11cf84ba13214310ac9ce4b833ec7f02a
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
types, sos = x
t = list(types)
n = len(t)
prev = sos
for i in range(n):
if t[i] == 'NSM':
t[i] = 'ON' if prev in ('LRI', 'RLI', 'FSI', 'PDI') else prev
prev = t[i]
last_strong = sos
for i in range(n):
if t[i] in ('L', 'R', 'AL'):
last_strong = t[i]
elif t[i] == 'EN' and last_strong == 'AL':
t[i] = 'AN'
t = ['R' if c == 'AL' else c for c in t]
for i in range(1, n - 1):
if t[i] == 'ES' and t[i - 1] == 'EN' and t[i + 1] == 'EN':
t[i] = 'EN'
elif t[i] == 'CS' and t[i - 1] == t[i + 1] and t[i - 1] in ('EN', 'AN'):
t[i] = t[i - 1]
i = 0
while i < n:
if t[i] == 'ET':
j = i
while j < n and t[j] == 'ET':
j += 1
if (i > 0 and t[i - 1] == 'EN') or (j < n and t[j] == 'EN'):
for k in range(i, j):
t[k] = 'EN'
i = j
else:
i += 1
t = ['ON' if c in ('ES', 'ET', 'CS') else c for c in t]
strong = sos
for i in range(n):
if t[i] in ('L', 'R'):
strong = t[i]
elif t[i] == 'EN' and strong == 'L':
t[i] = 'L'
return t
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('NSM chain after R', [['R', 'NSM', 'NSM', 'EN'], 'L'], ['R', 'R', 'R', 'EN']), ('regression: nonspacing mark inheritance', [['NSM', 'EN', 'LRI', 'ET', 'NSM', 'AN', 'ES', 'ET'], 'L'], ['L', 'L', 'LRI', 'ON', 'ON', 'AN', 'ON', 'ON']), ('regression: nonspacing mark inheritance', [['LRI', 'NSM', 'AN'], 'L'], ['LRI', 'ON', 'AN']), ('partial-repair probe', [['NSM', 'NSM', 'R', 'AL', 'AN', 'CS'], 'R'], ['R', 'R', 'R', 'R', 'AN', 'ON']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('percent after number', [['EN', 'ET', 'ET', 'L'], 'R'], ['EN', 'EN', 'EN', 'L']), ('control layout', [['AN', 'EN'], 'R'], ['AN', 'EN']), ('control layout', [['WS', 'L'], 'L'], ['WS', 'L'])], [('regression: nonspacing mark inheritance', [['L', 'LRI', 'CS', 'WS', 'CS', 'AN', 'NSM', 'CS', 'ON', 'AN', 'CS'], 'L'], ['L', 'LRI', 'ON', 'WS', 'ON', 'AN', 'AN', 'ON', 'ON', 'AN', 'ON']), ('regression: nonspacing mark inheritance', [['EN', 'AL', 'L', 'ES', 'NSM', 'ES', 'AL', 'ES', 'EN', 'AL'], 'R'], ['EN', 'R', 'L', 'ON', 'ON', 'ON', 'R', 'ON', 'AN', 'R']), ('partial-repair probe', [['EN', 'EN', 'NSM', 'NSM', 'EN', 'AN'], 'L'], ['L', 'L', 'L', 'L', 'L', 'AN']), ('partial-repair probe', [['R', 'L', 'NSM', 'NSM', 'AN', 'ES', 'WS', 'EN', 'EN', 'CS'], 'L'], ['R', 'L', 'L', 'L', 'AN', 'ON', 'WS', 'L', 'L', 'ON']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('percent after number', [['EN', 'ET', 'ET', 'L'], 'R'], ['EN', 'EN', 'EN', 'L']), ('control layout', [['WS', 'L', 'ET', 'EN', 'AN', 'R'], 'L'], ['WS', 'L', 'L', 'L', 'AN', 'R']), ('control layout', [['LRI', 'WS', 'ET'], 'R'], ['LRI', 'WS', 'ON'])], [('regression: nonspacing mark inheritance', [['EN', 'AL', 'L', 'ES', 'NSM', 'ES', 'AL', 'ES', 'EN', 'AL'], 'R'], ['EN', 'R', 'L', 'ON', 'ON', 'ON', 'R', 'ON', 'AN', 'R']), ('regression: nonspacing mark inheritance', [['PDI', 'ET', 'NSM', 'NSM', 'ET'], 'R'], ['PDI', 'ON', 'ON', 'ON', 'ON']), ('regression: nonspacing mark inheritance', [['NSM', 'AN', 'AL', 'NSM', 'AL', 'NSM', 'PDI', 'NSM', 'EN'], 'L'], ['L', 'AN', 'R', 'R', 'R', 'R', 'PDI', 'ON', 'AN']), ('partial-repair probe', [['NSM', 'NSM', 'EN', 'CS', 'EN', 'ON', 'WS', 'LRI', 'CS'], 'L'], ['L', 'L', 'L', 'L', 'L', 'ON', 'WS', 'LRI', 'ON']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['AL', 'R', 'ON'], 'R'], ['R', 'R', 'ON']), ('control layout', [['ET', 'EN', 'AN', 'L'], 'L'], ['L', 'L', 'AN', 'L'])], [('regression: nonspacing mark inheritance', [['AN', 'NSM', 'AN', 'EN', 'CS', 'CS', 'EN', 'EN', 'AL'], 'L'], ['AN', 'AN', 'AN', 'L', 'ON', 'ON', 'L', 'L', 'R']), ('regression: nonspacing mark inheritance', [['EN', 'CS', 'NSM', 'LRI'], 'R'], ['EN', 'ON', 'ON', 'LRI']), ('regression: nonspacing mark inheritance', [['ET', 'PDI', 'NSM', 'ON', 'ON', 'NSM', 'NSM', 'EN'], 'L'], ['ON', 'PDI', 'ON', 'ON', 'ON', 'ON', 'ON', 'L']), ('regression: nonspacing mark inheritance', [['ES', 'R', 'L', 'LRI', 'NSM'], 'R'], ['ON', 'R', 'L', 'LRI', 'ON']), ('Arabic number context', [['AL', 'EN', 'CS', 'EN'], 'L'], ['R', 'AN', 'AN', 'AN']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['EN', 'CS', 'R', 'AL', 'ET', 'ES', 'AN', 'R', 'AL', 'AL', 'L'], 'L'], ['L', 'ON', 'R', 'R', 'ON', 'ON', 'AN', 'R', 'R', 'R', 'L']), ('control layout', [['L', 'ES', 'AL', 'LRI'], 'R'], ['L', 'ON', 'R', 'LRI'])], [('regression: nonspacing mark inheritance', [['L', 'L', 'CS', 'ET', 'CS', 'NSM', 'AL', 'LRI', 'PDI', 'L', 'ES'], 'R'], ['L', 'L', 'ON', 'ON', 'ON', 'ON', 'R', 'LRI', 'PDI', 'L', 'ON']), ('regression: nonspacing mark inheritance', [['L', 'CS', 'AL', 'NSM', 'ET', 'CS', 'AN', 'ES', 'EN'], 'R'], ['L', 'ON', 'R', 'R', 'ON', 'ON', 'AN', 'ON', 'AN']), ('partial-repair probe', [['ET', 'PDI', 'EN', 'NSM', 'NSM', 'R', 'L', 'AL'], 'L'], ['ON', 'PDI', 'L', 'L', 'L', 'R', 'L', 'R']), ('regression: nonspacing mark inheritance', [['NSM', 'AN', 'AL', 'NSM', 'AL', 'NSM', 'PDI', 'NSM', 'EN'], 'L'], ['L', 'AN', 'R', 'R', 'R', 'R', 'PDI', 'ON', 'AN']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['NSM', 'LRI', 'EN', 'L', 'WS'], 'L'], ['L', 'LRI', 'L', 'L', 'WS']), ('control layout', [['AN', 'ES', 'ET', 'ON', 'AL'], 'L'], ['AN', 'ON', 'ON', 'ON', '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| NSM chain after R | ['R', 'R', 'R', 'EN'] | ['R', 'R', 'R', 'EN'] | Passed |
| regression: nonspacing mark inheritance | ['L', 'L', 'LRI', 'ON', 'ON', 'AN', 'ON', 'ON'] | ['L', 'L', 'LRI', 'ON', 'ON', 'AN', 'ON', 'ON'] | Passed |
| regression: nonspacing mark inheritance | ['LRI', 'ON', 'AN'] | ['LRI', 'ON', 'AN'] | Passed |
| partial-repair probe | ['R', 'R', 'R', 'R', 'AN', 'ON'] | ['R', 'R', 'R', 'R', 'AN', 'ON'] | Passed |
| NSM after isolate initiator | ['LRI', 'ON', 'L', 'PDI'] | ['LRI', 'ON', 'L', 'PDI'] | Passed |
| percent after number | ['EN', 'EN', 'EN', 'L'] | ['EN', 'EN', 'EN', 'L'] | Passed |
| control layout | ['AN', 'EN'] | ['AN', 'EN'] | Passed |
| control layout | ['WS', 'L'] | ['WS', 'L'] | Passed |
SHA-256 / b6a5f36627d5df08f7cd6eb42388b3f6d7ead2596e773f30ed900bc24533437a
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.241081+00:00.
Case digest / ed9a21b9a115d5c30b175be7c64342ef80135d8d692ff0a9b3b6cc0595b239aa