FA-80491 / Bidirectional text layout / Open access
Visual reordering by levels: visual map direction · case 01
Callers receive a logical-to-visual map instead of visual order.
ROOT CAUSE
The result is inverted into visual positions per logical index.
THE FAILURE
The result is inverted into visual positions per logical index.
Unsuccessful approach: Mirroring the indices is not the same as reordering.
Case contract
Input resolved levels of one line. From the highest level down to the lowest odd level on the line, reverse every maximal visual run of characters at that level or higher. Return logical indices in visual order (identity when no odd level).
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):
levels = x
order = list(range(len(levels)))
odd = [l for l in levels if l % 2 == 1]
if not odd:
return order
hi = max(levels)
lo = min(odd)
vis = [[lv, i] for i, lv in enumerate(levels)]
for lev in range(hi, lo - 1, -1):
i = 0
while i < len(vis):
if vis[i][0] >= lev:
j = i
while j < len(vis) and vis[j][0] >= lev:
j += 1
vis[i:j] = vis[i:j][::-1]
i = j
else:
i += 1
pos = [0] * len(vis)
for v, p in enumerate(vis):
pos[p[1]] = v
return pos
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('regression: visual map direction', [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 2, 2], [3, 4, 5, 6, 9, 8, 7, 10, 11, 2, 1, 0]), ('regression: visual map direction', [1, 1, 1, 2, 2, 2], [3, 4, 5, 2, 1, 0]), ('partial-repair probe', [1, 1, 1, 4], [3, 2, 1, 0]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('control layout', [2], [0]), ('control layout', [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8])], [('regression: visual map direction', [4, 4, 4, 4, 1, 1, 1, 4], [7, 6, 5, 4, 0, 1, 2, 3]), ('regression: visual map direction', [3, 3, 4, 4], [2, 3, 1, 0]), ('regression: visual map direction', [2, 2, 2, 2, 2, 2, 2, 1, 1, 1], [9, 8, 7, 0, 1, 2, 3, 4, 5, 6]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('control layout', [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), ('control layout', [2, 2, 2, 2, 2, 2], [0, 1, 2, 3, 4, 5])], [('regression: visual map direction', [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4], [6, 7, 8, 9, 10, 11, 5, 4, 3, 2, 1, 0]), ('regression: visual map direction', [2, 2, 3, 3, 3, 1, 1, 4, 4, 4], [7, 8, 9, 6, 5, 0, 1, 4, 3, 2]), ('partial-repair probe', [1, 0, 0], [0, 1, 2]), ('regression: visual map direction', [2, 2, 2, 2, 1, 1], [5, 4, 0, 1, 2, 3]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('control layout', [4, 4, 4, 2], [0, 1, 2, 3]), ('control layout', [0, 0, 0, 0, 0], [0, 1, 2, 3, 4])], [('regression: visual map direction', [2, 2, 1, 1, 1, 1, 1, 1, 0, 0], [7, 6, 5, 4, 3, 2, 0, 1, 8, 9]), ('regression: visual map direction', [4, 4, 4, 3, 3, 3, 3], [6, 5, 4, 3, 0, 1, 2]), ('partial-repair probe', [3, 3], [1, 0]), ('regression: visual map direction', [0, 0, 0, 2, 1, 1, 1, 2, 2, 2, 2, 1], [0, 1, 2, 11, 7, 8, 9, 10, 6, 5, 4, 3]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('control layout', [0, 0, 0], [0, 1, 2]), ('control layout', [1], [0])], [('regression: visual map direction', [2, 2, 2, 1, 1, 1, 1, 3, 3, 3], [9, 8, 7, 6, 5, 4, 3, 0, 1, 2]), ('regression: visual map direction', [2, 2, 2, 2, 2, 1, 1, 1], [7, 6, 5, 0, 1, 2, 3, 4]), ('regression: visual map direction', [1, 1, 1, 2, 2, 2, 2, 2, 2, 2], [3, 4, 5, 6, 7, 8, 9, 2, 1, 0]), ('regression: visual map direction', [3, 1, 1, 1, 1, 2, 2], [5, 6, 4, 3, 2, 1, 0]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('control layout', [0, 0, 0, 0, 0], [0, 1, 2, 3, 4]), ('control layout', [2, 2, 4], [0, 1, 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| number inside RTL | [4, 3, 1, 2, 0] | [4, 2, 3, 1, 0] | Failed |
| regression: visual map direction | [11, 10, 9, 0, 1, 2, 3, 6, 5, 4, 7, 8] | [3, 4, 5, 6, 9, 8, 7, 10, 11, 2, 1, 0] | Failed |
| regression: visual map direction | [5, 4, 3, 0, 1, 2] | [3, 4, 5, 2, 1, 0] | Failed |
| partial-repair probe | [3, 2, 1, 0] | [3, 2, 1, 0] | Passed |
| all even levels | [0, 1, 2, 3] | [0, 1, 2, 3] | Passed |
| lowest odd is three | [0, 2, 1, 3] | [0, 2, 1, 3] | Passed |
| control layout | [0] | [0] | Passed |
| control layout | [0, 1, 2, 3, 4, 5, 6, 7, 8] | [0, 1, 2, 3, 4, 5, 6, 7, 8] | Passed |
SHA-256 / a9f210e4ae078f6c76d388c0aa32dbfa7cd289bfdf02c7ac8dfb4c43423d8c5f
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
levels = x
order = list(range(len(levels)))
odd = [l for l in levels if l % 2 == 1]
if not odd:
return order
hi = max(levels)
lo = min(odd)
vis = [[lv, i] for i, lv in enumerate(levels)]
for lev in range(hi, lo - 1, -1):
i = 0
while i < len(vis):
if vis[i][0] >= lev:
j = i
while j < len(vis) and vis[j][0] >= lev:
j += 1
vis[i:j] = vis[i:j][::-1]
i = j
else:
i += 1
return [len(vis) - 1 - p[1] for p in vis]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('regression: visual map direction', [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 2, 2], [3, 4, 5, 6, 9, 8, 7, 10, 11, 2, 1, 0]), ('regression: visual map direction', [1, 1, 1, 2, 2, 2], [3, 4, 5, 2, 1, 0]), ('partial-repair probe', [1, 1, 1, 4], [3, 2, 1, 0]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('control layout', [2], [0]), ('control layout', [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8])], [('regression: visual map direction', [4, 4, 4, 4, 1, 1, 1, 4], [7, 6, 5, 4, 0, 1, 2, 3]), ('regression: visual map direction', [3, 3, 4, 4], [2, 3, 1, 0]), ('regression: visual map direction', [2, 2, 2, 2, 2, 2, 2, 1, 1, 1], [9, 8, 7, 0, 1, 2, 3, 4, 5, 6]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('control layout', [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), ('control layout', [2, 2, 2, 2, 2, 2], [0, 1, 2, 3, 4, 5])], [('regression: visual map direction', [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4], [6, 7, 8, 9, 10, 11, 5, 4, 3, 2, 1, 0]), ('regression: visual map direction', [2, 2, 3, 3, 3, 1, 1, 4, 4, 4], [7, 8, 9, 6, 5, 0, 1, 4, 3, 2]), ('partial-repair probe', [1, 0, 0], [0, 1, 2]), ('regression: visual map direction', [2, 2, 2, 2, 1, 1], [5, 4, 0, 1, 2, 3]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('control layout', [4, 4, 4, 2], [0, 1, 2, 3]), ('control layout', [0, 0, 0, 0, 0], [0, 1, 2, 3, 4])], [('regression: visual map direction', [2, 2, 1, 1, 1, 1, 1, 1, 0, 0], [7, 6, 5, 4, 3, 2, 0, 1, 8, 9]), ('regression: visual map direction', [4, 4, 4, 3, 3, 3, 3], [6, 5, 4, 3, 0, 1, 2]), ('partial-repair probe', [3, 3], [1, 0]), ('regression: visual map direction', [0, 0, 0, 2, 1, 1, 1, 2, 2, 2, 2, 1], [0, 1, 2, 11, 7, 8, 9, 10, 6, 5, 4, 3]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('control layout', [0, 0, 0], [0, 1, 2]), ('control layout', [1], [0])], [('regression: visual map direction', [2, 2, 2, 1, 1, 1, 1, 3, 3, 3], [9, 8, 7, 6, 5, 4, 3, 0, 1, 2]), ('regression: visual map direction', [2, 2, 2, 2, 2, 1, 1, 1], [7, 6, 5, 0, 1, 2, 3, 4]), ('regression: visual map direction', [1, 1, 1, 2, 2, 2, 2, 2, 2, 2], [3, 4, 5, 6, 7, 8, 9, 2, 1, 0]), ('regression: visual map direction', [3, 1, 1, 1, 1, 2, 2], [5, 6, 4, 3, 2, 1, 0]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('control layout', [0, 0, 0, 0, 0], [0, 1, 2, 3, 4]), ('control layout', [2, 2, 4], [0, 1, 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| number inside RTL | [0, 2, 1, 3, 4] | [4, 2, 3, 1, 0] | Failed |
| regression: visual map direction | [8, 7, 6, 5, 2, 3, 4, 1, 0, 9, 10, 11] | [3, 4, 5, 6, 9, 8, 7, 10, 11, 2, 1, 0] | Failed |
| regression: visual map direction | [2, 1, 0, 3, 4, 5] | [3, 4, 5, 2, 1, 0] | Failed |
| partial-repair probe | [0, 1, 2, 3] | [3, 2, 1, 0] | Failed |
| all even levels | [0, 1, 2, 3] | [0, 1, 2, 3] | Passed |
| lowest odd is three | [3, 1, 2, 0] | [0, 2, 1, 3] | Failed |
| control layout | [0] | [0] | Passed |
| control layout | [0, 1, 2, 3, 4, 5, 6, 7, 8] | [0, 1, 2, 3, 4, 5, 6, 7, 8] | Passed |
SHA-256 / 499ee19647b9bebdfcaae2c9b2f53b9f288172c205a8cd729694d8f62c6e913e
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.232740+00:00.
Case digest / be91dc9c9437ffd1c6ac12a5e9fb967f4366c713e3c1f81317b3e2b3c9cf0b49