FA-80366 / Bidirectional text layout / Open access
First-strong paragraph direction: isolate content skipping · case 01
Letters inside isolates decide the paragraph direction.
ROOT CAUSE
Strong characters are accepted at any isolate depth.
VERIFIED REPAIR
Only accept strong characters at depth zero.
Unsuccessful approach: Accepting depth one still reads into single isolates.
Case contract
Input [bidi classes, default level]. Scan for the first L (level 0) or R/AL (level 1), skipping characters between an isolate initiator (LRI, RLI, FSI) and its matching PDI (nesting counted; an unmatched PDI is ignored). Embedding codes are not skipped. Return [level, index of deciding character] or [default, None].
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):
classes, default = x
depth = 0
for i, c in enumerate(classes):
if c in ('LRI', 'RLI', 'FSI'):
depth += 1
elif c == 'PDI':
if depth > 0:
depth -= 1
else:
if c == 'L':
return [0, i]
if c in ('R', 'AL'):
return [1, i]
return [default, None]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('stray PDI before isolate', [['PDI', 'RLI', 'L', 'PDI', 'R'], 0], [1, 4]), ('regression: isolate content skipping', [['FSI', 'L'], 0], [0, None]), ('regression: isolate content skipping', [['FSI', 'EN', 'AL', 'PDI', 'NSM', 'AL', 'LRE', 'L', 'AL', 'PDI'], 0], [1, 5]), ('regression: isolate content skipping', [['FSI', 'AL', 'ON', 'RLI', 'FSI', 'PDI'], 1], [1, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('control layout', [['L', 'PDI', 'WS', 'ON', 'PDI', 'ON', 'EN', 'LRE', 'EN', 'RLI'], 0], [0, 0]), ('control layout', [['FSI', 'AN'], 1], [1, None])], [('regression: isolate content skipping', [['FSI', 'ON', 'AL', 'EN', 'PDI', 'L', 'ES'], 1], [0, 5]), ('regression: isolate content skipping', [['LRE', 'EN', 'EN', 'WS', 'RLI', 'R'], 0], [0, None]), ('regression: isolate content skipping', [['FSI', 'ES', 'WS', 'EN', 'L', 'PDI'], 0], [0, None]), ('regression: isolate content skipping', [['RLI', 'L', 'PDI', 'FSI', 'LRE', 'WS', 'ON', 'RLI'], 1], [1, None]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('stray PDI before isolate', [['PDI', 'RLI', 'L', 'PDI', 'R'], 0], [1, 4]), ('control layout', [['EN', 'RLI'], 1], [1, None]), ('control layout', [['EN', 'L', 'FSI', 'LRI', 'ON', 'R', 'EN', 'ON', 'ON', 'AL'], 0], [0, 1])], [('regression: isolate content skipping', [['LRI', 'FSI', 'WS', 'R', 'ES', 'AN'], 1], [1, None]), ('regression: isolate content skipping', [['WS', 'RLI', 'FSI', 'ON', 'AL'], 1], [1, None]), ('regression: isolate content skipping', [['RLI', 'WS', 'R', 'L', 'RLI'], 0], [0, None]), ('regression: isolate content skipping', [['FSI', 'R', 'L', 'LRE'], 1], [1, None]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('control layout', [['NSM', 'EN', 'L', 'PDI', 'ES', 'AL', 'LRI'], 0], [0, 2]), ('control layout', [['ON', 'WS', 'R', 'LRI', 'AL', 'LRE', 'R'], 0], [1, 2])], [('regression: isolate content skipping', [['EN', 'FSI', 'FSI', 'FSI', 'R', 'FSI', 'L'], 0], [0, None]), ('regression: isolate content skipping', [['LRI', 'ON', 'LRI', 'EN', 'L', 'PDI', 'EN'], 1], [1, None]), ('regression: isolate content skipping', [['LRI', 'AL', 'ON', 'PDI', 'LRI', 'EN', 'PDI'], 0], [0, None]), ('regression: isolate content skipping', [['RLI', 'AL', 'LRI', 'LRI', 'WS', 'ON'], 0], [0, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('control layout', [['L', 'PDI', 'EN', 'LRI', 'RLI', 'R', 'R', 'NSM', 'AN', 'R'], 0], [0, 0]), ('control layout', [['PDI'], 0], [0, None])], [('regression: isolate content skipping', [['FSI', 'L', 'EN', 'ON', 'AL', 'NSM', 'R', 'RLI', 'WS'], 0], [0, None]), ('regression: isolate content skipping', [['EN', 'ES', 'LRI', 'WS', 'WS', 'FSI', 'PDI', 'AL'], 1], [1, None]), ('regression: isolate content skipping', [['PDI', 'FSI', 'ON', 'R', 'RLI', 'WS', 'FSI', 'AL'], 1], [1, None]), ('regression: isolate content skipping', [['RLI', 'R', 'LRI', 'PDI', 'NSM', 'AN'], 1], [1, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('FSI content skipped', [['FSI', 'R', 'PDI', 'L'], 1], [0, 3]), ('control layout', [['ES', 'LRE', 'LRE', 'ON', 'AL', 'ON', 'R'], 0], [1, 4]), ('control layout', [['EN'], 0], [0, None])]]
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 |
|---|---|---|---|
| stray PDI before isolate | [0, 2] | [1, 4] | Failed |
| regression: isolate content skipping | [0, 1] | [0, None] | Failed |
| regression: isolate content skipping | [1, 2] | [1, 5] | Failed |
| regression: isolate content skipping | [1, 1] | [1, None] | Failed |
| numbers are not strong | [1, 2] | [1, 2] | Passed |
| nested isolates | [1, 2] | [1, 6] | Failed |
| control layout | [0, 0] | [0, 0] | Passed |
| control layout | [1, None] | [1, None] | Passed |
SHA-256 / 89fd9e3e216dd7d32430eee3a2fcb326431cf50aca2ce23df055323e08cccb38
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
classes, default = x
depth = 0
for i, c in enumerate(classes):
if c in ('LRI', 'RLI', 'FSI'):
depth += 1
elif c == 'PDI':
if depth > 0:
depth -= 1
elif depth <= 1:
if c == 'L':
return [0, i]
if c in ('R', 'AL'):
return [1, i]
return [default, None]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('stray PDI before isolate', [['PDI', 'RLI', 'L', 'PDI', 'R'], 0], [1, 4]), ('regression: isolate content skipping', [['FSI', 'L'], 0], [0, None]), ('regression: isolate content skipping', [['FSI', 'EN', 'AL', 'PDI', 'NSM', 'AL', 'LRE', 'L', 'AL', 'PDI'], 0], [1, 5]), ('regression: isolate content skipping', [['FSI', 'AL', 'ON', 'RLI', 'FSI', 'PDI'], 1], [1, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('control layout', [['L', 'PDI', 'WS', 'ON', 'PDI', 'ON', 'EN', 'LRE', 'EN', 'RLI'], 0], [0, 0]), ('control layout', [['FSI', 'AN'], 1], [1, None])], [('regression: isolate content skipping', [['FSI', 'ON', 'AL', 'EN', 'PDI', 'L', 'ES'], 1], [0, 5]), ('regression: isolate content skipping', [['LRE', 'EN', 'EN', 'WS', 'RLI', 'R'], 0], [0, None]), ('regression: isolate content skipping', [['FSI', 'ES', 'WS', 'EN', 'L', 'PDI'], 0], [0, None]), ('regression: isolate content skipping', [['RLI', 'L', 'PDI', 'FSI', 'LRE', 'WS', 'ON', 'RLI'], 1], [1, None]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('stray PDI before isolate', [['PDI', 'RLI', 'L', 'PDI', 'R'], 0], [1, 4]), ('control layout', [['EN', 'RLI'], 1], [1, None]), ('control layout', [['EN', 'L', 'FSI', 'LRI', 'ON', 'R', 'EN', 'ON', 'ON', 'AL'], 0], [0, 1])], [('regression: isolate content skipping', [['LRI', 'FSI', 'WS', 'R', 'ES', 'AN'], 1], [1, None]), ('regression: isolate content skipping', [['WS', 'RLI', 'FSI', 'ON', 'AL'], 1], [1, None]), ('regression: isolate content skipping', [['RLI', 'WS', 'R', 'L', 'RLI'], 0], [0, None]), ('regression: isolate content skipping', [['FSI', 'R', 'L', 'LRE'], 1], [1, None]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('control layout', [['NSM', 'EN', 'L', 'PDI', 'ES', 'AL', 'LRI'], 0], [0, 2]), ('control layout', [['ON', 'WS', 'R', 'LRI', 'AL', 'LRE', 'R'], 0], [1, 2])], [('regression: isolate content skipping', [['EN', 'FSI', 'FSI', 'FSI', 'R', 'FSI', 'L'], 0], [0, None]), ('regression: isolate content skipping', [['LRI', 'ON', 'LRI', 'EN', 'L', 'PDI', 'EN'], 1], [1, None]), ('regression: isolate content skipping', [['LRI', 'AL', 'ON', 'PDI', 'LRI', 'EN', 'PDI'], 0], [0, None]), ('regression: isolate content skipping', [['RLI', 'AL', 'LRI', 'LRI', 'WS', 'ON'], 0], [0, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('control layout', [['L', 'PDI', 'EN', 'LRI', 'RLI', 'R', 'R', 'NSM', 'AN', 'R'], 0], [0, 0]), ('control layout', [['PDI'], 0], [0, None])], [('regression: isolate content skipping', [['FSI', 'L', 'EN', 'ON', 'AL', 'NSM', 'R', 'RLI', 'WS'], 0], [0, None]), ('regression: isolate content skipping', [['EN', 'ES', 'LRI', 'WS', 'WS', 'FSI', 'PDI', 'AL'], 1], [1, None]), ('regression: isolate content skipping', [['PDI', 'FSI', 'ON', 'R', 'RLI', 'WS', 'FSI', 'AL'], 1], [1, None]), ('regression: isolate content skipping', [['RLI', 'R', 'LRI', 'PDI', 'NSM', 'AN'], 1], [1, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('FSI content skipped', [['FSI', 'R', 'PDI', 'L'], 1], [0, 3]), ('control layout', [['ES', 'LRE', 'LRE', 'ON', 'AL', 'ON', 'R'], 0], [1, 4]), ('control layout', [['EN'], 0], [0, None])]]
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 |
|---|---|---|---|
| stray PDI before isolate | [0, 2] | [1, 4] | Failed |
| regression: isolate content skipping | [0, 1] | [0, None] | Failed |
| regression: isolate content skipping | [1, 2] | [1, 5] | Failed |
| regression: isolate content skipping | [1, 1] | [1, None] | Failed |
| numbers are not strong | [1, 2] | [1, 2] | Passed |
| nested isolates | [0, 4] | [1, 6] | Failed |
| control layout | [0, 0] | [0, 0] | Passed |
| control layout | [1, None] | [1, None] | Passed |
SHA-256 / 0c5f53ea676dad02be38f13af7bcfdbed3953b4a953f727666cb86dd03765659
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
classes, default = x
depth = 0
for i, c in enumerate(classes):
if c in ('LRI', 'RLI', 'FSI'):
depth += 1
elif c == 'PDI':
if depth > 0:
depth -= 1
elif depth == 0:
if c == 'L':
return [0, i]
if c in ('R', 'AL'):
return [1, i]
return [default, None]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('stray PDI before isolate', [['PDI', 'RLI', 'L', 'PDI', 'R'], 0], [1, 4]), ('regression: isolate content skipping', [['FSI', 'L'], 0], [0, None]), ('regression: isolate content skipping', [['FSI', 'EN', 'AL', 'PDI', 'NSM', 'AL', 'LRE', 'L', 'AL', 'PDI'], 0], [1, 5]), ('regression: isolate content skipping', [['FSI', 'AL', 'ON', 'RLI', 'FSI', 'PDI'], 1], [1, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('control layout', [['L', 'PDI', 'WS', 'ON', 'PDI', 'ON', 'EN', 'LRE', 'EN', 'RLI'], 0], [0, 0]), ('control layout', [['FSI', 'AN'], 1], [1, None])], [('regression: isolate content skipping', [['FSI', 'ON', 'AL', 'EN', 'PDI', 'L', 'ES'], 1], [0, 5]), ('regression: isolate content skipping', [['LRE', 'EN', 'EN', 'WS', 'RLI', 'R'], 0], [0, None]), ('regression: isolate content skipping', [['FSI', 'ES', 'WS', 'EN', 'L', 'PDI'], 0], [0, None]), ('regression: isolate content skipping', [['RLI', 'L', 'PDI', 'FSI', 'LRE', 'WS', 'ON', 'RLI'], 1], [1, None]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('stray PDI before isolate', [['PDI', 'RLI', 'L', 'PDI', 'R'], 0], [1, 4]), ('control layout', [['EN', 'RLI'], 1], [1, None]), ('control layout', [['EN', 'L', 'FSI', 'LRI', 'ON', 'R', 'EN', 'ON', 'ON', 'AL'], 0], [0, 1])], [('regression: isolate content skipping', [['LRI', 'FSI', 'WS', 'R', 'ES', 'AN'], 1], [1, None]), ('regression: isolate content skipping', [['WS', 'RLI', 'FSI', 'ON', 'AL'], 1], [1, None]), ('regression: isolate content skipping', [['RLI', 'WS', 'R', 'L', 'RLI'], 0], [0, None]), ('regression: isolate content skipping', [['FSI', 'R', 'L', 'LRE'], 1], [1, None]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('control layout', [['NSM', 'EN', 'L', 'PDI', 'ES', 'AL', 'LRI'], 0], [0, 2]), ('control layout', [['ON', 'WS', 'R', 'LRI', 'AL', 'LRE', 'R'], 0], [1, 2])], [('regression: isolate content skipping', [['EN', 'FSI', 'FSI', 'FSI', 'R', 'FSI', 'L'], 0], [0, None]), ('regression: isolate content skipping', [['LRI', 'ON', 'LRI', 'EN', 'L', 'PDI', 'EN'], 1], [1, None]), ('regression: isolate content skipping', [['LRI', 'AL', 'ON', 'PDI', 'LRI', 'EN', 'PDI'], 0], [0, None]), ('regression: isolate content skipping', [['RLI', 'AL', 'LRI', 'LRI', 'WS', 'ON'], 0], [0, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('control layout', [['L', 'PDI', 'EN', 'LRI', 'RLI', 'R', 'R', 'NSM', 'AN', 'R'], 0], [0, 0]), ('control layout', [['PDI'], 0], [0, None])], [('regression: isolate content skipping', [['FSI', 'L', 'EN', 'ON', 'AL', 'NSM', 'R', 'RLI', 'WS'], 0], [0, None]), ('regression: isolate content skipping', [['EN', 'ES', 'LRI', 'WS', 'WS', 'FSI', 'PDI', 'AL'], 1], [1, None]), ('regression: isolate content skipping', [['PDI', 'FSI', 'ON', 'R', 'RLI', 'WS', 'FSI', 'AL'], 1], [1, None]), ('regression: isolate content skipping', [['RLI', 'R', 'LRI', 'PDI', 'NSM', 'AN'], 1], [1, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('FSI content skipped', [['FSI', 'R', 'PDI', 'L'], 1], [0, 3]), ('control layout', [['ES', 'LRE', 'LRE', 'ON', 'AL', 'ON', 'R'], 0], [1, 4]), ('control layout', [['EN'], 0], [0, None])]]
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 |
|---|---|---|---|
| stray PDI before isolate | [1, 4] | [1, 4] | Passed |
| regression: isolate content skipping | [0, None] | [0, None] | Passed |
| regression: isolate content skipping | [1, 5] | [1, 5] | Passed |
| regression: isolate content skipping | [1, None] | [1, None] | Passed |
| numbers are not strong | [1, 2] | [1, 2] | Passed |
| nested isolates | [1, 6] | [1, 6] | Passed |
| control layout | [0, 0] | [0, 0] | Passed |
| control layout | [1, None] | [1, None] | Passed |
SHA-256 / 06cfb6a7a3c50e94f7342e5e58ff78ebb607e4867b49fc07f9c2d29f2e75d06d
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.155146+00:00.
Case digest / 0575b47224b2e8a837fc8cf1d00cdae667e47122d78106fdeacd7230fe646767