{"abstract":"The final space on the line keeps its embedded level.","category":"Bidirectional text layout","checks":8,"contract":"Input [original classes, resolved levels, paragraph level]. Reset to the paragraph level: every S and B; any run of WS and isolate formatting characters (FSI LRI RLI PDI) immediately before an S or B; and such a run at the end of the line. Return levels.","contract_signature":"x","evaluation_group":"w2-bidirectional-text-layout-whitespace-reset","failed_approach":"Stopping before index 0 misses all-whitespace lines.","family":"w2-bidirectional-text-layout-whitespace-reset-trailing-run-start","id":"FA-80506","implementations":{"attempt":{"sha256":"16266a1ad21b68ca11d6c9db7b9172c66fb7f416155b86ca2b890bcfd0727968","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    classes, levels, para = x\n    out = list(levels)\n    n = len(classes)\n    RESETTABLE = ('WS', 'FSI', 'LRI', 'RLI', 'PDI')\n    j = n - 1\n    while j > 0 and classes[j] in RESETTABLE:\n        out[j] = para\n        j -= 1\n    for i, c in enumerate(classes):\n        if c in ('S', 'B'):\n            out[i] = para\n            k = i - 1\n            while k >= 0 and classes[k] in RESETTABLE:\n                out[k] = para\n                k -= 1\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('regression: trailing run start', [['LRI', 'EN', 'WS', 'WS', 'R', 'RLI', 'S', 'WS', 'ON', 'L', 'EN', 'PDI'], [2, 2, 1, 2, 2, 2, 1, 1, 3, 3, 1, 3], 0], [2, 2, 1, 2, 2, 0, 0, 1, 3, 3, 1, 0]), ('partial-repair probe', [['RLI', 'WS', 'FSI', 'WS', 'WS'], [0, 0, 0, 0, 1], 1], [1, 1, 1, 1, 1]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('control layout', [['WS', 'WS', 'L', 'PDI', 'ON', 'R', 'L'], [1, 1, 1, 4, 4, 3, 3], 0], [1, 1, 1, 4, 4, 3, 3]), ('control layout', [['WS', 'FSI', 'WS', 'RLI', 'R', 'L', 'R', 'WS', 'S', 'L'], [2, 2, 2, 1, 1, 1, 1, 1, 2, 2], 0], [2, 2, 2, 1, 1, 1, 1, 0, 0, 2]), ('control layout', [['LRI', 'R', 'ON', 'ON', 'PDI', 'PDI'], [1, 1, 1, 1, 1, 1], 1], [1, 1, 1, 1, 1, 1])], [('regression: trailing run start', [['FSI', 'L', 'L', 'LRI', 'WS', 'ON', 'WS', 'RLI', 'WS', 'B', 'PDI', 'L'], [2, 2, 2, 2, 1, 0, 0, 1, 1, 1, 1, 1], 0], [2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 1, 1]), ('regression: trailing run start', [['R', 'PDI', 'LRI', 'WS', 'R', 'WS', 'RLI'], [1, 0, 0, 0, 0, 0, 0], 1], [1, 0, 0, 0, 0, 1, 1]), ('regression: trailing run start', [['PDI', 'WS', 'WS', 'LRI', 'RLI', 'WS'], [1, 1, 1, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0]), ('regression: trailing run start', [['LRI'], [2], 0], [0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('control layout', [['WS', 'R', 'LRI', 'L', 'R'], [2, 2, 2, 1, 1], 1], [2, 2, 2, 1, 1]), ('control layout', [['EN', 'LRI', 'FSI', 'R', 'WS', 'WS', 'FSI', 'R', 'R', 'S'], [2, 2, 2, 2, 1, 1, 1, 2, 2, 2], 0], [2, 2, 2, 2, 1, 1, 1, 2, 2, 0])], [('regression: trailing run start', [['S', 'R', 'L', 'L', 'S', 'WS'], [0, 3, 3, 3, 3, 3], 1], [1, 3, 3, 3, 1, 1]), ('regression: trailing run start', [['LRI', 'R', 'EN', 'S', 'L', 'L', 'LRI', 'FSI', 'WS'], [3, 3, 3, 3, 3, 3, 3, 3, 4], 1], [3, 3, 3, 1, 3, 3, 1, 1, 1]), ('regression: trailing run start', [['RLI'], [0], 1], [1]), ('regression: trailing run start', [['LRI'], [3], 0], [0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['R'], [3], 1], [3]), ('control layout', [['LRI', 'R', 'EN', 'WS', 'B', 'L', 'L', 'PDI', 'LRI', 'ON'], [3, 3, 3, 3, 0, 0, 1, 1, 1, 1], 1], [3, 3, 3, 1, 1, 0, 1, 1, 1, 1])], [('regression: trailing run start', [['PDI', 'S', 'R', 'ON', 'LRI'], [1, 4, 4, 4, 4], 1], [1, 1, 4, 4, 1]), ('regression: trailing run start', [['L', 'S', 'ON', 'WS', 'LRI', 'L', 'R', 'L', 'ON', 'PDI'], [1, 1, 1, 1, 1, 1, 1, 1, 0, 1], 0], [1, 0, 1, 1, 1, 1, 1, 1, 0, 0]), ('regression: trailing run start', [['LRI', 'WS'], [2, 2], 0], [0, 0]), ('regression: trailing run start', [['WS'], [1], 0], [0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['L', 'R', 'L', 'R', 'S'], [0, 0, 0, 0, 1], 0], [0, 0, 0, 0, 0]), ('control layout', [['R'], [3], 1], [3])], [('regression: trailing run start', [['WS', 'ON'], [3, 3], 0], [3, 3]), ('regression: trailing run start', [['FSI', 'R', 'EN', 'L', 'R', 'L', 'EN', 'L', 'LRI'], [1, 1, 1, 4, 4, 4, 4, 1, 3], 1], [1, 1, 1, 4, 4, 4, 4, 1, 1]), ('regression: trailing run start', [['FSI'], [2], 1], [1]), ('regression: trailing run start', [['WS', 'PDI'], [1, 1], 0], [0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['S'], [3], 0], [0]), ('control layout', [['R', 'L', 'R', 'L', 'ON', 'R', 'ON', 'L'], [1, 1, 1, 1, 1, 1, 2, 2], 0], [1, 1, 1, 1, 1, 1, 2, 2])]]\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":"0649ab8cf1c14d14e6648dcb9da7efe77fd7f0fdb7649ef39f7e6288e827ce53","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    classes, levels, para = x\n    out = list(levels)\n    n = len(classes)\n    RESETTABLE = ('WS', 'FSI', 'LRI', 'RLI', 'PDI')\n    j = n - 2\n    while j >= 0 and classes[j] in RESETTABLE:\n        out[j] = para\n        j -= 1\n    for i, c in enumerate(classes):\n        if c in ('S', 'B'):\n            out[i] = para\n            k = i - 1\n            while k >= 0 and classes[k] in RESETTABLE:\n                out[k] = para\n                k -= 1\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('regression: trailing run start', [['LRI', 'EN', 'WS', 'WS', 'R', 'RLI', 'S', 'WS', 'ON', 'L', 'EN', 'PDI'], [2, 2, 1, 2, 2, 2, 1, 1, 3, 3, 1, 3], 0], [2, 2, 1, 2, 2, 0, 0, 1, 3, 3, 1, 0]), ('partial-repair probe', [['RLI', 'WS', 'FSI', 'WS', 'WS'], [0, 0, 0, 0, 1], 1], [1, 1, 1, 1, 1]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('control layout', [['WS', 'WS', 'L', 'PDI', 'ON', 'R', 'L'], [1, 1, 1, 4, 4, 3, 3], 0], [1, 1, 1, 4, 4, 3, 3]), ('control layout', [['WS', 'FSI', 'WS', 'RLI', 'R', 'L', 'R', 'WS', 'S', 'L'], [2, 2, 2, 1, 1, 1, 1, 1, 2, 2], 0], [2, 2, 2, 1, 1, 1, 1, 0, 0, 2]), ('control layout', [['LRI', 'R', 'ON', 'ON', 'PDI', 'PDI'], [1, 1, 1, 1, 1, 1], 1], [1, 1, 1, 1, 1, 1])], [('regression: trailing run start', [['FSI', 'L', 'L', 'LRI', 'WS', 'ON', 'WS', 'RLI', 'WS', 'B', 'PDI', 'L'], [2, 2, 2, 2, 1, 0, 0, 1, 1, 1, 1, 1], 0], [2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 1, 1]), ('regression: trailing run start', [['R', 'PDI', 'LRI', 'WS', 'R', 'WS', 'RLI'], [1, 0, 0, 0, 0, 0, 0], 1], [1, 0, 0, 0, 0, 1, 1]), ('regression: trailing run start', [['PDI', 'WS', 'WS', 'LRI', 'RLI', 'WS'], [1, 1, 1, 2, 2, 2], 0], [0, 0, 0, 0, 0, 0]), ('regression: trailing run start', [['LRI'], [2], 0], [0]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('control layout', [['WS', 'R', 'LRI', 'L', 'R'], [2, 2, 2, 1, 1], 1], [2, 2, 2, 1, 1]), ('control layout', [['EN', 'LRI', 'FSI', 'R', 'WS', 'WS', 'FSI', 'R', 'R', 'S'], [2, 2, 2, 2, 1, 1, 1, 2, 2, 2], 0], [2, 2, 2, 2, 1, 1, 1, 2, 2, 0])], [('regression: trailing run start', [['S', 'R', 'L', 'L', 'S', 'WS'], [0, 3, 3, 3, 3, 3], 1], [1, 3, 3, 3, 1, 1]), ('regression: trailing run start', [['LRI', 'R', 'EN', 'S', 'L', 'L', 'LRI', 'FSI', 'WS'], [3, 3, 3, 3, 3, 3, 3, 3, 4], 1], [3, 3, 3, 1, 3, 3, 1, 1, 1]), ('regression: trailing run start', [['RLI'], [0], 1], [1]), ('regression: trailing run start', [['LRI'], [3], 0], [0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['R'], [3], 1], [3]), ('control layout', [['LRI', 'R', 'EN', 'WS', 'B', 'L', 'L', 'PDI', 'LRI', 'ON'], [3, 3, 3, 3, 0, 0, 1, 1, 1, 1], 1], [3, 3, 3, 1, 1, 0, 1, 1, 1, 1])], [('regression: trailing run start', [['PDI', 'S', 'R', 'ON', 'LRI'], [1, 4, 4, 4, 4], 1], [1, 1, 4, 4, 1]), ('regression: trailing run start', [['L', 'S', 'ON', 'WS', 'LRI', 'L', 'R', 'L', 'ON', 'PDI'], [1, 1, 1, 1, 1, 1, 1, 1, 0, 1], 0], [1, 0, 1, 1, 1, 1, 1, 1, 0, 0]), ('regression: trailing run start', [['LRI', 'WS'], [2, 2], 0], [0, 0]), ('regression: trailing run start', [['WS'], [1], 0], [0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('trailing isolate and space', [['R', 'R', 'PDI', 'WS'], [1, 1, 1, 1], 0], [1, 1, 0, 0]), ('control layout', [['L', 'R', 'L', 'R', 'S'], [0, 0, 0, 0, 1], 0], [0, 0, 0, 0, 0]), ('control layout', [['R'], [3], 1], [3])], [('regression: trailing run start', [['WS', 'ON'], [3, 3], 0], [3, 3]), ('regression: trailing run start', [['FSI', 'R', 'EN', 'L', 'R', 'L', 'EN', 'L', 'LRI'], [1, 1, 1, 4, 4, 4, 4, 1, 3], 1], [1, 1, 1, 4, 4, 4, 4, 1, 1]), ('regression: trailing run start', [['FSI'], [2], 1], [1]), ('regression: trailing run start', [['WS', 'PDI'], [1, 1], 0], [0, 0]), ('space before tab', [['R', 'WS', 'S', 'R'], [1, 1, 1, 1], 0], [1, 0, 0, 1]), ('all whitespace line', [['WS', 'WS'], [1, 1], 0], [0, 0]), ('control layout', [['S'], [3], 0], [0]), ('control layout', [['R', 'L', 'R', 'L', 'ON', 'R', 'ON', 'L'], [1, 1, 1, 1, 1, 1, 2, 2], 0], [1, 1, 1, 1, 1, 1, 2, 2])]]\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-whitespace-reset-trailing-run-start","generated_at":"2026-09-29T14:49:54.420373+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":"The trailing scan starts at the second-to-last character.","sha256":"3a075b99bdb0dac21e5b7071edffff429b6baab1d9332ac32b69e1c4edbc5bc9","title":"Line-end whitespace level reset: trailing run start · 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":37.664,"exit_code":1,"observations":[{"actual":[1,1,0,0],"check":"trailing isolate and space","expected":[1,1,0,0],"passed":true},{"actual":[2,2,1,2,2,0,0,1,3,3,1,0],"check":"regression: trailing run start","expected":[2,2,1,2,2,0,0,1,3,3,1,0],"passed":true},{"actual":[0,1,1,1,1],"check":"partial-repair probe","expected":[1,1,1,1,1],"passed":false},{"actual":[1,0],"check":"all whitespace line","expected":[0,0],"passed":false},{"actual":[1,0,0,1],"check":"space before tab","expected":[1,0,0,1],"passed":true},{"actual":[1,1,1,4,4,3,3],"check":"control layout","expected":[1,1,1,4,4,3,3],"passed":true},{"actual":[2,2,2,1,1,1,1,0,0,2],"check":"control layout","expected":[2,2,2,1,1,1,1,0,0,2],"passed":true},{"actual":[1,1,1,1,1,1],"check":"control layout","expected":[1,1,1,1,1,1],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"trailing isolate and space\", \"actual\": [1, 1, 0, 0], \"expected\": [1, 1, 0, 0], \"passed\": true}, {\"check\": \"regression: trailing run start\", \"actual\": [2, 2, 1, 2, 2, 0, 0, 1, 3, 3, 1, 0], \"expected\": [2, 2, 1, 2, 2, 0, 0, 1, 3, 3, 1, 0], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [0, 1, 1, 1, 1], \"expected\": [1, 1, 1, 1, 1], \"passed\": false}, {\"check\": \"all whitespace line\", \"actual\": [1, 0], \"expected\": [0, 0], \"passed\": false}, {\"check\": \"space before tab\", \"actual\": [1, 0, 0, 1], \"expected\": [1, 0, 0, 1], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [1, 1, 1, 4, 4, 3, 3], \"expected\": [1, 1, 1, 4, 4, 3, 3], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [2, 2, 2, 1, 1, 1, 1, 0, 0, 2], \"expected\": [2, 2, 2, 1, 1, 1, 1, 0, 0, 2], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [1, 1, 1, 1, 1, 1], \"expected\": [1, 1, 1, 1, 1, 1], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.103,"exit_code":1,"observations":[{"actual":[1,1,0,1],"check":"trailing isolate and space","expected":[1,1,0,0],"passed":false},{"actual":[2,2,1,2,2,0,0,1,3,3,1,3],"check":"regression: trailing run start","expected":[2,2,1,2,2,0,0,1,3,3,1,0],"passed":false},{"actual":[1,1,1,1,1],"check":"partial-repair probe","expected":[1,1,1,1,1],"passed":true},{"actual":[0,1],"check":"all whitespace line","expected":[0,0],"passed":false},{"actual":[1,0,0,1],"check":"space before tab","expected":[1,0,0,1],"passed":true},{"actual":[1,1,1,4,4,3,3],"check":"control layout","expected":[1,1,1,4,4,3,3],"passed":true},{"actual":[2,2,2,1,1,1,1,0,0,2],"check":"control layout","expected":[2,2,2,1,1,1,1,0,0,2],"passed":true},{"actual":[1,1,1,1,1,1],"check":"control layout","expected":[1,1,1,1,1,1],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"trailing isolate and space\", \"actual\": [1, 1, 0, 1], \"expected\": [1, 1, 0, 0], \"passed\": false}, {\"check\": \"regression: trailing run start\", \"actual\": [2, 2, 1, 2, 2, 0, 0, 1, 3, 3, 1, 3], \"expected\": [2, 2, 1, 2, 2, 0, 0, 1, 3, 3, 1, 0], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [1, 1, 1, 1, 1], \"expected\": [1, 1, 1, 1, 1], \"passed\": true}, {\"check\": \"all whitespace line\", \"actual\": [0, 1], \"expected\": [0, 0], \"passed\": false}, {\"check\": \"space before tab\", \"actual\": [1, 0, 0, 1], \"expected\": [1, 0, 0, 1], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [1, 1, 1, 4, 4, 3, 3], \"expected\": [1, 1, 1, 4, 4, 3, 3], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [2, 2, 2, 1, 1, 1, 1, 0, 0, 2], \"expected\": [2, 2, 2, 1, 1, 1, 1, 0, 0, 2], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [1, 1, 1, 1, 1, 1], \"expected\": [1, 1, 1, 1, 1, 1], \"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."}}