{"abstract":"A space-padded quantity is encoded as a digit pair value because int() ignores whitespace.","category":"Barcode symbology encoding","checks":8,"contract":"Turn planned Code 128 segments into symbol values (without the checksum). Segments are [set, text], [\"FNC1\"] or [\"SHIFT\", char]. The first set segment emits its start (A 103, B 104, C 105); later set changes emit Code A 101, Code B 100 or Code C 99. Set A encodes 32..95 as ord-32 and 0..31 as ord+64; set B encodes 32..127 as ord-32; set C encodes even-length ASCII digit text as pair values. FNC1 is 102 and needs a prior start; SHIFT (98) is only valid in A or B and encodes one character in the other of A/B. Errors: no-start, bad-shift, bad-c, unencodable.","contract_signature":"segs","evaluation_group":"w2-barcode-symbology-encoding-code128-symbol-values","failed_approach":"Checking isdigit without the parity lets an odd final digit become a single-digit pair.","family":"w2-barcode-symbology-encoding-code128-symbol-values-set-c-digits","id":"FA-79446","implementations":{"attempt":{"sha256":"2a82d253fbc1a8160560df6dc8a1eed35262a04c5dc60d465fc07849d258f757","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(segs):\n    out = []\n    cur = None\n    starts = {'A': 103, 'B': 104, 'C': 105}\n    switch = {'A': 101, 'B': 100, 'C': 99}\n    def val(s, ch):\n        o = ord(ch)\n        if s == 'A':\n            if 32 <= o <= 95:\n                return o - 32\n            if 0 <= o <= 31:\n                return o + 64\n            return None\n        if 32 <= o <= 127:\n            return o - 32\n        return None\n    for seg in segs:\n        kind = seg[0]\n        if kind == 'FNC1':\n            if cur is None:\n                return {'error': 'no-start'}\n            out.append(102)\n            continue\n        if kind == 'SHIFT':\n            if cur not in ('A', 'B'):\n                return {'error': 'bad-shift'}\n            other = 'B' if cur == 'A' else 'A'\n            v = val(other, seg[1])\n            if v is None:\n                return {'error': 'unencodable', 'char': seg[1]}\n            out += [98, v]\n            continue\n        s, text = seg\n        if cur is None:\n            out.append(starts[s])\n        elif s != cur:\n            out.append(switch[s])\n        cur = s\n        if s == 'C':\n            if not text.isdigit():\n                return {'error': 'bad-c'}\n            out += [int(text[j:j + 2]) for j in range(0, len(text), 2)]\n        else:\n            for ch in text:\n                v = val(s, ch)\n                if v is None:\n                    return {'error': 'unencodable', 'char': ch}\n                out.append(v)\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[[['B', 'Lot 7'], ['C', '12'], ['C', ' 1']], {'error': 'bad-c'}], [[['B', 'Q'], ['B', '{x}'], ['C', '123']], {'error': 'bad-c'}], [[['C', '12'], ['A', 'HELLO']], [105, 12, 101, 40, 37, 44, 44, 47]], [[['B', 'ab'], ['A', '\\x00Q'], ['SHIFT', '\\t'], ['FNC1']], {'error': 'unencodable', 'char': '\\t'}], [[['B', 'Lot 7'], ['A', '\\x00Q'], ['FNC1'], ['C', '4711']], [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11]], [[['A', 'X\\x1d1']], [103, 56, 93, 17]], [[['A', 'HELLO'], ['A', 'AB'], ['A', 'X\\x1d1']], [103, 40, 37, 44, 44, 47, 33, 34, 56, 93, 17]], [[['B', '{x}'], ['A', 'X\\x1d1'], ['C', ' 1'], ['SHIFT', '\\x1d']], {'error': 'bad-c'}]], [[[['C', ' 1'], ['FNC1']], {'error': 'bad-c'}], [[['A', '\\t'], ['C', '0099'], ['A', 'HELLO'], ['C', '123']], {'error': 'bad-c'}], [[['A', '\\x00Q'], ['B', '{x}'], ['A', 'X\\x1d1'], ['SHIFT', 'z']], [103, 64, 49, 100, 91, 88, 93, 101, 56, 93, 17, 98, 90]], [[['A', 'AB'], ['B', 'Q'], ['B', 'z~']], [103, 33, 34, 100, 49, 90, 94]], [[['A', 'AB'], ['FNC1']], [103, 33, 34, 102]], [[['B', 'z~'], ['SHIFT', 'z'], ['FNC1']], {'error': 'unencodable', 'char': 'z'}], [[['B', '{x}'], ['A', '_^']], [104, 91, 88, 93, 101, 63, 62]], [[['C', ' 1'], ['A', '\\x00Q'], ['FNC1'], ['B', '{x}']], {'error': 'bad-c'}]], [[[['C', ' 1']], {'error': 'bad-c'}], [[['C', '123'], ['A', 'AB'], ['A', '\\t'], ['A', '\\x00Q']], {'error': 'bad-c'}], [[['FNC1'], ['C', '0099'], ['B', 'Lot 7'], ['C', '4711'], ['C', '12']], {'error': 'no-start'}], [[['B', 'Lot 7']], [104, 44, 79, 84, 0, 23]], [[['C', '0099']], [105, 0, 99]], [[['A', 'AB']], [103, 33, 34]], [[['A', 'X\\x1d1']], [103, 56, 93, 17]], [[['B', '{x}'], ['C', ' 1']], {'error': 'bad-c'}]], [[[['C', ' 1'], ['C', '0099']], {'error': 'bad-c'}], [[['B', '{x}'], ['C', '123'], ['C', '0099']], {'error': 'bad-c'}], [[['B', 'z~']], [104, 90, 94]], [[['C', '4711']], [105, 47, 11]], [[['A', 'HELLO'], ['A', '_^'], ['A', '_^']], [103, 40, 37, 44, 44, 47, 63, 62, 63, 62]], [[['A', '\\t']], [103, 73]], [[['B', 'Lot 7']], [104, 44, 79, 84, 0, 23]], [[['B', 'Lot 7'], ['C', ' 1'], ['A', 'AB'], ['B', 'ab']], {'error': 'bad-c'}]], [[[['B', 'ab'], ['C', ' 1']], {'error': 'bad-c'}], [[['C', '0099'], ['C', '123']], {'error': 'bad-c'}], [[['FNC1'], ['A', 'HELLO']], {'error': 'no-start'}], [[['C', '4711'], ['B', 'Q'], ['B', '{x}']], [105, 47, 11, 100, 49, 91, 88, 93]], [[['B', '{x}'], ['B', 'Q']], [104, 91, 88, 93, 49]], [[['A', 'AB']], [103, 33, 34]], [[['FNC1'], ['A', 'X\\x1d1']], {'error': 'no-start'}], [[['C', ' 1'], ['A', '_^'], ['SHIFT', '\\x1d']], {'error': 'bad-c'}]]]\nlabels = [\"regression: set C text validation\", \"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":"ce74fb8d8fbd6ed60c92d6911de93271339f540eca8474e2c2d648f79d5188d9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(segs):\n    out = []\n    cur = None\n    starts = {'A': 103, 'B': 104, 'C': 105}\n    switch = {'A': 101, 'B': 100, 'C': 99}\n    def val(s, ch):\n        o = ord(ch)\n        if s == 'A':\n            if 32 <= o <= 95:\n                return o - 32\n            if 0 <= o <= 31:\n                return o + 64\n            return None\n        if 32 <= o <= 127:\n            return o - 32\n        return None\n    for seg in segs:\n        kind = seg[0]\n        if kind == 'FNC1':\n            if cur is None:\n                return {'error': 'no-start'}\n            out.append(102)\n            continue\n        if kind == 'SHIFT':\n            if cur not in ('A', 'B'):\n                return {'error': 'bad-shift'}\n            other = 'B' if cur == 'A' else 'A'\n            v = val(other, seg[1])\n            if v is None:\n                return {'error': 'unencodable', 'char': seg[1]}\n            out += [98, v]\n            continue\n        s, text = seg\n        if cur is None:\n            out.append(starts[s])\n        elif s != cur:\n            out.append(switch[s])\n        cur = s\n        if s == 'C':\n            if len(text) % 2:\n                return {'error': 'bad-c'}\n            out += [int(text[j:j + 2]) for j in range(0, len(text), 2)]\n        else:\n            for ch in text:\n                v = val(s, ch)\n                if v is None:\n                    return {'error': 'unencodable', 'char': ch}\n                out.append(v)\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[[['B', 'Lot 7'], ['C', '12'], ['C', ' 1']], {'error': 'bad-c'}], [[['B', 'Q'], ['B', '{x}'], ['C', '123']], {'error': 'bad-c'}], [[['C', '12'], ['A', 'HELLO']], [105, 12, 101, 40, 37, 44, 44, 47]], [[['B', 'ab'], ['A', '\\x00Q'], ['SHIFT', '\\t'], ['FNC1']], {'error': 'unencodable', 'char': '\\t'}], [[['B', 'Lot 7'], ['A', '\\x00Q'], ['FNC1'], ['C', '4711']], [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11]], [[['A', 'X\\x1d1']], [103, 56, 93, 17]], [[['A', 'HELLO'], ['A', 'AB'], ['A', 'X\\x1d1']], [103, 40, 37, 44, 44, 47, 33, 34, 56, 93, 17]], [[['B', '{x}'], ['A', 'X\\x1d1'], ['C', ' 1'], ['SHIFT', '\\x1d']], {'error': 'bad-c'}]], [[[['C', ' 1'], ['FNC1']], {'error': 'bad-c'}], [[['A', '\\t'], ['C', '0099'], ['A', 'HELLO'], ['C', '123']], {'error': 'bad-c'}], [[['A', '\\x00Q'], ['B', '{x}'], ['A', 'X\\x1d1'], ['SHIFT', 'z']], [103, 64, 49, 100, 91, 88, 93, 101, 56, 93, 17, 98, 90]], [[['A', 'AB'], ['B', 'Q'], ['B', 'z~']], [103, 33, 34, 100, 49, 90, 94]], [[['A', 'AB'], ['FNC1']], [103, 33, 34, 102]], [[['B', 'z~'], ['SHIFT', 'z'], ['FNC1']], {'error': 'unencodable', 'char': 'z'}], [[['B', '{x}'], ['A', '_^']], [104, 91, 88, 93, 101, 63, 62]], [[['C', ' 1'], ['A', '\\x00Q'], ['FNC1'], ['B', '{x}']], {'error': 'bad-c'}]], [[[['C', ' 1']], {'error': 'bad-c'}], [[['C', '123'], ['A', 'AB'], ['A', '\\t'], ['A', '\\x00Q']], {'error': 'bad-c'}], [[['FNC1'], ['C', '0099'], ['B', 'Lot 7'], ['C', '4711'], ['C', '12']], {'error': 'no-start'}], [[['B', 'Lot 7']], [104, 44, 79, 84, 0, 23]], [[['C', '0099']], [105, 0, 99]], [[['A', 'AB']], [103, 33, 34]], [[['A', 'X\\x1d1']], [103, 56, 93, 17]], [[['B', '{x}'], ['C', ' 1']], {'error': 'bad-c'}]], [[[['C', ' 1'], ['C', '0099']], {'error': 'bad-c'}], [[['B', '{x}'], ['C', '123'], ['C', '0099']], {'error': 'bad-c'}], [[['B', 'z~']], [104, 90, 94]], [[['C', '4711']], [105, 47, 11]], [[['A', 'HELLO'], ['A', '_^'], ['A', '_^']], [103, 40, 37, 44, 44, 47, 63, 62, 63, 62]], [[['A', '\\t']], [103, 73]], [[['B', 'Lot 7']], [104, 44, 79, 84, 0, 23]], [[['B', 'Lot 7'], ['C', ' 1'], ['A', 'AB'], ['B', 'ab']], {'error': 'bad-c'}]], [[[['B', 'ab'], ['C', ' 1']], {'error': 'bad-c'}], [[['C', '0099'], ['C', '123']], {'error': 'bad-c'}], [[['FNC1'], ['A', 'HELLO']], {'error': 'no-start'}], [[['C', '4711'], ['B', 'Q'], ['B', '{x}']], [105, 47, 11, 100, 49, 91, 88, 93]], [[['B', '{x}'], ['B', 'Q']], [104, 91, 88, 93, 49]], [[['A', 'AB']], [103, 33, 34]], [[['FNC1'], ['A', 'X\\x1d1']], {'error': 'no-start'}], [[['C', ' 1'], ['A', '_^'], ['SHIFT', '\\x1d']], {'error': 'bad-c'}]]]\nlabels = [\"regression: set C text validation\", \"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-symbol-values-set-c-digits","generated_at":"2026-09-29T14:49:44.476151+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.","root_cause":"Only the length parity is checked before converting pairs with int().","sha256":"bd364c6f1063c0f68dbc2cb45b2dccb92533166cfd64223b5e434717202c0797","title":"Set C accepts pairs containing spaces · 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.127,"exit_code":1,"observations":[{"actual":{"error":"bad-c"},"check":"regression: set C text validation 0","expected":{"error":"bad-c"},"passed":true},{"actual":[104,49,91,88,93,99,12,3],"check":"repair trap 1","expected":{"error":"bad-c"},"passed":false},{"actual":[105,12,101,40,37,44,44,47],"check":"combined fault 2","expected":[105,12,101,40,37,44,44,47],"passed":true},{"actual":{"char":"\t","error":"unencodable"},"check":"control 3","expected":{"char":"\t","error":"unencodable"},"passed":true},{"actual":[104,44,79,84,0,23,101,64,49,102,99,47,11],"check":"control 4","expected":[104,44,79,84,0,23,101,64,49,102,99,47,11],"passed":true},{"actual":[103,56,93,17],"check":"boundary 5","expected":[103,56,93,17],"passed":true},{"actual":[103,40,37,44,44,47,33,34,56,93,17],"check":"boundary 6","expected":[103,40,37,44,44,47,33,34,56,93,17],"passed":true},{"actual":{"error":"bad-c"},"check":"control 7","expected":{"error":"bad-c"},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: set C text validation 0\", \"actual\": {\"error\": \"bad-c\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [104, 49, 91, 88, 93, 99, 12, 3], \"expected\": {\"error\": \"bad-c\"}, \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": [105, 12, 101, 40, 37, 44, 44, 47], \"expected\": [105, 12, 101, 40, 37, 44, 44, 47], \"passed\": true}, {\"check\": \"control 3\", \"actual\": {\"error\": \"unencodable\", \"char\": \"\\t\"}, \"expected\": {\"error\": \"unencodable\", \"char\": \"\\t\"}, \"passed\": true}, {\"check\": \"control 4\", \"actual\": [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11], \"expected\": [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [103, 56, 93, 17], \"expected\": [103, 56, 93, 17], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [103, 40, 37, 44, 44, 47, 33, 34, 56, 93, 17], \"expected\": [103, 40, 37, 44, 44, 47, 33, 34, 56, 93, 17], \"passed\": true}, {\"check\": \"control 7\", \"actual\": {\"error\": \"bad-c\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":43.153,"exit_code":1,"observations":[{"actual":[104,44,79,84,0,23,99,12,1],"check":"regression: set C text validation 0","expected":{"error":"bad-c"},"passed":false},{"actual":{"error":"bad-c"},"check":"repair trap 1","expected":{"error":"bad-c"},"passed":true},{"actual":[105,12,101,40,37,44,44,47],"check":"combined fault 2","expected":[105,12,101,40,37,44,44,47],"passed":true},{"actual":{"char":"\t","error":"unencodable"},"check":"control 3","expected":{"char":"\t","error":"unencodable"},"passed":true},{"actual":[104,44,79,84,0,23,101,64,49,102,99,47,11],"check":"control 4","expected":[104,44,79,84,0,23,101,64,49,102,99,47,11],"passed":true},{"actual":[103,56,93,17],"check":"boundary 5","expected":[103,56,93,17],"passed":true},{"actual":[103,40,37,44,44,47,33,34,56,93,17],"check":"boundary 6","expected":[103,40,37,44,44,47,33,34,56,93,17],"passed":true},{"actual":{"error":"bad-shift"},"check":"control 7","expected":{"error":"bad-c"},"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: set C text validation 0\", \"actual\": [104, 44, 79, 84, 0, 23, 99, 12, 1], \"expected\": {\"error\": \"bad-c\"}, \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": {\"error\": \"bad-c\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": [105, 12, 101, 40, 37, 44, 44, 47], \"expected\": [105, 12, 101, 40, 37, 44, 44, 47], \"passed\": true}, {\"check\": \"control 3\", \"actual\": {\"error\": \"unencodable\", \"char\": \"\\t\"}, \"expected\": {\"error\": \"unencodable\", \"char\": \"\\t\"}, \"passed\": true}, {\"check\": \"control 4\", \"actual\": [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11], \"expected\": [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [103, 56, 93, 17], \"expected\": [103, 56, 93, 17], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [103, 40, 37, 44, 44, 47, 33, 34, 56, 93, 17], \"expected\": [103, 40, 37, 44, 44, 47, 33, 34, 56, 93, 17], \"passed\": true}, {\"check\": \"control 7\", \"actual\": {\"error\": \"bad-shift\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": false}], \"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."}}