{"abstract":"Brackets are mirrored based on the level found at their visual slot.","category":"Bidirectional text layout","checks":8,"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.","contract_signature":"x","evaluation_group":"w2-bidirectional-text-layout-mirrored-rendering","failed_approach":"Using the first character's level for all characters ignores mixed levels.","family":"w2-bidirectional-text-layout-mirrored-rendering-mirror-level-lookup","id":"FA-80566","implementations":{"attempt":{"sha256":"25b9b5b66995ef4d924cdad7f0607d101a9197f2dccd5d84bf1462f678e29f0b","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport itertools\nN = 1\nobservations = []\ndef solve(x):\n    text, levels = x\n    M = {'(': ')', ')': '(', '[': ']', ']': '[', '{': '}', '}': '{', '<': '>', '>': '<', '«': '»', '»': '«'}\n    n = len(text)\n    glyphs = [M.get(ch, ch) if levels[0] % 2 == 1 else ch for i, ch in enumerate(text)]\n    order = list(range(n))\n    odd = [l for l in levels if l % 2]\n    if odd:\n        for lev in range(max(levels), min(odd) - 1, -1):\n            runs = []\n            for key, grp in itertools.groupby(order, key=lambda i: levels[i] >= lev):\n                g = list(grp)\n                runs.extend(g[::-1] if key else g)\n            order = runs\n    return ''.join(glyphs[i] for i in order)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: mirror level lookup', ['y[]x}<()]a', [4, 4, 2, 1, 3, 3, 2, 2, 1, 3]], 'a[>{()xy[]'), ('regression: mirror level lookup', ['{»{»}(»a>', [2, 2, 2, 1, 4, 2, 2, 2, 4]], '}(»a>«{»{'), ('regression: mirror level lookup', [']]{)«)<x»<}[', [1, 4, 4, 4, 4, 1, 1, 1, 2, 2, 2, 3]], '»<}]x>(]{)«['), ('regression: mirror level lookup', ['[}a[y{]}»', [2, 1, 1, 3, 2, 2, 2, 2, 3]], ']y{]}«a{['), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('control layout', ['y<', [1, 1]], '>y'), ('control layout', ['ba', [3, 3]], 'ab')], [('regression: mirror level lookup', ['>[){x', [3, 3, 3, 3, 4]], 'x}(]<'), ('regression: mirror level lookup', ['»>x»', [1, 2, 2, 2]], '>x»«'), ('regression: mirror level lookup', ['}<a<(a>«]', [1, 1, 1, 2, 2, 2, 2, 2, 2]], '<(a>«]a>{'), ('regression: mirror level lookup', ['[]<<«y»]xb)', [2, 2, 2, 2, 2, 3, 3, 3, 3, 1, 3]], '(b[]<<«x[«y'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('control layout', ['»', [2]], '»'), ('control layout', ['«{>}]]ax}', [1, 1, 1, 1, 1, 1, 1, 1, 1]], '{xa[[{<}»')], [('regression: mirror level lookup', ['}«x[[ab', [1, 1, 1, 1, 2, 1, 1]], 'ba[]x»{'), ('regression: mirror level lookup', ['y«{»]<]', [2, 2, 2, 1, 1, 4, 4]], '<][«y«{'), ('regression: mirror level lookup', ['>b<x<b»b)b', [0, 0, 0, 0, 1, 1, 1, 1, 2, 2]], '>b<x)bb«b>'), ('partial-repair probe', [')}<)<>[(a', [0, 0, 0, 0, 3, 3, 3, 3, 1]], ')}<)a)]<>'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('control layout', ['ya[', [1, 1, 1]], ']ay'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)')], [('regression: mirror level lookup', ['ay]»y[', [2, 2, 2, 2, 1, 2]], '[yay]»'), ('regression: mirror level lookup', ['xx>>}(b]{]«', [1, 1, 2, 1, 3, 3, 3, 3, 1, 1, 3]], '»[}[b){<>xx'), ('regression: mirror level lookup', ['«])ay}xb', [2, 2, 2, 2, 2, 3, 3, 4]], '«])aybx{'), ('partial-repair probe', ['««a<>x{)}>', [1, 1, 2, 2, 2, 4, 2, 2, 1, 1]], '<{a<>x{)»»'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('control layout', ['a[', [1, 1]], ']a'), ('control layout', ['(x)](', [1, 1, 1, 1, 3]], ')[(x)')], [('regression: mirror level lookup', ['a]»y]«)<»<x)', [3, 3, 3, 2, 4, 2, 2, 2, 2, 1, 1, 1]], '(x>«[ay]«)<»'), ('regression: mirror level lookup', [']]b{{{)', [3, 2, 2, 1, 1, 1, 1]], '(}}}[]b'), ('regression: mirror level lookup', ['xy(»«y{(', [2, 2, 4, 3, 3, 3, 3, 1]], ')xy}y»«('), ('regression: mirror level lookup', ['y{]]>[[x>>', [1, 1, 1, 2, 2, 2, 2, 2, 1, 2]], '><]>[[x[}y'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('control layout', [')>b»', [1, 1, 1, 1]], '«b<('), ('control layout', ['«x', [3, 3]], 'x»')]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"35dfc0fa383d8a4d38b8e92eccc6e4ea260de162104f5bea6cf8bffe8152c876","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport itertools\nN = 1\nobservations = []\ndef solve(x):\n    text, levels = x\n    M = {'(': ')', ')': '(', '[': ']', ']': '[', '{': '}', '}': '{', '<': '>', '>': '<', '«': '»', '»': '«'}\n    n = len(text)\n    glyphs = list(text)\n    order = list(range(n))\n    odd = [l for l in levels if l % 2]\n    if odd:\n        for lev in range(max(levels), min(odd) - 1, -1):\n            runs = []\n            for key, grp in itertools.groupby(order, key=lambda i: levels[i] >= lev):\n                g = list(grp)\n                runs.extend(g[::-1] if key else g)\n            order = runs\n    return ''.join(M.get(text[i], text[i]) if levels[v] % 2 == 1 else text[i] for v, i in enumerate(order))\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: mirror level lookup', ['y[]x}<()]a', [4, 4, 2, 1, 3, 3, 2, 2, 1, 3]], 'a[>{()xy[]'), ('regression: mirror level lookup', ['{»{»}(»a>', [2, 2, 2, 1, 4, 2, 2, 2, 4]], '}(»a>«{»{'), ('regression: mirror level lookup', [']]{)«)<x»<}[', [1, 4, 4, 4, 4, 1, 1, 1, 2, 2, 2, 3]], '»<}]x>(]{)«['), ('regression: mirror level lookup', ['[}a[y{]}»', [2, 1, 1, 3, 2, 2, 2, 2, 3]], ']y{]}«a{['), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('control layout', ['y<', [1, 1]], '>y'), ('control layout', ['ba', [3, 3]], 'ab')], [('regression: mirror level lookup', ['>[){x', [3, 3, 3, 3, 4]], 'x}(]<'), ('regression: mirror level lookup', ['»>x»', [1, 2, 2, 2]], '>x»«'), ('regression: mirror level lookup', ['}<a<(a>«]', [1, 1, 1, 2, 2, 2, 2, 2, 2]], '<(a>«]a>{'), ('regression: mirror level lookup', ['[]<<«y»]xb)', [2, 2, 2, 2, 2, 3, 3, 3, 3, 1, 3]], '(b[]<<«x[«y'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('control layout', ['»', [2]], '»'), ('control layout', ['«{>}]]ax}', [1, 1, 1, 1, 1, 1, 1, 1, 1]], '{xa[[{<}»')], [('regression: mirror level lookup', ['}«x[[ab', [1, 1, 1, 1, 2, 1, 1]], 'ba[]x»{'), ('regression: mirror level lookup', ['y«{»]<]', [2, 2, 2, 1, 1, 4, 4]], '<][«y«{'), ('regression: mirror level lookup', ['>b<x<b»b)b', [0, 0, 0, 0, 1, 1, 1, 1, 2, 2]], '>b<x)bb«b>'), ('partial-repair probe', [')}<)<>[(a', [0, 0, 0, 0, 3, 3, 3, 3, 1]], ')}<)a)]<>'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('control layout', ['ya[', [1, 1, 1]], ']ay'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)')], [('regression: mirror level lookup', ['ay]»y[', [2, 2, 2, 2, 1, 2]], '[yay]»'), ('regression: mirror level lookup', ['xx>>}(b]{]«', [1, 1, 2, 1, 3, 3, 3, 3, 1, 1, 3]], '»[}[b){<>xx'), ('regression: mirror level lookup', ['«])ay}xb', [2, 2, 2, 2, 2, 3, 3, 4]], '«])aybx{'), ('partial-repair probe', ['««a<>x{)}>', [1, 1, 2, 2, 2, 4, 2, 2, 1, 1]], '<{a<>x{)»»'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('guillemets RTL', ['«ab»', [1, 1, 1, 1]], '«ba»'), ('control layout', ['a[', [1, 1]], ']a'), ('control layout', ['(x)](', [1, 1, 1, 1, 3]], ')[(x)')], [('regression: mirror level lookup', ['a]»y]«)<»<x)', [3, 3, 3, 2, 4, 2, 2, 2, 2, 1, 1, 1]], '(x>«[ay]«)<»'), ('regression: mirror level lookup', [']]b{{{)', [3, 2, 2, 1, 1, 1, 1]], '(}}}[]b'), ('regression: mirror level lookup', ['xy(»«y{(', [2, 2, 4, 3, 3, 3, 3, 1]], ')xy}y»«('), ('regression: mirror level lookup', ['y{]]>[[x>>', [1, 1, 1, 2, 2, 2, 2, 2, 1, 2]], '><]>[[x[}y'), ('bracket in RTL run', ['a(b)', [1, 1, 1, 1]], '(b)a'), ('bracket at level two', ['(x)', [2, 2, 2]], '(x)'), ('control layout', [')>b»', [1, 1, 1, 1]], '«b<('), ('control layout', ['«x', [3, 3]], 'x»')]]\nfor label, args, expected in fixtures[N - 1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-bidirectional-text-layout-mirrored-rendering-mirror-level-lookup","generated_at":"2026-09-29T14:49:54.895826+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"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.","root_cause":"Mirroring is applied after reordering using the visual position as a logical index.","sha256":"233992c9a83428cbe5570b6e009a839264b8aedf55beaa091177a270316d9b53","title":"Mirrored glyph rendering: mirror level lookup · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":42.964,"exit_code":1,"observations":[{"actual":"a]<}()xy[]","check":"regression: mirror level lookup","expected":"a[>{()xy[]","passed":false},{"actual":"}(»a>»{»{","check":"regression: mirror level lookup","expected":"}(»a>«{»{","passed":false},{"actual":"«>{]x>([}(»[","check":"regression: mirror level lookup","expected":"»<}]x>(]{)«[","passed":false},{"actual":"[y{]}»a}[","check":"regression: mirror level lookup","expected":"]y{]}«a{[","passed":false},{"actual":"(x)","check":"bracket at level two","expected":"(x)","passed":true},{"actual":"«ba»","check":"guillemets RTL","expected":"«ba»","passed":true},{"actual":">y","check":"control layout","expected":">y","passed":true},{"actual":"ab","check":"control layout","expected":"ab","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: mirror level lookup\", \"actual\": \"a]<}()xy[]\", \"expected\": \"a[>{()xy[]\", \"passed\": false}, {\"check\": \"regression: mirror level lookup\", \"actual\": \"}(»a>»{»{\", \"expected\": \"}(»a>«{»{\", \"passed\": false}, {\"check\": \"regression: mirror level lookup\", \"actual\": \"«>{]x>([}(»[\", \"expected\": \"»<}]x>(]{)«[\", \"passed\": false}, {\"check\": \"regression: mirror level lookup\", \"actual\": \"[y{]}»a}[\", \"expected\": \"]y{]}«a{[\", \"passed\": false}, {\"check\": \"bracket at level two\", \"actual\": \"(x)\", \"expected\": \"(x)\", \"passed\": true}, {\"check\": \"guillemets RTL\", \"actual\": \"«ba»\", \"expected\": \"«ba»\", \"passed\": true}, {\"check\": \"control layout\", \"actual\": \">y\", \"expected\": \">y\", \"passed\": true}, {\"check\": \"control layout\", \"actual\": \"ab\", \"expected\": \"ab\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.934,"exit_code":1,"observations":[{"actual":"a]<{)(xy][","check":"regression: mirror level lookup","expected":"a[>{()xy[]","passed":false},{"actual":"}(»a>»{»{","check":"regression: mirror level lookup","expected":"}(»a>«{»{","passed":false},{"actual":"«<}[x>([{)«[","check":"regression: mirror level lookup","expected":"»<}]x>(]{)«[","passed":false},{"actual":"[y}[}»a}]","check":"regression: mirror level lookup","expected":"]y{]}«a{[","passed":false},{"actual":"(x)","check":"bracket at level two","expected":"(x)","passed":true},{"actual":"«ba»","check":"guillemets RTL","expected":"«ba»","passed":true},{"actual":">y","check":"control layout","expected":">y","passed":true},{"actual":"ab","check":"control layout","expected":"ab","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: mirror level lookup\", \"actual\": \"a]<{)(xy][\", \"expected\": \"a[>{()xy[]\", \"passed\": false}, {\"check\": \"regression: mirror level lookup\", \"actual\": \"}(»a>»{»{\", \"expected\": \"}(»a>«{»{\", \"passed\": false}, {\"check\": \"regression: mirror level lookup\", \"actual\": \"«<}[x>([{)«[\", \"expected\": \"»<}]x>(]{)«[\", \"passed\": false}, {\"check\": \"regression: mirror level lookup\", \"actual\": \"[y}[}»a}]\", \"expected\": \"]y{]}«a{[\", \"passed\": false}, {\"check\": \"bracket at level two\", \"actual\": \"(x)\", \"expected\": \"(x)\", \"passed\": true}, {\"check\": \"guillemets RTL\", \"actual\": \"«ba»\", \"expected\": \"«ba»\", \"passed\": true}, {\"check\": \"control layout\", \"actual\": \">y\", \"expected\": \">y\", \"passed\": true}, {\"check\": \"control layout\", \"actual\": \"ab\", \"expected\": \"ab\", \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}