{"abstract":"The last line of a justified RTL paragraph sits on the left.","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":"Centering the last line is not start alignment.","family":"w2-bidirectional-text-layout-direction-alignment-justified-last-line","id":"FA-80751","implementations":{"attempt":{"sha256":"cceb2b27686e7dea1ebeeeb1309498c1f298ccafa71c4433c44bd47a92439056","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 = 'center'\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: justified last line', [13, 48, 'justify', True], -35), ('regression: justified last line', [22, 44, 'justify', True], -22), ('regression: justified last line', [18, 12, 'justify', True], 6), ('regression: justified last line', [33, 4, 'justify', True], 29), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [36, 2, 'center', True], 17), ('control layout', [17, 15, 'left', True], 0)], [('regression: justified last line', [27, 25, 'justify', True], 2), ('regression: justified last line', [21, 48, 'justify', True], -27), ('partial-repair probe', [36, 23, 'justify', False], 0), ('partial-repair probe', [31, 16, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [30, 30, 'end', True], 0), ('control layout', [30, 34, 'justify', False], 0)], [('regression: justified last line', [37, 31, 'justify', True], 6), ('regression: justified last line', [12, 31, 'justify', True], -19), ('regression: justified last line', [17, 9, 'justify', True], 8), ('regression: justified last line', [38, 35, 'justify', True], 3), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [22, 21, 'right', False], 1), ('control layout', [16, 28, 'start', False], 0)], [('regression: justified last line', [23, 3, 'justify', True], 20), ('regression: justified last line', [29, 38, 'justify', True], -9), ('partial-repair probe', [26, 19, 'justify', False], 0), ('regression: justified last line', [38, 31, 'justify', True], 7), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [17, 15, 'left', True], 0), ('control layout', [21, 8, 'end', True], 0)], [('regression: justified last line', [38, 10, 'justify', True], 28), ('regression: justified last line', [38, 31, 'justify', True], 7), ('regression: justified last line', [17, 9, 'justify', True], 8), ('regression: justified last line', [37, 31, 'justify', True], 6), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [24, 27, 'start', True], -3), ('control layout', [24, 46, 'start', True], -22)]]\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":"5dd3b1db91d3bcfd32db8006da72094e390aec37ecb9309ca37c8a4d85d2eba6","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 = 'left'\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: justified last line', [13, 48, 'justify', True], -35), ('regression: justified last line', [22, 44, 'justify', True], -22), ('regression: justified last line', [18, 12, 'justify', True], 6), ('regression: justified last line', [33, 4, 'justify', True], 29), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [36, 2, 'center', True], 17), ('control layout', [17, 15, 'left', True], 0)], [('regression: justified last line', [27, 25, 'justify', True], 2), ('regression: justified last line', [21, 48, 'justify', True], -27), ('partial-repair probe', [36, 23, 'justify', False], 0), ('partial-repair probe', [31, 16, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [30, 30, 'end', True], 0), ('control layout', [30, 34, 'justify', False], 0)], [('regression: justified last line', [37, 31, 'justify', True], 6), ('regression: justified last line', [12, 31, 'justify', True], -19), ('regression: justified last line', [17, 9, 'justify', True], 8), ('regression: justified last line', [38, 35, 'justify', True], 3), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [22, 21, 'right', False], 1), ('control layout', [16, 28, 'start', False], 0)], [('regression: justified last line', [23, 3, 'justify', True], 20), ('regression: justified last line', [29, 38, 'justify', True], -9), ('partial-repair probe', [26, 19, 'justify', False], 0), ('regression: justified last line', [38, 31, 'justify', True], 7), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [17, 15, 'left', True], 0), ('control layout', [21, 8, 'end', True], 0)], [('regression: justified last line', [38, 10, 'justify', True], 28), ('regression: justified last line', [38, 31, 'justify', True], 7), ('regression: justified last line', [17, 9, 'justify', True], 8), ('regression: justified last line', [37, 31, 'justify', True], 6), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [24, 27, 'start', True], -3), ('control layout', [24, 46, 'start', True], -22)]]\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":"7c0531e534d9cac23a96864d07dc7a91aeea9c5f7e9f49b50d3924358dd0be0e","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: justified last line', [13, 48, 'justify', True], -35), ('regression: justified last line', [22, 44, 'justify', True], -22), ('regression: justified last line', [18, 12, 'justify', True], 6), ('regression: justified last line', [33, 4, 'justify', True], 29), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [36, 2, 'center', True], 17), ('control layout', [17, 15, 'left', True], 0)], [('regression: justified last line', [27, 25, 'justify', True], 2), ('regression: justified last line', [21, 48, 'justify', True], -27), ('partial-repair probe', [36, 23, 'justify', False], 0), ('partial-repair probe', [31, 16, 'justify', False], 0), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [30, 30, 'end', True], 0), ('control layout', [30, 34, 'justify', False], 0)], [('regression: justified last line', [37, 31, 'justify', True], 6), ('regression: justified last line', [12, 31, 'justify', True], -19), ('regression: justified last line', [17, 9, 'justify', True], 8), ('regression: justified last line', [38, 35, 'justify', True], 3), ('RTL end is left', [20, 5, 'end', True], 0), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [22, 21, 'right', False], 1), ('control layout', [16, 28, 'start', False], 0)], [('regression: justified last line', [23, 3, 'justify', True], 20), ('regression: justified last line', [29, 38, 'justify', True], -9), ('partial-repair probe', [26, 19, 'justify', False], 0), ('regression: justified last line', [38, 31, 'justify', True], 7), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [17, 15, 'left', True], 0), ('control layout', [21, 8, 'end', True], 0)], [('regression: justified last line', [38, 10, 'justify', True], 28), ('regression: justified last line', [38, 31, 'justify', True], 7), ('regression: justified last line', [17, 9, 'justify', True], 8), ('regression: justified last line', [37, 31, 'justify', True], 6), ('odd slack RTL center', [20, 5, 'center', True], 8), ('overflowing center RTL', [10, 15, 'center', True], -5), ('control layout', [24, 27, 'start', True], -3), ('control layout', [24, 46, 'start', True], -22)]]\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-justified-last-line","generated_at":"2026-09-29T14:49:56.749789+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":"Treat justify as start on the last line.","root_cause":"justify is mapped to left instead of start.","sha256":"4e010e617b3c14b2e7b1a5b3798aa8cfb7d9252edaf0c0c1a8993f5dc165aa21","title":"Direction-relative alignment: justified last line · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":37.27,"exit_code":1,"observations":[{"actual":-35,"check":"regression: justified last line","expected":-35,"passed":true},{"actual":-22,"check":"regression: justified last line","expected":-22,"passed":true},{"actual":3,"check":"regression: justified last line","expected":6,"passed":false},{"actual":15,"check":"regression: justified last line","expected":29,"passed":false},{"actual":8,"check":"odd slack RTL center","expected":8,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":17,"check":"control layout","expected":17,"passed":true},{"actual":0,"check":"control layout","expected":0,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: justified last line\", \"actual\": -35, \"expected\": -35, \"passed\": true}, {\"check\": \"regression: justified last line\", \"actual\": -22, \"expected\": -22, \"passed\": true}, {\"check\": \"regression: justified last line\", \"actual\": 3, \"expected\": 6, \"passed\": false}, {\"check\": \"regression: justified last line\", \"actual\": 15, \"expected\": 29, \"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\": 17, \"expected\": 17, \"passed\": true}, {\"check\": \"control layout\", \"actual\": 0, \"expected\": 0, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.744,"exit_code":1,"observations":[{"actual":0,"check":"regression: justified last line","expected":-35,"passed":false},{"actual":0,"check":"regression: justified last line","expected":-22,"passed":false},{"actual":0,"check":"regression: justified last line","expected":6,"passed":false},{"actual":0,"check":"regression: justified last line","expected":29,"passed":false},{"actual":8,"check":"odd slack RTL center","expected":8,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":17,"check":"control layout","expected":17,"passed":true},{"actual":0,"check":"control layout","expected":0,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: justified last line\", \"actual\": 0, \"expected\": -35, \"passed\": false}, {\"check\": \"regression: justified last line\", \"actual\": 0, \"expected\": -22, \"passed\": false}, {\"check\": \"regression: justified last line\", \"actual\": 0, \"expected\": 6, \"passed\": false}, {\"check\": \"regression: justified last line\", \"actual\": 0, \"expected\": 29, \"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\": 17, \"expected\": 17, \"passed\": true}, {\"check\": \"control layout\", \"actual\": 0, \"expected\": 0, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":38.379,"exit_code":0,"observations":[{"actual":-35,"check":"regression: justified last line","expected":-35,"passed":true},{"actual":-22,"check":"regression: justified last line","expected":-22,"passed":true},{"actual":6,"check":"regression: justified last line","expected":6,"passed":true},{"actual":29,"check":"regression: justified last line","expected":29,"passed":true},{"actual":8,"check":"odd slack RTL center","expected":8,"passed":true},{"actual":-5,"check":"overflowing center RTL","expected":-5,"passed":true},{"actual":17,"check":"control layout","expected":17,"passed":true},{"actual":0,"check":"control layout","expected":0,"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: justified last line\", \"actual\": -35, \"expected\": -35, \"passed\": true}, {\"check\": \"regression: justified last line\", \"actual\": -22, \"expected\": -22, \"passed\": true}, {\"check\": \"regression: justified last line\", \"actual\": 6, \"expected\": 6, \"passed\": true}, {\"check\": \"regression: justified last line\", \"actual\": 29, \"expected\": 29, \"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\": 17, \"expected\": 17, \"passed\": true}, {\"check\": \"control layout\", \"actual\": 0, \"expected\": 0, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}