{"abstract":"RTL selections are drawn as many one-unit fragments.","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":"Sorting in descending order defeats the adjacency merge.","family":"w2-bidirectional-text-layout-selection-highlight-slot-sorting","id":"FA-80666","implementations":{"attempt":{"sha256":"17f8ab11d760b234fc48fc076a9ec7c43baadabb29b6344544c6c333333fffcd","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)), reverse=True)\n    rects = []\n    for p in sel:\n        if rects and rects[-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 = [[('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('regression: slot sorting', [[0, 0, 0, 0, 2, 0, 0, 0, 3, 3, 0, 0], 12, 7], [[7, 12]]), ('partial-repair probe', [[0, 0, 0, 0, 0, 2, 0, 0, 1, 0], 8, 6], [[6, 8]]), ('partial-repair probe', [[2, 2, 2, 2, 1, 1, 4, 4, 4, 4, 1], 8, 6], [[1, 3]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[4, 4, 4, 4, 1, 1, 3], 1, 0], [[3, 4]]), ('control layout', [[2, 2, 2, 1, 1, 1, 1, 3, 3], 6, 5], [[3, 4]]), ('control layout', [[0], 1, 1], [])], [('regression: slot sorting', [[3, 3, 3, 3, 3, 3, 3, 2], 8, 4], [[0, 3], [7, 8]]), ('regression: slot sorting', [[1, 1, 1, 1, 3, 1, 1, 1, 2, 2, 2], 9, 3], [[0, 1], [3, 8]]), ('regression: slot sorting', [[3, 3, 3, 1, 1, 1, 2], 4, 2], [[3, 5]]), ('regression: slot sorting', [[3, 3, 3, 2, 2, 1, 1, 1, 1, 2, 2], 3, 8], [[3, 6], [9, 11]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[1, 2, 2, 2, 4, 4, 4, 4, 1, 1, 1], 10, 9], [[1, 2]]), ('control layout', [[1, 1, 2, 2, 2, 2, 1, 3, 3, 1, 1], 8, 9], [[2, 3]])], [('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('regression: slot sorting', [[1, 1, 1, 1, 4, 4, 3, 2, 2], 4, 7], [[0, 3]]), ('regression: slot sorting', [[1, 1, 1, 4, 4, 3, 3, 3, 2], 3, 7], [[1, 5]]), ('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]]), ('control layout', [[0, 0], 0, 0], []), ('control layout', [[3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2], 2, 1], [[9, 10]]), ('control layout', [[1, 1], 1, 1], [])], [('regression: slot sorting', [[4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1], 6, 11], [[0, 5]]), ('regression: slot sorting', [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3], 8, 3], [[4, 9]]), ('regression: slot sorting', [[3, 3, 3, 3, 2], 4, 2], [[0, 2]]), ('partial-repair probe', [[4, 2, 2, 2, 2, 2, 2, 2], 7, 1], [[1, 7]]), ('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, 0], []), ('control layout', [[1, 3, 3, 3, 3, 0, 0], 1, 0], [[4, 5]])], [('regression: slot sorting', [[0, 1, 1, 2, 2, 0, 0, 0, 0], 2, 8], [[1, 4], [5, 8]]), ('regression: slot sorting', [[2, 2, 1, 1], 4, 1], [[0, 2], [3, 4]]), ('regression: slot sorting', [[1, 1, 1, 4, 4, 4], 3, 1], [[3, 5]]), ('partial-repair probe', [[2, 2, 4, 2, 2, 2, 2, 2], 7, 4], [[4, 7]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[1, 3, 3, 3, 0, 0, 3, 3], 8, 8], []), ('control layout', [[2, 2, 2, 2, 2, 4, 4, 4, 3, 3, 3], 10, 11], [[5, 6]])]]\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":"8ca99e755671cbb5e3edb762933f7699af3ba0db5f8b243aa0b7aeb6e7b80d96","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 = [pos[i] for i in range(a, b)]\n    rects = []\n    for p in sel:\n        if rects and rects[-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 = [[('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('regression: slot sorting', [[0, 0, 0, 0, 2, 0, 0, 0, 3, 3, 0, 0], 12, 7], [[7, 12]]), ('partial-repair probe', [[0, 0, 0, 0, 0, 2, 0, 0, 1, 0], 8, 6], [[6, 8]]), ('partial-repair probe', [[2, 2, 2, 2, 1, 1, 4, 4, 4, 4, 1], 8, 6], [[1, 3]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[4, 4, 4, 4, 1, 1, 3], 1, 0], [[3, 4]]), ('control layout', [[2, 2, 2, 1, 1, 1, 1, 3, 3], 6, 5], [[3, 4]]), ('control layout', [[0], 1, 1], [])], [('regression: slot sorting', [[3, 3, 3, 3, 3, 3, 3, 2], 8, 4], [[0, 3], [7, 8]]), ('regression: slot sorting', [[1, 1, 1, 1, 3, 1, 1, 1, 2, 2, 2], 9, 3], [[0, 1], [3, 8]]), ('regression: slot sorting', [[3, 3, 3, 1, 1, 1, 2], 4, 2], [[3, 5]]), ('regression: slot sorting', [[3, 3, 3, 2, 2, 1, 1, 1, 1, 2, 2], 3, 8], [[3, 6], [9, 11]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[1, 2, 2, 2, 4, 4, 4, 4, 1, 1, 1], 10, 9], [[1, 2]]), ('control layout', [[1, 1, 2, 2, 2, 2, 1, 3, 3, 1, 1], 8, 9], [[2, 3]])], [('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('regression: slot sorting', [[1, 1, 1, 1, 4, 4, 3, 2, 2], 4, 7], [[0, 3]]), ('regression: slot sorting', [[1, 1, 1, 4, 4, 3, 3, 3, 2], 3, 7], [[1, 5]]), ('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]]), ('control layout', [[0, 0], 0, 0], []), ('control layout', [[3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2], 2, 1], [[9, 10]]), ('control layout', [[1, 1], 1, 1], [])], [('regression: slot sorting', [[4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1], 6, 11], [[0, 5]]), ('regression: slot sorting', [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3], 8, 3], [[4, 9]]), ('regression: slot sorting', [[3, 3, 3, 3, 2], 4, 2], [[0, 2]]), ('partial-repair probe', [[4, 2, 2, 2, 2, 2, 2, 2], 7, 1], [[1, 7]]), ('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, 0], []), ('control layout', [[1, 3, 3, 3, 3, 0, 0], 1, 0], [[4, 5]])], [('regression: slot sorting', [[0, 1, 1, 2, 2, 0, 0, 0, 0], 2, 8], [[1, 4], [5, 8]]), ('regression: slot sorting', [[2, 2, 1, 1], 4, 1], [[0, 2], [3, 4]]), ('regression: slot sorting', [[1, 1, 1, 4, 4, 4], 3, 1], [[3, 5]]), ('partial-repair probe', [[2, 2, 4, 2, 2, 2, 2, 2], 7, 4], [[4, 7]]), ('selection crossing direction change', [[0, 0, 1, 1, 0], 1, 4], [[1, 4]]), ('backward selection', [[1, 1, 1], 3, 1], [[0, 2]]), ('control layout', [[1, 3, 3, 3, 0, 0, 3, 3], 8, 8], []), ('control layout', [[2, 2, 2, 2, 2, 4, 4, 4, 3, 3, 3], 10, 11], [[5, 6]])]]\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-slot-sorting","generated_at":"2026-09-29T14:49:56.106345+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":"Visual slots are merged in logical order without sorting.","sha256":"6365b6d9ae91c6444ee56eb6a7aeccae2da0bbc794957f685dcd68d8d401b9b6","title":"Bidi selection highlight: slot sorting · 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.049,"exit_code":1,"observations":[{"actual":[[3,4],[2,3],[1,2]],"check":"selection crossing direction change","expected":[[1,4]],"passed":false},{"actual":[[11,12],[10,11],[9,10],[8,9],[7,8]],"check":"regression: slot sorting","expected":[[7,12]],"passed":false},{"actual":[[7,8],[6,7]],"check":"partial-repair probe","expected":[[6,8]],"passed":false},{"actual":[[2,3],[1,2]],"check":"partial-repair probe","expected":[[1,3]],"passed":false},{"actual":[[1,2],[0,1]],"check":"backward selection","expected":[[0,2]],"passed":false},{"actual":[[3,4]],"check":"control layout","expected":[[3,4]],"passed":true},{"actual":[[3,4]],"check":"control layout","expected":[[3,4]],"passed":true},{"actual":[],"check":"control layout","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"selection crossing direction change\", \"actual\": [[3, 4], [2, 3], [1, 2]], \"expected\": [[1, 4]], \"passed\": false}, {\"check\": \"regression: slot sorting\", \"actual\": [[11, 12], [10, 11], [9, 10], [8, 9], [7, 8]], \"expected\": [[7, 12]], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [[7, 8], [6, 7]], \"expected\": [[6, 8]], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [[2, 3], [1, 2]], \"expected\": [[1, 3]], \"passed\": false}, {\"check\": \"backward selection\", \"actual\": [[1, 2], [0, 1]], \"expected\": [[0, 2]], \"passed\": false}, {\"check\": \"control layout\", \"actual\": [[3, 4]], \"expected\": [[3, 4]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[3, 4]], \"expected\": [[3, 4]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.848,"exit_code":1,"observations":[{"actual":[[1,2],[3,4],[2,3]],"check":"selection crossing direction change","expected":[[1,4]],"passed":false},{"actual":[[7,8],[9,10],[8,9],[10,12]],"check":"regression: slot sorting","expected":[[7,12]],"passed":false},{"actual":[[6,8]],"check":"partial-repair probe","expected":[[6,8]],"passed":true},{"actual":[[1,3]],"check":"partial-repair probe","expected":[[1,3]],"passed":true},{"actual":[[1,2],[0,1]],"check":"backward selection","expected":[[0,2]],"passed":false},{"actual":[[3,4]],"check":"control layout","expected":[[3,4]],"passed":true},{"actual":[[3,4]],"check":"control layout","expected":[[3,4]],"passed":true},{"actual":[],"check":"control layout","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"selection crossing direction change\", \"actual\": [[1, 2], [3, 4], [2, 3]], \"expected\": [[1, 4]], \"passed\": false}, {\"check\": \"regression: slot sorting\", \"actual\": [[7, 8], [9, 10], [8, 9], [10, 12]], \"expected\": [[7, 12]], \"passed\": false}, {\"check\": \"partial-repair probe\", \"actual\": [[6, 8]], \"expected\": [[6, 8]], \"passed\": true}, {\"check\": \"partial-repair probe\", \"actual\": [[1, 3]], \"expected\": [[1, 3]], \"passed\": true}, {\"check\": \"backward selection\", \"actual\": [[1, 2], [0, 1]], \"expected\": [[0, 2]], \"passed\": false}, {\"check\": \"control layout\", \"actual\": [[3, 4]], \"expected\": [[3, 4]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[3, 4]], \"expected\": [[3, 4]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [], \"expected\": [], \"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."}}