FAILURE MAP
← Case archive

FA-79781 / Barcode symbology encoding / Open access

Width threshold is rounded to an integer · case 01

Elements just above the true midpoint are misread when min + max is odd.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The midpoint is floored to an integer before comparing doubled widths.

VERIFIED REPAIR

Compare 2*width with min + max exactly.

Unsuccessful approach: Rounding the midpoint up moves the error to the other side.

Case contract

Classify measured element widths of a two-width symbology scanline (bars at even indexes, spaces at odd) into N/W. Bars and spaces are classified separately because ink spread widens bars. Within a class, if max < 1.5 * min all elements are narrow; otherwise the threshold is (min + max) / 2, elements above it are wide, below it narrow, and an element exactly on it is {"error": "ambiguous", "index": i}.

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(w):
    out = [''] * len(w)
    for parity in (0, 1):
        idx = list(range(parity, len(w), 2))
        if not idx:
            continue
        vals = [w[i] for i in idx]
        lo, hi = min(vals), max(vals)
        if hi * 2 < lo * 3:
            for i in idx:
                out[i] = 'N'
            continue
        t2 = (lo + hi) // 2 * 2
        for i in idx:
            if w[i] * 2 == t2:
                return {'error': 'ambiguous', 'index': i}
            out[i] = 'W' if w[i] * 2 > t2 else 'N'
    return ''.join(out)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[5, 10, 6, 11, 8, 11, 6, 11], 'NNNNWNNN'], [[13, 2, 5, 1, 5, 2, 5], 'WWNNNWN'], [[9, 2, 5, 1, 5, 1, 10, 2], 'WWNNNNWW'], [[4, 4, 4, 4, 3, 3, 3, 3], 'NNNNNNNN'], [[6, 8, 4, 3, 3, 8, 7], 'WWNNNWW'], [[2, 5, 2, 10, 9], 'NNNWW'], [[6, 11, 6, 3, 6, 4, 6, 3, 5], 'NWNNNNNNN'], [[15, 2, 15, 3, 2, 3, 2], 'WNWWNWN']], [[[3, 2, 10, 3, 11, 2, 3], 'NNWWWNN'], [[5, 2, 13, 3, 5, 2, 5, 2], 'NNWWNNNN'], [[9, 2, 2, 3, 8, 2, 2, 3, 8], 'WNNWWNNWW'], [[5, 2, 11, 2, 11, 6, 11, 2], 'NNWNWWWN'], [[3, 11, 2, 4, 6], 'NWNNW'], [[6, 2, 7, 2, 6], 'NNNNN'], [[2, 6, 2, 3, 13, 6], 'NWNNWW'], [[3, 7, 3, 7, 3, 4, 4, 5, 3], 'NWNWNNNNN']], [[[2, 5, 3, 5, 2], 'NNWNN'], [[4, 2, 4, 3, 11, 3, 4], 'NNNWWWN'], [[11, 4, 4, 4, 3, 10], 'WNNNNW'], [[9, 3, 9, 4, 5], 'WNWNN'], [[8, 1], 'NN'], [[3, 4, 3, 6, 4, 6, 11, 5], {'error': 'ambiguous', 'index': 7}], [[2, 4], 'NN'], [[3, 3, 4, 2, 8], 'NWNNW']], [[[5, 1, 5, 2, 8, 1], 'NNNWWN'], [[6, 2, 3, 3], 'WNNW'], [[13, 4, 5, 3, 12, 4, 6, 4, 6], 'WNNNWNNNN'], [[6, 4], 'NN'], [[3, 3, 3, 3, 4], 'NNNNN'], [[2], 'N'], [[4], 'N'], [[6, 3, 5, 3, 8, 4, 5, 10], 'NNNNWNNW']], [[[3, 3, 12, 2, 3, 3, 4], 'NWWNNWN'], [[13, 1, 6, 2], 'WNNW'], [[4, 2, 4, 9, 5], 'NNNWN'], [[13, 9, 5, 4, 13, 8, 6], 'WWNNWWN'], [[4, 5, 10], 'NNW'], [[10, 2], 'NN'], [[6, 5, 5, 3, 6], 'NWNNN'], [[2, 1, 2, 1, 3, 2, 3, 11, 2], 'NNNNWNWWN']]]
labels = ["regression: integer threshold rounding", "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 fixtureActualExpectedOutcome
regression: integer threshold rounding 0{'error': 'ambiguous', 'index': 2}NNNNWNNNFailed
repair trap 1{'error': 'ambiguous', 'index': 3}WWNNNWNFailed
combined fault 2{'error': 'ambiguous', 'index': 3}WWNNNNWWFailed
control 3NNNNNNNNNNNNNNNNPassed
control 4WWNNNWWWWNNNWWPassed
boundary 5NNNWWNNNWWPassed
boundary 6NWNNNNNNNNWNNNNNNNPassed
control 7{'error': 'ambiguous', 'index': 1}WNWWNWNFailed

SHA-256 / a5724f57f8cb55e8d5dea1f8202fd945fea919fb8256854ede492b24318fe4b5

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(w):
    out = [''] * len(w)
    for parity in (0, 1):
        idx = list(range(parity, len(w), 2))
        if not idx:
            continue
        vals = [w[i] for i in idx]
        lo, hi = min(vals), max(vals)
        if hi * 2 < lo * 3:
            for i in idx:
                out[i] = 'N'
            continue
        t2 = (lo + hi + 1) // 2 * 2
        for i in idx:
            if w[i] * 2 == t2:
                return {'error': 'ambiguous', 'index': i}
            out[i] = 'W' if w[i] * 2 > t2 else 'N'
    return ''.join(out)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[5, 10, 6, 11, 8, 11, 6, 11], 'NNNNWNNN'], [[13, 2, 5, 1, 5, 2, 5], 'WWNNNWN'], [[9, 2, 5, 1, 5, 1, 10, 2], 'WWNNNNWW'], [[4, 4, 4, 4, 3, 3, 3, 3], 'NNNNNNNN'], [[6, 8, 4, 3, 3, 8, 7], 'WWNNNWW'], [[2, 5, 2, 10, 9], 'NNNWW'], [[6, 11, 6, 3, 6, 4, 6, 3, 5], 'NWNNNNNNN'], [[15, 2, 15, 3, 2, 3, 2], 'WNWWNWN']], [[[3, 2, 10, 3, 11, 2, 3], 'NNWWWNN'], [[5, 2, 13, 3, 5, 2, 5, 2], 'NNWWNNNN'], [[9, 2, 2, 3, 8, 2, 2, 3, 8], 'WNNWWNNWW'], [[5, 2, 11, 2, 11, 6, 11, 2], 'NNWNWWWN'], [[3, 11, 2, 4, 6], 'NWNNW'], [[6, 2, 7, 2, 6], 'NNNNN'], [[2, 6, 2, 3, 13, 6], 'NWNNWW'], [[3, 7, 3, 7, 3, 4, 4, 5, 3], 'NWNWNNNNN']], [[[2, 5, 3, 5, 2], 'NNWNN'], [[4, 2, 4, 3, 11, 3, 4], 'NNNWWWN'], [[11, 4, 4, 4, 3, 10], 'WNNNNW'], [[9, 3, 9, 4, 5], 'WNWNN'], [[8, 1], 'NN'], [[3, 4, 3, 6, 4, 6, 11, 5], {'error': 'ambiguous', 'index': 7}], [[2, 4], 'NN'], [[3, 3, 4, 2, 8], 'NWNNW']], [[[5, 1, 5, 2, 8, 1], 'NNNWWN'], [[6, 2, 3, 3], 'WNNW'], [[13, 4, 5, 3, 12, 4, 6, 4, 6], 'WNNNWNNNN'], [[6, 4], 'NN'], [[3, 3, 3, 3, 4], 'NNNNN'], [[2], 'N'], [[4], 'N'], [[6, 3, 5, 3, 8, 4, 5, 10], 'NNNNWNNW']], [[[3, 3, 12, 2, 3, 3, 4], 'NWWNNWN'], [[13, 1, 6, 2], 'WNNW'], [[4, 2, 4, 9, 5], 'NNNWN'], [[13, 9, 5, 4, 13, 8, 6], 'WWNNWWN'], [[4, 5, 10], 'NNW'], [[10, 2], 'NN'], [[6, 5, 5, 3, 6], 'NWNNN'], [[2, 1, 2, 1, 3, 2, 3, 11, 2], 'NNNNWNWWN']]]
labels = ["regression: integer threshold rounding", "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 fixtureActualExpectedOutcome
regression: integer threshold rounding 0NNNNWNNNNNNNWNNNPassed
repair trap 1{'error': 'ambiguous', 'index': 1}WWNNNWNFailed
combined fault 2{'error': 'ambiguous', 'index': 1}WWNNNNWWFailed
control 3NNNNNNNNNNNNNNNNPassed
control 4WWNNNWWWWNNNWWPassed
boundary 5NNNWWNNNWWPassed
boundary 6NWNNNNNNNNWNNNNNNNPassed
control 7{'error': 'ambiguous', 'index': 3}WNWWNWNFailed

SHA-256 / bd230bf0b85746daaef6109bc050688190c35289a8580ba29e7a86c5ee6a56da

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(w):
    out = [''] * len(w)
    for parity in (0, 1):
        idx = list(range(parity, len(w), 2))
        if not idx:
            continue
        vals = [w[i] for i in idx]
        lo, hi = min(vals), max(vals)
        if hi * 2 < lo * 3:
            for i in idx:
                out[i] = 'N'
            continue
        t2 = lo + hi
        for i in idx:
            if w[i] * 2 == t2:
                return {'error': 'ambiguous', 'index': i}
            out[i] = 'W' if w[i] * 2 > t2 else 'N'
    return ''.join(out)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[[5, 10, 6, 11, 8, 11, 6, 11], 'NNNNWNNN'], [[13, 2, 5, 1, 5, 2, 5], 'WWNNNWN'], [[9, 2, 5, 1, 5, 1, 10, 2], 'WWNNNNWW'], [[4, 4, 4, 4, 3, 3, 3, 3], 'NNNNNNNN'], [[6, 8, 4, 3, 3, 8, 7], 'WWNNNWW'], [[2, 5, 2, 10, 9], 'NNNWW'], [[6, 11, 6, 3, 6, 4, 6, 3, 5], 'NWNNNNNNN'], [[15, 2, 15, 3, 2, 3, 2], 'WNWWNWN']], [[[3, 2, 10, 3, 11, 2, 3], 'NNWWWNN'], [[5, 2, 13, 3, 5, 2, 5, 2], 'NNWWNNNN'], [[9, 2, 2, 3, 8, 2, 2, 3, 8], 'WNNWWNNWW'], [[5, 2, 11, 2, 11, 6, 11, 2], 'NNWNWWWN'], [[3, 11, 2, 4, 6], 'NWNNW'], [[6, 2, 7, 2, 6], 'NNNNN'], [[2, 6, 2, 3, 13, 6], 'NWNNWW'], [[3, 7, 3, 7, 3, 4, 4, 5, 3], 'NWNWNNNNN']], [[[2, 5, 3, 5, 2], 'NNWNN'], [[4, 2, 4, 3, 11, 3, 4], 'NNNWWWN'], [[11, 4, 4, 4, 3, 10], 'WNNNNW'], [[9, 3, 9, 4, 5], 'WNWNN'], [[8, 1], 'NN'], [[3, 4, 3, 6, 4, 6, 11, 5], {'error': 'ambiguous', 'index': 7}], [[2, 4], 'NN'], [[3, 3, 4, 2, 8], 'NWNNW']], [[[5, 1, 5, 2, 8, 1], 'NNNWWN'], [[6, 2, 3, 3], 'WNNW'], [[13, 4, 5, 3, 12, 4, 6, 4, 6], 'WNNNWNNNN'], [[6, 4], 'NN'], [[3, 3, 3, 3, 4], 'NNNNN'], [[2], 'N'], [[4], 'N'], [[6, 3, 5, 3, 8, 4, 5, 10], 'NNNNWNNW']], [[[3, 3, 12, 2, 3, 3, 4], 'NWWNNWN'], [[13, 1, 6, 2], 'WNNW'], [[4, 2, 4, 9, 5], 'NNNWN'], [[13, 9, 5, 4, 13, 8, 6], 'WWNNWWN'], [[4, 5, 10], 'NNW'], [[10, 2], 'NN'], [[6, 5, 5, 3, 6], 'NWNNN'], [[2, 1, 2, 1, 3, 2, 3, 11, 2], 'NNNNWNWWN']]]
labels = ["regression: integer threshold rounding", "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 fixtureActualExpectedOutcome
regression: integer threshold rounding 0NNNNWNNNNNNNWNNNPassed
repair trap 1WWNNNWNWWNNNWNPassed
combined fault 2WWNNNNWWWWNNNNWWPassed
control 3NNNNNNNNNNNNNNNNPassed
control 4WWNNNWWWWNNNWWPassed
boundary 5NNNWWNNNWWPassed
boundary 6NWNNNNNNNNWNNNNNNNPassed
control 7WNWWNWNWNWWNWNPassed

SHA-256 / 1bd105a553ac682b80c4a9692fb8d39e69884554d02688209af30bb4a2c8fb4c

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.608610+00:00.

Case digest / f3e08b0205f94738a3dcdf8d5211c18e063d230dcf2d61e0e5217d2fbc74171f