FA-80561 / Bidirectional text layout / Open access
Mirrored glyph rendering: mirror table symmetry · case 01
Closing brackets in RTL text render unflipped.
ROOT CAUSE
The mirror table maps only opening characters to closing ones.
THE FAILURE
The mirror table maps only opening characters to closing ones.
Unsuccessful approach: A symmetric ASCII-only table still misses guillemets.
Case contract
Input [text, resolved levels]. Characters at odd levels with a mirror pair ( ) [ ] { } < > « » are replaced by their mirror, decided per logical character; then runs are reversed from the highest level to the lowest odd level. Return the visual string.
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
import itertools
N = 1
observations = []
def solve(x):
text, levels = x
M = {'(': ')', '[': ']', '{': '}', '<': '>', '«': '»'}
n = len(text)
glyphs = [M.get(ch, ch) if levels[i] % 2 == 1 else ch for i, ch in enumerate(text)]
order = list(range(n))
odd = [l for l in levels if l % 2]
if odd:
for lev in range(max(levels), min(odd) - 1, -1):
runs = []
for key, grp in itertools.groupby(order, key=lambda i: levels[i] >= lev):
g = list(grp)
runs.extend(g[::-1] if key else g)
order = runs
return ''.join(glyphs[i] for i in order)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('regression: mirror table symmetry', ['b(][)]{«({b]', [3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2]], '({b]»}[(][)b'), ('regression: mirror table symmetry', ['>»yyb)', [3, 3, 3, 3, 3, 1]], '(byy«<'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('control layout', ['<<«a', [2, 2, 2, 2]], '<<«a'), ('control layout', ['xy(>(xb', [2, 2, 2, 2, 2, 2, 2]], 'xy(>(xb'), ('control layout', ['y(x«[', [1, 0, 0, 0, 0]], 'y(x«[')], [('regression: mirror table symmetry', [')', [1]], '('), ('regression: mirror table symmetry', ['<[}y{([y', [1, 1, 1, 1, 1, 3, 3, 0]], '])}y{]>y'), ('regression: mirror table symmetry', ['{<[b«}x>«x', [0, 0, 0, 0, 0, 0, 0, 3, 3, 3]], '{<[b«}xx»<'), ('regression: mirror table symmetry', ['}«<)<yya<[y(', [1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1]], ')y]>yay>(>»{'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('control layout', ['a[', [1, 1]], ']a'), ('control layout', ['»a[', [0, 0, 0]], '»a[')], [('regression: mirror table symmetry', ['«])ay}xb', [2, 2, 2, 2, 2, 3, 3, 4]], '«])aybx{'), ('regression: mirror table symmetry', ['xy(»«y{(', [2, 2, 4, 3, 3, 3, 3, 1]], ')xy}y»«('), ('regression: mirror table symmetry', ['<»b«{', [1, 1, 1, 4, 3]], '}«b«>'), ('regression: mirror table symmetry', ['y]«', [3, 3, 3]], '»[y'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('control layout', ['»»}<y[«}ay{x', [2, 2, 2, 2, 2, 1, 2, 2, 1, 1, 4, 4]], '{xya«}]»»}<y'), ('control layout', ['ay]»y[', [2, 2, 2, 2, 1, 2]], '[yay]»')], [('regression: mirror table symmetry', ['x}b>y]({}>({', [0, 0, 1, 3, 0, 0, 0, 0, 1, 2, 2, 0]], 'x}<by]({>({{'), ('regression: mirror table symmetry', ['«]x)<', [1, 1, 1, 0, 1]], 'x[»)>'), ('regression: mirror table symmetry', ['}«<)<yya<[y(', [1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1]], ')y]>yay>(>»{'), ('regression: mirror table symmetry', ['xy(»«y{(', [2, 2, 4, 3, 3, 3, 3, 1]], ')xy}y»«('), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('control layout', ['a', [2]], 'a'), ('control layout', ['b({()', [1, 1, 1, 0, 0]], '})b()')], [('regression: mirror table symmetry', ['<<(b]b)]]»', [3, 3, 3, 1, 1, 1, 0, 0, 0, 2]], 'b[b)>>)]]»'), ('regression: mirror table symmetry', ['()»<x»)yy', [3, 3, 0, 0, 0, 0, 0, 0, 0]], '()»<x»)yy'), ('partial-repair probe', ['yy(«x', [1, 1, 1, 1, 2]], 'x»)yy'), ('partial-repair probe', ['y[([ay[«', [1, 1, 1, 1, 1, 2, 2, 1]], '»y[a])]y'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('control layout', ['ba', [3, 3]], 'ab'), ('control layout', ['y', [3]], 'y')]]
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 |
|---|---|---|---|
| bracket in RTL run | )b)a | (b)a | Failed |
| regression: mirror table symmetry | ({b]»}])]])b | ({b]»}[(][)b | Failed |
| regression: mirror table symmetry | )byy»> | (byy«< | Failed |
| guillemets RTL | »ba» | «ba» | Failed |
| bracket at level two | (x) | (x) | Passed |
| control layout | <<«a | <<«a | Passed |
| control layout | xy(>(xb | xy(>(xb | Passed |
| control layout | y(x«[ | y(x«[ | Passed |
SHA-256 / dfbf1a71dc1b314190f25ceef2415cb19b6a5811e60615913024ed6da60dd2bb
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import itertools
N = 1
observations = []
def solve(x):
text, levels = x
M = {'(': ')', ')': '(', '[': ']', ']': '[', '{': '}', '}': '{', '<': '>', '>': '<'}
n = len(text)
glyphs = [M.get(ch, ch) if levels[i] % 2 == 1 else ch for i, ch in enumerate(text)]
order = list(range(n))
odd = [l for l in levels if l % 2]
if odd:
for lev in range(max(levels), min(odd) - 1, -1):
runs = []
for key, grp in itertools.groupby(order, key=lambda i: levels[i] >= lev):
g = list(grp)
runs.extend(g[::-1] if key else g)
order = runs
return ''.join(glyphs[i] for i in order)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('regression: mirror table symmetry', ['b(][)]{«({b]', [3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2]], '({b]»}[(][)b'), ('regression: mirror table symmetry', ['>»yyb)', [3, 3, 3, 3, 3, 1]], '(byy«<'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('control layout', ['<<«a', [2, 2, 2, 2]], '<<«a'), ('control layout', ['xy(>(xb', [2, 2, 2, 2, 2, 2, 2]], 'xy(>(xb'), ('control layout', ['y(x«[', [1, 0, 0, 0, 0]], 'y(x«[')], [('regression: mirror table symmetry', [')', [1]], '('), ('regression: mirror table symmetry', ['<[}y{([y', [1, 1, 1, 1, 1, 3, 3, 0]], '])}y{]>y'), ('regression: mirror table symmetry', ['{<[b«}x>«x', [0, 0, 0, 0, 0, 0, 0, 3, 3, 3]], '{<[b«}xx»<'), ('regression: mirror table symmetry', ['}«<)<yya<[y(', [1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1]], ')y]>yay>(>»{'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('control layout', ['a[', [1, 1]], ']a'), ('control layout', ['»a[', [0, 0, 0]], '»a[')], [('regression: mirror table symmetry', ['«])ay}xb', [2, 2, 2, 2, 2, 3, 3, 4]], '«])aybx{'), ('regression: mirror table symmetry', ['xy(»«y{(', [2, 2, 4, 3, 3, 3, 3, 1]], ')xy}y»«('), ('regression: mirror table symmetry', ['<»b«{', [1, 1, 1, 4, 3]], '}«b«>'), ('regression: mirror table symmetry', ['y]«', [3, 3, 3]], '»[y'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('control layout', ['»»}<y[«}ay{x', [2, 2, 2, 2, 2, 1, 2, 2, 1, 1, 4, 4]], '{xya«}]»»}<y'), ('control layout', ['ay]»y[', [2, 2, 2, 2, 1, 2]], '[yay]»')], [('regression: mirror table symmetry', ['x}b>y]({}>({', [0, 0, 1, 3, 0, 0, 0, 0, 1, 2, 2, 0]], 'x}<by]({>({{'), ('regression: mirror table symmetry', ['«]x)<', [1, 1, 1, 0, 1]], 'x[»)>'), ('regression: mirror table symmetry', ['}«<)<yya<[y(', [1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1]], ')y]>yay>(>»{'), ('regression: mirror table symmetry', ['xy(»«y{(', [2, 2, 4, 3, 3, 3, 3, 1]], ')xy}y»«('), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('control layout', ['a', [2]], 'a'), ('control layout', ['b({()', [1, 1, 1, 0, 0]], '})b()')], [('regression: mirror table symmetry', ['<<(b]b)]]»', [3, 3, 3, 1, 1, 1, 0, 0, 0, 2]], 'b[b)>>)]]»'), ('regression: mirror table symmetry', ['()»<x»)yy', [3, 3, 0, 0, 0, 0, 0, 0, 0]], '()»<x»)yy'), ('partial-repair probe', ['yy(«x', [1, 1, 1, 1, 2]], 'x»)yy'), ('partial-repair probe', ['y[([ay[«', [1, 1, 1, 1, 1, 2, 2, 1]], '»y[a])]y'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('control layout', ['ba', [3, 3]], 'ab'), ('control layout', ['y', [3]], 'y')]]
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 |
|---|---|---|---|
| bracket in RTL run | (b)a | (b)a | Passed |
| regression: mirror table symmetry | ({b]«}[(][)b | ({b]»}[(][)b | Failed |
| regression: mirror table symmetry | (byy»< | (byy«< | Failed |
| guillemets RTL | »ba« | «ba» | Failed |
| bracket at level two | (x) | (x) | Passed |
| control layout | <<«a | <<«a | Passed |
| control layout | xy(>(xb | xy(>(xb | Passed |
| control layout | y(x«[ | y(x«[ | Passed |
SHA-256 / 3b25dc12519b6af88ff22f9832ce0c2d9d69452c7eb0609f605fbb76f7956683
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.892686+00:00.
Case digest / 486ec10508918017d65a49044ab6b018190b491b770087a1f50597c95c8b9ed4