{"abstract":"Switching from C to B decodes as a switch to A, so lowercase letters decode as control codes.","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":"Using 98 for Code C emits a SHIFT instead of a set change.","family":"w2-barcode-symbology-encoding-code128-symbol-values-switch-values","id":"FA-79436","implementations":{"attempt":{"sha256":"03e1b3ce2f661e44237ea9a910f3ee1f17b5007c311f75137a9cd01d1ab42690","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': 98}\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 or not all(c in '0123456789' for c in text):\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 = [[[[['C', '12'], ['A', 'HELLO']], [105, 12, 101, 40, 37, 44, 44, 47]], [[['B', 'Lot 7'], ['A', '\\x00Q'], ['FNC1'], ['C', '4711']], [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11]], [[['A', 'AB'], ['C', '0099'], ['B', '{x}'], ['B', 'z~']], [103, 33, 34, 99, 0, 99, 100, 91, 88, 93, 90, 94]], [[['B', 'Q'], ['B', '{x}'], ['C', '123']], {'error': 'bad-c'}], [[['B', '{x}'], ['SHIFT', '\\t'], ['C', '1'], ['A', '\\x00Q']], {'error': 'bad-c'}], [[['B', 'ab'], ['A', '\\x00Q'], ['SHIFT', '\\t'], ['FNC1']], {'error': 'unencodable', 'char': '\\t'}], [[['C', '123'], ['FNC1']], {'error': 'bad-c'}], [[['C', '4711'], ['A', 'X\\x1d1'], ['B', 'ab']], [105, 47, 11, 101, 56, 93, 17, 100, 65, 66]]], [[[['A', '\\x00Q'], ['B', '{x}'], ['A', 'X\\x1d1'], ['SHIFT', 'z']], [103, 64, 49, 100, 91, 88, 93, 101, 56, 93, 17, 98, 90]], [[['B', 'z~'], ['C', '12'], ['FNC1']], [104, 90, 94, 99, 12, 102]], [[['A', 'HELLO'], ['C', '0099'], ['B', 'Lot 7']], [103, 40, 37, 44, 44, 47, 99, 0, 99, 100, 44, 79, 84, 0, 23]], [[['A', 'AB'], ['FNC1']], [103, 33, 34, 102]], [[['B', 'z~'], ['SHIFT', 'z'], ['FNC1']], {'error': 'unencodable', 'char': 'z'}], [[['C', ' 1'], ['C', '0099'], ['FNC1'], ['SHIFT', '\\x1d']], {'error': 'bad-c'}], [[['B', 'Lot 7']], [104, 44, 79, 84, 0, 23]], [[['A', 'AB'], ['B', 'Q'], ['B', 'z~']], [103, 33, 34, 100, 49, 90, 94]]], [[[['B', 'ab'], ['A', 'HELLO']], [104, 65, 66, 101, 40, 37, 44, 44, 47]], [[['A', '\\t'], ['C', '4711'], ['B', 'Q'], ['B', 'ab']], [103, 73, 99, 47, 11, 100, 49, 65, 66]], [[['A', '\\x00Q'], ['C', '0099'], ['A', '\\x00Q']], [103, 64, 49, 99, 0, 99, 101, 64, 49]], [[['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]], [[['C', '0099'], ['B', 'Q']], [105, 0, 99, 100, 49]]], [[[['C', '12'], ['B', 'Q']], [105, 12, 100, 49]], [[['B', 'ab'], ['B', 'Q'], ['C', '4711'], ['FNC1']], [104, 65, 66, 49, 99, 47, 11, 102]], [[['B', 'Lot 7'], ['A', '_^'], ['C', '4711']], [104, 44, 79, 84, 0, 23, 101, 63, 62, 99, 47, 11]], [[['B', 'Lot 7'], ['C', ' 1'], ['A', 'AB'], ['B', 'ab']], {'error': 'bad-c'}], [[['B', 'z~']], [104, 90, 94]], [[['C', ' 1'], ['FNC1'], ['C', ' 1'], ['A', '_^']], {'error': 'bad-c'}], [[['C', ' 1'], ['C', '0099']], {'error': 'bad-c'}], [[['B', 'z~'], ['A', 'X\\x1d1'], ['B', '{x}'], ['C', '0099']], [104, 90, 94, 101, 56, 93, 17, 100, 91, 88, 93, 99, 0, 99]]], [[[['C', '12'], ['A', '\\t'], ['FNC1'], ['FNC1']], [105, 12, 101, 73, 102, 102]], [[['B', '{x}'], ['SHIFT', 'B'], ['C', '12'], ['A', 'AB']], [104, 91, 88, 93, 98, 34, 99, 12, 101, 33, 34]], [[['B', '{x}'], ['C', '12'], ['A', '\\x00Q']], [104, 91, 88, 93, 99, 12, 101, 64, 49]], [[['B', 'Q']], [104, 49]], [[['FNC1'], ['A', 'HELLO']], {'error': 'no-start'}], [[['B', '{x}'], ['B', 'Q']], [104, 91, 88, 93, 49]], [[['A', 'AB']], [103, 33, 34]], [[['B', 'Q'], ['B', 'z~'], ['A', 'HELLO'], ['SHIFT', 'B']], [104, 49, 90, 94, 101, 40, 37, 44, 44, 47, 98, 34]]]]\nlabels = [\"regression: code set switch values\", \"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":"6a853dc86ef2d5310d1f9b597b94ddfde61153ce98b84efbd5828bf2df76e6be","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': 100, 'B': 101, '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 or not all(c in '0123456789' for c in text):\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 = [[[[['C', '12'], ['A', 'HELLO']], [105, 12, 101, 40, 37, 44, 44, 47]], [[['B', 'Lot 7'], ['A', '\\x00Q'], ['FNC1'], ['C', '4711']], [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11]], [[['A', 'AB'], ['C', '0099'], ['B', '{x}'], ['B', 'z~']], [103, 33, 34, 99, 0, 99, 100, 91, 88, 93, 90, 94]], [[['B', 'Q'], ['B', '{x}'], ['C', '123']], {'error': 'bad-c'}], [[['B', '{x}'], ['SHIFT', '\\t'], ['C', '1'], ['A', '\\x00Q']], {'error': 'bad-c'}], [[['B', 'ab'], ['A', '\\x00Q'], ['SHIFT', '\\t'], ['FNC1']], {'error': 'unencodable', 'char': '\\t'}], [[['C', '123'], ['FNC1']], {'error': 'bad-c'}], [[['C', '4711'], ['A', 'X\\x1d1'], ['B', 'ab']], [105, 47, 11, 101, 56, 93, 17, 100, 65, 66]]], [[[['A', '\\x00Q'], ['B', '{x}'], ['A', 'X\\x1d1'], ['SHIFT', 'z']], [103, 64, 49, 100, 91, 88, 93, 101, 56, 93, 17, 98, 90]], [[['B', 'z~'], ['C', '12'], ['FNC1']], [104, 90, 94, 99, 12, 102]], [[['A', 'HELLO'], ['C', '0099'], ['B', 'Lot 7']], [103, 40, 37, 44, 44, 47, 99, 0, 99, 100, 44, 79, 84, 0, 23]], [[['A', 'AB'], ['FNC1']], [103, 33, 34, 102]], [[['B', 'z~'], ['SHIFT', 'z'], ['FNC1']], {'error': 'unencodable', 'char': 'z'}], [[['C', ' 1'], ['C', '0099'], ['FNC1'], ['SHIFT', '\\x1d']], {'error': 'bad-c'}], [[['B', 'Lot 7']], [104, 44, 79, 84, 0, 23]], [[['A', 'AB'], ['B', 'Q'], ['B', 'z~']], [103, 33, 34, 100, 49, 90, 94]]], [[[['B', 'ab'], ['A', 'HELLO']], [104, 65, 66, 101, 40, 37, 44, 44, 47]], [[['A', '\\t'], ['C', '4711'], ['B', 'Q'], ['B', 'ab']], [103, 73, 99, 47, 11, 100, 49, 65, 66]], [[['A', '\\x00Q'], ['C', '0099'], ['A', '\\x00Q']], [103, 64, 49, 99, 0, 99, 101, 64, 49]], [[['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]], [[['C', '0099'], ['B', 'Q']], [105, 0, 99, 100, 49]]], [[[['C', '12'], ['B', 'Q']], [105, 12, 100, 49]], [[['B', 'ab'], ['B', 'Q'], ['C', '4711'], ['FNC1']], [104, 65, 66, 49, 99, 47, 11, 102]], [[['B', 'Lot 7'], ['A', '_^'], ['C', '4711']], [104, 44, 79, 84, 0, 23, 101, 63, 62, 99, 47, 11]], [[['B', 'Lot 7'], ['C', ' 1'], ['A', 'AB'], ['B', 'ab']], {'error': 'bad-c'}], [[['B', 'z~']], [104, 90, 94]], [[['C', ' 1'], ['FNC1'], ['C', ' 1'], ['A', '_^']], {'error': 'bad-c'}], [[['C', ' 1'], ['C', '0099']], {'error': 'bad-c'}], [[['B', 'z~'], ['A', 'X\\x1d1'], ['B', '{x}'], ['C', '0099']], [104, 90, 94, 101, 56, 93, 17, 100, 91, 88, 93, 99, 0, 99]]], [[[['C', '12'], ['A', '\\t'], ['FNC1'], ['FNC1']], [105, 12, 101, 73, 102, 102]], [[['B', '{x}'], ['SHIFT', 'B'], ['C', '12'], ['A', 'AB']], [104, 91, 88, 93, 98, 34, 99, 12, 101, 33, 34]], [[['B', '{x}'], ['C', '12'], ['A', '\\x00Q']], [104, 91, 88, 93, 99, 12, 101, 64, 49]], [[['B', 'Q']], [104, 49]], [[['FNC1'], ['A', 'HELLO']], {'error': 'no-start'}], [[['B', '{x}'], ['B', 'Q']], [104, 91, 88, 93, 49]], [[['A', 'AB']], [103, 33, 34]], [[['B', 'Q'], ['B', 'z~'], ['A', 'HELLO'], ['SHIFT', 'B']], [104, 49, 90, 94, 101, 40, 37, 44, 44, 47, 98, 34]]]]\nlabels = [\"regression: code set switch values\", \"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-switch-values","generated_at":"2026-09-29T14:49:44.480649+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":"The switch table maps A to 100 and B to 101.","sha256":"11f88ae8e1e6e038a87872ecaeae8cbf290233fe357a35baaddd05976f12b514","title":"Code A and Code B switch characters are exchanged · 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":42.742,"exit_code":1,"observations":[{"actual":[105,12,101,40,37,44,44,47],"check":"regression: code set switch values 0","expected":[105,12,101,40,37,44,44,47],"passed":true},{"actual":[104,44,79,84,0,23,101,64,49,102,98,47,11],"check":"repair trap 1","expected":[104,44,79,84,0,23,101,64,49,102,99,47,11],"passed":false},{"actual":[103,33,34,98,0,99,100,91,88,93,90,94],"check":"combined fault 2","expected":[103,33,34,99,0,99,100,91,88,93,90,94],"passed":false},{"actual":{"error":"bad-c"},"check":"control 3","expected":{"error":"bad-c"},"passed":true},{"actual":{"error":"bad-c"},"check":"control 4","expected":{"error":"bad-c"},"passed":true},{"actual":{"char":"\t","error":"unencodable"},"check":"boundary 5","expected":{"char":"\t","error":"unencodable"},"passed":true},{"actual":{"error":"bad-c"},"check":"boundary 6","expected":{"error":"bad-c"},"passed":true},{"actual":[105,47,11,101,56,93,17,100,65,66],"check":"control 7","expected":[105,47,11,101,56,93,17,100,65,66],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: code set switch values 0\", \"actual\": [105, 12, 101, 40, 37, 44, 44, 47], \"expected\": [105, 12, 101, 40, 37, 44, 44, 47], \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 98, 47, 11], \"expected\": [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": [103, 33, 34, 98, 0, 99, 100, 91, 88, 93, 90, 94], \"expected\": [103, 33, 34, 99, 0, 99, 100, 91, 88, 93, 90, 94], \"passed\": false}, {\"check\": \"control 3\", \"actual\": {\"error\": \"bad-c\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": true}, {\"check\": \"control 4\", \"actual\": {\"error\": \"bad-c\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": {\"error\": \"unencodable\", \"char\": \"\\t\"}, \"expected\": {\"error\": \"unencodable\", \"char\": \"\\t\"}, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": {\"error\": \"bad-c\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": true}, {\"check\": \"control 7\", \"actual\": [105, 47, 11, 101, 56, 93, 17, 100, 65, 66], \"expected\": [105, 47, 11, 101, 56, 93, 17, 100, 65, 66], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.585,"exit_code":1,"observations":[{"actual":[105,12,100,40,37,44,44,47],"check":"regression: code set switch values 0","expected":[105,12,101,40,37,44,44,47],"passed":false},{"actual":[104,44,79,84,0,23,100,64,49,102,99,47,11],"check":"repair trap 1","expected":[104,44,79,84,0,23,101,64,49,102,99,47,11],"passed":false},{"actual":[103,33,34,99,0,99,101,91,88,93,90,94],"check":"combined fault 2","expected":[103,33,34,99,0,99,100,91,88,93,90,94],"passed":false},{"actual":{"error":"bad-c"},"check":"control 3","expected":{"error":"bad-c"},"passed":true},{"actual":{"error":"bad-c"},"check":"control 4","expected":{"error":"bad-c"},"passed":true},{"actual":{"char":"\t","error":"unencodable"},"check":"boundary 5","expected":{"char":"\t","error":"unencodable"},"passed":true},{"actual":{"error":"bad-c"},"check":"boundary 6","expected":{"error":"bad-c"},"passed":true},{"actual":[105,47,11,100,56,93,17,101,65,66],"check":"control 7","expected":[105,47,11,101,56,93,17,100,65,66],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: code set switch values 0\", \"actual\": [105, 12, 100, 40, 37, 44, 44, 47], \"expected\": [105, 12, 101, 40, 37, 44, 44, 47], \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": [104, 44, 79, 84, 0, 23, 100, 64, 49, 102, 99, 47, 11], \"expected\": [104, 44, 79, 84, 0, 23, 101, 64, 49, 102, 99, 47, 11], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": [103, 33, 34, 99, 0, 99, 101, 91, 88, 93, 90, 94], \"expected\": [103, 33, 34, 99, 0, 99, 100, 91, 88, 93, 90, 94], \"passed\": false}, {\"check\": \"control 3\", \"actual\": {\"error\": \"bad-c\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": true}, {\"check\": \"control 4\", \"actual\": {\"error\": \"bad-c\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": {\"error\": \"unencodable\", \"char\": \"\\t\"}, \"expected\": {\"error\": \"unencodable\", \"char\": \"\\t\"}, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": {\"error\": \"bad-c\"}, \"expected\": {\"error\": \"bad-c\"}, \"passed\": true}, {\"check\": \"control 7\", \"actual\": [105, 47, 11, 100, 56, 93, 17, 101, 65, 66], \"expected\": [105, 47, 11, 101, 56, 93, 17, 100, 65, 66], \"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."}}