{"abstract":"Odd slack in RTL lines is split toward the wrong side.","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":"Always rounding up breaks LTR lines.","family":"w2-bidirectional-text-layout-direction-alignment-center-rounding-by-direction","id":"FA-80746","implementations":{"attempt":{"sha256":"af84e0904d28d897f2a5ed1b5cebc11fc8a6b01c7a1fa56dc945a476f598e675","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 = 'left' if rtl else '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\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('odd slack RTL center', [20, 5, 'center', True], 8), ('regression: center rounding by direction', [35, 32, 'center', True], 2), ('partial-repair probe', [22, 5, 'center', False], 8), ('partial-repair probe', [39, 34, 'center', False], 2), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [23, 19, 'left', True], 0), ('control layout', [28, 30, 'left', False], 0)], [('regression: center rounding by direction', [33, 4, 'center', True], 15), ('regression: center rounding by direction', [23, 12, 'center', True], 6), ('partial-repair probe', [39, 34, 'center', False], 2), ('partial-repair probe', [37, 14, 'center', False], 11), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [23, 29, 'left', True], 0), ('control layout', [31, 48, 'right', False], -17)], [('regression: center rounding by direction', [40, 5, 'center', True], 18), ('regression: center rounding by direction', [33, 4, 'center', True], 15), ('partial-repair probe', [29, 18, 'center', False], 5), ('partial-repair probe', [22, 5, 'center', False], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 1, 'justify', False], 0), ('control layout', [25, 40, 'left', False], 0)], [('odd slack RTL center', [20, 5, 'center', True], 8), ('regression: center rounding by direction', [35, 32, 'center', True], 2), ('partial-repair probe', [19, 4, 'center', False], 7), ('partial-repair probe', [22, 5, 'center', False], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [26, 12, 'right', False], 14), ('control layout', [20, 47, 'right', True], -27)], [('regression: center rounding by direction', [17, 8, 'center', True], 5), ('regression: center rounding by direction', [35, 32, 'center', True], 2), ('partial-repair probe', [39, 34, 'center', False], 2), ('partial-repair probe', [29, 18, 'center', False], 5), ('overflowing center RTL', [10, 15, 'center', True], -5), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 4, 'left', False], 0), ('control layout', [17, 4, 'end', True], 0)]]\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":"4429b6c409896abcae462e0f1cbd1d96bbc477eb6d0a253bdc094d14e45e8e07","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 = 'left' if rtl else '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 // 2\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('odd slack RTL center', [20, 5, 'center', True], 8), ('regression: center rounding by direction', [35, 32, 'center', True], 2), ('partial-repair probe', [22, 5, 'center', False], 8), ('partial-repair probe', [39, 34, 'center', False], 2), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [23, 19, 'left', True], 0), ('control layout', [28, 30, 'left', False], 0)], [('regression: center rounding by direction', [33, 4, 'center', True], 15), ('regression: center rounding by direction', [23, 12, 'center', True], 6), ('partial-repair probe', [39, 34, 'center', False], 2), ('partial-repair probe', [37, 14, 'center', False], 11), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [23, 29, 'left', True], 0), ('control layout', [31, 48, 'right', False], -17)], [('regression: center rounding by direction', [40, 5, 'center', True], 18), ('regression: center rounding by direction', [33, 4, 'center', True], 15), ('partial-repair probe', [29, 18, 'center', False], 5), ('partial-repair probe', [22, 5, 'center', False], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 1, 'justify', False], 0), ('control layout', [25, 40, 'left', False], 0)], [('odd slack RTL center', [20, 5, 'center', True], 8), ('regression: center rounding by direction', [35, 32, 'center', True], 2), ('partial-repair probe', [19, 4, 'center', False], 7), ('partial-repair probe', [22, 5, 'center', False], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [26, 12, 'right', False], 14), ('control layout', [20, 47, 'right', True], -27)], [('regression: center rounding by direction', [17, 8, 'center', True], 5), ('regression: center rounding by direction', [35, 32, 'center', True], 2), ('partial-repair probe', [39, 34, 'center', False], 2), ('partial-repair probe', [29, 18, 'center', False], 5), ('overflowing center RTL', [10, 15, 'center', True], -5), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 4, 'left', False], 0), ('control layout', [17, 4, 'end', True], 0)]]\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-center-rounding-by-direction","generated_at":"2026-09-29T14:49:56.741460+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":"Centering always rounds the offset down.","sha256":"1bddb0b635b0380d97100173ea9f585921ddcf468005920f83d59eb8579eb02e","title":"Direction-relative alignment: center rounding by direction · 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":40.191,"exit_code":1,"observations":[{"actual":8,"check":"odd slack RTL center","expected":8,"passed":true},{"actual":2,"check":"regression: center rounding by direction","expected":2,"passed":true},{"actual":9,"check":"partial-repair probe","expected":8,"passed":false},{"actual":3,"check":"partial-repair probe","expected":2,"passed":false},{"actual":0,"check":"RTL end is left","expected":0,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":0,"check":"control layout","expected":0,"passed":true},{"actual":0,"check":"control layout","expected":0,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"odd slack RTL center\", \"actual\": 8, \"expected\": 8, \"passed\": true}, {\"check\": \"regression: center rounding by direction\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": 9, \"expected\": 8, \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": 3, \"expected\": 2, \"passed\": false}, {\"check\": \"RTL end is left\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"overflowing center RTL\", \"actual\": -5, \"expected\": -5, \"passed\": true}, {\"check\": \"control layout\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"control layout\", \"actual\": 0, \"expected\": 0, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":37.739,"exit_code":1,"observations":[{"actual":7,"check":"odd slack RTL center","expected":8,"passed":false},{"actual":1,"check":"regression: center rounding by direction","expected":2,"passed":false},{"actual":8,"check":"partial-repair probe","expected":8,"passed":true},{"actual":2,"check":"partial-repair probe","expected":2,"passed":true},{"actual":0,"check":"RTL end is left","expected":0,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":0,"check":"control layout","expected":0,"passed":true},{"actual":0,"check":"control layout","expected":0,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"odd slack RTL center\", \"actual\": 7, \"expected\": 8, \"passed\": false}, {\"check\": \"regression: center rounding by direction\", \"actual\": 1, \"expected\": 2, \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": 8, \"expected\": 8, \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": 2, \"expected\": 2, \"passed\": true}, {\"check\": \"RTL end is left\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"overflowing center RTL\", \"actual\": -5, \"expected\": -5, \"passed\": true}, {\"check\": \"control layout\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"control layout\", \"actual\": 0, \"expected\": 0, \"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."}}