FA-80741 / Bidirectional text layout / Open access
Direction-relative alignment: overflowing center fallback · case 01
Overflowing centered lines hang off both edges.
ROOT CAUSE
The overflow fallback checks the wrong alignment value.
THE FAILURE
The overflow fallback checks the wrong alignment value.
Unsuccessful approach: Falling back to left regardless of direction clips RTL starts.
Case contract
Input [line width, content width, align, rtl]. justify (last line) behaves as start. start = left for LTR, right for RTL; end is the opposite. Overflowing centered content aligns to start. center offset is floor(slack/2) for LTR and ceil(slack/2) for RTL. Return the x offset of the content.
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):
lw, cw, align, rtl = x
if align == 'justify':
align = 'start'
if align == 'start':
align = 'right' if rtl else 'left'
elif align == 'end':
align = 'left' if rtl else 'right'
if cw > lw and align == 'start':
align = 'left' if not rtl else 'right'
if align == 'left':
return 0
if align == 'right':
return lw - cw
slack = lw - cw
return (slack + 1) // 2 if rtl else slack // 2
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('overflowing center RTL', [10, 15, 'center', True], -5), ('regression: overflowing center fallback', [17, 50, 'center', False], 0), ('regression: overflowing center fallback', [17, 45, 'center', True], -28), ('regression: overflowing center fallback', [29, 32, 'center', True], -3), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [37, 42, 'start', False], 0), ('control layout', [36, 39, 'right', False], -3)], [('regression: overflowing center fallback', [13, 20, 'center', False], 0), ('regression: overflowing center fallback', [26, 42, 'center', False], 0), ('regression: overflowing center fallback', [37, 38, 'center', True], -1), ('regression: overflowing center fallback', [12, 13, 'center', True], -1), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [29, 31, 'left', False], 0), ('control layout', [37, 29, 'left', True], 0)], [('regression: overflowing center fallback', [10, 49, 'center', True], -39), ('overflowing center RTL', [10, 15, 'center', True], -5), ('regression: overflowing center fallback', [19, 31, 'center', True], -12), ('regression: overflowing center fallback', [24, 25, 'center', True], -1), ('odd slack RTL center', [20, 5, 'center', True], 8), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [26, 13, 'left', True], 0), ('control layout', [36, 2, 'left', False], 0)], [('regression: overflowing center fallback', [37, 38, 'center', True], -1), ('regression: overflowing center fallback', [13, 28, 'center', False], 0), ('regression: overflowing center fallback', [32, 42, 'center', True], -10), ('regression: overflowing center fallback', [21, 22, 'center', True], -1), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [22, 27, 'justify', True], -5), ('control layout', [10, 19, 'left', False], 0)], [('regression: overflowing center fallback', [24, 33, 'center', False], 0), ('regression: overflowing center fallback', [15, 28, 'center', False], 0), ('regression: overflowing center fallback', [17, 28, 'center', True], -11), ('regression: overflowing center fallback', [19, 25, 'center', True], -6), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [17, 26, 'end', True], 0), ('control layout', [23, 9, 'start', True], 14)]]
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 |
|---|---|---|---|
| overflowing center RTL | -2 | -5 | Failed |
| regression: overflowing center fallback | -17 | 0 | Failed |
| regression: overflowing center fallback | -14 | -28 | Failed |
| regression: overflowing center fallback | -1 | -3 | Failed |
| RTL end is left | 0 | 0 | Passed |
| odd slack RTL center | 8 | 8 | Passed |
| control layout | 0 | 0 | Passed |
| control layout | -3 | -3 | Passed |
SHA-256 / 1420902b80b0fe20f5abd3cd4fa212b8ca2bd1b0b0cb3e43f63a9659eebd27d2
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
lw, cw, align, rtl = x
if align == 'justify':
align = 'start'
if align == 'start':
align = 'right' if rtl else 'left'
elif align == 'end':
align = 'left' if rtl else 'right'
if cw > lw and align == 'center':
align = 'left'
if align == 'left':
return 0
if align == 'right':
return lw - cw
slack = lw - cw
return (slack + 1) // 2 if rtl else slack // 2
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('overflowing center RTL', [10, 15, 'center', True], -5), ('regression: overflowing center fallback', [17, 50, 'center', False], 0), ('regression: overflowing center fallback', [17, 45, 'center', True], -28), ('regression: overflowing center fallback', [29, 32, 'center', True], -3), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [37, 42, 'start', False], 0), ('control layout', [36, 39, 'right', False], -3)], [('regression: overflowing center fallback', [13, 20, 'center', False], 0), ('regression: overflowing center fallback', [26, 42, 'center', False], 0), ('regression: overflowing center fallback', [37, 38, 'center', True], -1), ('regression: overflowing center fallback', [12, 13, 'center', True], -1), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [29, 31, 'left', False], 0), ('control layout', [37, 29, 'left', True], 0)], [('regression: overflowing center fallback', [10, 49, 'center', True], -39), ('overflowing center RTL', [10, 15, 'center', True], -5), ('regression: overflowing center fallback', [19, 31, 'center', True], -12), ('regression: overflowing center fallback', [24, 25, 'center', True], -1), ('odd slack RTL center', [20, 5, 'center', True], 8), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [26, 13, 'left', True], 0), ('control layout', [36, 2, 'left', False], 0)], [('regression: overflowing center fallback', [37, 38, 'center', True], -1), ('regression: overflowing center fallback', [13, 28, 'center', False], 0), ('regression: overflowing center fallback', [32, 42, 'center', True], -10), ('regression: overflowing center fallback', [21, 22, 'center', True], -1), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [22, 27, 'justify', True], -5), ('control layout', [10, 19, 'left', False], 0)], [('regression: overflowing center fallback', [24, 33, 'center', False], 0), ('regression: overflowing center fallback', [15, 28, 'center', False], 0), ('regression: overflowing center fallback', [17, 28, 'center', True], -11), ('regression: overflowing center fallback', [19, 25, 'center', True], -6), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [17, 26, 'end', True], 0), ('control layout', [23, 9, 'start', True], 14)]]
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 |
|---|---|---|---|
| overflowing center RTL | 0 | -5 | Failed |
| regression: overflowing center fallback | 0 | 0 | Passed |
| regression: overflowing center fallback | 0 | -28 | Failed |
| regression: overflowing center fallback | 0 | -3 | Failed |
| RTL end is left | 0 | 0 | Passed |
| odd slack RTL center | 8 | 8 | Passed |
| control layout | 0 | 0 | Passed |
| control layout | -3 | -3 | Passed |
SHA-256 / cbdf15ef52cc6c2018415dc68c60389111ebaa5ac81e3aa6a0b688fe0aa26ec1
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:56.743373+00:00.
Case digest / 7272cea60170fd804d9c9361a88e128538a38999feae5f9ad7a84ea7722c46fe