{"abstract":"End-aligned RTL text sits on the right.","category":"Bidirectional text layout","checks":8,"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.","contract_signature":"x","evaluation_group":"w2-bidirectional-text-layout-direction-alignment","failed_approach":"Mapping end like start swaps both directions.","family":"w2-bidirectional-text-layout-direction-alignment-end-alignment-mapping","id":"FA-80731","implementations":{"attempt":{"sha256":"781fe22f55ef85844642ef9b8087db614ac986168e6da1a6fb79ae9ffa533028","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    lw, cw, align, rtl = x\n    if align == 'justify':\n        align = 'start'\n    if align == 'start':\n        align = 'right' if rtl else 'left'\n    elif align == 'end':\n        align = 'right' if rtl else 'left'\n    if cw > lw and align == 'center':\n        align = 'left' if not rtl else 'right'\n    if align == 'left':\n        return 0\n    if align == 'right':\n        return lw - cw\n    slack = lw - cw\n    return (slack + 1) // 2 if rtl else slack // 2\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('RTL end is left', [20, 5, 'end', True], 0), ('regression: end alignment mapping', [36, 28, 'end', True], 0), ('partial-repair probe', [16, 28, 'end', False], -12), ('partial-repair probe', [21, 46, 'end', False], -25), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [17, 39, 'center', True], -22), ('control layout', [37, 31, 'justify', True], 6)], [('regression: end alignment mapping', [37, 25, 'end', True], 0), ('regression: end alignment mapping', [22, 30, 'end', True], 0), ('regression: end alignment mapping', [11, 26, 'end', True], 0), ('partial-repair probe', [13, 1, 'end', False], 12), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [23, 3, 'justify', True], 20), ('control layout', [29, 29, 'justify', False], 0)], [('regression: end alignment mapping', [18, 8, 'end', True], 0), ('regression: end alignment mapping', [36, 9, 'end', True], 0), ('partial-repair probe', [38, 19, 'end', False], 19), ('partial-repair probe', [27, 20, 'end', False], 7), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [20, 40, 'start', False], 0), ('control layout', [15, 28, 'center', False], 0)], [('regression: end alignment mapping', [11, 34, 'end', True], 0), ('regression: end alignment mapping', [37, 25, 'end', True], 0), ('regression: end alignment mapping', [21, 8, 'end', True], 0), ('partial-repair probe', [33, 31, 'end', False], 2), ('odd slack RTL center', [20, 5, 'center', True], 8), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [35, 16, 'right', True], 19), ('control layout', [21, 20, 'left', False], 0)], [('regression: end alignment mapping', [35, 50, 'end', True], 0), ('regression: end alignment mapping', [20, 7, 'end', True], 0), ('partial-repair probe', [33, 31, 'end', False], 2), ('regression: end alignment mapping', [32, 30, 'end', True], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [10, 37, 'start', True], -27), ('control layout', [35, 3, 'center', True], 16)]]\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":"ff96e32ecbfcb2d65988c5bde1b41ea937903c8059437057708fd9c176b5e27f","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    lw, cw, align, rtl = x\n    if align == 'justify':\n        align = 'start'\n    if align == 'start':\n        align = 'right' if rtl else 'left'\n    elif align == 'end':\n        align = 'right'\n    if cw > lw and align == 'center':\n        align = 'left' if not rtl else 'right'\n    if align == 'left':\n        return 0\n    if align == 'right':\n        return lw - cw\n    slack = lw - cw\n    return (slack + 1) // 2 if rtl else slack // 2\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('RTL end is left', [20, 5, 'end', True], 0), ('regression: end alignment mapping', [36, 28, 'end', True], 0), ('partial-repair probe', [16, 28, 'end', False], -12), ('partial-repair probe', [21, 46, 'end', False], -25), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [17, 39, 'center', True], -22), ('control layout', [37, 31, 'justify', True], 6)], [('regression: end alignment mapping', [37, 25, 'end', True], 0), ('regression: end alignment mapping', [22, 30, 'end', True], 0), ('regression: end alignment mapping', [11, 26, 'end', True], 0), ('partial-repair probe', [13, 1, 'end', False], 12), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [23, 3, 'justify', True], 20), ('control layout', [29, 29, 'justify', False], 0)], [('regression: end alignment mapping', [18, 8, 'end', True], 0), ('regression: end alignment mapping', [36, 9, 'end', True], 0), ('partial-repair probe', [38, 19, 'end', False], 19), ('partial-repair probe', [27, 20, 'end', False], 7), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [20, 40, 'start', False], 0), ('control layout', [15, 28, 'center', False], 0)], [('regression: end alignment mapping', [11, 34, 'end', True], 0), ('regression: end alignment mapping', [37, 25, 'end', True], 0), ('regression: end alignment mapping', [21, 8, 'end', True], 0), ('partial-repair probe', [33, 31, 'end', False], 2), ('odd slack RTL center', [20, 5, 'center', True], 8), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [35, 16, 'right', True], 19), ('control layout', [21, 20, 'left', False], 0)], [('regression: end alignment mapping', [35, 50, 'end', True], 0), ('regression: end alignment mapping', [20, 7, 'end', True], 0), ('partial-repair probe', [33, 31, 'end', False], 2), ('regression: end alignment mapping', [32, 30, 'end', True], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [10, 37, 'start', True], -27), ('control layout', [35, 3, 'center', True], 16)]]\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-direction-alignment-end-alignment-mapping","generated_at":"2026-09-29T14:49:56.700224+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":"end always maps to the right edge.","sha256":"40e5efa4eb3b2f96230061ff1528d7ff0cb914ab041ec11fe153a1b934185ce2","title":"Direction-relative alignment: end alignment mapping · 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":41.165,"exit_code":1,"observations":[{"actual":15,"check":"RTL end is left","expected":0,"passed":false},{"actual":8,"check":"regression: end alignment mapping","expected":0,"passed":false},{"actual":0,"check":"partial-repair probe","expected":-12,"passed":false},{"actual":0,"check":"partial-repair probe","expected":-25,"passed":false},{"actual":8,"check":"odd slack RTL center","expected":8,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":-22,"check":"control layout","expected":-22,"passed":true},{"actual":6,"check":"control layout","expected":6,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"RTL end is left\", \"actual\": 15, \"expected\": 0, \"passed\": false}, {\"check\": \"regression: end alignment mapping\", \"actual\": 8, \"expected\": 0, \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": 0, \"expected\": -12, \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": 0, \"expected\": -25, \"passed\": false}, {\"check\": \"odd slack RTL center\", \"actual\": 8, \"expected\": 8, \"passed\": true}, {\"check\": \"overflowing center RTL\", \"actual\": -5, \"expected\": -5, \"passed\": true}, {\"check\": \"control layout\", \"actual\": -22, \"expected\": -22, \"passed\": true}, {\"check\": \"control layout\", \"actual\": 6, \"expected\": 6, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.12,"exit_code":1,"observations":[{"actual":15,"check":"RTL end is left","expected":0,"passed":false},{"actual":8,"check":"regression: end alignment mapping","expected":0,"passed":false},{"actual":-12,"check":"partial-repair probe","expected":-12,"passed":true},{"actual":-25,"check":"partial-repair probe","expected":-25,"passed":true},{"actual":8,"check":"odd slack RTL center","expected":8,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":-22,"check":"control layout","expected":-22,"passed":true},{"actual":6,"check":"control layout","expected":6,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"RTL end is left\", \"actual\": 15, \"expected\": 0, \"passed\": false}, {\"check\": \"regression: end alignment mapping\", \"actual\": 8, \"expected\": 0, \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": -12, \"expected\": -12, \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": -25, \"expected\": -25, \"passed\": true}, {\"check\": \"odd slack RTL center\", \"actual\": 8, \"expected\": 8, \"passed\": true}, {\"check\": \"overflowing center RTL\", \"actual\": -5, \"expected\": -5, \"passed\": true}, {\"check\": \"control layout\", \"actual\": -22, \"expected\": -22, \"passed\": true}, {\"check\": \"control layout\", \"actual\": 6, \"expected\": 6, \"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."}}