{"abstract":"Runs at the lowest odd level stay in logical order.","category":"Bidirectional text layout","checks":8,"contract":"Input resolved levels of one line. From the highest level down to the lowest odd level on the line, reverse every maximal visual run of characters at that level or higher. Return logical indices in visual order (identity when no odd level).","contract_signature":"x","evaluation_group":"w2-bidirectional-text-layout-l2-reordering","failed_approach":"Starting one below the highest level skips the top pass.","family":"w2-bidirectional-text-layout-l2-reordering-reversal-loop-bound","id":"FA-80476","implementations":{"attempt":{"sha256":"5139651ec313046be82339159ca2cc5893820e5ed977cc89ab840e07f9d69ef6","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    levels = x\n    order = list(range(len(levels)))\n    odd = [l for l in levels if l % 2 == 1]\n    if not odd:\n        return order\n    hi = max(levels)\n    lo = min(odd)\n    vis = [[lv, i] for i, lv in enumerate(levels)]\n    for lev in range(hi - 1, lo - 1, -1):\n        i = 0\n        while i < len(vis):\n            if vis[i][0] >= lev:\n                j = i\n                while j < len(vis) and vis[j][0] >= lev:\n                    j += 1\n                vis[i:j] = vis[i:j][::-1]\n                i = j\n            else:\n                i += 1\n    return [p[1] for p in vis]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('regression: reversal loop bound', [3, 3, 3, 3, 1, 1, 1, 3, 3, 3], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]), ('regression: reversal loop bound', [3, 3, 3, 0, 0, 0, 2, 2, 2, 2], [2, 1, 0, 3, 4, 5, 6, 7, 8, 9]), ('regression: reversal loop bound', [1, 1, 2, 2, 3, 3, 2, 2], [2, 3, 5, 4, 6, 7, 1, 0]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('control layout', [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7]), ('control layout', [2], [0])], [('regression: reversal loop bound', [1, 1, 1, 1, 1, 1], [5, 4, 3, 2, 1, 0]), ('regression: reversal loop bound', [1, 1, 1], [2, 1, 0]), ('regression: reversal loop bound', [3, 0, 3, 3, 3, 3], [0, 1, 5, 4, 3, 2]), ('regression: reversal loop bound', [2, 2, 1, 1, 1], [4, 3, 2, 0, 1]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('control layout', [2, 2, 2], [0, 1, 2]), ('control layout', [2, 2], [0, 1])], [('regression: reversal loop bound', [1, 0, 0, 0, 2, 2, 2, 0, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8]), ('regression: reversal loop bound', [2, 2, 2, 0, 0, 1, 1, 1, 1, 1], [0, 1, 2, 3, 4, 9, 8, 7, 6, 5]), ('regression: reversal loop bound', [4, 4, 4, 1, 1, 1, 2], [6, 5, 4, 3, 0, 1, 2]), ('regression: reversal loop bound', [3, 3, 2, 2, 2, 2, 1, 1, 1], [8, 7, 6, 1, 0, 2, 3, 4, 5]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('control layout', [2, 2], [0, 1]), ('control layout', [4, 4], [0, 1])], [('regression: reversal loop bound', [1, 1, 1], [2, 1, 0]), ('regression: reversal loop bound', [1, 1, 1, 0, 0, 0, 0, 0, 0, 1], [2, 1, 0, 3, 4, 5, 6, 7, 8, 9]), ('regression: reversal loop bound', [0, 0, 0, 2, 0, 3, 3], [0, 1, 2, 3, 4, 6, 5]), ('regression: reversal loop bound', [1, 1, 1, 2, 2, 2], [3, 4, 5, 2, 1, 0]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('control layout', [1], [0]), ('control layout', [0, 0, 0, 0, 0], [0, 1, 2, 3, 4])], [('regression: reversal loop bound', [3, 1, 1, 2, 2], [3, 4, 2, 1, 0]), ('regression: reversal loop bound', [2, 2, 2, 2, 1, 1, 1, 1, 1], [8, 7, 6, 5, 4, 0, 1, 2, 3]), ('regression: reversal loop bound', [1, 1, 1, 3, 3, 3], [5, 4, 3, 2, 1, 0]), ('regression: reversal loop bound', [3, 2, 2, 2, 1, 1, 1, 4, 4, 4, 4, 1], [11, 7, 8, 9, 10, 6, 5, 4, 0, 1, 2, 3]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('control layout', [2], [0]), ('control layout', [0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])]]\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":"a9fe41627ddf3f3e197538d9b574c5a67c1eaa1cd3ae10427fdd4d6b230aed7c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    levels = x\n    order = list(range(len(levels)))\n    odd = [l for l in levels if l % 2 == 1]\n    if not odd:\n        return order\n    hi = max(levels)\n    lo = min(odd)\n    vis = [[lv, i] for i, lv in enumerate(levels)]\n    for lev in range(hi, lo, -1):\n        i = 0\n        while i < len(vis):\n            if vis[i][0] >= lev:\n                j = i\n                while j < len(vis) and vis[j][0] >= lev:\n                    j += 1\n                vis[i:j] = vis[i:j][::-1]\n                i = j\n            else:\n                i += 1\n    return [p[1] for p in vis]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('regression: reversal loop bound', [3, 3, 3, 3, 1, 1, 1, 3, 3, 3], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]), ('regression: reversal loop bound', [3, 3, 3, 0, 0, 0, 2, 2, 2, 2], [2, 1, 0, 3, 4, 5, 6, 7, 8, 9]), ('regression: reversal loop bound', [1, 1, 2, 2, 3, 3, 2, 2], [2, 3, 5, 4, 6, 7, 1, 0]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('control layout', [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7]), ('control layout', [2], [0])], [('regression: reversal loop bound', [1, 1, 1, 1, 1, 1], [5, 4, 3, 2, 1, 0]), ('regression: reversal loop bound', [1, 1, 1], [2, 1, 0]), ('regression: reversal loop bound', [3, 0, 3, 3, 3, 3], [0, 1, 5, 4, 3, 2]), ('regression: reversal loop bound', [2, 2, 1, 1, 1], [4, 3, 2, 0, 1]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('control layout', [2, 2, 2], [0, 1, 2]), ('control layout', [2, 2], [0, 1])], [('regression: reversal loop bound', [1, 0, 0, 0, 2, 2, 2, 0, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8]), ('regression: reversal loop bound', [2, 2, 2, 0, 0, 1, 1, 1, 1, 1], [0, 1, 2, 3, 4, 9, 8, 7, 6, 5]), ('regression: reversal loop bound', [4, 4, 4, 1, 1, 1, 2], [6, 5, 4, 3, 0, 1, 2]), ('regression: reversal loop bound', [3, 3, 2, 2, 2, 2, 1, 1, 1], [8, 7, 6, 1, 0, 2, 3, 4, 5]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('control layout', [2, 2], [0, 1]), ('control layout', [4, 4], [0, 1])], [('regression: reversal loop bound', [1, 1, 1], [2, 1, 0]), ('regression: reversal loop bound', [1, 1, 1, 0, 0, 0, 0, 0, 0, 1], [2, 1, 0, 3, 4, 5, 6, 7, 8, 9]), ('regression: reversal loop bound', [0, 0, 0, 2, 0, 3, 3], [0, 1, 2, 3, 4, 6, 5]), ('regression: reversal loop bound', [1, 1, 1, 2, 2, 2], [3, 4, 5, 2, 1, 0]), ('all even levels', [0, 2, 2, 0], [0, 1, 2, 3]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('control layout', [1], [0]), ('control layout', [0, 0, 0, 0, 0], [0, 1, 2, 3, 4])], [('regression: reversal loop bound', [3, 1, 1, 2, 2], [3, 4, 2, 1, 0]), ('regression: reversal loop bound', [2, 2, 2, 2, 1, 1, 1, 1, 1], [8, 7, 6, 5, 4, 0, 1, 2, 3]), ('regression: reversal loop bound', [1, 1, 1, 3, 3, 3], [5, 4, 3, 2, 1, 0]), ('regression: reversal loop bound', [3, 2, 2, 2, 1, 1, 1, 4, 4, 4, 4, 1], [11, 7, 8, 9, 10, 6, 5, 4, 0, 1, 2, 3]), ('number inside RTL', [1, 1, 2, 2, 1], [4, 2, 3, 1, 0]), ('lowest odd is three', [2, 3, 3, 2], [0, 2, 1, 3]), ('control layout', [2], [0]), ('control layout', [0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])]]\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-l2-reordering-reversal-loop-bound","generated_at":"2026-09-29T14:49:54.185948+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 level loop excludes its lower bound.","sha256":"7d406b1cea043f9b6b4b8e95a688a8881676ec356f61b72b999b9d59645e1ecd","title":"Visual reordering by levels: reversal loop bound · 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":43.283,"exit_code":1,"observations":[{"actual":[4,3,2,1,0],"check":"number inside RTL","expected":[4,2,3,1,0],"passed":false},{"actual":[7,8,9,6,5,4,0,1,2,3],"check":"regression: reversal loop bound","expected":[9,8,7,6,5,4,3,2,1,0],"passed":false},{"actual":[0,1,2,3,4,5,6,7,8,9],"check":"regression: reversal loop bound","expected":[2,1,0,3,4,5,6,7,8,9],"passed":false},{"actual":[2,3,4,5,6,7,1,0],"check":"regression: reversal loop bound","expected":[2,3,5,4,6,7,1,0],"passed":false},{"actual":[0,1,2,3],"check":"lowest odd is three","expected":[0,2,1,3],"passed":false},{"actual":[0,1,2,3],"check":"all even levels","expected":[0,1,2,3],"passed":true},{"actual":[0,1,2,3,4,5,6,7],"check":"control layout","expected":[0,1,2,3,4,5,6,7],"passed":true},{"actual":[0],"check":"control layout","expected":[0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"number inside RTL\", \"actual\": [4, 3, 2, 1, 0], \"expected\": [4, 2, 3, 1, 0], \"passed\": false}, {\"check\": \"regression: reversal loop bound\", \"actual\": [7, 8, 9, 6, 5, 4, 0, 1, 2, 3], \"expected\": [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], \"passed\": false}, {\"check\": \"regression: reversal loop bound\", \"actual\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], \"expected\": [2, 1, 0, 3, 4, 5, 6, 7, 8, 9], \"passed\": false}, {\"check\": \"regression: reversal loop bound\", \"actual\": [2, 3, 4, 5, 6, 7, 1, 0], \"expected\": [2, 3, 5, 4, 6, 7, 1, 0], \"passed\": false}, {\"check\": \"lowest odd is three\", \"actual\": [0, 1, 2, 3], \"expected\": [0, 2, 1, 3], \"passed\": false}, {\"check\": \"all even levels\", \"actual\": [0, 1, 2, 3], \"expected\": [0, 1, 2, 3], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [0, 1, 2, 3, 4, 5, 6, 7], \"expected\": [0, 1, 2, 3, 4, 5, 6, 7], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [0], \"expected\": [0], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.197,"exit_code":1,"observations":[{"actual":[0,1,3,2,4],"check":"number inside RTL","expected":[4,2,3,1,0],"passed":false},{"actual":[0,1,2,3,4,5,6,7,8,9],"check":"regression: reversal loop bound","expected":[9,8,7,6,5,4,3,2,1,0],"passed":false},{"actual":[0,1,2,3,4,5,6,7,8,9],"check":"regression: reversal loop bound","expected":[2,1,0,3,4,5,6,7,8,9],"passed":false},{"actual":[0,1,7,6,4,5,3,2],"check":"regression: reversal loop bound","expected":[2,3,5,4,6,7,1,0],"passed":false},{"actual":[0,1,2,3],"check":"lowest odd is three","expected":[0,2,1,3],"passed":false},{"actual":[0,1,2,3],"check":"all even levels","expected":[0,1,2,3],"passed":true},{"actual":[0,1,2,3,4,5,6,7],"check":"control layout","expected":[0,1,2,3,4,5,6,7],"passed":true},{"actual":[0],"check":"control layout","expected":[0],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"number inside RTL\", \"actual\": [0, 1, 3, 2, 4], \"expected\": [4, 2, 3, 1, 0], \"passed\": false}, {\"check\": \"regression: reversal loop bound\", \"actual\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], \"expected\": [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], \"passed\": false}, {\"check\": \"regression: reversal loop bound\", \"actual\": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], \"expected\": [2, 1, 0, 3, 4, 5, 6, 7, 8, 9], \"passed\": false}, {\"check\": \"regression: reversal loop bound\", \"actual\": [0, 1, 7, 6, 4, 5, 3, 2], \"expected\": [2, 3, 5, 4, 6, 7, 1, 0], \"passed\": false}, {\"check\": \"lowest odd is three\", \"actual\": [0, 1, 2, 3], \"expected\": [0, 2, 1, 3], \"passed\": false}, {\"check\": \"all even levels\", \"actual\": [0, 1, 2, 3], \"expected\": [0, 1, 2, 3], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [0, 1, 2, 3, 4, 5, 6, 7], \"expected\": [0, 1, 2, 3, 4, 5, 6, 7], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [0], \"expected\": [0], \"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."}}