{"abstract":"Serial numbers ending in four or five digits produce longer symbols than necessary.","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":"Allowing the run to stop one character early switches before a final letter.","family":"w2-barcode-symbology-encoding-code128-codeset-plan-end-run","id":"FA-79411","implementations":{"attempt":{"sha256":"0679ee9437a24620e2c57e13046288381c9590d2cf432a1c1d6f7ce464806961","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 - 1):\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 = [[['ABlot61791', [['B', 'ABlot6'], ['C', '1791']]], [' lot1300 ', [['B', ' lot1300 ']]], ['3580131', [['C', '358013'], ['B', '1']]], ['lot17764124x', [['B', 'lot'], ['C', '17764124'], ['B', 'x']]], ['xAB', [['B', 'xAB']]], [' 193261lot', [['B', ' '], ['C', '193261'], ['B', 'lot']]], ['AB', [['B', 'AB']]], ['02 1847', [['B', '02 '], ['C', '1847']]]], [['lot0696', [['B', 'lot'], ['C', '0696']]], ['03 2849 ', [['B', '03 2849 ']]], ['Q7lotQ7lot', [['B', 'Q7lotQ7lot']]], ['101874486507729', [['C', '10187448650772'], ['B', '9']]], ['x22', [['B', 'x22']]], [' ', [['B', ' ']]], ['-006', [['B', '-006']]], ['338376558854179 84977', [['C', '33837655885417'], ['B', '9 8'], ['C', '4977']]]], [['x03107', [['B', 'x0'], ['C', '3107']]], ['AB1234x', [['B', 'AB1234x']]], ['0964853799773055547674lot', [['C', '0964853799773055547674'], ['B', 'lot']]], ['lot', [['B', 'lot']]], ['1', [['B', '1']]], ['Q7 lotAB', [['B', 'Q7 lotAB']]], ['-753024468324', [['B', '-'], ['C', '753024468324']]], ['827 AB51544', [['B', '827 AB5'], ['C', '1544']]]], [[' 1019', [['B', ' '], ['C', '1019']]], ['lot9876A', [['B', 'lot9876A']]], ['3807356726022 ', [['C', '380735672602'], ['B', '2 ']]], ['733-', [['B', '733-']]], ['46450162930', [['C', '4645016293'], ['B', '0']]], [' - ', [['B', ' - ']]], [' Q7', [['B', ' Q7']]], ['-Q7Q7805', [['B', '-Q7Q'], ['C', '7805']]]], [[' Q72484', [['B', ' Q7'], ['C', '2484']]], ['AB1234x', [['B', 'AB1234x']]], ['xlot045355094', [['B', 'xlot0'], ['C', '45355094']]], ['007775830', [['C', '00777583'], ['B', '0']]], ['AB8', [['B', 'AB8']]], ['014550632960 753', [['C', '014550632960'], ['B', ' 753']]], [' x', [['B', ' x']]], ['3283655059x2996', [['C', '3283655059'], ['B', 'x'], ['C', '2996']]]]]\nlabels = [\"regression: trailing digit run switch\", \"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":"6228b30bb7557b8a9f038678dafe6a51df487c18a4b9c5b880e9a387ef9d8bb5","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:\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 = [[['ABlot61791', [['B', 'ABlot6'], ['C', '1791']]], [' lot1300 ', [['B', ' lot1300 ']]], ['3580131', [['C', '358013'], ['B', '1']]], ['lot17764124x', [['B', 'lot'], ['C', '17764124'], ['B', 'x']]], ['xAB', [['B', 'xAB']]], [' 193261lot', [['B', ' '], ['C', '193261'], ['B', 'lot']]], ['AB', [['B', 'AB']]], ['02 1847', [['B', '02 '], ['C', '1847']]]], [['lot0696', [['B', 'lot'], ['C', '0696']]], ['03 2849 ', [['B', '03 2849 ']]], ['Q7lotQ7lot', [['B', 'Q7lotQ7lot']]], ['101874486507729', [['C', '10187448650772'], ['B', '9']]], ['x22', [['B', 'x22']]], [' ', [['B', ' ']]], ['-006', [['B', '-006']]], ['338376558854179 84977', [['C', '33837655885417'], ['B', '9 8'], ['C', '4977']]]], [['x03107', [['B', 'x0'], ['C', '3107']]], ['AB1234x', [['B', 'AB1234x']]], ['0964853799773055547674lot', [['C', '0964853799773055547674'], ['B', 'lot']]], ['lot', [['B', 'lot']]], ['1', [['B', '1']]], ['Q7 lotAB', [['B', 'Q7 lotAB']]], ['-753024468324', [['B', '-'], ['C', '753024468324']]], ['827 AB51544', [['B', '827 AB5'], ['C', '1544']]]], [[' 1019', [['B', ' '], ['C', '1019']]], ['lot9876A', [['B', 'lot9876A']]], ['3807356726022 ', [['C', '380735672602'], ['B', '2 ']]], ['733-', [['B', '733-']]], ['46450162930', [['C', '4645016293'], ['B', '0']]], [' - ', [['B', ' - ']]], [' Q7', [['B', ' Q7']]], ['-Q7Q7805', [['B', '-Q7Q'], ['C', '7805']]]], [[' Q72484', [['B', ' Q7'], ['C', '2484']]], ['AB1234x', [['B', 'AB1234x']]], ['xlot045355094', [['B', 'xlot0'], ['C', '45355094']]], ['007775830', [['C', '00777583'], ['B', '0']]], ['AB8', [['B', 'AB8']]], ['014550632960 753', [['C', '014550632960'], ['B', ' 753']]], [' x', [['B', ' x']]], ['3283655059x2996', [['C', '3283655059'], ['B', 'x'], ['C', '2996']]]]]\nlabels = [\"regression: trailing digit run switch\", \"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":"6bb21ffaa0706c0f55122c0773c1f8f1ab90e2282ddd32ef6b37a48b26f9fb9b","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 = [[['ABlot61791', [['B', 'ABlot6'], ['C', '1791']]], [' lot1300 ', [['B', ' lot1300 ']]], ['3580131', [['C', '358013'], ['B', '1']]], ['lot17764124x', [['B', 'lot'], ['C', '17764124'], ['B', 'x']]], ['xAB', [['B', 'xAB']]], [' 193261lot', [['B', ' '], ['C', '193261'], ['B', 'lot']]], ['AB', [['B', 'AB']]], ['02 1847', [['B', '02 '], ['C', '1847']]]], [['lot0696', [['B', 'lot'], ['C', '0696']]], ['03 2849 ', [['B', '03 2849 ']]], ['Q7lotQ7lot', [['B', 'Q7lotQ7lot']]], ['101874486507729', [['C', '10187448650772'], ['B', '9']]], ['x22', [['B', 'x22']]], [' ', [['B', ' ']]], ['-006', [['B', '-006']]], ['338376558854179 84977', [['C', '33837655885417'], ['B', '9 8'], ['C', '4977']]]], [['x03107', [['B', 'x0'], ['C', '3107']]], ['AB1234x', [['B', 'AB1234x']]], ['0964853799773055547674lot', [['C', '0964853799773055547674'], ['B', 'lot']]], ['lot', [['B', 'lot']]], ['1', [['B', '1']]], ['Q7 lotAB', [['B', 'Q7 lotAB']]], ['-753024468324', [['B', '-'], ['C', '753024468324']]], ['827 AB51544', [['B', '827 AB5'], ['C', '1544']]]], [[' 1019', [['B', ' '], ['C', '1019']]], ['lot9876A', [['B', 'lot9876A']]], ['3807356726022 ', [['C', '380735672602'], ['B', '2 ']]], ['733-', [['B', '733-']]], ['46450162930', [['C', '4645016293'], ['B', '0']]], [' - ', [['B', ' - ']]], [' Q7', [['B', ' Q7']]], ['-Q7Q7805', [['B', '-Q7Q'], ['C', '7805']]]], [[' Q72484', [['B', ' Q7'], ['C', '2484']]], ['AB1234x', [['B', 'AB1234x']]], ['xlot045355094', [['B', 'xlot0'], ['C', '45355094']]], ['007775830', [['C', '00777583'], ['B', '0']]], ['AB8', [['B', 'AB8']]], ['014550632960 753', [['C', '014550632960'], ['B', ' 753']]], [' x', [['B', ' x']]], ['3283655059x2996', [['C', '3283655059'], ['B', 'x'], ['C', '2996']]]]]\nlabels = [\"regression: trailing digit run switch\", \"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-end-run","generated_at":"2026-09-29T14:49:44.392215+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":"Also switch to C for runs of four or more digits that reach the end of the data.","root_cause":"The end-of-data exception for 4 and 5 digit runs is missing.","sha256":"fe0904523d28f3a99288ba98cf189aab46fc996c4487395638ed5069bc3366b9","title":"Trailing four-digit runs stay in set B · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.941,"exit_code":1,"observations":[{"actual":[["B","ABlot6"],["C","1791"]],"check":"regression: trailing digit run switch 0","expected":[["B","ABlot6"],["C","1791"]],"passed":true},{"actual":[["B"," lot"],["C","1300"],["B"," "]],"check":"repair trap 1","expected":[["B"," lot1300 "]],"passed":false},{"actual":[["C","358013"],["B","1"]],"check":"combined fault 2","expected":[["C","358013"],["B","1"]],"passed":true},{"actual":[["B","lot"],["C","17764124"],["B","x"]],"check":"control 3","expected":[["B","lot"],["C","17764124"],["B","x"]],"passed":true},{"actual":[["B","xAB"]],"check":"control 4","expected":[["B","xAB"]],"passed":true},{"actual":[["B"," "],["C","193261"],["B","lot"]],"check":"boundary 5","expected":[["B"," "],["C","193261"],["B","lot"]],"passed":true},{"actual":[["B","AB"]],"check":"boundary 6","expected":[["B","AB"]],"passed":true},{"actual":[["B","02 "],["C","1847"]],"check":"control 7","expected":[["B","02 "],["C","1847"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: trailing digit run switch 0\", \"actual\": [[\"B\", \"ABlot6\"], [\"C\", \"1791\"]], \"expected\": [[\"B\", \"ABlot6\"], [\"C\", \"1791\"]], \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [[\"B\", \" lot\"], [\"C\", \"1300\"], [\"B\", \" \"]], \"expected\": [[\"B\", \" lot1300 \"]], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"expected\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"expected\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [[\"B\", \"xAB\"]], \"expected\": [[\"B\", \"xAB\"]], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [[\"B\", \" \"], [\"C\", \"193261\"], [\"B\", \"lot\"]], \"expected\": [[\"B\", \" \"], [\"C\", \"193261\"], [\"B\", \"lot\"]], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [[\"B\", \"AB\"]], \"expected\": [[\"B\", \"AB\"]], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [[\"B\", \"02 \"], [\"C\", \"1847\"]], \"expected\": [[\"B\", \"02 \"], [\"C\", \"1847\"]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.613,"exit_code":1,"observations":[{"actual":[["B","ABlot61791"]],"check":"regression: trailing digit run switch 0","expected":[["B","ABlot6"],["C","1791"]],"passed":false},{"actual":[["B"," lot1300 "]],"check":"repair trap 1","expected":[["B"," lot1300 "]],"passed":true},{"actual":[["C","358013"],["B","1"]],"check":"combined fault 2","expected":[["C","358013"],["B","1"]],"passed":true},{"actual":[["B","lot"],["C","17764124"],["B","x"]],"check":"control 3","expected":[["B","lot"],["C","17764124"],["B","x"]],"passed":true},{"actual":[["B","xAB"]],"check":"control 4","expected":[["B","xAB"]],"passed":true},{"actual":[["B"," "],["C","193261"],["B","lot"]],"check":"boundary 5","expected":[["B"," "],["C","193261"],["B","lot"]],"passed":true},{"actual":[["B","AB"]],"check":"boundary 6","expected":[["B","AB"]],"passed":true},{"actual":[["B","02 1847"]],"check":"control 7","expected":[["B","02 "],["C","1847"]],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: trailing digit run switch 0\", \"actual\": [[\"B\", \"ABlot61791\"]], \"expected\": [[\"B\", \"ABlot6\"], [\"C\", \"1791\"]], \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": [[\"B\", \" lot1300 \"]], \"expected\": [[\"B\", \" lot1300 \"]], \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"expected\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"expected\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [[\"B\", \"xAB\"]], \"expected\": [[\"B\", \"xAB\"]], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [[\"B\", \" \"], [\"C\", \"193261\"], [\"B\", \"lot\"]], \"expected\": [[\"B\", \" \"], [\"C\", \"193261\"], [\"B\", \"lot\"]], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [[\"B\", \"AB\"]], \"expected\": [[\"B\", \"AB\"]], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [[\"B\", \"02 1847\"]], \"expected\": [[\"B\", \"02 \"], [\"C\", \"1847\"]], \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":40.808,"exit_code":0,"observations":[{"actual":[["B","ABlot6"],["C","1791"]],"check":"regression: trailing digit run switch 0","expected":[["B","ABlot6"],["C","1791"]],"passed":true},{"actual":[["B"," lot1300 "]],"check":"repair trap 1","expected":[["B"," lot1300 "]],"passed":true},{"actual":[["C","358013"],["B","1"]],"check":"combined fault 2","expected":[["C","358013"],["B","1"]],"passed":true},{"actual":[["B","lot"],["C","17764124"],["B","x"]],"check":"control 3","expected":[["B","lot"],["C","17764124"],["B","x"]],"passed":true},{"actual":[["B","xAB"]],"check":"control 4","expected":[["B","xAB"]],"passed":true},{"actual":[["B"," "],["C","193261"],["B","lot"]],"check":"boundary 5","expected":[["B"," "],["C","193261"],["B","lot"]],"passed":true},{"actual":[["B","AB"]],"check":"boundary 6","expected":[["B","AB"]],"passed":true},{"actual":[["B","02 "],["C","1847"]],"check":"control 7","expected":[["B","02 "],["C","1847"]],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: trailing digit run switch 0\", \"actual\": [[\"B\", \"ABlot6\"], [\"C\", \"1791\"]], \"expected\": [[\"B\", \"ABlot6\"], [\"C\", \"1791\"]], \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [[\"B\", \" lot1300 \"]], \"expected\": [[\"B\", \" lot1300 \"]], \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"expected\": [[\"C\", \"358013\"], [\"B\", \"1\"]], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"expected\": [[\"B\", \"lot\"], [\"C\", \"17764124\"], [\"B\", \"x\"]], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [[\"B\", \"xAB\"]], \"expected\": [[\"B\", \"xAB\"]], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [[\"B\", \" \"], [\"C\", \"193261\"], [\"B\", \"lot\"]], \"expected\": [[\"B\", \" \"], [\"C\", \"193261\"], [\"B\", \"lot\"]], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [[\"B\", \"AB\"]], \"expected\": [[\"B\", \"AB\"]], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [[\"B\", \"02 \"], [\"C\", \"1847\"]], \"expected\": [[\"B\", \"02 \"], [\"C\", \"1847\"]], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}