FAILURE MAP
← Case archive

FA-80496 / Bidirectional text layout / Open access

Line-end whitespace level reset: isolate controls in reset runs · case 01

Isolate controls at the line end keep embedded levels.

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

ROOT CAUSE

Only WS is treated as resettable whitespace.

VERIFIED REPAIR

Treat isolate formatting characters like whitespace in reset runs.

Unsuccessful approach: Adding only PDI still misses initiators.

Case contract

Input [original classes, resolved levels, paragraph level]. Reset to the paragraph level: every S and B; any run of WS and isolate formatting characters (FSI LRI RLI PDI) immediately before an S or B; and such a run at the end of the line. Return levels.

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, levels, para = x
    out = list(levels)
    n = len(classes)
    RESETTABLE = ('WS',)
    j = n - 1
    while j >= 0 and classes[j] in RESETTABLE:
        out[j] = para
        j -= 1
    for i, c in enumerate(classes):
        if c in ('S', 'B'):
            out[i] = para
            k = i - 1
            while k >= 0 and classes[k] in RESETTABLE:
                out[k] = para
                k -= 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('regression: isolate controls in reset runs', [['FSI', 'LRI', 'FSI', 'WS', 'B', 'RLI', 'WS', 'WS'], [1, 1, 3, 3, 2, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['S', 'WS', 'WS', 'FSI', 'B', 'ON', 'S', 'R'], [1, 1, 1, 1, 1, 1, 1, 1], 0], [0, 0, 0, 0, 0, 1, 0, 1]), ('regression: isolate controls in reset runs', [['PDI', 'WS', 'WS', 'LRI', 'RLI', 'WS'], [1, 1, 1, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('control layout', [['PDI', 'LRI', 'L', 'L', 'WS', 'ON'], [0, 0, 1, 1, 1, 1], 0], [0, 0, 1, 1, 1, 1]), ('control layout', [['WS', 'L', 'R', 'FSI', 'L'], [2, 2, 2, 2, 2], 1], [2, 2, 2, 2, 2])], [('regression: isolate controls in reset runs', [['RLI', 'R', 'LRI', 'FSI', 'WS'], [1, 2, 4, 4, 4], 0], [1, 2, 0, 0, 0]), ('regression: isolate controls in reset runs', [['ON', 'ON', 'WS', 'R', 'RLI', 'LRI'], [4, 4, 4, 4, 3, 4], 1], [4, 4, 4, 4, 1, 1]), ('regression: isolate controls in reset runs', [['ON', 'WS', 'R', 'ON', 'WS', 'R', 'WS', 'FSI', 'PDI'], [4, 4, 4, 4, 2, 2, 3, 4, 1], 0], [4, 4, 4, 4, 2, 2, 0, 0, 0]), ('regression: isolate controls in reset runs', [['S', 'WS', 'L', 'WS', 'R', 'L', 'RLI', 'PDI'], [4, 4, 2, 2, 2, 2, 3, 2], 0], [0, 4, 2, 2, 2, 2, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['B', 'S', 'WS', 'ON', 'L', 'FSI', 'WS', 'L', 'RLI', 'WS', 'L', 'B'], [1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 0], 1], [1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 1]), ('control layout', [['R'], [2], 1], [2])], [('regression: isolate controls in reset runs', [['L', 'L', 'WS', 'PDI'], [2, 2, 2, 2], 0], [2, 2, 0, 0]), ('regression: isolate controls in reset runs', [['ON', 'R', 'PDI', 'B', 'WS', 'RLI', 'FSI', 'B', 'WS'], [0, 0, 0, 0, 1, 1, 1, 3, 3], 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['B', 'WS', 'R', 'L', 'B', 'R', 'WS', 'FSI', 'ON', 'FSI'], [3, 3, 3, 3, 4, 4, 2, 2, 2, 4], 1], [1, 3, 3, 3, 1, 4, 2, 2, 2, 1]), ('regression: isolate controls in reset runs', [['LRI', 'R', 'EN', 'S', 'L', 'L', 'LRI', 'FSI', 'WS'], [3, 3, 3, 3, 3, 3, 3, 3, 4], 1], [3, 3, 3, 1, 3, 3, 1, 1, 1]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['L', 'L', 'R', 'ON', 'WS', 'WS', 'WS', 'L', 'WS', 'PDI', 'R'], [2, 2, 4, 4, 4, 1, 2, 2, 2, 2, 2], 0], [2, 2, 4, 4, 4, 1, 2, 2, 2, 2, 2]), ('control layout', [['LRI', 'R', 'ON', 'ON', 'PDI', 'PDI'], [1, 1, 1, 1, 1, 1], 1], [1, 1, 1, 1, 1, 1])], [('regression: isolate controls in reset runs', [['FSI', 'LRI', 'FSI', 'WS', 'B', 'RLI', 'WS', 'WS'], [1, 1, 3, 3, 2, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['L', 'WS', 'R', 'EN', 'WS', 'B', 'B', 'R', 'B', 'WS', 'L', 'LRI'], [2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 4, 4], 1], [2, 2, 2, 1, 1, 1, 1, 4, 1, 4, 4, 1]), ('regression: isolate controls in reset runs', [['WS', 'PDI', 'RLI'], [3, 1, 1], 0], [0, 0, 0]), ('regression: isolate controls in reset runs', [['PDI', 'FSI'], [0, 0], 1], [1, 1]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['B', 'L', 'EN'], [3, 3, 1], 1], [1, 3, 1]), ('control layout', [['WS', 'R', 'L'], [1, 1, 1], 0], [1, 1, 1])], [('regression: isolate controls in reset runs', [['WS', 'FSI', 'ON', 'RLI', 'PDI', 'RLI', 'FSI'], [0, 0, 0, 1, 1, 1, 1], 0], [0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['L', 'WS', 'R', 'L', 'S', 'WS', 'L', 'LRI'], [2, 2, 2, 2, 4, 4, 4, 4], 1], [2, 2, 2, 2, 1, 4, 4, 1]), ('regression: isolate controls in reset runs', [['LRI', 'R', 'EN', 'S', 'L', 'L', 'LRI', 'FSI', 'WS'], [3, 3, 3, 3, 3, 3, 3, 3, 4], 1], [3, 3, 3, 1, 3, 3, 1, 1, 1]), ('regression: isolate controls in reset runs', [['EN', 'WS', 'L', 'WS', 'R', 'PDI', 'WS', 'R', 'R', 'S', 'RLI'], [1, 1, 1, 1, 0, 0, 2, 3, 3, 3, 3], 0], [1, 1, 1, 1, 0, 0, 2, 3, 3, 0, 0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['R', 'RLI', 'EN', 'R', 'R', 'R', 'L'], [1, 1, 1, 0, 0, 0, 0], 1], [1, 1, 1, 0, 0, 0, 0]), ('control layout', [['L', 'ON', 'L', 'WS', 'S', 'PDI', 'WS', 'R', 'R', 'PDI', 'EN'], [3, 1, 1, 0, 0, 2, 3, 3, 3, 0, 0], 1], [3, 1, 1, 1, 1, 2, 3, 3, 3, 0, 0])]]
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
trailing isolate and space[1, 1, 1, 0][1, 1, 0, 0]Failed
regression: isolate controls in reset runs[1, 1, 3, 0, 0, 2, 0, 0][0, 0, 0, 0, 0, 0, 0, 0]Failed
regression: isolate controls in reset runs[0, 1, 1, 1, 0, 1, 0, 1][0, 0, 0, 0, 0, 1, 0, 1]Failed
regression: isolate controls in reset runs[1, 1, 1, 2, 2, 0][0, 0, 0, 0, 0, 0]Failed
all whitespace line[0, 0][0, 0]Passed
space before tab[1, 0, 0, 1][1, 0, 0, 1]Passed
control layout[0, 0, 1, 1, 1, 1][0, 0, 1, 1, 1, 1]Passed
control layout[2, 2, 2, 2, 2][2, 2, 2, 2, 2]Passed

SHA-256 / ab4224ec5ed4fd55499dd3efa13817cb3f0d493b5fba6d4b6218e16320329a43

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    classes, levels, para = x
    out = list(levels)
    n = len(classes)
    RESETTABLE = ('WS', 'PDI')
    j = n - 1
    while j >= 0 and classes[j] in RESETTABLE:
        out[j] = para
        j -= 1
    for i, c in enumerate(classes):
        if c in ('S', 'B'):
            out[i] = para
            k = i - 1
            while k >= 0 and classes[k] in RESETTABLE:
                out[k] = para
                k -= 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('regression: isolate controls in reset runs', [['FSI', 'LRI', 'FSI', 'WS', 'B', 'RLI', 'WS', 'WS'], [1, 1, 3, 3, 2, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['S', 'WS', 'WS', 'FSI', 'B', 'ON', 'S', 'R'], [1, 1, 1, 1, 1, 1, 1, 1], 0], [0, 0, 0, 0, 0, 1, 0, 1]), ('regression: isolate controls in reset runs', [['PDI', 'WS', 'WS', 'LRI', 'RLI', 'WS'], [1, 1, 1, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('control layout', [['PDI', 'LRI', 'L', 'L', 'WS', 'ON'], [0, 0, 1, 1, 1, 1], 0], [0, 0, 1, 1, 1, 1]), ('control layout', [['WS', 'L', 'R', 'FSI', 'L'], [2, 2, 2, 2, 2], 1], [2, 2, 2, 2, 2])], [('regression: isolate controls in reset runs', [['RLI', 'R', 'LRI', 'FSI', 'WS'], [1, 2, 4, 4, 4], 0], [1, 2, 0, 0, 0]), ('regression: isolate controls in reset runs', [['ON', 'ON', 'WS', 'R', 'RLI', 'LRI'], [4, 4, 4, 4, 3, 4], 1], [4, 4, 4, 4, 1, 1]), ('regression: isolate controls in reset runs', [['ON', 'WS', 'R', 'ON', 'WS', 'R', 'WS', 'FSI', 'PDI'], [4, 4, 4, 4, 2, 2, 3, 4, 1], 0], [4, 4, 4, 4, 2, 2, 0, 0, 0]), ('regression: isolate controls in reset runs', [['S', 'WS', 'L', 'WS', 'R', 'L', 'RLI', 'PDI'], [4, 4, 2, 2, 2, 2, 3, 2], 0], [0, 4, 2, 2, 2, 2, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['B', 'S', 'WS', 'ON', 'L', 'FSI', 'WS', 'L', 'RLI', 'WS', 'L', 'B'], [1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 0], 1], [1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 1]), ('control layout', [['R'], [2], 1], [2])], [('regression: isolate controls in reset runs', [['L', 'L', 'WS', 'PDI'], [2, 2, 2, 2], 0], [2, 2, 0, 0]), ('regression: isolate controls in reset runs', [['ON', 'R', 'PDI', 'B', 'WS', 'RLI', 'FSI', 'B', 'WS'], [0, 0, 0, 0, 1, 1, 1, 3, 3], 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['B', 'WS', 'R', 'L', 'B', 'R', 'WS', 'FSI', 'ON', 'FSI'], [3, 3, 3, 3, 4, 4, 2, 2, 2, 4], 1], [1, 3, 3, 3, 1, 4, 2, 2, 2, 1]), ('regression: isolate controls in reset runs', [['LRI', 'R', 'EN', 'S', 'L', 'L', 'LRI', 'FSI', 'WS'], [3, 3, 3, 3, 3, 3, 3, 3, 4], 1], [3, 3, 3, 1, 3, 3, 1, 1, 1]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['L', 'L', 'R', 'ON', 'WS', 'WS', 'WS', 'L', 'WS', 'PDI', 'R'], [2, 2, 4, 4, 4, 1, 2, 2, 2, 2, 2], 0], [2, 2, 4, 4, 4, 1, 2, 2, 2, 2, 2]), ('control layout', [['LRI', 'R', 'ON', 'ON', 'PDI', 'PDI'], [1, 1, 1, 1, 1, 1], 1], [1, 1, 1, 1, 1, 1])], [('regression: isolate controls in reset runs', [['FSI', 'LRI', 'FSI', 'WS', 'B', 'RLI', 'WS', 'WS'], [1, 1, 3, 3, 2, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['L', 'WS', 'R', 'EN', 'WS', 'B', 'B', 'R', 'B', 'WS', 'L', 'LRI'], [2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 4, 4], 1], [2, 2, 2, 1, 1, 1, 1, 4, 1, 4, 4, 1]), ('regression: isolate controls in reset runs', [['WS', 'PDI', 'RLI'], [3, 1, 1], 0], [0, 0, 0]), ('regression: isolate controls in reset runs', [['PDI', 'FSI'], [0, 0], 1], [1, 1]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['B', 'L', 'EN'], [3, 3, 1], 1], [1, 3, 1]), ('control layout', [['WS', 'R', 'L'], [1, 1, 1], 0], [1, 1, 1])], [('regression: isolate controls in reset runs', [['WS', 'FSI', 'ON', 'RLI', 'PDI', 'RLI', 'FSI'], [0, 0, 0, 1, 1, 1, 1], 0], [0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['L', 'WS', 'R', 'L', 'S', 'WS', 'L', 'LRI'], [2, 2, 2, 2, 4, 4, 4, 4], 1], [2, 2, 2, 2, 1, 4, 4, 1]), ('regression: isolate controls in reset runs', [['LRI', 'R', 'EN', 'S', 'L', 'L', 'LRI', 'FSI', 'WS'], [3, 3, 3, 3, 3, 3, 3, 3, 4], 1], [3, 3, 3, 1, 3, 3, 1, 1, 1]), ('regression: isolate controls in reset runs', [['EN', 'WS', 'L', 'WS', 'R', 'PDI', 'WS', 'R', 'R', 'S', 'RLI'], [1, 1, 1, 1, 0, 0, 2, 3, 3, 3, 3], 0], [1, 1, 1, 1, 0, 0, 2, 3, 3, 0, 0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['R', 'RLI', 'EN', 'R', 'R', 'R', 'L'], [1, 1, 1, 0, 0, 0, 0], 1], [1, 1, 1, 0, 0, 0, 0]), ('control layout', [['L', 'ON', 'L', 'WS', 'S', 'PDI', 'WS', 'R', 'R', 'PDI', 'EN'], [3, 1, 1, 0, 0, 2, 3, 3, 3, 0, 0], 1], [3, 1, 1, 1, 1, 2, 3, 3, 3, 0, 0])]]
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
trailing isolate and space[1, 1, 0, 0][1, 1, 0, 0]Passed
regression: isolate controls in reset runs[1, 1, 3, 0, 0, 2, 0, 0][0, 0, 0, 0, 0, 0, 0, 0]Failed
regression: isolate controls in reset runs[0, 1, 1, 1, 0, 1, 0, 1][0, 0, 0, 0, 0, 1, 0, 1]Failed
regression: isolate controls in reset runs[1, 1, 1, 2, 2, 0][0, 0, 0, 0, 0, 0]Failed
all whitespace line[0, 0][0, 0]Passed
space before tab[1, 0, 0, 1][1, 0, 0, 1]Passed
control layout[0, 0, 1, 1, 1, 1][0, 0, 1, 1, 1, 1]Passed
control layout[2, 2, 2, 2, 2][2, 2, 2, 2, 2]Passed

SHA-256 / 3340b23fbbaa6e1093fd0f3d6d0a515ea5a46cdb35116d36c3eac6ed5d795c51

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    classes, levels, para = x
    out = list(levels)
    n = len(classes)
    RESETTABLE = ('WS', 'FSI', 'LRI', 'RLI', 'PDI')
    j = n - 1
    while j >= 0 and classes[j] in RESETTABLE:
        out[j] = para
        j -= 1
    for i, c in enumerate(classes):
        if c in ('S', 'B'):
            out[i] = para
            k = i - 1
            while k >= 0 and classes[k] in RESETTABLE:
                out[k] = para
                k -= 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('regression: isolate controls in reset runs', [['FSI', 'LRI', 'FSI', 'WS', 'B', 'RLI', 'WS', 'WS'], [1, 1, 3, 3, 2, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['S', 'WS', 'WS', 'FSI', 'B', 'ON', 'S', 'R'], [1, 1, 1, 1, 1, 1, 1, 1], 0], [0, 0, 0, 0, 0, 1, 0, 1]), ('regression: isolate controls in reset runs', [['PDI', 'WS', 'WS', 'LRI', 'RLI', 'WS'], [1, 1, 1, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('control layout', [['PDI', 'LRI', 'L', 'L', 'WS', 'ON'], [0, 0, 1, 1, 1, 1], 0], [0, 0, 1, 1, 1, 1]), ('control layout', [['WS', 'L', 'R', 'FSI', 'L'], [2, 2, 2, 2, 2], 1], [2, 2, 2, 2, 2])], [('regression: isolate controls in reset runs', [['RLI', 'R', 'LRI', 'FSI', 'WS'], [1, 2, 4, 4, 4], 0], [1, 2, 0, 0, 0]), ('regression: isolate controls in reset runs', [['ON', 'ON', 'WS', 'R', 'RLI', 'LRI'], [4, 4, 4, 4, 3, 4], 1], [4, 4, 4, 4, 1, 1]), ('regression: isolate controls in reset runs', [['ON', 'WS', 'R', 'ON', 'WS', 'R', 'WS', 'FSI', 'PDI'], [4, 4, 4, 4, 2, 2, 3, 4, 1], 0], [4, 4, 4, 4, 2, 2, 0, 0, 0]), ('regression: isolate controls in reset runs', [['S', 'WS', 'L', 'WS', 'R', 'L', 'RLI', 'PDI'], [4, 4, 2, 2, 2, 2, 3, 2], 0], [0, 4, 2, 2, 2, 2, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['B', 'S', 'WS', 'ON', 'L', 'FSI', 'WS', 'L', 'RLI', 'WS', 'L', 'B'], [1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 0], 1], [1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 1]), ('control layout', [['R'], [2], 1], [2])], [('regression: isolate controls in reset runs', [['L', 'L', 'WS', 'PDI'], [2, 2, 2, 2], 0], [2, 2, 0, 0]), ('regression: isolate controls in reset runs', [['ON', 'R', 'PDI', 'B', 'WS', 'RLI', 'FSI', 'B', 'WS'], [0, 0, 0, 0, 1, 1, 1, 3, 3], 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['B', 'WS', 'R', 'L', 'B', 'R', 'WS', 'FSI', 'ON', 'FSI'], [3, 3, 3, 3, 4, 4, 2, 2, 2, 4], 1], [1, 3, 3, 3, 1, 4, 2, 2, 2, 1]), ('regression: isolate controls in reset runs', [['LRI', 'R', 'EN', 'S', 'L', 'L', 'LRI', 'FSI', 'WS'], [3, 3, 3, 3, 3, 3, 3, 3, 4], 1], [3, 3, 3, 1, 3, 3, 1, 1, 1]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['L', 'L', 'R', 'ON', 'WS', 'WS', 'WS', 'L', 'WS', 'PDI', 'R'], [2, 2, 4, 4, 4, 1, 2, 2, 2, 2, 2], 0], [2, 2, 4, 4, 4, 1, 2, 2, 2, 2, 2]), ('control layout', [['LRI', 'R', 'ON', 'ON', 'PDI', 'PDI'], [1, 1, 1, 1, 1, 1], 1], [1, 1, 1, 1, 1, 1])], [('regression: isolate controls in reset runs', [['FSI', 'LRI', 'FSI', 'WS', 'B', 'RLI', 'WS', 'WS'], [1, 1, 3, 3, 2, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['L', 'WS', 'R', 'EN', 'WS', 'B', 'B', 'R', 'B', 'WS', 'L', 'LRI'], [2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 4, 4], 1], [2, 2, 2, 1, 1, 1, 1, 4, 1, 4, 4, 1]), ('regression: isolate controls in reset runs', [['WS', 'PDI', 'RLI'], [3, 1, 1], 0], [0, 0, 0]), ('regression: isolate controls in reset runs', [['PDI', 'FSI'], [0, 0], 1], [1, 1]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['B', 'L', 'EN'], [3, 3, 1], 1], [1, 3, 1]), ('control layout', [['WS', 'R', 'L'], [1, 1, 1], 0], [1, 1, 1])], [('regression: isolate controls in reset runs', [['WS', 'FSI', 'ON', 'RLI', 'PDI', 'RLI', 'FSI'], [0, 0, 0, 1, 1, 1, 1], 0], [0, 0, 0, 0, 0, 0, 0]), ('regression: isolate controls in reset runs', [['L', 'WS', 'R', 'L', 'S', 'WS', 'L', 'LRI'], [2, 2, 2, 2, 4, 4, 4, 4], 1], [2, 2, 2, 2, 1, 4, 4, 1]), ('regression: isolate controls in reset runs', [['LRI', 'R', 'EN', 'S', 'L', 'L', 'LRI', 'FSI', 'WS'], [3, 3, 3, 3, 3, 3, 3, 3, 4], 1], [3, 3, 3, 1, 3, 3, 1, 1, 1]), ('regression: isolate controls in reset runs', [['EN', 'WS', 'L', 'WS', 'R', 'PDI', 'WS', 'R', 'R', 'S', 'RLI'], [1, 1, 1, 1, 0, 0, 2, 3, 3, 3, 3], 0], [1, 1, 1, 1, 0, 0, 2, 3, 3, 0, 0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['R', 'RLI', 'EN', 'R', 'R', 'R', 'L'], [1, 1, 1, 0, 0, 0, 0], 1], [1, 1, 1, 0, 0, 0, 0]), ('control layout', [['L', 'ON', 'L', 'WS', 'S', 'PDI', 'WS', 'R', 'R', 'PDI', 'EN'], [3, 1, 1, 0, 0, 2, 3, 3, 3, 0, 0], 1], [3, 1, 1, 1, 1, 2, 3, 3, 3, 0, 0])]]
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
trailing isolate and space[1, 1, 0, 0][1, 1, 0, 0]Passed
regression: isolate controls in reset runs[0, 0, 0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0, 0, 0]Passed
regression: isolate controls in reset runs[0, 0, 0, 0, 0, 1, 0, 1][0, 0, 0, 0, 0, 1, 0, 1]Passed
regression: isolate controls in reset runs[0, 0, 0, 0, 0, 0][0, 0, 0, 0, 0, 0]Passed
all whitespace line[0, 0][0, 0]Passed
space before tab[1, 0, 0, 1][1, 0, 0, 1]Passed
control layout[0, 0, 1, 1, 1, 1][0, 0, 1, 1, 1, 1]Passed
control layout[2, 2, 2, 2, 2][2, 2, 2, 2, 2]Passed

SHA-256 / 9007bb6d62c01482a90c211d15a3b625c0dc8c9b36745b3187dd5f4085655fdd

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

Case digest / da1b110af59e7f255e087a5e01a24db2f717fca376b0dc716ce2df63d7bf2f08