{"abstract":"Clicks in the right half are treated as left half.","category":"Bidirectional text layout","checks":8,"contract":"Input [levels, x in half-character units]. Clamp to a visual slot (each character 2 units). The right half of an LTR character or the left half of an RTL character is its trailing side. Points before the line use the left half of slot 0, beyond it the right half of the last slot. Return [logical index, trailing, caret offset].","evaluation_group":"w2-bidirectional-text-layout-hit-testing","failed_approach":"Using the parity of x misclassifies clicks outside the line.","family":"w2-bidirectional-text-layout-hit-testing-half-boundary","id":"FA-80701","implementations":{"attempt":{"sha256":"9ef0248b93ac46fcb7dfe5582cec74b11ed60b8a4b8322a387864b5930abe17a","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    def reorder(lv):\n        vis = list(range(len(lv)))\n        odd = [l for l in lv if l % 2 == 1]\n        if not odd:\n            return vis\n        for lev in range(max(lv), min(odd) - 1, -1):\n            i = 0\n            while i < len(vis):\n                if lv[vis[i]] >= lev:\n                    j = i\n                    while j < len(vis) and lv[vis[j]] >= lev:\n                        j += 1\n                    vis[i:j] = vis[i:j][::-1]\n                    i = j\n                else:\n                    i += 1\n        return vis\n    \n    levels, px = x\n    n = len(levels)\n    if n == 0:\n        return [None, False, 0]\n    vis = reorder(levels)\n    v = min(max(px // 2, 0), n - 1)\n    i = vis[v]\n    right_half = px % 2 == 1\n    rtl = levels[i] % 2 == 1\n    trailing = right_half != rtl\n    return [i, trailing, i + 1 if trailing else i]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('regression: half boundary', [[3, 3, 3, 3, 1, 1, 1, 1, 1], 15], [1, False, 1]), ('partial-repair probe', [[4, 4, 4, 4, 1, 1, 1, 1], 16], [3, True, 4]), ('partial-repair probe', [[1, 3, 3, 3, 3, 1, 3], 14], [0, False, 0]), ('click left of RTL line', [[1, 1, 1], -1], [2, True, 3]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('control layout', [[0, 0, 3, 1, 1, 1, 1, 3], 14], [2, True, 3]), ('control layout', [[1, 1], 2], [0, True, 1])], [('regression: half boundary', [[2, 2, 1, 1, 2, 2, 2, 2, 2, 2], 1], [4, True, 5]), ('regression: half boundary', [[3, 3, 3, 1, 1, 1], 3], [4, False, 4]), ('partial-repair probe', [[1, 1, 1, 1, 2, 2, 2], -3], [4, False, 4]), ('partial-repair probe', [[4, 4, 4, 4, 4, 4], 14], [5, True, 6]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('control layout', [[2, 0, 0, 0], 9], [3, True, 4]), ('control layout', [[2, 2], 2], [1, False, 1])], [('regression: half boundary', [[0, 0, 0, 0, 3, 3, 3, 1, 3], 13], [6, False, 6]), ('regression: half boundary', [[3, 3, 3], 1], [2, False, 2]), ('partial-repair probe', [[1, 1], -1], [1, True, 2]), ('partial-repair probe', [[4, 4, 4, 2, 2, 2], 12], [5, True, 6]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('control layout', [[2, 2, 2, 2, 1, 1, 1, 2, 3], 2], [8, True, 9]), ('control layout', [[2, 2, 1, 1, 1, 2], 15], [1, True, 2])], [('regression: half boundary', [[2, 2, 2, 2, 2], 3], [1, True, 2]), ('regression: half boundary', [[1, 0, 0, 0, 0], 3], [1, True, 2]), ('partial-repair probe', [[1, 1, 1], -1], [2, True, 3]), ('partial-repair probe', [[1, 1, 3, 3, 3, 3, 3, 3, 3], 18], [0, False, 0]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('click left of RTL line', [[1, 1, 1], -1], [2, True, 3]), ('control layout', [[1], 3], [0, False, 0]), ('control layout', [[2, 2, 2, 2], -2], [0, False, 0])], [('regression: half boundary', [[4, 4, 4, 1, 1, 1], 3], [4, False, 4]), ('regression: half boundary', [[0, 0, 0, 0, 1, 1, 1, 1, 0, 0], 13], [5, False, 5]), ('partial-repair probe', [[4], 4], [0, True, 1]), ('partial-repair probe', [[0, 0, 1, 1, 1, 1, 1], -1], [0, False, 0]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('control layout', [[1, 1, 1, 1, 1, 1], 6], [2, True, 3]), ('control layout', [[3, 3, 3, 3, 3, 3, 3], 6], [3, True, 4])]]\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":"33329e8bfd52af149274c662f6db34080828ec61c0f1b7aab096769296f84103","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    def reorder(lv):\n        vis = list(range(len(lv)))\n        odd = [l for l in lv if l % 2 == 1]\n        if not odd:\n            return vis\n        for lev in range(max(lv), min(odd) - 1, -1):\n            i = 0\n            while i < len(vis):\n                if lv[vis[i]] >= lev:\n                    j = i\n                    while j < len(vis) and lv[vis[j]] >= lev:\n                        j += 1\n                    vis[i:j] = vis[i:j][::-1]\n                    i = j\n                else:\n                    i += 1\n        return vis\n    \n    levels, px = x\n    n = len(levels)\n    if n == 0:\n        return [None, False, 0]\n    vis = reorder(levels)\n    v = min(max(px // 2, 0), n - 1)\n    i = vis[v]\n    right_half = px - 2 * v > 1\n    rtl = levels[i] % 2 == 1\n    trailing = right_half != rtl\n    return [i, trailing, i + 1 if trailing else i]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('regression: half boundary', [[3, 3, 3, 3, 1, 1, 1, 1, 1], 15], [1, False, 1]), ('partial-repair probe', [[4, 4, 4, 4, 1, 1, 1, 1], 16], [3, True, 4]), ('partial-repair probe', [[1, 3, 3, 3, 3, 1, 3], 14], [0, False, 0]), ('click left of RTL line', [[1, 1, 1], -1], [2, True, 3]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('control layout', [[0, 0, 3, 1, 1, 1, 1, 3], 14], [2, True, 3]), ('control layout', [[1, 1], 2], [0, True, 1])], [('regression: half boundary', [[2, 2, 1, 1, 2, 2, 2, 2, 2, 2], 1], [4, True, 5]), ('regression: half boundary', [[3, 3, 3, 1, 1, 1], 3], [4, False, 4]), ('partial-repair probe', [[1, 1, 1, 1, 2, 2, 2], -3], [4, False, 4]), ('partial-repair probe', [[4, 4, 4, 4, 4, 4], 14], [5, True, 6]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('control layout', [[2, 0, 0, 0], 9], [3, True, 4]), ('control layout', [[2, 2], 2], [1, False, 1])], [('regression: half boundary', [[0, 0, 0, 0, 3, 3, 3, 1, 3], 13], [6, False, 6]), ('regression: half boundary', [[3, 3, 3], 1], [2, False, 2]), ('partial-repair probe', [[1, 1], -1], [1, True, 2]), ('partial-repair probe', [[4, 4, 4, 2, 2, 2], 12], [5, True, 6]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('control layout', [[2, 2, 2, 2, 1, 1, 1, 2, 3], 2], [8, True, 9]), ('control layout', [[2, 2, 1, 1, 1, 2], 15], [1, True, 2])], [('regression: half boundary', [[2, 2, 2, 2, 2], 3], [1, True, 2]), ('regression: half boundary', [[1, 0, 0, 0, 0], 3], [1, True, 2]), ('partial-repair probe', [[1, 1, 1], -1], [2, True, 3]), ('partial-repair probe', [[1, 1, 3, 3, 3, 3, 3, 3, 3], 18], [0, False, 0]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('click left of RTL line', [[1, 1, 1], -1], [2, True, 3]), ('control layout', [[1], 3], [0, False, 0]), ('control layout', [[2, 2, 2, 2], -2], [0, False, 0])], [('regression: half boundary', [[4, 4, 4, 1, 1, 1], 3], [4, False, 4]), ('regression: half boundary', [[0, 0, 0, 0, 1, 1, 1, 1, 0, 0], 13], [5, False, 5]), ('partial-repair probe', [[4], 4], [0, True, 1]), ('partial-repair probe', [[0, 0, 1, 1, 1, 1, 1], -1], [0, False, 0]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('control layout', [[1, 1, 1, 1, 1, 1], 6], [2, True, 3]), ('control layout', [[3, 3, 3, 3, 3, 3, 3], 6], [3, True, 4])]]\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":"49588ba90853d2ebfe47042a2ee8cb4e6a8d801640bdd5b6db46d212aa42dab2","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    def reorder(lv):\n        vis = list(range(len(lv)))\n        odd = [l for l in lv if l % 2 == 1]\n        if not odd:\n            return vis\n        for lev in range(max(lv), min(odd) - 1, -1):\n            i = 0\n            while i < len(vis):\n                if lv[vis[i]] >= lev:\n                    j = i\n                    while j < len(vis) and lv[vis[j]] >= lev:\n                        j += 1\n                    vis[i:j] = vis[i:j][::-1]\n                    i = j\n                else:\n                    i += 1\n        return vis\n    \n    levels, px = x\n    n = len(levels)\n    if n == 0:\n        return [None, False, 0]\n    vis = reorder(levels)\n    v = min(max(px // 2, 0), n - 1)\n    i = vis[v]\n    right_half = px - 2 * v >= 1\n    rtl = levels[i] % 2 == 1\n    trailing = right_half != rtl\n    return [i, trailing, i + 1 if trailing else i]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('regression: half boundary', [[3, 3, 3, 3, 1, 1, 1, 1, 1], 15], [1, False, 1]), ('partial-repair probe', [[4, 4, 4, 4, 1, 1, 1, 1], 16], [3, True, 4]), ('partial-repair probe', [[1, 3, 3, 3, 3, 1, 3], 14], [0, False, 0]), ('click left of RTL line', [[1, 1, 1], -1], [2, True, 3]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('control layout', [[0, 0, 3, 1, 1, 1, 1, 3], 14], [2, True, 3]), ('control layout', [[1, 1], 2], [0, True, 1])], [('regression: half boundary', [[2, 2, 1, 1, 2, 2, 2, 2, 2, 2], 1], [4, True, 5]), ('regression: half boundary', [[3, 3, 3, 1, 1, 1], 3], [4, False, 4]), ('partial-repair probe', [[1, 1, 1, 1, 2, 2, 2], -3], [4, False, 4]), ('partial-repair probe', [[4, 4, 4, 4, 4, 4], 14], [5, True, 6]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('control layout', [[2, 0, 0, 0], 9], [3, True, 4]), ('control layout', [[2, 2], 2], [1, False, 1])], [('regression: half boundary', [[0, 0, 0, 0, 3, 3, 3, 1, 3], 13], [6, False, 6]), ('regression: half boundary', [[3, 3, 3], 1], [2, False, 2]), ('partial-repair probe', [[1, 1], -1], [1, True, 2]), ('partial-repair probe', [[4, 4, 4, 2, 2, 2], 12], [5, True, 6]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('control layout', [[2, 2, 2, 2, 1, 1, 1, 2, 3], 2], [8, True, 9]), ('control layout', [[2, 2, 1, 1, 1, 2], 15], [1, True, 2])], [('regression: half boundary', [[2, 2, 2, 2, 2], 3], [1, True, 2]), ('regression: half boundary', [[1, 0, 0, 0, 0], 3], [1, True, 2]), ('partial-repair probe', [[1, 1, 1], -1], [2, True, 3]), ('partial-repair probe', [[1, 1, 3, 3, 3, 3, 3, 3, 3], 18], [0, False, 0]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('click left of RTL line', [[1, 1, 1], -1], [2, True, 3]), ('control layout', [[1], 3], [0, False, 0]), ('control layout', [[2, 2, 2, 2], -2], [0, False, 0])], [('regression: half boundary', [[4, 4, 4, 1, 1, 1], 3], [4, False, 4]), ('regression: half boundary', [[0, 0, 0, 0, 1, 1, 1, 1, 0, 0], 13], [5, False, 5]), ('partial-repair probe', [[4], 4], [0, True, 1]), ('partial-repair probe', [[0, 0, 1, 1, 1, 1, 1], -1], [0, False, 0]), ('click past end', [[0, 1, 1], 9], [1, False, 1]), ('right half of RTL char', [[1, 1], 1], [1, False, 1]), ('control layout', [[1, 1, 1, 1, 1, 1], 6], [2, True, 3]), ('control layout', [[3, 3, 3, 3, 3, 3, 3], 6], [3, True, 4])]]\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-hit-testing-half-boundary","generated_at":"2026-09-29T14:49:56.158505+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":"The right half starts one unit into the slot.","root_cause":"The right-half test requires more than one unit into the slot.","sha256":"72045c549a6a7d66fc8f6153125c46596d3217df60d1186859ee78edd909fe37","title":"Bidi hit testing: half boundary · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":41.506,"exit_code":1,"observations":[{"actual":[1,false,1],"check":"right half of RTL char","expected":[1,false,1],"passed":true},{"actual":[1,false,1],"check":"regression: half boundary","expected":[1,false,1],"passed":true},{"actual":[3,false,3],"check":"partial-repair probe","expected":[3,true,4],"passed":false},{"actual":[0,true,1],"check":"partial-repair probe","expected":[0,false,0],"passed":false},{"actual":[2,false,2],"check":"click left of RTL line","expected":[2,true,3],"passed":false},{"actual":[1,false,1],"check":"click past end","expected":[1,false,1],"passed":true},{"actual":[2,true,3],"check":"control layout","expected":[2,true,3],"passed":true},{"actual":[0,true,1],"check":"control layout","expected":[0,true,1],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"right half of RTL char\", \"actual\": [1, false, 1], \"expected\": [1, false, 1], \"passed\": true}, {\"check\": \"regression: half boundary\", \"actual\": [1, false, 1], \"expected\": [1, false, 1], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [3, false, 3], \"expected\": [3, true, 4], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [0, true, 1], \"expected\": [0, false, 0], \"passed\": false}, {\"check\": \"click left of RTL line\", \"actual\": [2, false, 2], \"expected\": [2, true, 3], \"passed\": false}, {\"check\": \"click past end\", \"actual\": [1, false, 1], \"expected\": [1, false, 1], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [2, true, 3], \"expected\": [2, true, 3], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [0, true, 1], \"expected\": [0, true, 1], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.064,"exit_code":1,"observations":[{"actual":[1,true,2],"check":"right half of RTL char","expected":[1,false,1],"passed":false},{"actual":[1,true,2],"check":"regression: half boundary","expected":[1,false,1],"passed":false},{"actual":[3,true,4],"check":"partial-repair probe","expected":[3,true,4],"passed":true},{"actual":[0,false,0],"check":"partial-repair probe","expected":[0,false,0],"passed":true},{"actual":[2,true,3],"check":"click left of RTL line","expected":[2,true,3],"passed":true},{"actual":[1,false,1],"check":"click past end","expected":[1,false,1],"passed":true},{"actual":[2,true,3],"check":"control layout","expected":[2,true,3],"passed":true},{"actual":[0,true,1],"check":"control layout","expected":[0,true,1],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"right half of RTL char\", \"actual\": [1, true, 2], \"expected\": [1, false, 1], \"passed\": false}, {\"check\": \"regression: half boundary\", \"actual\": [1, true, 2], \"expected\": [1, false, 1], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [3, true, 4], \"expected\": [3, true, 4], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [0, false, 0], \"expected\": [0, false, 0], \"passed\": true}, {\"check\": \"click left of RTL line\", \"actual\": [2, true, 3], \"expected\": [2, true, 3], \"passed\": true}, {\"check\": \"click past end\", \"actual\": [1, false, 1], \"expected\": [1, false, 1], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [2, true, 3], \"expected\": [2, true, 3], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [0, true, 1], \"expected\": [0, true, 1], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":38.908,"exit_code":0,"observations":[{"actual":[1,false,1],"check":"right half of RTL char","expected":[1,false,1],"passed":true},{"actual":[1,false,1],"check":"regression: half boundary","expected":[1,false,1],"passed":true},{"actual":[3,true,4],"check":"partial-repair probe","expected":[3,true,4],"passed":true},{"actual":[0,false,0],"check":"partial-repair probe","expected":[0,false,0],"passed":true},{"actual":[2,true,3],"check":"click left of RTL line","expected":[2,true,3],"passed":true},{"actual":[1,false,1],"check":"click past end","expected":[1,false,1],"passed":true},{"actual":[2,true,3],"check":"control layout","expected":[2,true,3],"passed":true},{"actual":[0,true,1],"check":"control layout","expected":[0,true,1],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"right half of RTL char\", \"actual\": [1, false, 1], \"expected\": [1, false, 1], \"passed\": true}, {\"check\": \"regression: half boundary\", \"actual\": [1, false, 1], \"expected\": [1, false, 1], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [3, true, 4], \"expected\": [3, true, 4], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [0, false, 0], \"expected\": [0, false, 0], \"passed\": true}, {\"check\": \"click left of RTL line\", \"actual\": [2, true, 3], \"expected\": [2, true, 3], \"passed\": true}, {\"check\": \"click past end\", \"actual\": [1, false, 1], \"expected\": [1, false, 1], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [2, true, 3], \"expected\": [2, true, 3], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [0, true, 1], \"expected\": [0, true, 1], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}