FA-80511 / Bidirectional text layout / Open access
Line-end whitespace level reset: whitespace before separator · case 01
Only one space before a tab is reset.
ROOT CAUSE
The backward scan before a separator resets a single character.
THE FAILURE
The backward scan before a separator resets a single character.
Unsuccessful approach: Stopping before index 0 misses runs at the line start.
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] = para
j -= 1
for i, c in enumerate(classes):
if c in ('S', 'B'):
out[i] = para
k = i - 1
if k >= 0 and classes[k] in RESETTABLE:
out[k] = para
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: whitespace before separator', [['FSI', 'RLI', 'B', 'R', 'ON', 'RLI', 'LRI', 'ON', 'WS'], [2, 2, 2, 2, 2, 1, 2, 0, 0], 1], [1, 1, 1, 2, 2, 1, 2, 0, 1]), ('regression: whitespace before separator', [['WS', 'WS', 'WS', 'S', 'WS'], [1, 1, 1, 1, 2], 0], [0, 0, 0, 0, 0]), ('partial-repair probe', [['PDI', 'S', 'ON', 'R'], [3, 3, 1, 1], 1], [1, 1, 1, 1]), ('partial-repair probe', [['WS', 'S', 'FSI', 'FSI', 'EN', 'ON'], [1, 1, 1, 1, 1, 1], 0], [0, 0, 1, 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', 'WS', 'L', 'WS', 'WS', 'ON', 'S', 'WS', 'WS'], [2, 2, 2, 1, 1, 1, 1, 1, 1], 0], [2, 2, 2, 1, 1, 1, 0, 0, 0]), ('control layout', [['ON', 'WS', 'ON'], [1, 1, 1], 0], [1, 1, 1])], [('regression: whitespace before separator', [['L', 'B', 'RLI', 'WS', 'B', 'R', 'WS', 'RLI', 'L'], [1, 1, 1, 1, 3, 3, 3, 1, 2], 0], [1, 0, 0, 0, 0, 3, 3, 1, 2]), ('regression: whitespace before separator', [['WS', 'WS', 'RLI', 'S', 'WS', 'WS', 'WS', 'PDI', 'LRI', 'ON'], [4, 4, 4, 3, 3, 4, 4, 4, 4, 4], 0], [0, 0, 0, 0, 3, 4, 4, 4, 4, 4]), ('regression: whitespace before separator', [['PDI', 'WS', 'LRI', 'B'], [0, 1, 1, 1], 1], [1, 1, 1, 1]), ('regression: whitespace before separator', [['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]), ('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', [['FSI'], [1], 1], [1]), ('control layout', [['EN', 'L'], [2, 2], 0], [2, 2])], [('regression: whitespace before separator', [['LRI', 'L', 'FSI', 'R', 'WS', 'FSI', 'S', 'R', 'WS'], [1, 1, 2, 2, 2, 0, 0, 0, 0], 0], [1, 1, 2, 2, 0, 0, 0, 0, 0]), ('regression: whitespace before separator', [['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]), ('partial-repair probe', [['PDI', 'S', 'ON', 'R'], [3, 3, 1, 1], 1], [1, 1, 1, 1]), ('partial-repair probe', [['WS', 'S'], [3, 3], 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', [['FSI'], [1], 1], [1]), ('control layout', [['ON', 'B', 'WS', 'LRI', 'R'], [1, 2, 2, 2, 2], 0], [1, 0, 2, 2, 2])], [('regression: whitespace before separator', [['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: whitespace before separator', [['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: whitespace before separator', [['PDI', 'WS', 'LRI', 'B'], [0, 1, 1, 1], 1], [1, 1, 1, 1]), ('regression: whitespace before separator', [['WS', 'WS', 'S', 'L', 'R', 'R', 'R'], [2, 2, 2, 2, 2, 0, 0], 0], [0, 0, 0, 2, 2, 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', [['FSI', 'R', 'S', 'RLI', 'S', 'R', 'PDI', 'ON', 'LRI', 'L', 'WS'], [1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1], 1], [1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1]), ('control layout', [['L', 'L', 'RLI', 'PDI'], [1, 1, 2, 1], 1], [1, 1, 1, 1])], [('regression: whitespace before separator', [['EN', 'LRI', 'LRI', 'S', 'B', 'FSI', 'R', 'ON', 'PDI', 'B'], [2, 2, 2, 2, 2, 2, 2, 2, 2, 3], 1], [2, 1, 1, 1, 1, 2, 2, 2, 1, 1]), ('regression: whitespace before separator', [['ON', 'S', 'B', 'WS', 'WS', 'FSI', 'S', 'R', 'S', 'L', 'PDI'], [4, 4, 4, 4, 3, 3, 2, 1, 1, 1, 1], 0], [4, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0]), ('partial-repair probe', [['WS', 'S', 'L', 'R', 'PDI', 'R', 'B', 'WS', 'RLI', 'LRI'], [0, 2, 2, 2, 2, 3, 3, 0, 0, 0], 1], [1, 1, 2, 2, 2, 3, 1, 1, 1, 1]), ('regression: whitespace before separator', [['WS', 'WS', 'RLI', 'S', 'WS', 'WS', 'WS', 'PDI', 'LRI', 'ON'], [4, 4, 4, 3, 3, 4, 4, 4, 4, 4], 0], [0, 0, 0, 0, 3, 4, 4, 4, 4, 4]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['RLI', 'L', 'PDI', 'WS', 'L'], [4, 4, 4, 1, 4], 0], [4, 4, 4, 1, 4]), ('control layout', [['EN', 'WS'], [1, 1], 1], [1, 1])]]
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: whitespace before separator | [2, 1, 1, 2, 2, 1, 2, 0, 1] | [1, 1, 1, 2, 2, 1, 2, 0, 1] | Failed |
| regression: whitespace before separator | [1, 1, 0, 0, 0] | [0, 0, 0, 0, 0] | Failed |
| partial-repair probe | [1, 1, 1, 1] | [1, 1, 1, 1] | Passed |
| partial-repair probe | [0, 0, 1, 1, 1, 1] | [0, 0, 1, 1, 1, 1] | Passed |
| all whitespace line | [0, 0] | [0, 0] | Passed |
| trailing isolate and space | [1, 1, 0, 0] | [1, 1, 0, 0] | Passed |
| control layout | [2, 2, 2, 1, 1, 1, 0, 0, 0] | [2, 2, 2, 1, 1, 1, 0, 0, 0] | Passed |
| control layout | [1, 1, 1] | [1, 1, 1] | Passed |
SHA-256 / 6147eeb5fdb9a2dab6c82081c39e81da5894f8cb055767e7c6607ceb66b70519
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] = 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 = [[('regression: whitespace before separator', [['FSI', 'RLI', 'B', 'R', 'ON', 'RLI', 'LRI', 'ON', 'WS'], [2, 2, 2, 2, 2, 1, 2, 0, 0], 1], [1, 1, 1, 2, 2, 1, 2, 0, 1]), ('regression: whitespace before separator', [['WS', 'WS', 'WS', 'S', 'WS'], [1, 1, 1, 1, 2], 0], [0, 0, 0, 0, 0]), ('partial-repair probe', [['PDI', 'S', 'ON', 'R'], [3, 3, 1, 1], 1], [1, 1, 1, 1]), ('partial-repair probe', [['WS', 'S', 'FSI', 'FSI', 'EN', 'ON'], [1, 1, 1, 1, 1, 1], 0], [0, 0, 1, 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', 'WS', 'L', 'WS', 'WS', 'ON', 'S', 'WS', 'WS'], [2, 2, 2, 1, 1, 1, 1, 1, 1], 0], [2, 2, 2, 1, 1, 1, 0, 0, 0]), ('control layout', [['ON', 'WS', 'ON'], [1, 1, 1], 0], [1, 1, 1])], [('regression: whitespace before separator', [['L', 'B', 'RLI', 'WS', 'B', 'R', 'WS', 'RLI', 'L'], [1, 1, 1, 1, 3, 3, 3, 1, 2], 0], [1, 0, 0, 0, 0, 3, 3, 1, 2]), ('regression: whitespace before separator', [['WS', 'WS', 'RLI', 'S', 'WS', 'WS', 'WS', 'PDI', 'LRI', 'ON'], [4, 4, 4, 3, 3, 4, 4, 4, 4, 4], 0], [0, 0, 0, 0, 3, 4, 4, 4, 4, 4]), ('regression: whitespace before separator', [['PDI', 'WS', 'LRI', 'B'], [0, 1, 1, 1], 1], [1, 1, 1, 1]), ('regression: whitespace before separator', [['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]), ('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', [['FSI'], [1], 1], [1]), ('control layout', [['EN', 'L'], [2, 2], 0], [2, 2])], [('regression: whitespace before separator', [['LRI', 'L', 'FSI', 'R', 'WS', 'FSI', 'S', 'R', 'WS'], [1, 1, 2, 2, 2, 0, 0, 0, 0], 0], [1, 1, 2, 2, 0, 0, 0, 0, 0]), ('regression: whitespace before separator', [['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]), ('partial-repair probe', [['PDI', 'S', 'ON', 'R'], [3, 3, 1, 1], 1], [1, 1, 1, 1]), ('partial-repair probe', [['WS', 'S'], [3, 3], 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', [['FSI'], [1], 1], [1]), ('control layout', [['ON', 'B', 'WS', 'LRI', 'R'], [1, 2, 2, 2, 2], 0], [1, 0, 2, 2, 2])], [('regression: whitespace before separator', [['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: whitespace before separator', [['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: whitespace before separator', [['PDI', 'WS', 'LRI', 'B'], [0, 1, 1, 1], 1], [1, 1, 1, 1]), ('regression: whitespace before separator', [['WS', 'WS', 'S', 'L', 'R', 'R', 'R'], [2, 2, 2, 2, 2, 0, 0], 0], [0, 0, 0, 2, 2, 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', [['FSI', 'R', 'S', 'RLI', 'S', 'R', 'PDI', 'ON', 'LRI', 'L', 'WS'], [1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1], 1], [1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1]), ('control layout', [['L', 'L', 'RLI', 'PDI'], [1, 1, 2, 1], 1], [1, 1, 1, 1])], [('regression: whitespace before separator', [['EN', 'LRI', 'LRI', 'S', 'B', 'FSI', 'R', 'ON', 'PDI', 'B'], [2, 2, 2, 2, 2, 2, 2, 2, 2, 3], 1], [2, 1, 1, 1, 1, 2, 2, 2, 1, 1]), ('regression: whitespace before separator', [['ON', 'S', 'B', 'WS', 'WS', 'FSI', 'S', 'R', 'S', 'L', 'PDI'], [4, 4, 4, 4, 3, 3, 2, 1, 1, 1, 1], 0], [4, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0]), ('partial-repair probe', [['WS', 'S', 'L', 'R', 'PDI', 'R', 'B', 'WS', 'RLI', 'LRI'], [0, 2, 2, 2, 2, 3, 3, 0, 0, 0], 1], [1, 1, 2, 2, 2, 3, 1, 1, 1, 1]), ('regression: whitespace before separator', [['WS', 'WS', 'RLI', 'S', 'WS', 'WS', 'WS', 'PDI', 'LRI', 'ON'], [4, 4, 4, 3, 3, 4, 4, 4, 4, 4], 0], [0, 0, 0, 0, 3, 4, 4, 4, 4, 4]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['RLI', 'L', 'PDI', 'WS', 'L'], [4, 4, 4, 1, 4], 0], [4, 4, 4, 1, 4]), ('control layout', [['EN', 'WS'], [1, 1], 1], [1, 1])]]
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: whitespace before separator | [2, 1, 1, 2, 2, 1, 2, 0, 1] | [1, 1, 1, 2, 2, 1, 2, 0, 1] | Failed |
| regression: whitespace before separator | [1, 0, 0, 0, 0] | [0, 0, 0, 0, 0] | Failed |
| partial-repair probe | [3, 1, 1, 1] | [1, 1, 1, 1] | Failed |
| partial-repair probe | [1, 0, 1, 1, 1, 1] | [0, 0, 1, 1, 1, 1] | Failed |
| all whitespace line | [0, 0] | [0, 0] | Passed |
| trailing isolate and space | [1, 1, 0, 0] | [1, 1, 0, 0] | Passed |
| control layout | [2, 2, 2, 1, 1, 1, 0, 0, 0] | [2, 2, 2, 1, 1, 1, 0, 0, 0] | Passed |
| control layout | [1, 1, 1] | [1, 1, 1] | Passed |
SHA-256 / 7e24ec3be781a319297ed2d940d23ba2dbc76e2e2edb3f355c377a6c8b4f6b7c
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.552068+00:00.
Case digest / 31f737d34bce4acb96feb37d5975c180339d31498cbf62479cc6f019d4fd1815