FA-79786 / Barcode symbology encoding / Open access
Data Matrix digit pairs are offset by 128 · case 01
Numeric pairs 00 and 01 collide with the pad and upper-shift range and serial numbers decode wrongly.
ROOT CAUSE
Digit pairs are encoded as 128 + value instead of 130 + value.
VERIFIED REPAIR
Encode a digit pair as 130 + its two-digit value.
Unsuccessful approach: value + 1 encodes the pair as a single ASCII character.
Case contract
Data Matrix ASCII encodation into `capacity` data codewords: two consecutive ASCII digits become 130 + their value; ASCII 0..127 becomes ord + 1; 128..255 becomes Upper Shift 235 then ord - 127; higher code points are unencodable. Too many codewords -> overflow. Padding: the first pad is 129; each later pad at 1-based position p is 129 + ((149 * p) mod 253) + 1, minus 254 if above 254.
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(text, capacity):
cw = []
i = 0
while i < len(text):
c = text[i]
if c in '0123456789' and i + 1 < len(text) and text[i + 1] in '0123456789':
cw.append(128 + int(text[i:i + 2]))
i += 2
continue
o = ord(c)
if o > 255:
return {'error': 'unencodable'}
if o > 127:
cw += [235, o - 127]
else:
cw.append(o + 1)
i += 1
if len(cw) > capacity:
return {'error': 'overflow'}
if len(cw) < capacity:
cw.append(129)
while len(cw) < capacity:
p = len(cw) + 1
v = 129 + ((149 * p) % 253) + 1
if v > 254:
v -= 254
cw.append(v)
return cw
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[('99x', 5), [229, 121, 129, 220, 115]], [('ÿÿ\x8012', 7), [235, 128, 235, 128, 235, 1, 142]], [('', 6), [129, 175, 70, 220, 115, 11]], [('', 11), [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251]], [('\x80', 4), [235, 1, 129, 220]], [('0AB12', 3), {'error': 'overflow'}], [('ABé', 1), {'error': 'overflow'}], [('é99AB0', 10), [235, 106, 229, 66, 67, 49, 129, 56, 206, 101]]], [[(' x99x', 10), [33, 121, 229, 121, 129, 11, 161, 56, 206, 101]], [('55xé', 9), [185, 121, 235, 106, 129, 11, 161, 56, 206]], [('ABxx', 2), {'error': 'overflow'}], [(' AB', 4), [33, 66, 67, 129]], [('0', 9), [49, 129, 70, 220, 115, 11, 161, 56, 206]], [('', 2), [129, 175]], [('0', 4), [49, 129, 70, 220]], [('AB\x8012', 10), [66, 67, 235, 1, 142, 129, 161, 56, 206, 101]]], [[('99ÿé', 7), [229, 235, 128, 235, 106, 129, 161]], [('12', 3), [142, 129, 70]], [('é€5', 6), {'error': 'unencodable'}], [('éé', 3), {'error': 'overflow'}], [('é\x80\x80', 3), {'error': 'overflow'}], [('', 4), [129, 175, 70, 220]], [('', 5), [129, 175, 70, 220, 115]], [('ÿé12', 9), [235, 128, 235, 106, 142, 129, 161, 56, 206]]], [[('120ÿ', 6), [142, 49, 235, 128, 129, 11]], [('55', 8), [185, 129, 70, 220, 115, 11, 161, 56]], [('', 6), [129, 175, 70, 220, 115, 11]], [('\x8012x5', 1), {'error': 'overflow'}], [(' €ÿ\x80', 5), {'error': 'unencodable'}], [('', 11), [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251]], [('0xÿ', 8), [49, 121, 235, 128, 129, 11, 161, 56]], [('99', 3), [229, 129, 70]]], [[('é99\x805', 9), [235, 106, 229, 235, 1, 54, 129, 56, 206]], [('12\x80', 6), [142, 235, 1, 129, 115, 11]], [('5', 2), [54, 129]], [('990', 1), {'error': 'overflow'}], [('599AB€', 8), {'error': 'unencodable'}], [('', 7), [129, 175, 70, 220, 115, 11, 161]], [('xÿ ', 8), [121, 235, 128, 33, 129, 11, 161, 56]], [('995', 11), [229, 54, 129, 220, 115, 11, 161, 56, 206, 101, 251]]]]
labels = ["regression: digit pair codeword", "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: digit pair codeword 0 | [227, 121, 129, 220, 115] | [229, 121, 129, 220, 115] | Failed |
| repair trap 1 | [235, 128, 235, 128, 235, 1, 140] | [235, 128, 235, 128, 235, 1, 142] | Failed |
| combined fault 2 | [129, 175, 70, 220, 115, 11] | [129, 175, 70, 220, 115, 11] | Passed |
| control 3 | [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251] | [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251] | Passed |
| control 4 | [235, 1, 129, 220] | [235, 1, 129, 220] | Passed |
| boundary 5 | {'error': 'overflow'} | {'error': 'overflow'} | Passed |
| boundary 6 | {'error': 'overflow'} | {'error': 'overflow'} | Passed |
| control 7 | [235, 106, 227, 66, 67, 49, 129, 56, 206, 101] | [235, 106, 229, 66, 67, 49, 129, 56, 206, 101] | Failed |
SHA-256 / f6d9a2b05f57677c0c5f778b38ea8be2ec576222630ac1a53092e709cc55e87a
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(text, capacity):
cw = []
i = 0
while i < len(text):
c = text[i]
if c in '0123456789' and i + 1 < len(text) and text[i + 1] in '0123456789':
cw.append(int(text[i:i + 2]) + 1)
i += 2
continue
o = ord(c)
if o > 255:
return {'error': 'unencodable'}
if o > 127:
cw += [235, o - 127]
else:
cw.append(o + 1)
i += 1
if len(cw) > capacity:
return {'error': 'overflow'}
if len(cw) < capacity:
cw.append(129)
while len(cw) < capacity:
p = len(cw) + 1
v = 129 + ((149 * p) % 253) + 1
if v > 254:
v -= 254
cw.append(v)
return cw
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[('99x', 5), [229, 121, 129, 220, 115]], [('ÿÿ\x8012', 7), [235, 128, 235, 128, 235, 1, 142]], [('', 6), [129, 175, 70, 220, 115, 11]], [('', 11), [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251]], [('\x80', 4), [235, 1, 129, 220]], [('0AB12', 3), {'error': 'overflow'}], [('ABé', 1), {'error': 'overflow'}], [('é99AB0', 10), [235, 106, 229, 66, 67, 49, 129, 56, 206, 101]]], [[(' x99x', 10), [33, 121, 229, 121, 129, 11, 161, 56, 206, 101]], [('55xé', 9), [185, 121, 235, 106, 129, 11, 161, 56, 206]], [('ABxx', 2), {'error': 'overflow'}], [(' AB', 4), [33, 66, 67, 129]], [('0', 9), [49, 129, 70, 220, 115, 11, 161, 56, 206]], [('', 2), [129, 175]], [('0', 4), [49, 129, 70, 220]], [('AB\x8012', 10), [66, 67, 235, 1, 142, 129, 161, 56, 206, 101]]], [[('99ÿé', 7), [229, 235, 128, 235, 106, 129, 161]], [('12', 3), [142, 129, 70]], [('é€5', 6), {'error': 'unencodable'}], [('éé', 3), {'error': 'overflow'}], [('é\x80\x80', 3), {'error': 'overflow'}], [('', 4), [129, 175, 70, 220]], [('', 5), [129, 175, 70, 220, 115]], [('ÿé12', 9), [235, 128, 235, 106, 142, 129, 161, 56, 206]]], [[('120ÿ', 6), [142, 49, 235, 128, 129, 11]], [('55', 8), [185, 129, 70, 220, 115, 11, 161, 56]], [('', 6), [129, 175, 70, 220, 115, 11]], [('\x8012x5', 1), {'error': 'overflow'}], [(' €ÿ\x80', 5), {'error': 'unencodable'}], [('', 11), [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251]], [('0xÿ', 8), [49, 121, 235, 128, 129, 11, 161, 56]], [('99', 3), [229, 129, 70]]], [[('é99\x805', 9), [235, 106, 229, 235, 1, 54, 129, 56, 206]], [('12\x80', 6), [142, 235, 1, 129, 115, 11]], [('5', 2), [54, 129]], [('990', 1), {'error': 'overflow'}], [('599AB€', 8), {'error': 'unencodable'}], [('', 7), [129, 175, 70, 220, 115, 11, 161]], [('xÿ ', 8), [121, 235, 128, 33, 129, 11, 161, 56]], [('995', 11), [229, 54, 129, 220, 115, 11, 161, 56, 206, 101, 251]]]]
labels = ["regression: digit pair codeword", "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: digit pair codeword 0 | [100, 121, 129, 220, 115] | [229, 121, 129, 220, 115] | Failed |
| repair trap 1 | [235, 128, 235, 128, 235, 1, 13] | [235, 128, 235, 128, 235, 1, 142] | Failed |
| combined fault 2 | [129, 175, 70, 220, 115, 11] | [129, 175, 70, 220, 115, 11] | Passed |
| control 3 | [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251] | [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251] | Passed |
| control 4 | [235, 1, 129, 220] | [235, 1, 129, 220] | Passed |
| boundary 5 | {'error': 'overflow'} | {'error': 'overflow'} | Passed |
| boundary 6 | {'error': 'overflow'} | {'error': 'overflow'} | Passed |
| control 7 | [235, 106, 100, 66, 67, 49, 129, 56, 206, 101] | [235, 106, 229, 66, 67, 49, 129, 56, 206, 101] | Failed |
SHA-256 / 5024caaba8d55071cb192ffa85ef9dad4b0c5c93688d8336a33fe11191d52814
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(text, capacity):
cw = []
i = 0
while i < len(text):
c = text[i]
if c in '0123456789' and i + 1 < len(text) and text[i + 1] in '0123456789':
cw.append(130 + int(text[i:i + 2]))
i += 2
continue
o = ord(c)
if o > 255:
return {'error': 'unencodable'}
if o > 127:
cw += [235, o - 127]
else:
cw.append(o + 1)
i += 1
if len(cw) > capacity:
return {'error': 'overflow'}
if len(cw) < capacity:
cw.append(129)
while len(cw) < capacity:
p = len(cw) + 1
v = 129 + ((149 * p) % 253) + 1
if v > 254:
v -= 254
cw.append(v)
return cw
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[('99x', 5), [229, 121, 129, 220, 115]], [('ÿÿ\x8012', 7), [235, 128, 235, 128, 235, 1, 142]], [('', 6), [129, 175, 70, 220, 115, 11]], [('', 11), [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251]], [('\x80', 4), [235, 1, 129, 220]], [('0AB12', 3), {'error': 'overflow'}], [('ABé', 1), {'error': 'overflow'}], [('é99AB0', 10), [235, 106, 229, 66, 67, 49, 129, 56, 206, 101]]], [[(' x99x', 10), [33, 121, 229, 121, 129, 11, 161, 56, 206, 101]], [('55xé', 9), [185, 121, 235, 106, 129, 11, 161, 56, 206]], [('ABxx', 2), {'error': 'overflow'}], [(' AB', 4), [33, 66, 67, 129]], [('0', 9), [49, 129, 70, 220, 115, 11, 161, 56, 206]], [('', 2), [129, 175]], [('0', 4), [49, 129, 70, 220]], [('AB\x8012', 10), [66, 67, 235, 1, 142, 129, 161, 56, 206, 101]]], [[('99ÿé', 7), [229, 235, 128, 235, 106, 129, 161]], [('12', 3), [142, 129, 70]], [('é€5', 6), {'error': 'unencodable'}], [('éé', 3), {'error': 'overflow'}], [('é\x80\x80', 3), {'error': 'overflow'}], [('', 4), [129, 175, 70, 220]], [('', 5), [129, 175, 70, 220, 115]], [('ÿé12', 9), [235, 128, 235, 106, 142, 129, 161, 56, 206]]], [[('120ÿ', 6), [142, 49, 235, 128, 129, 11]], [('55', 8), [185, 129, 70, 220, 115, 11, 161, 56]], [('', 6), [129, 175, 70, 220, 115, 11]], [('\x8012x5', 1), {'error': 'overflow'}], [(' €ÿ\x80', 5), {'error': 'unencodable'}], [('', 11), [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251]], [('0xÿ', 8), [49, 121, 235, 128, 129, 11, 161, 56]], [('99', 3), [229, 129, 70]]], [[('é99\x805', 9), [235, 106, 229, 235, 1, 54, 129, 56, 206]], [('12\x80', 6), [142, 235, 1, 129, 115, 11]], [('5', 2), [54, 129]], [('990', 1), {'error': 'overflow'}], [('599AB€', 8), {'error': 'unencodable'}], [('', 7), [129, 175, 70, 220, 115, 11, 161]], [('xÿ ', 8), [121, 235, 128, 33, 129, 11, 161, 56]], [('995', 11), [229, 54, 129, 220, 115, 11, 161, 56, 206, 101, 251]]]]
labels = ["regression: digit pair codeword", "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: digit pair codeword 0 | [229, 121, 129, 220, 115] | [229, 121, 129, 220, 115] | Passed |
| repair trap 1 | [235, 128, 235, 128, 235, 1, 142] | [235, 128, 235, 128, 235, 1, 142] | Passed |
| combined fault 2 | [129, 175, 70, 220, 115, 11] | [129, 175, 70, 220, 115, 11] | Passed |
| control 3 | [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251] | [129, 175, 70, 220, 115, 11, 161, 56, 206, 101, 251] | Passed |
| control 4 | [235, 1, 129, 220] | [235, 1, 129, 220] | Passed |
| boundary 5 | {'error': 'overflow'} | {'error': 'overflow'} | Passed |
| boundary 6 | {'error': 'overflow'} | {'error': 'overflow'} | Passed |
| control 7 | [235, 106, 229, 66, 67, 49, 129, 56, 206, 101] | [235, 106, 229, 66, 67, 49, 129, 56, 206, 101] | Passed |
SHA-256 / 4fe8830102ab2af1c92d2dba1d2866e3e4332f1183dbfc5555ec23b4518a751e
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:47.649672+00:00.
Case digest / 5cc373b6979954bbd04e611cf080bcefffd0fbbca22399d4de3f55badded450d