FAILURE MAP
← Case archive

FA-80736 / Bidirectional text layout / Open access

Direction-relative alignment: start alignment mapping · case 01

Start-aligned RTL paragraphs are left aligned.

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

ROOT CAUSE

start always maps to the left edge.

VERIFIED REPAIR

Map start to right for RTL.

Unsuccessful approach: Inverting the condition swaps LTR too.

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 = 'left'
    elif align == 'end':
        align = 'left' if rtl else 'right'
    if cw > lw and align == 'center':
        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 = [[('regression: start alignment mapping', [37, 31, 'justify', True], 6), ('regression: start alignment mapping', [10, 24, 'start', True], -14), ('partial-repair probe', [21, 5, 'justify', False], 0), ('regression: start alignment mapping', [22, 44, 'justify', True], -22), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [37, 2, 'right', True], 35), ('control layout', [36, 43, 'center', True], -7)], [('regression: start alignment mapping', [36, 5, 'start', True], 31), ('regression: start alignment mapping', [28, 33, 'start', True], -5), ('partial-repair probe', [11, 47, 'justify', False], 0), ('partial-repair probe', [34, 47, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 43, 'end', False], -10), ('control layout', [14, 28, 'end', False], -14)], [('regression: start alignment mapping', [28, 41, 'start', True], -13), ('regression: start alignment mapping', [22, 27, 'justify', True], -5), ('partial-repair probe', [15, 28, 'start', False], 0), ('regression: start alignment mapping', [21, 43, 'justify', True], -22), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [16, 22, 'right', True], -6), ('control layout', [12, 33, 'right', True], -21)], [('regression: start alignment mapping', [18, 12, 'justify', True], 6), ('regression: start alignment mapping', [16, 37, 'justify', True], -21), ('partial-repair probe', [35, 1, 'start', False], 0), ('regression: start alignment mapping', [38, 35, 'justify', True], 3), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [34, 34, 'right', False], 0), ('control layout', [11, 26, 'end', True], 0)], [('regression: start alignment mapping', [37, 26, 'start', True], 11), ('regression: start alignment mapping', [18, 41, 'justify', True], -23), ('partial-repair probe', [20, 46, 'start', False], 0), ('partial-repair probe', [29, 49, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [27, 32, 'center', False], 0), ('control layout', [36, 1, 'left', True], 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
regression: start alignment mapping06Failed
regression: start alignment mapping0-14Failed
partial-repair probe00Passed
regression: start alignment mapping0-22Failed
RTL end is left00Passed
overflowing center RTL-5-5Passed
control layout3535Passed
control layout-7-7Passed

SHA-256 / 4f33e6cece6c2ce495ed4a4d5db9f9e21ad67463843e4ebe6e2606ca0c3b67d1

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 not rtl else 'left'
    elif align == 'end':
        align = 'left' if rtl else 'right'
    if cw > lw and align == 'center':
        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 = [[('regression: start alignment mapping', [37, 31, 'justify', True], 6), ('regression: start alignment mapping', [10, 24, 'start', True], -14), ('partial-repair probe', [21, 5, 'justify', False], 0), ('regression: start alignment mapping', [22, 44, 'justify', True], -22), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [37, 2, 'right', True], 35), ('control layout', [36, 43, 'center', True], -7)], [('regression: start alignment mapping', [36, 5, 'start', True], 31), ('regression: start alignment mapping', [28, 33, 'start', True], -5), ('partial-repair probe', [11, 47, 'justify', False], 0), ('partial-repair probe', [34, 47, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 43, 'end', False], -10), ('control layout', [14, 28, 'end', False], -14)], [('regression: start alignment mapping', [28, 41, 'start', True], -13), ('regression: start alignment mapping', [22, 27, 'justify', True], -5), ('partial-repair probe', [15, 28, 'start', False], 0), ('regression: start alignment mapping', [21, 43, 'justify', True], -22), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [16, 22, 'right', True], -6), ('control layout', [12, 33, 'right', True], -21)], [('regression: start alignment mapping', [18, 12, 'justify', True], 6), ('regression: start alignment mapping', [16, 37, 'justify', True], -21), ('partial-repair probe', [35, 1, 'start', False], 0), ('regression: start alignment mapping', [38, 35, 'justify', True], 3), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [34, 34, 'right', False], 0), ('control layout', [11, 26, 'end', True], 0)], [('regression: start alignment mapping', [37, 26, 'start', True], 11), ('regression: start alignment mapping', [18, 41, 'justify', True], -23), ('partial-repair probe', [20, 46, 'start', False], 0), ('partial-repair probe', [29, 49, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [27, 32, 'center', False], 0), ('control layout', [36, 1, 'left', True], 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
regression: start alignment mapping06Failed
regression: start alignment mapping0-14Failed
partial-repair probe160Failed
regression: start alignment mapping0-22Failed
RTL end is left00Passed
overflowing center RTL-5-5Passed
control layout3535Passed
control layout-7-7Passed

SHA-256 / 23f91793c559dedac4b8e366fdaf323493b6533b5933e6a0055ac8689f632048

3 / The verified repair

Exit 0
"""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 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 = [[('regression: start alignment mapping', [37, 31, 'justify', True], 6), ('regression: start alignment mapping', [10, 24, 'start', True], -14), ('partial-repair probe', [21, 5, 'justify', False], 0), ('regression: start alignment mapping', [22, 44, 'justify', True], -22), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [37, 2, 'right', True], 35), ('control layout', [36, 43, 'center', True], -7)], [('regression: start alignment mapping', [36, 5, 'start', True], 31), ('regression: start alignment mapping', [28, 33, 'start', True], -5), ('partial-repair probe', [11, 47, 'justify', False], 0), ('partial-repair probe', [34, 47, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 43, 'end', False], -10), ('control layout', [14, 28, 'end', False], -14)], [('regression: start alignment mapping', [28, 41, 'start', True], -13), ('regression: start alignment mapping', [22, 27, 'justify', True], -5), ('partial-repair probe', [15, 28, 'start', False], 0), ('regression: start alignment mapping', [21, 43, 'justify', True], -22), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [16, 22, 'right', True], -6), ('control layout', [12, 33, 'right', True], -21)], [('regression: start alignment mapping', [18, 12, 'justify', True], 6), ('regression: start alignment mapping', [16, 37, 'justify', True], -21), ('partial-repair probe', [35, 1, 'start', False], 0), ('regression: start alignment mapping', [38, 35, 'justify', True], 3), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [34, 34, 'right', False], 0), ('control layout', [11, 26, 'end', True], 0)], [('regression: start alignment mapping', [37, 26, 'start', True], 11), ('regression: start alignment mapping', [18, 41, 'justify', True], -23), ('partial-repair probe', [20, 46, 'start', False], 0), ('partial-repair probe', [29, 49, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [27, 32, 'center', False], 0), ('control layout', [36, 1, 'left', True], 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
regression: start alignment mapping66Passed
regression: start alignment mapping-14-14Passed
partial-repair probe00Passed
regression: start alignment mapping-22-22Passed
RTL end is left00Passed
overflowing center RTL-5-5Passed
control layout3535Passed
control layout-7-7Passed

SHA-256 / 5fc6dcd43758c956f4d358c5a660bf6388648305d0acc709b9cf453374b10696

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

Case digest / 17a5eaac0e39e615e79cb3ddc0c5a5ab00728238024244483e4c94b542138d82