{"abstract":"A stray PDI hides the rest of the paragraph from direction detection.","category":"Bidirectional text layout","checks":8,"contract":"Input [bidi classes, default level]. Scan for the first L (level 0) or R/AL (level 1), skipping characters between an isolate initiator (LRI, RLI, FSI) and its matching PDI (nesting counted; an unmatched PDI is ignored). Embedding codes are not skipped. Return [level, index of deciding character] or [default, None].","contract_signature":"x","evaluation_group":"w2-bidirectional-text-layout-paragraph-direction","failed_approach":"Resetting depth to zero closes all nested isolates at once.","family":"w2-bidirectional-text-layout-paragraph-direction-unmatched-pdi","id":"FA-80346","implementations":{"attempt":{"sha256":"c869fbd23d099c1a72a2efbcfa1c55b6da413ab88dff5fd2dd2d53581616c92f","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    classes, default = x\n    depth = 0\n    for i, c in enumerate(classes):\n        if c in ('LRI', 'RLI', 'FSI'):\n            depth += 1\n        elif c == 'PDI':\n            depth = 0\n        elif depth == 0:\n            if c == 'L':\n                return [0, i]\n            if c in ('R', 'AL'):\n                return [1, i]\n    return [default, None]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('stray PDI before isolate', [['PDI', 'RLI', 'L', 'PDI', 'R'], 0], [1, 4]), ('regression: unmatched PDI', [['LRE', 'PDI', 'AL', 'PDI', 'AN', 'RLI', 'WS', 'AL', 'R', 'EN'], 1], [1, 2]), ('partial-repair probe', [['ON', 'RLI', 'ON', 'LRI', 'AL', 'PDI', 'L', 'NSM'], 0], [0, None]), ('partial-repair probe', [['LRI', 'ON', 'RLI', 'L', 'PDI', 'AL', 'R', 'WS'], 0], [0, None]), ('FSI content skipped', [['FSI', 'R', 'PDI', 'L'], 1], [0, 3]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('control layout', [['AL', 'PDI', 'L', 'WS', 'EN', 'L', 'ES', 'ON'], 0], [1, 0]), ('control layout', [['WS', 'L', 'PDI', 'WS', 'AL'], 1], [0, 1])], [('regression: unmatched PDI', [['PDI', 'PDI', 'L', 'ON', 'L', 'EN', 'ON', 'RLI'], 0], [0, 2]), ('regression: unmatched PDI', [['PDI', 'LRI', 'AL', 'ON'], 1], [1, None]), ('partial-repair probe', [['LRI', 'WS', 'RLI', 'AN', 'PDI', 'AN', 'R', 'LRE', 'ES', 'L'], 1], [1, None]), ('partial-repair probe', [['LRI', 'EN', 'AN', 'LRI', 'RLI', 'AL', 'R', 'AN', 'PDI', 'R'], 1], [1, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('control layout', [['LRI', 'AL', 'L', 'ON', 'AL', 'L', 'WS'], 1], [1, None]), ('control layout', [['RLI', 'WS', 'ON', 'ON', 'ON', 'L', 'R', 'LRI'], 0], [0, None])], [('regression: unmatched PDI', [['PDI', 'FSI', 'L', 'NSM', 'R', 'NSM', 'L', 'EN', 'WS', 'R'], 1], [1, None]), ('regression: unmatched PDI', [['PDI', 'AL', 'ON', 'PDI', 'L', 'WS', 'FSI', 'PDI', 'ON', 'LRI'], 0], [1, 1]), ('partial-repair probe', [['ON', 'RLI', 'ON', 'LRI', 'AL', 'PDI', 'L', 'NSM'], 0], [0, None]), ('partial-repair probe', [['LRI', 'EN', 'AN', 'LRI', 'RLI', 'AL', 'R', 'AN', 'PDI', 'R'], 1], [1, None]), ('FSI content skipped', [['FSI', 'R', 'PDI', 'L'], 1], [0, 3]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('control layout', [['WS'], 1], [1, None]), ('control layout', [['LRE', 'WS', 'LRI'], 0], [0, None])], [('regression: unmatched PDI', [['ON', 'PDI', 'LRE', 'L', 'AN', 'R', 'AL'], 1], [0, 3]), ('regression: unmatched PDI', [['EN', 'PDI', 'L', 'EN', 'FSI'], 1], [0, 2]), ('partial-repair probe', [['ON', 'RLI', 'ON', 'LRI', 'AL', 'PDI', 'L', 'NSM'], 0], [0, None]), ('partial-repair probe', [['WS', 'LRI', 'FSI', 'PDI', 'R', 'LRE'], 1], [1, None]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('control layout', [['EN', 'FSI', 'FSI', 'FSI', 'R', 'FSI', 'L'], 0], [0, None]), ('control layout', [['NSM', 'AN'], 1], [1, None])], [('regression: unmatched PDI', [['PDI', 'PDI', 'LRI', 'WS', 'LRI', 'PDI', 'LRI', 'R', 'EN', 'L'], 1], [1, None]), ('regression: unmatched PDI', [['PDI', 'AN', 'R', 'FSI', 'ES', 'EN'], 0], [1, 2]), ('partial-repair probe', [['EN', 'ES', 'LRI', 'WS', 'WS', 'FSI', 'PDI', 'AL'], 1], [1, None]), ('partial-repair probe', [['LRI', 'WS', 'RLI', 'AN', 'PDI', 'AN', 'R', 'LRE', 'ES', 'L'], 1], [1, None]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('control layout', [['WS', 'AN', 'R', 'WS', 'EN', 'WS', 'PDI'], 1], [1, 2]), ('control layout', [['AN'], 1], [1, None])]]\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":"5e3a3489d27acfc99d44255c2bef33308ab1d8608e8d05b5ba72133235ffecd9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    classes, default = x\n    depth = 0\n    for i, c in enumerate(classes):\n        if c in ('LRI', 'RLI', 'FSI'):\n            depth += 1\n        elif c == 'PDI':\n            depth -= 1\n        elif depth == 0:\n            if c == 'L':\n                return [0, i]\n            if c in ('R', 'AL'):\n                return [1, i]\n    return [default, None]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('stray PDI before isolate', [['PDI', 'RLI', 'L', 'PDI', 'R'], 0], [1, 4]), ('regression: unmatched PDI', [['LRE', 'PDI', 'AL', 'PDI', 'AN', 'RLI', 'WS', 'AL', 'R', 'EN'], 1], [1, 2]), ('partial-repair probe', [['ON', 'RLI', 'ON', 'LRI', 'AL', 'PDI', 'L', 'NSM'], 0], [0, None]), ('partial-repair probe', [['LRI', 'ON', 'RLI', 'L', 'PDI', 'AL', 'R', 'WS'], 0], [0, None]), ('FSI content skipped', [['FSI', 'R', 'PDI', 'L'], 1], [0, 3]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('control layout', [['AL', 'PDI', 'L', 'WS', 'EN', 'L', 'ES', 'ON'], 0], [1, 0]), ('control layout', [['WS', 'L', 'PDI', 'WS', 'AL'], 1], [0, 1])], [('regression: unmatched PDI', [['PDI', 'PDI', 'L', 'ON', 'L', 'EN', 'ON', 'RLI'], 0], [0, 2]), ('regression: unmatched PDI', [['PDI', 'LRI', 'AL', 'ON'], 1], [1, None]), ('partial-repair probe', [['LRI', 'WS', 'RLI', 'AN', 'PDI', 'AN', 'R', 'LRE', 'ES', 'L'], 1], [1, None]), ('partial-repair probe', [['LRI', 'EN', 'AN', 'LRI', 'RLI', 'AL', 'R', 'AN', 'PDI', 'R'], 1], [1, None]), ('numbers are not strong', [['EN', 'ON', 'R'], 0], [1, 2]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('control layout', [['LRI', 'AL', 'L', 'ON', 'AL', 'L', 'WS'], 1], [1, None]), ('control layout', [['RLI', 'WS', 'ON', 'ON', 'ON', 'L', 'R', 'LRI'], 0], [0, None])], [('regression: unmatched PDI', [['PDI', 'FSI', 'L', 'NSM', 'R', 'NSM', 'L', 'EN', 'WS', 'R'], 1], [1, None]), ('regression: unmatched PDI', [['PDI', 'AL', 'ON', 'PDI', 'L', 'WS', 'FSI', 'PDI', 'ON', 'LRI'], 0], [1, 1]), ('partial-repair probe', [['ON', 'RLI', 'ON', 'LRI', 'AL', 'PDI', 'L', 'NSM'], 0], [0, None]), ('partial-repair probe', [['LRI', 'EN', 'AN', 'LRI', 'RLI', 'AL', 'R', 'AN', 'PDI', 'R'], 1], [1, None]), ('FSI content skipped', [['FSI', 'R', 'PDI', 'L'], 1], [0, 3]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('control layout', [['WS'], 1], [1, None]), ('control layout', [['LRE', 'WS', 'LRI'], 0], [0, None])], [('regression: unmatched PDI', [['ON', 'PDI', 'LRE', 'L', 'AN', 'R', 'AL'], 1], [0, 3]), ('regression: unmatched PDI', [['EN', 'PDI', 'L', 'EN', 'FSI'], 1], [0, 2]), ('partial-repair probe', [['ON', 'RLI', 'ON', 'LRI', 'AL', 'PDI', 'L', 'NSM'], 0], [0, None]), ('partial-repair probe', [['WS', 'LRI', 'FSI', 'PDI', 'R', 'LRE'], 1], [1, None]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('control layout', [['EN', 'FSI', 'FSI', 'FSI', 'R', 'FSI', 'L'], 0], [0, None]), ('control layout', [['NSM', 'AN'], 1], [1, None])], [('regression: unmatched PDI', [['PDI', 'PDI', 'LRI', 'WS', 'LRI', 'PDI', 'LRI', 'R', 'EN', 'L'], 1], [1, None]), ('regression: unmatched PDI', [['PDI', 'AN', 'R', 'FSI', 'ES', 'EN'], 0], [1, 2]), ('partial-repair probe', [['EN', 'ES', 'LRI', 'WS', 'WS', 'FSI', 'PDI', 'AL'], 1], [1, None]), ('partial-repair probe', [['LRI', 'WS', 'RLI', 'AN', 'PDI', 'AN', 'R', 'LRE', 'ES', 'L'], 1], [1, None]), ('nested isolates', [['LRI', 'RLI', 'R', 'PDI', 'L', 'PDI', 'R'], 0], [1, 6]), ('Arabic letter decides', [['ON', 'AL', 'L'], 0], [1, 1]), ('control layout', [['WS', 'AN', 'R', 'WS', 'EN', 'WS', 'PDI'], 1], [1, 2]), ('control layout', [['AN'], 1], [1, None])]]\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-paragraph-direction-unmatched-pdi","generated_at":"2026-09-29T14:49:52.940037+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":"Every PDI decrements the isolate depth, driving it negative.","sha256":"047bcfe6037c2a7151fd5d36b53e718642c2ad64f6c7cd9764879a01ae9fce2b","title":"First-strong paragraph direction: unmatched PDI · 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":39.364,"exit_code":1,"observations":[{"actual":[1,4],"check":"stray PDI before isolate","expected":[1,4],"passed":true},{"actual":[1,2],"check":"regression: unmatched PDI","expected":[1,2],"passed":true},{"actual":[0,6],"check":"partial-repair probe","expected":[0,null],"passed":false},{"actual":[1,5],"check":"partial-repair probe","expected":[0,null],"passed":false},{"actual":[0,3],"check":"FSI content skipped","expected":[0,3],"passed":true},{"actual":[1,2],"check":"numbers are not strong","expected":[1,2],"passed":true},{"actual":[1,0],"check":"control layout","expected":[1,0],"passed":true},{"actual":[0,1],"check":"control layout","expected":[0,1],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"stray PDI before isolate\", \"actual\": [1, 4], \"expected\": [1, 4], \"passed\": true}, {\"check\": \"regression: unmatched PDI\", \"actual\": [1, 2], \"expected\": [1, 2], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [0, 6], \"expected\": [0, null], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [1, 5], \"expected\": [0, null], \"passed\": false}, {\"check\": \"FSI content skipped\", \"actual\": [0, 3], \"expected\": [0, 3], \"passed\": true}, {\"check\": \"numbers are not strong\", \"actual\": [1, 2], \"expected\": [1, 2], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [1, 0], \"expected\": [1, 0], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [0, 1], \"expected\": [0, 1], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.309,"exit_code":1,"observations":[{"actual":[0,2],"check":"stray PDI before isolate","expected":[1,4],"passed":false},{"actual":[1,null],"check":"regression: unmatched PDI","expected":[1,2],"passed":false},{"actual":[0,null],"check":"partial-repair probe","expected":[0,null],"passed":true},{"actual":[0,null],"check":"partial-repair probe","expected":[0,null],"passed":true},{"actual":[0,3],"check":"FSI content skipped","expected":[0,3],"passed":true},{"actual":[1,2],"check":"numbers are not strong","expected":[1,2],"passed":true},{"actual":[1,0],"check":"control layout","expected":[1,0],"passed":true},{"actual":[0,1],"check":"control layout","expected":[0,1],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"stray PDI before isolate\", \"actual\": [0, 2], \"expected\": [1, 4], \"passed\": false}, {\"check\": \"regression: unmatched PDI\", \"actual\": [1, null], \"expected\": [1, 2], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [0, null], \"expected\": [0, null], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [0, null], \"expected\": [0, null], \"passed\": true}, {\"check\": \"FSI content skipped\", \"actual\": [0, 3], \"expected\": [0, 3], \"passed\": true}, {\"check\": \"numbers are not strong\", \"actual\": [1, 2], \"expected\": [1, 2], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [1, 0], \"expected\": [1, 0], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [0, 1], \"expected\": [0, 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."}}