FAILURE MAP
← Case archive

FA-80516 / Bidirectional text layout / Open access

Line-end whitespace level reset: reset target level · case 01

Trailing whitespace is reset to the lowest level on the line.

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

ROOT CAUSE

The trailing reset uses the minimum resolved level instead of the paragraph level.

THE FAILURE

The trailing reset uses the minimum resolved level instead of the paragraph level.

Unsuccessful approach: Using the first character level is equally unrelated to the paragraph level.

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', 'FSI', 'LRI', 'RLI', 'PDI')
    j = n - 1
    while j >= 0 and classes[j] in RESETTABLE:
        out[j] = min(levels)
        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: reset target level', [['ON', 'WS'], [2, 2], 1], [2, 1]), ('partial-repair probe', [['R', 'R', 'PDI', 'R', 'PDI'], [2, 1, 1, 1, 1], 1], [2, 1, 1, 1, 1]), ('regression: reset target level', [['L', 'R', 'WS'], [2, 2, 2], 1], [2, 2, 1]), ('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', [['RLI', 'ON'], [2, 2], 1], [2, 2]), ('control layout', [['PDI', 'S', 'WS', 'R'], [4, 4, 4, 4], 1], [1, 1, 4, 4])], [('regression: reset target level', [['R', 'L', 'RLI', 'L', 'LRI', 'B', 'L', 'ON', 'PDI'], [1, 2, 2, 2, 2, 0, 0, 0, 1], 1], [1, 2, 2, 2, 1, 1, 0, 0, 1]), ('regression: reset target level', [['WS', 'R', 'L', 'WS', 'R', 'EN', 'FSI'], [3, 3, 2, 2, 2, 2, 3], 1], [3, 3, 2, 2, 2, 2, 1]), ('regression: reset target level', [['LRI'], [2], 0], [0]), ('regression: reset target level', [['WS', 'L', 'FSI', 'R', 'ON', 'R', 'WS'], [3, 3, 0, 0, 1, 3, 3], 1], [3, 3, 0, 0, 1, 3, 1]), ('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', [['WS', 'ON', 'L', 'WS', 'WS', 'ON', 'L', 'LRI', 'WS', 'EN', 'WS', 'L'], [4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3], 1], [4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3]), ('control layout', [['ON', 'WS', 'S', 'L', 'R', 'ON'], [1, 1, 1, 0, 1, 1], 1], [1, 1, 1, 0, 1, 1])], [('regression: reset target level', [['WS', 'L', 'R', 'WS', 'WS', 'L', 'WS', 'RLI'], [3, 3, 3, 3, 2, 2, 2, 0], 1], [3, 3, 3, 3, 2, 2, 1, 1]), ('regression: reset target level', [['WS'], [0], 1], [1]), ('regression: reset target level', [['ON', 'PDI', 'FSI', 'L', 'B', 'PDI', 'S', 'L', 'WS', 'L', 'RLI', 'WS'], [3, 3, 3, 3, 2, 2, 2, 2, 0, 0, 0, 0], 1], [3, 3, 3, 3, 1, 1, 1, 2, 0, 0, 1, 1]), ('partial-repair probe', [['FSI', 'R', 'WS', 'ON', 'B', 'LRI'], [2, 2, 2, 0, 0, 3], 0], [2, 2, 2, 0, 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', [['WS', 'R', 'WS', 'B', 'FSI', 'WS'], [1, 1, 1, 1, 1, 1], 1], [1, 1, 1, 1, 1, 1]), ('control layout', [['R', 'PDI', 'L', 'LRI', 'ON'], [2, 2, 2, 2, 2], 0], [2, 2, 2, 2, 2])], [('regression: reset target level', [['RLI', 'WS', 'WS'], [2, 2, 3], 1], [1, 1, 1]), ('regression: reset target level', [['L', 'B', 'WS', 'PDI', 'L', 'B', 'L', 'L', 'RLI'], [2, 2, 2, 2, 3, 3, 3, 2, 2], 1], [2, 1, 2, 2, 3, 1, 3, 2, 1]), ('regression: reset target level', [['B', 'L', 'R', 'L', 'PDI', 'ON', 'L', 'S', 'WS', 'ON', 'WS'], [4, 4, 4, 2, 2, 2, 2, 4, 4, 4, 3], 0], [0, 4, 4, 2, 2, 2, 2, 0, 4, 4, 0]), ('regression: reset target level', [['R', 'EN', 'PDI', 'S', 'WS'], [0, 0, 0, 0, 2], 1], [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', [['RLI', 'L', 'ON', 'WS', 'WS', 'FSI', 'ON', 'WS', 'L'], [2, 3, 3, 3, 3, 0, 0, 2, 2], 1], [2, 3, 3, 3, 3, 0, 0, 2, 2]), ('control layout', [['WS', 'FSI', 'S', 'B', 'R', 'L'], [1, 1, 1, 1, 4, 1], 1], [1, 1, 1, 1, 4, 1])], [('regression: reset target level', [['R', 'EN', 'PDI', 'S', 'WS'], [0, 0, 0, 0, 2], 1], [0, 0, 1, 1, 1]), ('regression: reset target level', [['L', 'L', 'WS', 'PDI'], [2, 2, 2, 2], 0], [2, 2, 0, 0]), ('partial-repair probe', [['RLI', 'PDI', 'WS', 'S', 'L', 'R', 'R', 'R', 'WS', 'LRI'], [2, 2, 2, 2, 2, 2, 2, 1, 1, 1], 1], [1, 1, 1, 1, 2, 2, 2, 1, 1, 1]), ('regression: reset target level', [['S', 'R', 'ON', 'LRI', 'WS', 'R', 'WS', 'LRI', 'WS', 'R', 'WS'], [0, 0, 0, 0, 3, 3, 0, 3, 3, 3, 3], 1], [1, 0, 0, 0, 3, 3, 0, 3, 3, 3, 1]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('control layout', [['RLI', 'PDI', 'FSI', 'PDI', 'EN', 'L', 'WS', 'WS', 'ON'], [2, 2, 2, 2, 2, 2, 2, 1, 4], 1], [2, 2, 2, 2, 2, 2, 2, 1, 4]), ('control layout', [['R', 'WS', 'R', 'EN', 'R'], [4, 4, 2, 2, 2], 0], [4, 4, 2, 2, 2])]]
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, 1][1, 1, 0, 0]Failed
regression: reset target level[2, 2][2, 1]Failed
partial-repair probe[2, 1, 1, 1, 1][2, 1, 1, 1, 1]Passed
regression: reset target level[2, 2, 2][2, 2, 1]Failed
all whitespace line[1, 1][0, 0]Failed
space before tab[1, 0, 0, 1][1, 0, 0, 1]Passed
control layout[2, 2][2, 2]Passed
control layout[1, 1, 4, 4][1, 1, 4, 4]Passed

SHA-256 / 292ae7dbe6688c404347d5b09db1cfe9c8e8a1315febc615f9428f7f778f9fc5

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', 'FSI', 'LRI', 'RLI', 'PDI')
    j = n - 1
    while j >= 0 and classes[j] in RESETTABLE:
        out[j] = levels[0]
        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: reset target level', [['ON', 'WS'], [2, 2], 1], [2, 1]), ('partial-repair probe', [['R', 'R', 'PDI', 'R', 'PDI'], [2, 1, 1, 1, 1], 1], [2, 1, 1, 1, 1]), ('regression: reset target level', [['L', 'R', 'WS'], [2, 2, 2], 1], [2, 2, 1]), ('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', [['RLI', 'ON'], [2, 2], 1], [2, 2]), ('control layout', [['PDI', 'S', 'WS', 'R'], [4, 4, 4, 4], 1], [1, 1, 4, 4])], [('regression: reset target level', [['R', 'L', 'RLI', 'L', 'LRI', 'B', 'L', 'ON', 'PDI'], [1, 2, 2, 2, 2, 0, 0, 0, 1], 1], [1, 2, 2, 2, 1, 1, 0, 0, 1]), ('regression: reset target level', [['WS', 'R', 'L', 'WS', 'R', 'EN', 'FSI'], [3, 3, 2, 2, 2, 2, 3], 1], [3, 3, 2, 2, 2, 2, 1]), ('regression: reset target level', [['LRI'], [2], 0], [0]), ('regression: reset target level', [['WS', 'L', 'FSI', 'R', 'ON', 'R', 'WS'], [3, 3, 0, 0, 1, 3, 3], 1], [3, 3, 0, 0, 1, 3, 1]), ('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', [['WS', 'ON', 'L', 'WS', 'WS', 'ON', 'L', 'LRI', 'WS', 'EN', 'WS', 'L'], [4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3], 1], [4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3]), ('control layout', [['ON', 'WS', 'S', 'L', 'R', 'ON'], [1, 1, 1, 0, 1, 1], 1], [1, 1, 1, 0, 1, 1])], [('regression: reset target level', [['WS', 'L', 'R', 'WS', 'WS', 'L', 'WS', 'RLI'], [3, 3, 3, 3, 2, 2, 2, 0], 1], [3, 3, 3, 3, 2, 2, 1, 1]), ('regression: reset target level', [['WS'], [0], 1], [1]), ('regression: reset target level', [['ON', 'PDI', 'FSI', 'L', 'B', 'PDI', 'S', 'L', 'WS', 'L', 'RLI', 'WS'], [3, 3, 3, 3, 2, 2, 2, 2, 0, 0, 0, 0], 1], [3, 3, 3, 3, 1, 1, 1, 2, 0, 0, 1, 1]), ('partial-repair probe', [['FSI', 'R', 'WS', 'ON', 'B', 'LRI'], [2, 2, 2, 0, 0, 3], 0], [2, 2, 2, 0, 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', [['WS', 'R', 'WS', 'B', 'FSI', 'WS'], [1, 1, 1, 1, 1, 1], 1], [1, 1, 1, 1, 1, 1]), ('control layout', [['R', 'PDI', 'L', 'LRI', 'ON'], [2, 2, 2, 2, 2], 0], [2, 2, 2, 2, 2])], [('regression: reset target level', [['RLI', 'WS', 'WS'], [2, 2, 3], 1], [1, 1, 1]), ('regression: reset target level', [['L', 'B', 'WS', 'PDI', 'L', 'B', 'L', 'L', 'RLI'], [2, 2, 2, 2, 3, 3, 3, 2, 2], 1], [2, 1, 2, 2, 3, 1, 3, 2, 1]), ('regression: reset target level', [['B', 'L', 'R', 'L', 'PDI', 'ON', 'L', 'S', 'WS', 'ON', 'WS'], [4, 4, 4, 2, 2, 2, 2, 4, 4, 4, 3], 0], [0, 4, 4, 2, 2, 2, 2, 0, 4, 4, 0]), ('regression: reset target level', [['R', 'EN', 'PDI', 'S', 'WS'], [0, 0, 0, 0, 2], 1], [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', [['RLI', 'L', 'ON', 'WS', 'WS', 'FSI', 'ON', 'WS', 'L'], [2, 3, 3, 3, 3, 0, 0, 2, 2], 1], [2, 3, 3, 3, 3, 0, 0, 2, 2]), ('control layout', [['WS', 'FSI', 'S', 'B', 'R', 'L'], [1, 1, 1, 1, 4, 1], 1], [1, 1, 1, 1, 4, 1])], [('regression: reset target level', [['R', 'EN', 'PDI', 'S', 'WS'], [0, 0, 0, 0, 2], 1], [0, 0, 1, 1, 1]), ('regression: reset target level', [['L', 'L', 'WS', 'PDI'], [2, 2, 2, 2], 0], [2, 2, 0, 0]), ('partial-repair probe', [['RLI', 'PDI', 'WS', 'S', 'L', 'R', 'R', 'R', 'WS', 'LRI'], [2, 2, 2, 2, 2, 2, 2, 1, 1, 1], 1], [1, 1, 1, 1, 2, 2, 2, 1, 1, 1]), ('regression: reset target level', [['S', 'R', 'ON', 'LRI', 'WS', 'R', 'WS', 'LRI', 'WS', 'R', 'WS'], [0, 0, 0, 0, 3, 3, 0, 3, 3, 3, 3], 1], [1, 0, 0, 0, 3, 3, 0, 3, 3, 3, 1]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('control layout', [['RLI', 'PDI', 'FSI', 'PDI', 'EN', 'L', 'WS', 'WS', 'ON'], [2, 2, 2, 2, 2, 2, 2, 1, 4], 1], [2, 2, 2, 2, 2, 2, 2, 1, 4]), ('control layout', [['R', 'WS', 'R', 'EN', 'R'], [4, 4, 2, 2, 2], 0], [4, 4, 2, 2, 2])]]
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, 1][1, 1, 0, 0]Failed
regression: reset target level[2, 2][2, 1]Failed
partial-repair probe[2, 1, 1, 1, 2][2, 1, 1, 1, 1]Failed
regression: reset target level[2, 2, 2][2, 2, 1]Failed
all whitespace line[1, 1][0, 0]Failed
space before tab[1, 0, 0, 1][1, 0, 0, 1]Passed
control layout[2, 2][2, 2]Passed
control layout[1, 1, 4, 4][1, 1, 4, 4]Passed

SHA-256 / 65e2247a258adc017c704f384b281f404a449df31de89946192bb0e529044123

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / bad4a542cce538763d6c9224fa3850a39d32d2ac3e69c60d2b4f893323ac0135