{"abstract":"Runs report lengths one short, dropping their last glyph.","category":"Bidirectional text layout","checks":8,"contract":"Input resolved levels of a line. Group maximal equal-level runs [logical start, length, level]; reorder whole runs from the highest level down to the lowest odd level by reversing sequences of runs at or above the level. Return [[start, length, \"rtl\"|\"ltr\"]] in visual order.","contract_signature":"x","evaluation_group":"w2-bidirectional-text-layout-visual-run-list","failed_approach":"Storing the absolute index as the length is wrong for runs not at the line start.","family":"w2-bidirectional-text-layout-visual-run-list-run-length-accumulation","id":"FA-80791","implementations":{"attempt":{"sha256":"f2888e1a75153ed53e9909dcde776b8c9eb1c619ad785b8d2308aff28610cc8f","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    levels = x\n    n = len(levels)\n    runs = []\n    for i in range(n):\n        if runs and runs[-1][2] == levels[i]:\n            runs[-1][1] = i\n        else:\n            runs.append([i, 1, levels[i]])\n    if not runs:\n        return []\n    odd = [r[2] for r in runs if r[2] % 2]\n    if odd:\n        for lev in range(max(r[2] for r in runs), min(odd) - 1, -1):\n            out, i = [], 0\n            while i < len(runs):\n                if runs[i][2] >= lev:\n                    j = i\n                    while j < len(runs) and runs[j][2] >= lev:\n                        j += 1\n                    out.extend(runs[i:j][::-1])\n                    i = j\n                else:\n                    out.append(runs[i])\n                    i += 1\n            runs = out\n    return [[s, ln, 'rtl' if lv % 2 else 'ltr'] for s, ln, lv in runs]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1, 0, 0, 0], [[2, 5, 'rtl'], [0, 2, 'ltr'], [7, 3, 'ltr']]), ('regression: run length accumulation', [4, 3, 3, 2, 2, 4], [[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 2, 'ltr'], [5, 1, 'ltr']]), ('regression: run length accumulation', [1, 1, 2, 4, 4, 4, 2, 2, 2, 2, 4, 4], [[2, 1, 'ltr'], [3, 3, 'ltr'], [6, 4, 'ltr'], [10, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']])], [('regression: run length accumulation', [2, 2, 2, 3, 3, 3, 3, 2], [[0, 3, 'ltr'], [3, 4, 'rtl'], [7, 1, 'ltr']]), ('regression: run length accumulation', [2, 2, 1], [[2, 1, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [1, 1, 1, 1, 1, 1, 1], [[0, 7, 'rtl']]), ('regression: run length accumulation', [0, 0, 0], [[0, 3, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [1], [[0, 1, 'rtl']]), ('control layout', [3], [[0, 1, 'rtl']])], [('regression: run length accumulation', [1, 1], [[0, 2, 'rtl']]), ('regression: run length accumulation', [1, 1, 3, 1, 1, 1, 1, 2, 2], [[7, 2, 'ltr'], [3, 4, 'rtl'], [2, 1, 'rtl'], [0, 2, 'rtl']]), ('regression: run length accumulation', [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [[0, 6, 'ltr'], [6, 4, 'rtl']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1], [[4, 2, 'rtl'], [0, 4, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2, 3], [[0, 1, 'ltr'], [1, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']])], [('regression: run length accumulation', [3, 3, 3, 0, 0, 0, 0, 0, 0], [[0, 3, 'rtl'], [3, 6, 'ltr']]), ('regression: run length accumulation', [1, 1, 1], [[0, 3, 'rtl']]), ('regression: run length accumulation', [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1], [[0, 2, 'ltr'], [3, 8, 'rtl'], [2, 1, 'rtl']]), ('regression: run length accumulation', [2, 2, 0, 0, 0, 0, 1, 1, 0], [[0, 2, 'ltr'], [2, 4, 'ltr'], [6, 2, 'rtl'], [8, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']]), ('control layout', [1], [[0, 1, 'rtl']])], [('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1], [[2, 5, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 1, 2], [[11, 1, 'ltr'], [10, 1, 'rtl'], [8, 2, 'rtl'], [4, 4, 'rtl'], [0, 4, 'ltr']]), ('regression: run length accumulation', [1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [[1, 2, 'rtl'], [0, 1, 'rtl'], [3, 9, 'ltr']]), ('regression: run length accumulation', [2, 4, 4, 1, 1, 1, 1, 2], [[7, 1, 'ltr'], [3, 4, 'rtl'], [0, 1, 'ltr'], [1, 2, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']])]]\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":"9935ace46057cbbd32598677aba2a8d1fd284a430e47ffa1b800fe3dfe0094d9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    levels = x\n    n = len(levels)\n    runs = []\n    for i in range(n):\n        if runs and runs[-1][2] == levels[i]:\n            runs[-1][1] = i - runs[-1][0]\n        else:\n            runs.append([i, 1, levels[i]])\n    if not runs:\n        return []\n    odd = [r[2] for r in runs if r[2] % 2]\n    if odd:\n        for lev in range(max(r[2] for r in runs), min(odd) - 1, -1):\n            out, i = [], 0\n            while i < len(runs):\n                if runs[i][2] >= lev:\n                    j = i\n                    while j < len(runs) and runs[j][2] >= lev:\n                        j += 1\n                    out.extend(runs[i:j][::-1])\n                    i = j\n                else:\n                    out.append(runs[i])\n                    i += 1\n            runs = out\n    return [[s, ln, 'rtl' if lv % 2 else 'ltr'] for s, ln, lv in runs]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1, 0, 0, 0], [[2, 5, 'rtl'], [0, 2, 'ltr'], [7, 3, 'ltr']]), ('regression: run length accumulation', [4, 3, 3, 2, 2, 4], [[1, 2, 'rtl'], [0, 1, 'ltr'], [3, 2, 'ltr'], [5, 1, 'ltr']]), ('regression: run length accumulation', [1, 1, 2, 4, 4, 4, 2, 2, 2, 2, 4, 4], [[2, 1, 'ltr'], [3, 3, 'ltr'], [6, 4, 'ltr'], [10, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']])], [('regression: run length accumulation', [2, 2, 2, 3, 3, 3, 3, 2], [[0, 3, 'ltr'], [3, 4, 'rtl'], [7, 1, 'ltr']]), ('regression: run length accumulation', [2, 2, 1], [[2, 1, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [1, 1, 1, 1, 1, 1, 1], [[0, 7, 'rtl']]), ('regression: run length accumulation', [0, 0, 0], [[0, 3, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [1], [[0, 1, 'rtl']]), ('control layout', [3], [[0, 1, 'rtl']])], [('regression: run length accumulation', [1, 1], [[0, 2, 'rtl']]), ('regression: run length accumulation', [1, 1, 3, 1, 1, 1, 1, 2, 2], [[7, 2, 'ltr'], [3, 4, 'rtl'], [2, 1, 'rtl'], [0, 2, 'rtl']]), ('regression: run length accumulation', [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [[0, 6, 'ltr'], [6, 4, 'rtl']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1], [[4, 2, 'rtl'], [0, 4, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2, 3], [[0, 1, 'ltr'], [1, 1, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']])], [('regression: run length accumulation', [3, 3, 3, 0, 0, 0, 0, 0, 0], [[0, 3, 'rtl'], [3, 6, 'ltr']]), ('regression: run length accumulation', [1, 1, 1], [[0, 3, 'rtl']]), ('regression: run length accumulation', [0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1], [[0, 2, 'ltr'], [3, 8, 'rtl'], [2, 1, 'rtl']]), ('regression: run length accumulation', [2, 2, 0, 0, 0, 0, 1, 1, 0], [[0, 2, 'ltr'], [2, 4, 'ltr'], [6, 2, 'rtl'], [8, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('control layout', [0], [[0, 1, 'ltr']]), ('control layout', [1], [[0, 1, 'rtl']])], [('regression: run length accumulation', [2, 2, 1, 1, 1, 1, 1], [[2, 5, 'rtl'], [0, 2, 'ltr']]), ('regression: run length accumulation', [2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 1, 2], [[11, 1, 'ltr'], [10, 1, 'rtl'], [8, 2, 'rtl'], [4, 4, 'rtl'], [0, 4, 'ltr']]), ('regression: run length accumulation', [1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [[1, 2, 'rtl'], [0, 1, 'rtl'], [3, 9, 'ltr']]), ('regression: run length accumulation', [2, 4, 4, 1, 1, 1, 1, 2], [[7, 1, 'ltr'], [3, 4, 'rtl'], [0, 1, 'ltr'], [1, 2, 'ltr']]), ('lowest odd is three', [2, 3, 2], [[0, 1, 'ltr'], [1, 1, 'rtl'], [2, 1, 'ltr']]), ('LTR number inside RTL', [1, 1, 2, 2, 1], [[4, 1, 'rtl'], [2, 2, 'ltr'], [0, 2, 'rtl']]), ('control layout', [2], [[0, 1, 'ltr']]), ('control layout', [3], [[0, 1, 'rtl']])]]\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-visual-run-list-run-length-accumulation","generated_at":"2026-09-29T14:49:57.096746+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 run length is recomputed from the start index without counting the current character.","sha256":"a3932248dded3c52df36d7a3c125ba3f9ff5b79fdbc63b5d9339170529502a8f","title":"Visual run list for shaping: run length accumulation · 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.687,"exit_code":1,"observations":[{"actual":[[4,1,"rtl"],[2,3,"ltr"],[0,1,"rtl"]],"check":"LTR number inside RTL","expected":[[4,1,"rtl"],[2,2,"ltr"],[0,2,"rtl"]],"passed":false},{"actual":[[2,6,"rtl"],[0,1,"ltr"],[7,9,"ltr"]],"check":"regression: run length accumulation","expected":[[2,5,"rtl"],[0,2,"ltr"],[7,3,"ltr"]],"passed":false},{"actual":[[1,2,"rtl"],[0,1,"ltr"],[3,4,"ltr"],[5,1,"ltr"]],"check":"regression: run length accumulation","expected":[[1,2,"rtl"],[0,1,"ltr"],[3,2,"ltr"],[5,1,"ltr"]],"passed":false},{"actual":[[2,1,"ltr"],[3,5,"ltr"],[6,9,"ltr"],[10,11,"ltr"],[0,1,"rtl"]],"check":"regression: run length accumulation","expected":[[2,1,"ltr"],[3,3,"ltr"],[6,4,"ltr"],[10,2,"ltr"],[0,2,"rtl"]],"passed":false},{"actual":[[0,1,"ltr"],[1,1,"rtl"],[2,1,"ltr"]],"check":"lowest odd is three","expected":[[0,1,"ltr"],[1,1,"rtl"],[2,1,"ltr"]],"passed":true},{"actual":[[0,1,"rtl"]],"check":"control layout","expected":[[0,1,"rtl"]],"passed":true},{"actual":[[0,1,"ltr"]],"check":"control layout","expected":[[0,1,"ltr"]],"passed":true},{"actual":[[0,1,"ltr"]],"check":"control layout","expected":[[0,1,"ltr"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"LTR number inside RTL\", \"actual\": [[4, 1, \"rtl\"], [2, 3, \"ltr\"], [0, 1, \"rtl\"]], \"expected\": [[4, 1, \"rtl\"], [2, 2, \"ltr\"], [0, 2, \"rtl\"]], \"passed\": false}, {\"check\": \"regression: run length accumulation\", \"actual\": [[2, 6, \"rtl\"], [0, 1, \"ltr\"], [7, 9, \"ltr\"]], \"expected\": [[2, 5, \"rtl\"], [0, 2, \"ltr\"], [7, 3, \"ltr\"]], \"passed\": false}, {\"check\": \"regression: run length accumulation\", \"actual\": [[1, 2, \"rtl\"], [0, 1, \"ltr\"], [3, 4, \"ltr\"], [5, 1, \"ltr\"]], \"expected\": [[1, 2, \"rtl\"], [0, 1, \"ltr\"], [3, 2, \"ltr\"], [5, 1, \"ltr\"]], \"passed\": false}, {\"check\": \"regression: run length accumulation\", \"actual\": [[2, 1, \"ltr\"], [3, 5, \"ltr\"], [6, 9, \"ltr\"], [10, 11, \"ltr\"], [0, 1, \"rtl\"]], \"expected\": [[2, 1, \"ltr\"], [3, 3, \"ltr\"], [6, 4, \"ltr\"], [10, 2, \"ltr\"], [0, 2, \"rtl\"]], \"passed\": false}, {\"check\": \"lowest odd is three\", \"actual\": [[0, 1, \"ltr\"], [1, 1, \"rtl\"], [2, 1, \"ltr\"]], \"expected\": [[0, 1, \"ltr\"], [1, 1, \"rtl\"], [2, 1, \"ltr\"]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[0, 1, \"rtl\"]], \"expected\": [[0, 1, \"rtl\"]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[0, 1, \"ltr\"]], \"expected\": [[0, 1, \"ltr\"]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[0, 1, \"ltr\"]], \"expected\": [[0, 1, \"ltr\"]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.443,"exit_code":1,"observations":[{"actual":[[4,1,"rtl"],[2,1,"ltr"],[0,1,"rtl"]],"check":"LTR number inside RTL","expected":[[4,1,"rtl"],[2,2,"ltr"],[0,2,"rtl"]],"passed":false},{"actual":[[2,4,"rtl"],[0,1,"ltr"],[7,2,"ltr"]],"check":"regression: run length accumulation","expected":[[2,5,"rtl"],[0,2,"ltr"],[7,3,"ltr"]],"passed":false},{"actual":[[1,1,"rtl"],[0,1,"ltr"],[3,1,"ltr"],[5,1,"ltr"]],"check":"regression: run length accumulation","expected":[[1,2,"rtl"],[0,1,"ltr"],[3,2,"ltr"],[5,1,"ltr"]],"passed":false},{"actual":[[2,1,"ltr"],[3,2,"ltr"],[6,3,"ltr"],[10,1,"ltr"],[0,1,"rtl"]],"check":"regression: run length accumulation","expected":[[2,1,"ltr"],[3,3,"ltr"],[6,4,"ltr"],[10,2,"ltr"],[0,2,"rtl"]],"passed":false},{"actual":[[0,1,"ltr"],[1,1,"rtl"],[2,1,"ltr"]],"check":"lowest odd is three","expected":[[0,1,"ltr"],[1,1,"rtl"],[2,1,"ltr"]],"passed":true},{"actual":[[0,1,"rtl"]],"check":"control layout","expected":[[0,1,"rtl"]],"passed":true},{"actual":[[0,1,"ltr"]],"check":"control layout","expected":[[0,1,"ltr"]],"passed":true},{"actual":[[0,1,"ltr"]],"check":"control layout","expected":[[0,1,"ltr"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"LTR number inside RTL\", \"actual\": [[4, 1, \"rtl\"], [2, 1, \"ltr\"], [0, 1, \"rtl\"]], \"expected\": [[4, 1, \"rtl\"], [2, 2, \"ltr\"], [0, 2, \"rtl\"]], \"passed\": false}, {\"check\": \"regression: run length accumulation\", \"actual\": [[2, 4, \"rtl\"], [0, 1, \"ltr\"], [7, 2, \"ltr\"]], \"expected\": [[2, 5, \"rtl\"], [0, 2, \"ltr\"], [7, 3, \"ltr\"]], \"passed\": false}, {\"check\": \"regression: run length accumulation\", \"actual\": [[1, 1, \"rtl\"], [0, 1, \"ltr\"], [3, 1, \"ltr\"], [5, 1, \"ltr\"]], \"expected\": [[1, 2, \"rtl\"], [0, 1, \"ltr\"], [3, 2, \"ltr\"], [5, 1, \"ltr\"]], \"passed\": false}, {\"check\": \"regression: run length accumulation\", \"actual\": [[2, 1, \"ltr\"], [3, 2, \"ltr\"], [6, 3, \"ltr\"], [10, 1, \"ltr\"], [0, 1, \"rtl\"]], \"expected\": [[2, 1, \"ltr\"], [3, 3, \"ltr\"], [6, 4, \"ltr\"], [10, 2, \"ltr\"], [0, 2, \"rtl\"]], \"passed\": false}, {\"check\": \"lowest odd is three\", \"actual\": [[0, 1, \"ltr\"], [1, 1, \"rtl\"], [2, 1, \"ltr\"]], \"expected\": [[0, 1, \"ltr\"], [1, 1, \"rtl\"], [2, 1, \"ltr\"]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[0, 1, \"rtl\"]], \"expected\": [[0, 1, \"rtl\"]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[0, 1, \"ltr\"]], \"expected\": [[0, 1, \"ltr\"]], \"passed\": true}, {\"check\": \"control layout\", \"actual\": [[0, 1, \"ltr\"]], \"expected\": [[0, 1, \"ltr\"]], \"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."}}