{"abstract":"Start-aligned RTL paragraphs are left aligned.","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.","evaluation_group":"w2-bidirectional-text-layout-direction-alignment","failed_approach":"Inverting the condition swaps LTR too.","family":"w2-bidirectional-text-layout-direction-alignment-start-alignment-mapping","id":"FA-80736","implementations":{"attempt":{"sha256":"23f91793c559dedac4b8e366fdaf323493b6533b5933e6a0055ac8689f632048","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 not 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 if rtl else slack // 2\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: start alignment mapping', [37, 31, 'justify', True], 6), ('regression: start alignment mapping', [10, 24, 'start', True], -14), ('partial-repair probe', [21, 5, 'justify', False], 0), ('regression: start alignment mapping', [22, 44, 'justify', True], -22), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [37, 2, 'right', True], 35), ('control layout', [36, 43, 'center', True], -7)], [('regression: start alignment mapping', [36, 5, 'start', True], 31), ('regression: start alignment mapping', [28, 33, 'start', True], -5), ('partial-repair probe', [11, 47, 'justify', False], 0), ('partial-repair probe', [34, 47, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 43, 'end', False], -10), ('control layout', [14, 28, 'end', False], -14)], [('regression: start alignment mapping', [28, 41, 'start', True], -13), ('regression: start alignment mapping', [22, 27, 'justify', True], -5), ('partial-repair probe', [15, 28, 'start', False], 0), ('regression: start alignment mapping', [21, 43, 'justify', True], -22), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [16, 22, 'right', True], -6), ('control layout', [12, 33, 'right', True], -21)], [('regression: start alignment mapping', [18, 12, 'justify', True], 6), ('regression: start alignment mapping', [16, 37, 'justify', True], -21), ('partial-repair probe', [35, 1, 'start', False], 0), ('regression: start alignment mapping', [38, 35, 'justify', True], 3), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [34, 34, 'right', False], 0), ('control layout', [11, 26, 'end', True], 0)], [('regression: start alignment mapping', [37, 26, 'start', True], 11), ('regression: start alignment mapping', [18, 41, 'justify', True], -23), ('partial-repair probe', [20, 46, 'start', False], 0), ('partial-repair probe', [29, 49, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [27, 32, 'center', False], 0), ('control layout', [36, 1, 'left', 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":"4f33e6cece6c2ce495ed4a4d5db9f9e21ad67463843e4ebe6e2606ca0c3b67d1","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 = '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 if rtl else slack // 2\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: start alignment mapping', [37, 31, 'justify', True], 6), ('regression: start alignment mapping', [10, 24, 'start', True], -14), ('partial-repair probe', [21, 5, 'justify', False], 0), ('regression: start alignment mapping', [22, 44, 'justify', True], -22), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [37, 2, 'right', True], 35), ('control layout', [36, 43, 'center', True], -7)], [('regression: start alignment mapping', [36, 5, 'start', True], 31), ('regression: start alignment mapping', [28, 33, 'start', True], -5), ('partial-repair probe', [11, 47, 'justify', False], 0), ('partial-repair probe', [34, 47, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 43, 'end', False], -10), ('control layout', [14, 28, 'end', False], -14)], [('regression: start alignment mapping', [28, 41, 'start', True], -13), ('regression: start alignment mapping', [22, 27, 'justify', True], -5), ('partial-repair probe', [15, 28, 'start', False], 0), ('regression: start alignment mapping', [21, 43, 'justify', True], -22), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [16, 22, 'right', True], -6), ('control layout', [12, 33, 'right', True], -21)], [('regression: start alignment mapping', [18, 12, 'justify', True], 6), ('regression: start alignment mapping', [16, 37, 'justify', True], -21), ('partial-repair probe', [35, 1, 'start', False], 0), ('regression: start alignment mapping', [38, 35, 'justify', True], 3), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [34, 34, 'right', False], 0), ('control layout', [11, 26, 'end', True], 0)], [('regression: start alignment mapping', [37, 26, 'start', True], 11), ('regression: start alignment mapping', [18, 41, 'justify', True], -23), ('partial-repair probe', [20, 46, 'start', False], 0), ('partial-repair probe', [29, 49, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [27, 32, 'center', False], 0), ('control layout', [36, 1, 'left', 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"},"fixed":{"sha256":"5fc6dcd43758c956f4d358c5a660bf6388648305d0acc709b9cf453374b10696","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 if rtl else slack // 2\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: start alignment mapping', [37, 31, 'justify', True], 6), ('regression: start alignment mapping', [10, 24, 'start', True], -14), ('partial-repair probe', [21, 5, 'justify', False], 0), ('regression: start alignment mapping', [22, 44, 'justify', True], -22), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [37, 2, 'right', True], 35), ('control layout', [36, 43, 'center', True], -7)], [('regression: start alignment mapping', [36, 5, 'start', True], 31), ('regression: start alignment mapping', [28, 33, 'start', True], -5), ('partial-repair probe', [11, 47, 'justify', False], 0), ('partial-repair probe', [34, 47, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('odd slack RTL center', [20, 5, 'center', True], 8), ('control layout', [33, 43, 'end', False], -10), ('control layout', [14, 28, 'end', False], -14)], [('regression: start alignment mapping', [28, 41, 'start', True], -13), ('regression: start alignment mapping', [22, 27, 'justify', True], -5), ('partial-repair probe', [15, 28, 'start', False], 0), ('regression: start alignment mapping', [21, 43, 'justify', True], -22), ('overflowing center RTL', [10, 15, 'center', True], -5), ('RTL end is left', [20, 5, 'end', True], 0), ('control layout', [16, 22, 'right', True], -6), ('control layout', [12, 33, 'right', True], -21)], [('regression: start alignment mapping', [18, 12, 'justify', True], 6), ('regression: start alignment mapping', [16, 37, 'justify', True], -21), ('partial-repair probe', [35, 1, 'start', False], 0), ('regression: start alignment mapping', [38, 35, 'justify', True], 3), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [34, 34, 'right', False], 0), ('control layout', [11, 26, 'end', True], 0)], [('regression: start alignment mapping', [37, 26, 'start', True], 11), ('regression: start alignment mapping', [18, 41, 'justify', True], -23), ('partial-repair probe', [20, 46, 'start', False], 0), ('partial-repair probe', [29, 49, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [27, 32, 'center', False], 0), ('control layout', [36, 1, 'left', 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-start-alignment-mapping","generated_at":"2026-09-29T14:49:56.740832+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.","repair":"Map start to right for RTL.","root_cause":"start always maps to the left edge.","sha256":"17a5eaac0e39e615e79cb3ddc0c5a5ab00728238024244483e4c94b542138d82","title":"Direction-relative alignment: start alignment mapping · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.09,"exit_code":1,"observations":[{"actual":0,"check":"regression: start alignment mapping","expected":6,"passed":false},{"actual":0,"check":"regression: start alignment mapping","expected":-14,"passed":false},{"actual":16,"check":"partial-repair probe","expected":0,"passed":false},{"actual":0,"check":"regression: start alignment mapping","expected":-22,"passed":false},{"actual":0,"check":"RTL end is left","expected":0,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":35,"check":"control layout","expected":35,"passed":true},{"actual":-7,"check":"control layout","expected":-7,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: start alignment mapping\", \"actual\": 0, \"expected\": 6, \"passed\": false}, {\"check\": \"regression: start alignment mapping\", \"actual\": 0, \"expected\": -14, \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": 16, \"expected\": 0, \"passed\": false}, {\"check\": \"regression: start alignment mapping\", \"actual\": 0, \"expected\": -22, \"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\": 35, \"expected\": 35, \"passed\": true}, {\"check\": \"control layout\", \"actual\": -7, \"expected\": -7, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.397,"exit_code":1,"observations":[{"actual":0,"check":"regression: start alignment mapping","expected":6,"passed":false},{"actual":0,"check":"regression: start alignment mapping","expected":-14,"passed":false},{"actual":0,"check":"partial-repair probe","expected":0,"passed":true},{"actual":0,"check":"regression: start alignment mapping","expected":-22,"passed":false},{"actual":0,"check":"RTL end is left","expected":0,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":35,"check":"control layout","expected":35,"passed":true},{"actual":-7,"check":"control layout","expected":-7,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: start alignment mapping\", \"actual\": 0, \"expected\": 6, \"passed\": false}, {\"check\": \"regression: start alignment mapping\", \"actual\": 0, \"expected\": -14, \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"regression: start alignment mapping\", \"actual\": 0, \"expected\": -22, \"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\": 35, \"expected\": 35, \"passed\": true}, {\"check\": \"control layout\", \"actual\": -7, \"expected\": -7, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":39.689,"exit_code":0,"observations":[{"actual":6,"check":"regression: start alignment mapping","expected":6,"passed":true},{"actual":-14,"check":"regression: start alignment mapping","expected":-14,"passed":true},{"actual":0,"check":"partial-repair probe","expected":0,"passed":true},{"actual":-22,"check":"regression: start alignment mapping","expected":-22,"passed":true},{"actual":0,"check":"RTL end is left","expected":0,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":35,"check":"control layout","expected":35,"passed":true},{"actual":-7,"check":"control layout","expected":-7,"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: start alignment mapping\", \"actual\": 6, \"expected\": 6, \"passed\": true}, {\"check\": \"regression: start alignment mapping\", \"actual\": -14, \"expected\": -14, \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": 0, \"expected\": 0, \"passed\": true}, {\"check\": \"regression: start alignment mapping\", \"actual\": -22, \"expected\": -22, \"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\": 35, \"expected\": 35, \"passed\": true}, {\"check\": \"control layout\", \"actual\": -7, \"expected\": -7, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}