{"abstract":"Separate highlight fragments are fused across unselected gaps.","category":"Bidirectional text layout","checks":8,"contract":"Input [levels, anchor, focus]. The logical selection covers characters min..max-1. Each selected character occupies its unit visual slot (level reversal); merge adjacent slots into [x0, x1) rectangles sorted by x. Return the rectangles.","contract_signature":"x","evaluation_group":"w2-bidirectional-text-layout-selection-highlight","failed_approach":"Requiring a one-unit gap prevents merging contiguous slots.","family":"w2-bidirectional-text-layout-selection-highlight-rectangle-adjacency","id":"FA-80671","implementations":{"attempt":{"sha256":"7bfe1132e31cc95e0a29068105daf227aede4553ba519c49af3b09cec8786068","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, a, b = x\n    a, b = min(a, b), max(a, b)\n    vis = reorder(levels)\n    pos = [0] * len(levels)\n    for v, i in enumerate(vis):\n        pos[i] = v\n    sel = sorted(pos[i] for i in range(a, b))\n    rects = []\n    for p in sel:\n        if rects and rects[-1][1] + 1 == p:\n            rects[-1][1] = p + 1\n        else:\n            rects.append([p, p + 1])\n    return rects\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: rectangle adjacency', [[2, 2, 2, 2, 1, 1, 1, 4, 4, 1, 1], 8, 2], [[2, 3], [4, 7], [9, 11]]), ('regression: rectangle adjacency', [[1, 1, 1, 1, 1, 3, 0, 0, 0, 0], 1, 10], [[0, 5], [6, 10]]), ('partial-repair probe', [[0, 3, 0, 0, 0, 3], 2, 0], [[0, 2]]), ('partial-repair probe', [[1, 1, 1, 1, 1, 1, 1, 0, 0, 0], 2, 8], [[0, 5], [7, 8]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3], 10, 10], []), ('control layout', [[3, 3, 3, 1, 1], 3, 4], [[1, 2]])], [('regression: rectangle adjacency', [[2, 1, 1, 1, 1, 1, 1, 1, 2, 4, 4], 7, 10], [[0, 2], [3, 4]]), ('regression: rectangle adjacency', [[2, 2, 2, 2, 1, 1, 1, 4, 4, 1, 1], 8, 2], [[2, 3], [4, 7], [9, 11]]), ('partial-repair probe', [[2, 3, 3, 3, 3, 3, 0, 0, 0, 2, 2], 6, 9], [[6, 9]]), ('partial-repair probe', [[3, 3, 3, 3, 2, 2, 2, 1, 1], 4, 1], [[2, 5]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('control layout', [[1, 2, 2, 2, 4, 4, 4, 4, 1, 1, 1], 10, 9], [[1, 2]]), ('control layout', [[4, 4, 4, 4, 1, 1, 3], 1, 0], [[3, 4]])], [('regression: rectangle adjacency', [[0, 0, 0, 0, 2, 2, 2, 2, 1], 2, 6], [[2, 4], [5, 7]]), ('regression: rectangle adjacency', [[0, 0, 0, 3, 3, 0, 0, 3, 3, 3, 0], 3, 9], [[3, 7], [8, 10]]), ('regression: rectangle adjacency', [[4, 4, 1, 1, 1, 1, 2], 1, 6], [[1, 5], [6, 7]]), ('partial-repair probe', [[0, 0, 0, 0, 0, 2, 0, 0, 1, 0], 8, 6], [[6, 8]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[0, 0], 1, 2], [[1, 2]]), ('control layout', [[3, 3, 3, 1, 1], 3, 4], [[1, 2]])], [('regression: rectangle adjacency', [[4, 4, 4, 4, 3, 2], 1, 5], [[0, 1], [2, 5]]), ('regression: rectangle adjacency', [[0, 0, 0, 3, 1], 2, 4], [[2, 3], [4, 5]]), ('partial-repair probe', [[3, 2, 2, 2, 2, 0, 1], 7, 2], [[2, 7]]), ('partial-repair probe', [[1, 1, 1, 1, 1, 1, 2], 4, 6], [[1, 3]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('control layout', [[2, 2, 0, 1, 3], 1, 0], [[0, 1]]), ('control layout', [[1, 1, 1, 1], 1, 1], [])], [('regression: rectangle adjacency', [[2, 2, 2, 1, 1], 1, 4], [[1, 2], [3, 5]]), ('regression: rectangle adjacency', [[0, 0, 0, 3, 1], 2, 4], [[2, 3], [4, 5]]), ('regression: rectangle adjacency', [[0, 0, 0, 0, 2, 2, 2, 2, 1], 2, 6], [[2, 4], [5, 7]]), ('partial-repair probe', [[2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1], 11, 6], [[0, 5]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('control layout', [[4, 4, 4, 1, 1], 0, 1], [[2, 3]]), ('control layout', [[2, 2, 2, 1, 4, 4], 4, 3], [[2, 3]])]]\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":"0e936c8bdb6a1770eed1720b7cae1aea1708cfc28d9bfff7a5e25171fa6a4b5f","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, a, b = x\n    a, b = min(a, b), max(a, b)\n    vis = reorder(levels)\n    pos = [0] * len(levels)\n    for v, i in enumerate(vis):\n        pos[i] = v\n    sel = sorted(pos[i] for i in range(a, b))\n    rects = []\n    for p in sel:\n        if rects and rects[-1][1] >= p - 1:\n            rects[-1][1] = p + 1\n        else:\n            rects.append([p, p + 1])\n    return rects\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: rectangle adjacency', [[2, 2, 2, 2, 1, 1, 1, 4, 4, 1, 1], 8, 2], [[2, 3], [4, 7], [9, 11]]), ('regression: rectangle adjacency', [[1, 1, 1, 1, 1, 3, 0, 0, 0, 0], 1, 10], [[0, 5], [6, 10]]), ('partial-repair probe', [[0, 3, 0, 0, 0, 3], 2, 0], [[0, 2]]), ('partial-repair probe', [[1, 1, 1, 1, 1, 1, 1, 0, 0, 0], 2, 8], [[0, 5], [7, 8]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3], 10, 10], []), ('control layout', [[3, 3, 3, 1, 1], 3, 4], [[1, 2]])], [('regression: rectangle adjacency', [[2, 1, 1, 1, 1, 1, 1, 1, 2, 4, 4], 7, 10], [[0, 2], [3, 4]]), ('regression: rectangle adjacency', [[2, 2, 2, 2, 1, 1, 1, 4, 4, 1, 1], 8, 2], [[2, 3], [4, 7], [9, 11]]), ('partial-repair probe', [[2, 3, 3, 3, 3, 3, 0, 0, 0, 2, 2], 6, 9], [[6, 9]]), ('partial-repair probe', [[3, 3, 3, 3, 2, 2, 2, 1, 1], 4, 1], [[2, 5]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('control layout', [[1, 2, 2, 2, 4, 4, 4, 4, 1, 1, 1], 10, 9], [[1, 2]]), ('control layout', [[4, 4, 4, 4, 1, 1, 3], 1, 0], [[3, 4]])], [('regression: rectangle adjacency', [[0, 0, 0, 0, 2, 2, 2, 2, 1], 2, 6], [[2, 4], [5, 7]]), ('regression: rectangle adjacency', [[0, 0, 0, 3, 3, 0, 0, 3, 3, 3, 0], 3, 9], [[3, 7], [8, 10]]), ('regression: rectangle adjacency', [[4, 4, 1, 1, 1, 1, 2], 1, 6], [[1, 5], [6, 7]]), ('partial-repair probe', [[0, 0, 0, 0, 0, 2, 0, 0, 1, 0], 8, 6], [[6, 8]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[0, 0], 1, 2], [[1, 2]]), ('control layout', [[3, 3, 3, 1, 1], 3, 4], [[1, 2]])], [('regression: rectangle adjacency', [[4, 4, 4, 4, 3, 2], 1, 5], [[0, 1], [2, 5]]), ('regression: rectangle adjacency', [[0, 0, 0, 3, 1], 2, 4], [[2, 3], [4, 5]]), ('partial-repair probe', [[3, 2, 2, 2, 2, 0, 1], 7, 2], [[2, 7]]), ('partial-repair probe', [[1, 1, 1, 1, 1, 1, 2], 4, 6], [[1, 3]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('control layout', [[2, 2, 0, 1, 3], 1, 0], [[0, 1]]), ('control layout', [[1, 1, 1, 1], 1, 1], [])], [('regression: rectangle adjacency', [[2, 2, 2, 1, 1], 1, 4], [[1, 2], [3, 5]]), ('regression: rectangle adjacency', [[0, 0, 0, 3, 1], 2, 4], [[2, 3], [4, 5]]), ('regression: rectangle adjacency', [[0, 0, 0, 0, 2, 2, 2, 2, 1], 2, 6], [[2, 4], [5, 7]]), ('partial-repair probe', [[2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1], 11, 6], [[0, 5]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('control layout', [[4, 4, 4, 1, 1], 0, 1], [[2, 3]]), ('control layout', [[2, 2, 2, 1, 4, 4], 4, 3], [[2, 3]])]]\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-selection-highlight-rectangle-adjacency","generated_at":"2026-09-29T14:49:56.106496+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 merge accepts a slot one unit past the rectangle end.","sha256":"e55919ab9bbf8632d0f7af1283086981748112454f710b3338f68739bb6d0708","title":"Bidi selection highlight: rectangle adjacency · 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":42.429,"exit_code":1,"observations":[{"actual":[[2,5],[5,6],[6,7],[9,10],[10,11]],"check":"regression: rectangle adjacency","expected":[[2,3],[4,7],[9,11]],"passed":false},{"actual":[[0,1],[1,2],[2,3],[3,4],[4,7],[7,8],[8,9],[9,10]],"check":"regression: rectangle adjacency","expected":[[0,5],[6,10]],"passed":false},{"actual":[[0,1],[1,2]],"check":"partial-repair probe","expected":[[0,2]],"passed":false},{"actual":[[0,1],[1,2],[2,3],[3,4],[4,5],[7,8]],"check":"partial-repair probe","expected":[[0,5],[7,8]],"passed":false},{"actual":[[1,2],[2,3],[3,4]],"check":"selection crossing direction change","expected":[[1,4]],"passed":false},{"actual":[[0,1],[1,2]],"check":"backward selection","expected":[[0,2]],"passed":false},{"actual":[],"check":"control layout","expected":[],"passed":true},{"actual":[[1,2]],"check":"control layout","expected":[[1,2]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: rectangle adjacency\", \"actual\": [[2, 5], [5, 6], [6, 7], [9, 10], [10, 11]], \"expected\": [[2, 3], [4, 7], [9, 11]], \"passed\": false}, {\"check\": \"regression: rectangle adjacency\", \"actual\": [[0, 1], [1, 2], [2, 3], [3, 4], [4, 7], [7, 8], [8, 9], [9, 10]], \"expected\": [[0, 5], [6, 10]], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [[0, 1], [1, 2]], \"expected\": [[0, 2]], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [7, 8]], \"expected\": [[0, 5], [7, 8]], \"passed\": false}, {\"check\": \"selection crossing direction change\", \"actual\": [[1, 2], [2, 3], [3, 4]], \"expected\": [[1, 4]], \"passed\": false}, {\"check\": \"backward selection\", \"actual\": [[0, 1], [1, 2]], \"expected\": [[0, 2]], \"passed\": false}, {\"check\": \"control layout\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[1, 2]], \"expected\": [[1, 2]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.748,"exit_code":1,"observations":[{"actual":[[2,7],[9,11]],"check":"regression: rectangle adjacency","expected":[[2,3],[4,7],[9,11]],"passed":false},{"actual":[[0,10]],"check":"regression: rectangle adjacency","expected":[[0,5],[6,10]],"passed":false},{"actual":[[0,2]],"check":"partial-repair probe","expected":[[0,2]],"passed":true},{"actual":[[0,5],[7,8]],"check":"partial-repair probe","expected":[[0,5],[7,8]],"passed":true},{"actual":[[1,4]],"check":"selection crossing direction change","expected":[[1,4]],"passed":true},{"actual":[[0,2]],"check":"backward selection","expected":[[0,2]],"passed":true},{"actual":[],"check":"control layout","expected":[],"passed":true},{"actual":[[1,2]],"check":"control layout","expected":[[1,2]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: rectangle adjacency\", \"actual\": [[2, 7], [9, 11]], \"expected\": [[2, 3], [4, 7], [9, 11]], \"passed\": false}, {\"check\": \"regression: rectangle adjacency\", \"actual\": [[0, 10]], \"expected\": [[0, 5], [6, 10]], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [[0, 2]], \"expected\": [[0, 2]], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [[0, 5], [7, 8]], \"expected\": [[0, 5], [7, 8]], \"passed\": true}, {\"check\": \"selection crossing direction change\", \"actual\": [[1, 4]], \"expected\": [[1, 4]], \"passed\": true}, {\"check\": \"backward selection\", \"actual\": [[0, 2]], \"expected\": [[0, 2]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[1, 2]], \"expected\": [[1, 2]], \"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."}}