FA-79421 / Barcode symbology encoding / Open access
Set C pairs a digit with a following letter · case 01
Data such as "1234567A" produces a set C segment containing "7A".
ROOT CAUSE
The C loop continues while one digit remains, so the pair can include a non-digit.
VERIFIED REPAIR
Stay in C only while at least two digits remain in the run.
Unsuccessful approach: Requiring three digits leaves a final pair in B unnecessarily.
Case 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", ""]].
Why this case matters
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.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(data):
if any(not (32 <= ord(ch) <= 126) for ch in data):
return None
n = len(data)
def run(j):
k = j
while k < n and data[k] in '0123456789':
k += 1
return k - j
segs = []
r = run(0)
if r >= 4 or (r == n and n >= 2 and n % 2 == 0):
cur = 'C'
else:
cur = 'B'
buf = ''
i = 0
while i < n:
if cur == 'C':
if run(i) >= 1:
buf += data[i:i + 2]
i += 2
continue
segs.append(['C', buf])
buf = ''
cur = 'B'
continue
r = run(i)
if r >= 6 or (r >= 4 and i + r == n):
if r % 2 == 1:
buf += data[i]
i += 1
if buf:
segs.append(['B', buf])
buf = ''
cur = 'C'
continue
buf += data[i]
i += 1
if buf or not segs:
segs.append([cur, buf])
return segs
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['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']]]]]
labels = ["regression: set C exit condition", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: set C exit condition 0 | [['C', '3580131']] | [['C', '358013'], ['B', '1']] | Failed |
| repair trap 1 | [['B', 'lot'], ['C', '17764124'], ['B', 'x']] | [['B', 'lot'], ['C', '17764124'], ['B', 'x']] | Passed |
| combined fault 2 | [['C', '38872Q7088']] | [['C', '3887'], ['B', '2Q'], ['C', '7088']] | Failed |
| control 3 | [['B', 'xAB']] | [['B', 'xAB']] | Passed |
| control 4 | [['B', 'AB']] | [['B', 'AB']] | Passed |
| boundary 5 | [['B', 'x15']] | [['B', 'x15']] | Passed |
| boundary 6 | [['B', '-']] | [['B', '-']] | Passed |
| control 7 | [['C', '83397787832796279-']] | [['C', '8339778783279627'], ['B', '9-']] | Failed |
SHA-256 / 5beb983211e4f071223f00b41b507256889aa003e5bf8eb8509b54573e8c6ba9
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(data):
if any(not (32 <= ord(ch) <= 126) for ch in data):
return None
n = len(data)
def run(j):
k = j
while k < n and data[k] in '0123456789':
k += 1
return k - j
segs = []
r = run(0)
if r >= 4 or (r == n and n >= 2 and n % 2 == 0):
cur = 'C'
else:
cur = 'B'
buf = ''
i = 0
while i < n:
if cur == 'C':
if run(i) >= 3:
buf += data[i:i + 2]
i += 2
continue
segs.append(['C', buf])
buf = ''
cur = 'B'
continue
r = run(i)
if r >= 6 or (r >= 4 and i + r == n):
if r % 2 == 1:
buf += data[i]
i += 1
if buf:
segs.append(['B', buf])
buf = ''
cur = 'C'
continue
buf += data[i]
i += 1
if buf or not segs:
segs.append([cur, buf])
return segs
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['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']]]]]
labels = ["regression: set C exit condition", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: set C exit condition 0 | [['C', '358013'], ['B', '1']] | [['C', '358013'], ['B', '1']] | Passed |
| repair trap 1 | [['B', 'lot'], ['C', '177641'], ['B', '24x']] | [['B', 'lot'], ['C', '17764124'], ['B', 'x']] | Failed |
| combined fault 2 | [['C', '3887'], ['B', '2Q'], ['C', '70'], ['B', '88']] | [['C', '3887'], ['B', '2Q'], ['C', '7088']] | Failed |
| control 3 | [['B', 'xAB']] | [['B', 'xAB']] | Passed |
| control 4 | [['B', 'AB']] | [['B', 'AB']] | Passed |
| boundary 5 | [['B', 'x15']] | [['B', 'x15']] | Passed |
| boundary 6 | [['B', '-']] | [['B', '-']] | Passed |
| control 7 | [['C', '8339778783279627'], ['B', '9-']] | [['C', '8339778783279627'], ['B', '9-']] | Passed |
SHA-256 / 7f4ac64d0fd289f60f59b4e7fc363b51e4fdb0af88d2885d4a0b5736f2949c29
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(data):
if any(not (32 <= ord(ch) <= 126) for ch in data):
return None
n = len(data)
def run(j):
k = j
while k < n and data[k] in '0123456789':
k += 1
return k - j
segs = []
r = run(0)
if r >= 4 or (r == n and n >= 2 and n % 2 == 0):
cur = 'C'
else:
cur = 'B'
buf = ''
i = 0
while i < n:
if cur == 'C':
if run(i) >= 2:
buf += data[i:i + 2]
i += 2
continue
segs.append(['C', buf])
buf = ''
cur = 'B'
continue
r = run(i)
if r >= 6 or (r >= 4 and i + r == n):
if r % 2 == 1:
buf += data[i]
i += 1
if buf:
segs.append(['B', buf])
buf = ''
cur = 'C'
continue
buf += data[i]
i += 1
if buf or not segs:
segs.append([cur, buf])
return segs
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['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']]]]]
labels = ["regression: set C exit condition", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("%s %d" % (labels[i % len(labels)], i), solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: set C exit condition 0 | [['C', '358013'], ['B', '1']] | [['C', '358013'], ['B', '1']] | Passed |
| repair trap 1 | [['B', 'lot'], ['C', '17764124'], ['B', 'x']] | [['B', 'lot'], ['C', '17764124'], ['B', 'x']] | Passed |
| combined fault 2 | [['C', '3887'], ['B', '2Q'], ['C', '7088']] | [['C', '3887'], ['B', '2Q'], ['C', '7088']] | Passed |
| control 3 | [['B', 'xAB']] | [['B', 'xAB']] | Passed |
| control 4 | [['B', 'AB']] | [['B', 'AB']] | Passed |
| boundary 5 | [['B', 'x15']] | [['B', 'x15']] | Passed |
| boundary 6 | [['B', '-']] | [['B', '-']] | Passed |
| control 7 | [['C', '8339778783279627'], ['B', '9-']] | [['C', '8339778783279627'], ['B', '9-']] | Passed |
SHA-256 / 15f515ef8e736d0c0f89c1ff3e5585ea59adfbdb4f2332c02d45df25632f5b15
Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:44.436411+00:00.
Case digest / bcb2b42c78b160f5d2c9e27b44380d7997ac1a87d2bae3f50d39d23612df5a4e