FAILURE MAP
← Case archive

FA-80401 / Bidirectional text layout / Open access

Weak type resolution: terminator run extent · case 01

Only the terminator touching the number is attached.

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

ROOT CAUSE

W5 treats each ET separately instead of as a run.

THE FAILURE

W5 treats each ET separately instead of as a run.

Unsuccessful approach: Letting ES join the run absorbs separators into numbers.

Case contract

Input [classes of one isolating run sequence, sos]. W1 NSM takes the previous type (sos at start; ON after LRI/RLI/FSI/PDI). W2 EN after the last strong AL becomes AN. W3 AL->R. W4 a single ES between EN and EN -> EN; a single CS between two numbers of the same type takes that type. W5 a run of ET adjacent to EN -> EN. W6 remaining ES/ET/CS -> ON. W7 EN whose last strong (sos at start) is L -> L. Return resolved classes.

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):
    types, sos = x
    t = list(types)
    n = len(t)
    prev = sos
    for i in range(n):
        if t[i] == 'NSM':
            t[i] = 'ON' if prev in ('LRI', 'RLI', 'FSI', 'PDI') else prev
        prev = t[i]
    last_strong = sos
    for i in range(n):
        if t[i] in ('L', 'R', 'AL'):
            last_strong = t[i]
        elif t[i] == 'EN' and last_strong == 'AL':
            t[i] = 'AN'
    t = ['R' if c == 'AL' else c for c in t]
    for i in range(1, n - 1):
        if t[i] == 'ES' and t[i - 1] == 'EN' and t[i + 1] == 'EN':
            t[i] = 'EN'
        elif t[i] == 'CS' and t[i - 1] == t[i + 1] and t[i - 1] in ('EN', 'AN'):
            t[i] = t[i - 1]
    i = 0
    while i < n:
        if t[i] == 'ET':
            j = i
            j = i + 1
            if (i > 0 and t[i - 1] == 'EN') or (j < n and t[j] == 'EN'):
                for k in range(i, j):
                    t[k] = 'EN'
            i = j
        else:
            i += 1
    t = ['ON' if c in ('ES', 'ET', 'CS') else c for c in t]
    strong = sos
    for i in range(n):
        if t[i] in ('L', 'R'):
            strong = t[i]
        elif t[i] == 'EN' and strong == 'L':
            t[i] = 'L'
    return t
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: terminator run extent', [['L', 'CS', 'EN', 'PDI', 'EN', 'R', 'ET', 'NSM', 'EN'], 'L'], ['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']), ('regression: terminator run extent', [['ES', 'L', 'CS', 'AN', 'ET', 'NSM', 'EN', 'R', 'CS', 'EN'], 'L'], ['ON', 'L', 'ON', 'AN', 'L', 'L', 'L', 'R', 'ON', 'EN']), ('partial-repair probe', [['EN', 'EN', 'ET', 'EN', 'ET', 'ES'], 'L'], ['L', 'L', 'L', 'L', 'L', 'ON']), ('partial-repair probe', [['EN', 'ET', 'ES', 'EN'], 'R'], ['EN', 'EN', 'ON', 'EN']), ('NSM chain after R', [['R', 'NSM', 'NSM', 'EN'], 'L'], ['R', 'R', 'R', 'EN']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['EN', 'L', 'ON', 'R'], 'R'], ['EN', 'L', 'ON', 'R']), ('control layout', [['EN', 'ET', 'WS', 'LRI', 'AL', 'LRI', 'R', 'EN', 'AL'], 'L'], ['L', 'L', 'WS', 'LRI', 'R', 'LRI', 'R', 'EN', 'R'])], [('regression: terminator run extent', [['ES', 'L', 'CS', 'AN', 'ET', 'NSM', 'EN', 'R', 'CS', 'EN'], 'L'], ['ON', 'L', 'ON', 'AN', 'L', 'L', 'L', 'R', 'ON', 'EN']), ('regression: terminator run extent', [['L', 'CS', 'EN', 'PDI', 'EN', 'R', 'ET', 'NSM', 'EN'], 'L'], ['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']), ('partial-repair probe', [['LRI', 'CS', 'ET', 'EN', 'NSM', 'ET', 'ES'], 'R'], ['LRI', 'ON', 'EN', 'EN', 'EN', 'EN', 'ON']), ('partial-repair probe', [['L', 'L', 'AN', 'ET', 'ES', 'EN', 'ON', 'EN'], 'L'], ['L', 'L', 'AN', 'ON', 'ON', 'L', 'ON', 'L']), ('Arabic number context', [['AL', 'EN', 'CS', 'EN'], 'L'], ['R', 'AN', 'AN', 'AN']), ('NSM chain after R', [['R', 'NSM', 'NSM', 'EN'], 'L'], ['R', 'R', 'R', 'EN']), ('control layout', [['ES', 'ET', 'R', 'ES', 'CS', 'ES'], 'R'], ['ON', 'ON', 'R', 'ON', 'ON', 'ON']), ('control layout', [['EN', 'WS', 'L', 'AN', 'L', 'AN'], 'R'], ['EN', 'WS', 'L', 'AN', 'L', 'AN'])], [('regression: terminator run extent', [['CS', 'EN', 'L', 'ET', 'NSM', 'EN', 'CS', 'EN', 'ON', 'ET'], 'R'], ['ON', 'EN', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'ON']), ('regression: terminator run extent', [['L', 'CS', 'EN', 'PDI', 'EN', 'R', 'ET', 'NSM', 'EN'], 'L'], ['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']), ('partial-repair probe', [['ET', 'ES', 'EN', 'AL'], 'R'], ['ON', 'ON', 'EN', 'R']), ('partial-repair probe', [['L', 'EN', 'ET', 'ES'], 'L'], ['L', 'L', 'L', 'ON']), ('Arabic number context', [['AL', 'EN', 'CS', 'EN'], 'L'], ['R', 'AN', 'AN', 'AN']), ('percent after number', [['EN', 'ET', 'ET', 'L'], 'R'], ['EN', 'EN', 'EN', 'L']), ('control layout', [['LRI', 'ON', 'L'], 'L'], ['LRI', 'ON', 'L']), ('control layout', [['AL', 'AN', 'L', 'LRI', 'ET', 'EN', 'AL', 'L', 'NSM', 'PDI', 'EN'], 'L'], ['R', 'AN', 'L', 'LRI', 'L', 'L', 'R', 'L', 'L', 'PDI', 'L'])], [('regression: terminator run extent', [['ES', 'L', 'CS', 'AN', 'ET', 'NSM', 'EN', 'R', 'CS', 'EN'], 'L'], ['ON', 'L', 'ON', 'AN', 'L', 'L', 'L', 'R', 'ON', 'EN']), ('regression: terminator run extent', [['L', 'CS', 'EN', 'PDI', 'EN', 'R', 'ET', 'NSM', 'EN'], 'L'], ['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']), ('partial-repair probe', [['L', 'EN', 'ET', 'ES'], 'L'], ['L', 'L', 'L', 'ON']), ('partial-repair probe', [['LRI', 'CS', 'ET', 'EN', 'NSM', 'ET', 'ES'], 'R'], ['LRI', 'ON', 'EN', 'EN', 'EN', 'EN', 'ON']), ('NSM chain after R', [['R', 'NSM', 'NSM', 'EN'], 'L'], ['R', 'R', 'R', 'EN']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['AL', 'AN'], 'L'], ['R', 'AN']), ('control layout', [['ES', 'WS', 'L', 'EN', 'AL', 'PDI', 'CS'], 'R'], ['ON', 'WS', 'L', 'L', 'R', 'PDI', 'ON'])], [('regression: terminator run extent', [['CS', 'EN', 'L', 'ET', 'NSM', 'EN', 'CS', 'EN', 'ON', 'ET'], 'R'], ['ON', 'EN', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'ON']), ('regression: terminator run extent', [['ES', 'ET', 'ET', 'EN', 'AL', 'ES', 'R', 'R'], 'R'], ['ON', 'EN', 'EN', 'EN', 'R', 'ON', 'R', 'R']), ('partial-repair probe', [['CS', 'ET', 'ES', 'EN', 'L', 'CS'], 'R'], ['ON', 'ON', 'ON', 'EN', 'L', 'ON']), ('partial-repair probe', [['ET', 'ES', 'EN', 'AL'], 'R'], ['ON', 'ON', 'EN', 'R']), ('Arabic number context', [['AL', 'EN', 'CS', 'EN'], 'L'], ['R', 'AN', 'AN', 'AN']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('control layout', [['AL', 'ON', 'AN', 'ON', 'EN', 'AL', 'ES'], 'L'], ['R', 'ON', 'AN', 'ON', 'AN', 'R', 'ON']), ('control layout', [['L', 'EN', 'LRI', 'ET', 'AL', 'EN'], 'R'], ['L', 'L', 'LRI', 'ON', 'R', 'AN'])]]
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: terminator run extent['L', 'ON', 'L', 'PDI', 'L', 'R', 'ON', 'EN', 'EN']['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']Failed
regression: terminator run extent['ON', 'L', 'ON', 'AN', 'ON', 'L', 'L', 'R', 'ON', 'EN']['ON', 'L', 'ON', 'AN', 'L', 'L', 'L', 'R', 'ON', 'EN']Failed
partial-repair probe['L', 'L', 'L', 'L', 'L', 'ON']['L', 'L', 'L', 'L', 'L', 'ON']Passed
partial-repair probe['EN', 'EN', 'ON', 'EN']['EN', 'EN', 'ON', 'EN']Passed
NSM chain after R['R', 'R', 'R', 'EN']['R', 'R', 'R', 'EN']Passed
plus between numbers['EN', 'EN', 'EN', 'R']['EN', 'EN', 'EN', 'R']Passed
control layout['EN', 'L', 'ON', 'R']['EN', 'L', 'ON', 'R']Passed
control layout['L', 'L', 'WS', 'LRI', 'R', 'LRI', 'R', 'EN', 'R']['L', 'L', 'WS', 'LRI', 'R', 'LRI', 'R', 'EN', 'R']Passed

SHA-256 / a6534c8b2a12f24b054f5982be59816213c324ad1ddd1c213bc9aff14c21829f

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    types, sos = x
    t = list(types)
    n = len(t)
    prev = sos
    for i in range(n):
        if t[i] == 'NSM':
            t[i] = 'ON' if prev in ('LRI', 'RLI', 'FSI', 'PDI') else prev
        prev = t[i]
    last_strong = sos
    for i in range(n):
        if t[i] in ('L', 'R', 'AL'):
            last_strong = t[i]
        elif t[i] == 'EN' and last_strong == 'AL':
            t[i] = 'AN'
    t = ['R' if c == 'AL' else c for c in t]
    for i in range(1, n - 1):
        if t[i] == 'ES' and t[i - 1] == 'EN' and t[i + 1] == 'EN':
            t[i] = 'EN'
        elif t[i] == 'CS' and t[i - 1] == t[i + 1] and t[i - 1] in ('EN', 'AN'):
            t[i] = t[i - 1]
    i = 0
    while i < n:
        if t[i] == 'ET':
            j = i
            while j < n and t[j] in ('ET', 'ES'):
                j += 1
            if (i > 0 and t[i - 1] == 'EN') or (j < n and t[j] == 'EN'):
                for k in range(i, j):
                    t[k] = 'EN'
            i = j
        else:
            i += 1
    t = ['ON' if c in ('ES', 'ET', 'CS') else c for c in t]
    strong = sos
    for i in range(n):
        if t[i] in ('L', 'R'):
            strong = t[i]
        elif t[i] == 'EN' and strong == 'L':
            t[i] = 'L'
    return t
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: terminator run extent', [['L', 'CS', 'EN', 'PDI', 'EN', 'R', 'ET', 'NSM', 'EN'], 'L'], ['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']), ('regression: terminator run extent', [['ES', 'L', 'CS', 'AN', 'ET', 'NSM', 'EN', 'R', 'CS', 'EN'], 'L'], ['ON', 'L', 'ON', 'AN', 'L', 'L', 'L', 'R', 'ON', 'EN']), ('partial-repair probe', [['EN', 'EN', 'ET', 'EN', 'ET', 'ES'], 'L'], ['L', 'L', 'L', 'L', 'L', 'ON']), ('partial-repair probe', [['EN', 'ET', 'ES', 'EN'], 'R'], ['EN', 'EN', 'ON', 'EN']), ('NSM chain after R', [['R', 'NSM', 'NSM', 'EN'], 'L'], ['R', 'R', 'R', 'EN']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['EN', 'L', 'ON', 'R'], 'R'], ['EN', 'L', 'ON', 'R']), ('control layout', [['EN', 'ET', 'WS', 'LRI', 'AL', 'LRI', 'R', 'EN', 'AL'], 'L'], ['L', 'L', 'WS', 'LRI', 'R', 'LRI', 'R', 'EN', 'R'])], [('regression: terminator run extent', [['ES', 'L', 'CS', 'AN', 'ET', 'NSM', 'EN', 'R', 'CS', 'EN'], 'L'], ['ON', 'L', 'ON', 'AN', 'L', 'L', 'L', 'R', 'ON', 'EN']), ('regression: terminator run extent', [['L', 'CS', 'EN', 'PDI', 'EN', 'R', 'ET', 'NSM', 'EN'], 'L'], ['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']), ('partial-repair probe', [['LRI', 'CS', 'ET', 'EN', 'NSM', 'ET', 'ES'], 'R'], ['LRI', 'ON', 'EN', 'EN', 'EN', 'EN', 'ON']), ('partial-repair probe', [['L', 'L', 'AN', 'ET', 'ES', 'EN', 'ON', 'EN'], 'L'], ['L', 'L', 'AN', 'ON', 'ON', 'L', 'ON', 'L']), ('Arabic number context', [['AL', 'EN', 'CS', 'EN'], 'L'], ['R', 'AN', 'AN', 'AN']), ('NSM chain after R', [['R', 'NSM', 'NSM', 'EN'], 'L'], ['R', 'R', 'R', 'EN']), ('control layout', [['ES', 'ET', 'R', 'ES', 'CS', 'ES'], 'R'], ['ON', 'ON', 'R', 'ON', 'ON', 'ON']), ('control layout', [['EN', 'WS', 'L', 'AN', 'L', 'AN'], 'R'], ['EN', 'WS', 'L', 'AN', 'L', 'AN'])], [('regression: terminator run extent', [['CS', 'EN', 'L', 'ET', 'NSM', 'EN', 'CS', 'EN', 'ON', 'ET'], 'R'], ['ON', 'EN', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'ON']), ('regression: terminator run extent', [['L', 'CS', 'EN', 'PDI', 'EN', 'R', 'ET', 'NSM', 'EN'], 'L'], ['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']), ('partial-repair probe', [['ET', 'ES', 'EN', 'AL'], 'R'], ['ON', 'ON', 'EN', 'R']), ('partial-repair probe', [['L', 'EN', 'ET', 'ES'], 'L'], ['L', 'L', 'L', 'ON']), ('Arabic number context', [['AL', 'EN', 'CS', 'EN'], 'L'], ['R', 'AN', 'AN', 'AN']), ('percent after number', [['EN', 'ET', 'ET', 'L'], 'R'], ['EN', 'EN', 'EN', 'L']), ('control layout', [['LRI', 'ON', 'L'], 'L'], ['LRI', 'ON', 'L']), ('control layout', [['AL', 'AN', 'L', 'LRI', 'ET', 'EN', 'AL', 'L', 'NSM', 'PDI', 'EN'], 'L'], ['R', 'AN', 'L', 'LRI', 'L', 'L', 'R', 'L', 'L', 'PDI', 'L'])], [('regression: terminator run extent', [['ES', 'L', 'CS', 'AN', 'ET', 'NSM', 'EN', 'R', 'CS', 'EN'], 'L'], ['ON', 'L', 'ON', 'AN', 'L', 'L', 'L', 'R', 'ON', 'EN']), ('regression: terminator run extent', [['L', 'CS', 'EN', 'PDI', 'EN', 'R', 'ET', 'NSM', 'EN'], 'L'], ['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']), ('partial-repair probe', [['L', 'EN', 'ET', 'ES'], 'L'], ['L', 'L', 'L', 'ON']), ('partial-repair probe', [['LRI', 'CS', 'ET', 'EN', 'NSM', 'ET', 'ES'], 'R'], ['LRI', 'ON', 'EN', 'EN', 'EN', 'EN', 'ON']), ('NSM chain after R', [['R', 'NSM', 'NSM', 'EN'], 'L'], ['R', 'R', 'R', 'EN']), ('plus between numbers', [['EN', 'ES', 'EN', 'R'], 'R'], ['EN', 'EN', 'EN', 'R']), ('control layout', [['AL', 'AN'], 'L'], ['R', 'AN']), ('control layout', [['ES', 'WS', 'L', 'EN', 'AL', 'PDI', 'CS'], 'R'], ['ON', 'WS', 'L', 'L', 'R', 'PDI', 'ON'])], [('regression: terminator run extent', [['CS', 'EN', 'L', 'ET', 'NSM', 'EN', 'CS', 'EN', 'ON', 'ET'], 'R'], ['ON', 'EN', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'ON']), ('regression: terminator run extent', [['ES', 'ET', 'ET', 'EN', 'AL', 'ES', 'R', 'R'], 'R'], ['ON', 'EN', 'EN', 'EN', 'R', 'ON', 'R', 'R']), ('partial-repair probe', [['CS', 'ET', 'ES', 'EN', 'L', 'CS'], 'R'], ['ON', 'ON', 'ON', 'EN', 'L', 'ON']), ('partial-repair probe', [['ET', 'ES', 'EN', 'AL'], 'R'], ['ON', 'ON', 'EN', 'R']), ('Arabic number context', [['AL', 'EN', 'CS', 'EN'], 'L'], ['R', 'AN', 'AN', 'AN']), ('NSM after isolate initiator', [['LRI', 'NSM', 'L', 'PDI'], 'R'], ['LRI', 'ON', 'L', 'PDI']), ('control layout', [['AL', 'ON', 'AN', 'ON', 'EN', 'AL', 'ES'], 'L'], ['R', 'ON', 'AN', 'ON', 'AN', 'R', 'ON']), ('control layout', [['L', 'EN', 'LRI', 'ET', 'AL', 'EN'], 'R'], ['L', 'L', 'LRI', 'ON', 'R', 'AN'])]]
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: terminator run extent['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']['L', 'ON', 'L', 'PDI', 'L', 'R', 'EN', 'EN', 'EN']Passed
regression: terminator run extent['ON', 'L', 'ON', 'AN', 'L', 'L', 'L', 'R', 'ON', 'EN']['ON', 'L', 'ON', 'AN', 'L', 'L', 'L', 'R', 'ON', 'EN']Passed
partial-repair probe['L', 'L', 'L', 'L', 'L', 'L']['L', 'L', 'L', 'L', 'L', 'ON']Failed
partial-repair probe['EN', 'EN', 'EN', 'EN']['EN', 'EN', 'ON', 'EN']Failed
NSM chain after R['R', 'R', 'R', 'EN']['R', 'R', 'R', 'EN']Passed
plus between numbers['EN', 'EN', 'EN', 'R']['EN', 'EN', 'EN', 'R']Passed
control layout['EN', 'L', 'ON', 'R']['EN', 'L', 'ON', 'R']Passed
control layout['L', 'L', 'WS', 'LRI', 'R', 'LRI', 'R', 'EN', 'R']['L', 'L', 'WS', 'LRI', 'R', 'LRI', 'R', 'EN', 'R']Passed

SHA-256 / a310dc32e4dee76378cd2ca914787f7cf2a91a1134773510c1edaffa99035d98

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

Case digest / e12bb27572c5dbd664dcc214ea5111d6dc9672044d2f6dcfb24d1cdfec84c116