{"abstract":"Data such as \"1234567A\" produces a set C segment containing \"7A\".","category":"Barcode symbology encoding","checks":8,"contract":"Plan Code 128 code sets for printable ASCII data (other characters -> None) as a list of [set, text] segments. Start in C when the data begins with at least 4 digits or is entirely digits of even length >= 2, else B. In C consume digit pairs and fall back to B when fewer than two digits remain in the run. In B switch to C before a run of at least 6 digits, or at least 4 digits that reach the end of the data; an odd run first encodes one digit in B. Empty data yields [[\"B\", \"\"]].","evaluation_group":"w2-barcode-symbology-encoding-code128-codeset-plan","failed_approach":"Requiring three digits leaves a final pair in B unnecessarily.","family":"w2-barcode-symbology-encoding-code128-codeset-plan-c-exit","id":"FA-79421","implementations":{"attempt":{"sha256":"7f4ac64d0fd289f60f59b4e7fc363b51e4fdb0af88d2885d4a0b5736f2949c29","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(data):\n    if any(not (32 <= ord(ch) <= 126) for ch in data):\n        return None\n    n = len(data)\n    def run(j):\n        k = j\n        while k < n and data[k] in '0123456789':\n            k += 1\n        return k - j\n    segs = []\n    r = run(0)\n    if r >= 4 or (r == n and n >= 2 and n % 2 == 0):\n        cur = 'C'\n    else:\n        cur = 'B'\n    buf = ''\n    i = 0\n    while i < n:\n        if cur == 'C':\n            if run(i) >= 3:\n                buf += data[i:i + 2]\n                i += 2\n                continue\n            segs.append(['C', buf])\n            buf = ''\n            cur = 'B'\n            continue\n        r = run(i)\n        if r >= 6 or (r >= 4 and i + r == n):\n            if r % 2 == 1:\n                buf += data[i]\n                i += 1\n            if buf:\n                segs.append(['B', buf])\n            buf = ''\n            cur = 'C'\n            continue\n        buf += data[i]\n        i += 1\n    if buf or not segs:\n        segs.append([cur, buf])\n    return segs\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['3580131', [['C', '358013'], ['B', '1']]], ['lot17764124x', [['B', 'lot'], ['C', '17764124'], ['B', 'x']]], ['38872Q7088', [['C', '3887'], ['B', '2Q'], ['C', '7088']]], ['xAB', [['B', 'xAB']]], ['AB', [['B', 'AB']]], ['x15', [['B', 'x15']]], ['-', [['B', '-']]], ['83397787832796279-', [['C', '8339778783279627'], ['B', '9-']]]], [['101874486507729', [['C', '10187448650772'], ['B', '9']]], ['82', [['C', '82']]], ['27762 510832', [['C', '2776'], ['B', '2 '], ['C', '510832']]], ['x22', [['B', 'x22']]], [' ', [['B', ' ']]], ['-006', [['B', '-006']]], ['-018', [['B', '-018']]], ['7825577', [['C', '782557'], ['B', '7']]]], [['987793180x', [['C', '98779318'], ['B', '0x']]], ['2921977210', [['C', '2921977210']]], ['99310234894799114-3320', [['C', '9931023489479911'], ['B', '4-'], ['C', '3320']]], ['lot', [['B', 'lot']]], ['1', [['B', '1']]], ['Q7 lotAB', [['B', 'Q7 lotAB']]], ['-00331 ', [['B', '-00331 ']]], ['9912416511515', [['C', '991241651151'], ['B', '5']]]], [['14789849620002739', [['C', '1478984962000273'], ['B', '9']]], ['67847770x7233496217', [['C', '67847770'], ['B', 'x'], ['C', '7233496217']]], ['253922686 -236376801', [['C', '25392268'], ['B', '6 -2'], ['C', '36376801']]], ['lot5899 ', [['B', 'lot5899 ']]], [' Q7', [['B', ' Q7']]], ['-', [['B', '-']]], ['lot', [['B', 'lot']]], ['3807356726022 ', [['C', '380735672602'], ['B', '2 ']]]], [['849552989677181287350031242482230', [['C', '84955298967718128735003124248223'], ['B', '0']]], ['3283655059x2996', [['C', '3283655059'], ['B', 'x'], ['C', '2996']]], ['32998293100126533-08028467', [['C', '3299829310012653'], ['B', '3-'], ['C', '08028467']]], ['x619--', [['B', 'x619--']]], ['113 ', [['B', '113 ']]], [' 10-Q7', [['B', ' 10-Q7']]], ['AB', [['B', 'AB']]], ['5776132lot', [['C', '577613'], ['B', '2lot']]]]]\nlabels = [\"regression: set C exit condition\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), 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":"5beb983211e4f071223f00b41b507256889aa003e5bf8eb8509b54573e8c6ba9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(data):\n    if any(not (32 <= ord(ch) <= 126) for ch in data):\n        return None\n    n = len(data)\n    def run(j):\n        k = j\n        while k < n and data[k] in '0123456789':\n            k += 1\n        return k - j\n    segs = []\n    r = run(0)\n    if r >= 4 or (r == n and n >= 2 and n % 2 == 0):\n        cur = 'C'\n    else:\n        cur = 'B'\n    buf = ''\n    i = 0\n    while i < n:\n        if cur == 'C':\n            if run(i) >= 1:\n                buf += data[i:i + 2]\n                i += 2\n                continue\n            segs.append(['C', buf])\n            buf = ''\n            cur = 'B'\n            continue\n        r = run(i)\n        if r >= 6 or (r >= 4 and i + r == n):\n            if r % 2 == 1:\n                buf += data[i]\n                i += 1\n            if buf:\n                segs.append(['B', buf])\n            buf = ''\n            cur = 'C'\n            continue\n        buf += data[i]\n        i += 1\n    if buf or not segs:\n        segs.append([cur, buf])\n    return segs\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['3580131', [['C', '358013'], ['B', '1']]], ['lot17764124x', [['B', 'lot'], ['C', '17764124'], ['B', 'x']]], ['38872Q7088', [['C', '3887'], ['B', '2Q'], ['C', '7088']]], ['xAB', [['B', 'xAB']]], ['AB', [['B', 'AB']]], ['x15', [['B', 'x15']]], ['-', [['B', '-']]], ['83397787832796279-', [['C', '8339778783279627'], ['B', '9-']]]], [['101874486507729', [['C', '10187448650772'], ['B', '9']]], ['82', [['C', '82']]], ['27762 510832', [['C', '2776'], ['B', '2 '], ['C', '510832']]], ['x22', [['B', 'x22']]], [' ', [['B', ' ']]], ['-006', [['B', '-006']]], ['-018', [['B', '-018']]], ['7825577', [['C', '782557'], ['B', '7']]]], [['987793180x', [['C', '98779318'], ['B', '0x']]], ['2921977210', [['C', '2921977210']]], ['99310234894799114-3320', [['C', '9931023489479911'], ['B', '4-'], ['C', '3320']]], ['lot', [['B', 'lot']]], ['1', [['B', '1']]], ['Q7 lotAB', [['B', 'Q7 lotAB']]], ['-00331 ', [['B', '-00331 ']]], ['9912416511515', [['C', '991241651151'], ['B', '5']]]], [['14789849620002739', [['C', '1478984962000273'], ['B', '9']]], ['67847770x7233496217', [['C', '67847770'], ['B', 'x'], ['C', '7233496217']]], ['253922686 -236376801', [['C', '25392268'], ['B', '6 -2'], ['C', '36376801']]], ['lot5899 ', [['B', 'lot5899 ']]], [' Q7', [['B', ' Q7']]], ['-', [['B', '-']]], ['lot', [['B', 'lot']]], ['3807356726022 ', [['C', '380735672602'], ['B', '2 ']]]], [['849552989677181287350031242482230', [['C', '84955298967718128735003124248223'], ['B', '0']]], ['3283655059x2996', [['C', '3283655059'], ['B', 'x'], ['C', '2996']]], ['32998293100126533-08028467', [['C', '3299829310012653'], ['B', '3-'], ['C', '08028467']]], ['x619--', [['B', 'x619--']]], ['113 ', [['B', '113 ']]], [' 10-Q7', [['B', ' 10-Q7']]], ['AB', [['B', 'AB']]], ['5776132lot', [['C', '577613'], ['B', '2lot']]]]]\nlabels = [\"regression: set C exit condition\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), 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":"15f515ef8e736d0c0f89c1ff3e5585ea59adfbdb4f2332c02d45df25632f5b15","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(data):\n    if any(not (32 <= ord(ch) <= 126) for ch in data):\n        return None\n    n = len(data)\n    def run(j):\n        k = j\n        while k < n and data[k] in '0123456789':\n            k += 1\n        return k - j\n    segs = []\n    r = run(0)\n    if r >= 4 or (r == n and n >= 2 and n % 2 == 0):\n        cur = 'C'\n    else:\n        cur = 'B'\n    buf = ''\n    i = 0\n    while i < n:\n        if cur == 'C':\n            if run(i) >= 2:\n                buf += data[i:i + 2]\n                i += 2\n                continue\n            segs.append(['C', buf])\n            buf = ''\n            cur = 'B'\n            continue\n        r = run(i)\n        if r >= 6 or (r >= 4 and i + r == n):\n            if r % 2 == 1:\n                buf += data[i]\n                i += 1\n            if buf:\n                segs.append(['B', buf])\n            buf = ''\n            cur = 'C'\n            continue\n        buf += data[i]\n        i += 1\n    if buf or not segs:\n        segs.append([cur, buf])\n    return segs\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['3580131', [['C', '358013'], ['B', '1']]], ['lot17764124x', [['B', 'lot'], ['C', '17764124'], ['B', 'x']]], ['38872Q7088', [['C', '3887'], ['B', '2Q'], ['C', '7088']]], ['xAB', [['B', 'xAB']]], ['AB', [['B', 'AB']]], ['x15', [['B', 'x15']]], ['-', [['B', '-']]], ['83397787832796279-', [['C', '8339778783279627'], ['B', '9-']]]], [['101874486507729', [['C', '10187448650772'], ['B', '9']]], ['82', [['C', '82']]], ['27762 510832', [['C', '2776'], ['B', '2 '], ['C', '510832']]], ['x22', [['B', 'x22']]], [' ', [['B', ' ']]], ['-006', [['B', '-006']]], ['-018', [['B', '-018']]], ['7825577', [['C', '782557'], ['B', '7']]]], [['987793180x', [['C', '98779318'], ['B', '0x']]], ['2921977210', [['C', '2921977210']]], ['99310234894799114-3320', [['C', '9931023489479911'], ['B', '4-'], ['C', '3320']]], ['lot', [['B', 'lot']]], ['1', [['B', '1']]], ['Q7 lotAB', [['B', 'Q7 lotAB']]], ['-00331 ', [['B', '-00331 ']]], ['9912416511515', [['C', '991241651151'], ['B', '5']]]], [['14789849620002739', [['C', '1478984962000273'], ['B', '9']]], ['67847770x7233496217', [['C', '67847770'], ['B', 'x'], ['C', '7233496217']]], ['253922686 -236376801', [['C', '25392268'], ['B', '6 -2'], ['C', '36376801']]], ['lot5899 ', [['B', 'lot5899 ']]], [' Q7', [['B', ' Q7']]], ['-', [['B', '-']]], ['lot', [['B', 'lot']]], ['3807356726022 ', [['C', '380735672602'], ['B', '2 ']]]], [['849552989677181287350031242482230', [['C', '84955298967718128735003124248223'], ['B', '0']]], ['3283655059x2996', [['C', '3283655059'], ['B', 'x'], ['C', '2996']]], ['32998293100126533-08028467', [['C', '3299829310012653'], ['B', '3-'], ['C', '08028467']]], ['x619--', [['B', 'x619--']]], ['113 ', [['B', '113 ']]], [' 10-Q7', [['B', ' 10-Q7']]], ['AB', [['B', 'AB']]], ['5776132lot', [['C', '577613'], ['B', '2lot']]]]]\nlabels = [\"regression: set C exit condition\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), 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 bounded teaching model with a stipulated contract; it makes no claim of conformance to any published specification. 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-barcode-symbology-encoding-code128-codeset-plan-c-exit","generated_at":"2026-09-29T14:49:44.436411+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Retail, logistics, pharmacy and document workflows depend on encoders that produce exactly the module pattern, code-set switches, separators and quiet zones scanners expect; one misplaced module or separator makes a label unreadable or, worse, scan as different data.","repair":"Stay in C only while at least two digits remain in the run.","root_cause":"The C loop continues while one digit remains, so the pair can include a non-digit.","sha256":"bcb2b42c78b160f5d2c9e27b44380d7997ac1a87d2bae3f50d39d23612df5a4e","title":"Set C pairs a digit with a following letter · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":42.869,"exit_code":1,"observations":[{"actual":[["C","358013"],["B","1"]],"check":"regression: set C exit condition 0","expected":[["C","358013"],["B","1"]],"passed":true},{"actual":[["B","lot"],["C","177641"],["B","24x"]],"check":"repair trap 1","expected":[["B","lot"],["C","17764124"],["B","x"]],"passed":false},{"actual":[["C","3887"],["B","2Q"],["C","70"],["B","88"]],"check":"combined fault 2","expected":[["C","3887"],["B","2Q"],["C","7088"]],"passed":false},{"actual":[["B","xAB"]],"check":"control 3","expected":[["B","xAB"]],"passed":true},{"actual":[["B","AB"]],"check":"control 4","expected":[["B","AB"]],"passed":true},{"actual":[["B","x15"]],"check":"boundary 5","expected":[["B","x15"]],"passed":true},{"actual":[["B","-"]],"check":"boundary 6","expected":[["B","-"]],"passed":true},{"actual":[["C","8339778783279627"],["B","9-"]],"check":"control 7","expected":[["C","8339778783279627"],["B","9-"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: set C exit condition 0\", \"actual\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"expected\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [[\"B\", \"lot\"], [\"C\", \"177641\"], [\"B\", \"24x\"]], \"expected\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": [[\"C\", \"3887\"], [\"B\", \"2Q\"], [\"C\", \"70\"], [\"B\", \"88\"]], \"expected\": [[\"C\", \"3887\"], [\"B\", \"2Q\"], [\"C\", \"7088\"]], \"passed\": false}, {\"check\": \"control 3\", \"actual\": [[\"B\", \"xAB\"]], \"expected\": [[\"B\", \"xAB\"]], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [[\"B\", \"AB\"]], \"expected\": [[\"B\", \"AB\"]], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [[\"B\", \"x15\"]], \"expected\": [[\"B\", \"x15\"]], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [[\"B\", \"-\"]], \"expected\": [[\"B\", \"-\"]], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [[\"C\", \"8339778783279627\"], [\"B\", \"9-\"]], \"expected\": [[\"C\", \"8339778783279627\"], [\"B\", \"9-\"]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.58,"exit_code":1,"observations":[{"actual":[["C","3580131"]],"check":"regression: set C exit condition 0","expected":[["C","358013"],["B","1"]],"passed":false},{"actual":[["B","lot"],["C","17764124"],["B","x"]],"check":"repair trap 1","expected":[["B","lot"],["C","17764124"],["B","x"]],"passed":true},{"actual":[["C","38872Q7088"]],"check":"combined fault 2","expected":[["C","3887"],["B","2Q"],["C","7088"]],"passed":false},{"actual":[["B","xAB"]],"check":"control 3","expected":[["B","xAB"]],"passed":true},{"actual":[["B","AB"]],"check":"control 4","expected":[["B","AB"]],"passed":true},{"actual":[["B","x15"]],"check":"boundary 5","expected":[["B","x15"]],"passed":true},{"actual":[["B","-"]],"check":"boundary 6","expected":[["B","-"]],"passed":true},{"actual":[["C","83397787832796279-"]],"check":"control 7","expected":[["C","8339778783279627"],["B","9-"]],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: set C exit condition 0\", \"actual\": [[\"C\", \"3580131\"]], \"expected\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"expected\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": [[\"C\", \"38872Q7088\"]], \"expected\": [[\"C\", \"3887\"], [\"B\", \"2Q\"], [\"C\", \"7088\"]], \"passed\": false}, {\"check\": \"control 3\", \"actual\": [[\"B\", \"xAB\"]], \"expected\": [[\"B\", \"xAB\"]], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [[\"B\", \"AB\"]], \"expected\": [[\"B\", \"AB\"]], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [[\"B\", \"x15\"]], \"expected\": [[\"B\", \"x15\"]], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [[\"B\", \"-\"]], \"expected\": [[\"B\", \"-\"]], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [[\"C\", \"83397787832796279-\"]], \"expected\": [[\"C\", \"8339778783279627\"], [\"B\", \"9-\"]], \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.476,"exit_code":0,"observations":[{"actual":[["C","358013"],["B","1"]],"check":"regression: set C exit condition 0","expected":[["C","358013"],["B","1"]],"passed":true},{"actual":[["B","lot"],["C","17764124"],["B","x"]],"check":"repair trap 1","expected":[["B","lot"],["C","17764124"],["B","x"]],"passed":true},{"actual":[["C","3887"],["B","2Q"],["C","7088"]],"check":"combined fault 2","expected":[["C","3887"],["B","2Q"],["C","7088"]],"passed":true},{"actual":[["B","xAB"]],"check":"control 3","expected":[["B","xAB"]],"passed":true},{"actual":[["B","AB"]],"check":"control 4","expected":[["B","AB"]],"passed":true},{"actual":[["B","x15"]],"check":"boundary 5","expected":[["B","x15"]],"passed":true},{"actual":[["B","-"]],"check":"boundary 6","expected":[["B","-"]],"passed":true},{"actual":[["C","8339778783279627"],["B","9-"]],"check":"control 7","expected":[["C","8339778783279627"],["B","9-"]],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: set C exit condition 0\", \"actual\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"expected\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"expected\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": [[\"C\", \"3887\"], [\"B\", \"2Q\"], [\"C\", \"7088\"]], \"expected\": [[\"C\", \"3887\"], [\"B\", \"2Q\"], [\"C\", \"7088\"]], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [[\"B\", \"xAB\"]], \"expected\": [[\"B\", \"xAB\"]], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [[\"B\", \"AB\"]], \"expected\": [[\"B\", \"AB\"]], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [[\"B\", \"x15\"]], \"expected\": [[\"B\", \"x15\"]], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [[\"B\", \"-\"]], \"expected\": [[\"B\", \"-\"]], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [[\"C\", \"8339778783279627\"], [\"B\", \"9-\"]], \"expected\": [[\"C\", \"8339778783279627\"], [\"B\", \"9-\"]], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}