FAILURE MAP
← Case archive

FA-79766 / Barcode symbology encoding / Open access

Bars and spaces share one width threshold · case 01

Heavily printed labels read every narrow bar as wide because ink spread shifts bars against spaces.

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

ROOT CAUSE

All elements are classified against a single threshold.

VERIFIED REPAIR

Compute separate thresholds for bars (even) and spaces (odd).

Unsuccessful approach: Overlapping index ranges let the second pass reclassify bars with the space threshold.

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,):
        idx = list(range(len(w)))
        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, 4, 6], 'WNN'], [[13, 2, 5, 1, 5, 2, 5], 'WWNNNWN'], [[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'], [[3, 10, 3, 11], 'NNNN']], [[[3, 11, 2, 4, 6], 'NWNNW'], [[4, 1, 7], 'NNW'], [[3, 5, 11], 'NNW'], [[4, 2, 4, 2, 3, 2, 3, 9, 4], 'NNNNNNNWN'], [[4, 3, 4, 4], 'NNNN'], [[13, 3, 13, 3, 13, 4, 2], 'WNWNWNN'], [[3, 4, 3, 3, 3, 3, 4], 'NNNNNNN'], [[6, 2, 7, 2, 6], 'NNNNN']], [[[2, 4], 'NN'], [[4, 5, 4, 5, 3, 5], 'NNNNNN'], [[2, 5, 3, 5, 2], 'NNWNN'], [[11, 4, 4, 4, 3, 10], 'WNNNNW'], [[9, 3, 9, 4, 5], 'WNWNN'], [[3, 1, 7, 1, 3, 11, 3, 12], 'NNWNNWNW'], [[3, 3, 9, 4, 3, 4, 2], 'NNWNNNN'], [[3, 4, 3, 6, 4, 6, 11, 5], {'error': 'ambiguous', 'index': 7}]], [[[13, 3], 'NN'], [[5, 2, 4, 2, 4, 2], 'NNNNNN'], [[2], 'N'], [[4], 'N'], [[14, 2, 14, 2, 4], 'WNWNN'], [[4, 2, 10, 11, 5, 2, 5, 12, 9], 'NNWWNNNWW'], [[4, 3, 3], 'NNN'], [[11, 1, 4, 2, 11, 1], 'WNNWWN']], [[[10, 2], 'NN'], [[11, 2, 11], 'NNN'], [[4, 5, 10], 'NNW'], [[3], 'N'], [[8], 'N'], [[4, 4, 3, 3, 3], 'NNNNN'], [[4, 4, 4, 3, 4, 3, 3, 3], 'NNNNNNNN'], [[8, 1, 6], 'NNN']]]
labels = ["regression: separate bar and space thresholds", "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: separate bar and space thresholds 0{'error': 'ambiguous', 'index': 4}NNNNWNNNFailed
repair trap 1WNNWNNPassed
combined fault 2WNNNNNNWWNNNWNFailed
control 3NNNNNNNNNNNNNNNNPassed
control 4WWNNNWWWWNNNWWPassed
boundary 5NNNWWNNNWWPassed
boundary 6NWNNNNNNNNWNNNNNNNPassed
control 7NWNWNNNNFailed

SHA-256 / 892123ef86d0ea7ddbe5b30ae8c039db296cd66c97808db29092e326bb7deeae

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)))
        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, 4, 6], 'WNN'], [[13, 2, 5, 1, 5, 2, 5], 'WWNNNWN'], [[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'], [[3, 10, 3, 11], 'NNNN']], [[[3, 11, 2, 4, 6], 'NWNNW'], [[4, 1, 7], 'NNW'], [[3, 5, 11], 'NNW'], [[4, 2, 4, 2, 3, 2, 3, 9, 4], 'NNNNNNNWN'], [[4, 3, 4, 4], 'NNNN'], [[13, 3, 13, 3, 13, 4, 2], 'WNWNWNN'], [[3, 4, 3, 3, 3, 3, 4], 'NNNNNNN'], [[6, 2, 7, 2, 6], 'NNNNN']], [[[2, 4], 'NN'], [[4, 5, 4, 5, 3, 5], 'NNNNNN'], [[2, 5, 3, 5, 2], 'NNWNN'], [[11, 4, 4, 4, 3, 10], 'WNNNNW'], [[9, 3, 9, 4, 5], 'WNWNN'], [[3, 1, 7, 1, 3, 11, 3, 12], 'NNWNNWNW'], [[3, 3, 9, 4, 3, 4, 2], 'NNWNNNN'], [[3, 4, 3, 6, 4, 6, 11, 5], {'error': 'ambiguous', 'index': 7}]], [[[13, 3], 'NN'], [[5, 2, 4, 2, 4, 2], 'NNNNNN'], [[2], 'N'], [[4], 'N'], [[14, 2, 14, 2, 4], 'WNWNN'], [[4, 2, 10, 11, 5, 2, 5, 12, 9], 'NNWWNNNWW'], [[4, 3, 3], 'NNN'], [[11, 1, 4, 2, 11, 1], 'WNNWWN']], [[[10, 2], 'NN'], [[11, 2, 11], 'NNN'], [[4, 5, 10], 'NNW'], [[3], 'N'], [[8], 'N'], [[4, 4, 3, 3, 3], 'NNNNN'], [[4, 4, 4, 3, 4, 3, 3, 3], 'NNNNNNNN'], [[8, 1, 6], 'NNN']]]
labels = ["regression: separate bar and space thresholds", "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: separate bar and space thresholds 0{'error': 'ambiguous', 'index': 4}NNNNWNNNFailed
repair trap 1WNWWNNFailed
combined fault 2WNWNWNWWWNNNWNFailed
control 3NNNNNNNNNNNNNNNNPassed
control 4WWNNNWWWWNNNWWPassed
boundary 5NNNWWNNNWWPassed
boundary 6NWNNNNNNNNWNNNNNNNPassed
control 7NWNWNNNNFailed

SHA-256 / b75057a726be7bc51ab8b2580c4467fd9e976f05740170496b7414889cfa0332

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, 4, 6], 'WNN'], [[13, 2, 5, 1, 5, 2, 5], 'WWNNNWN'], [[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'], [[3, 10, 3, 11], 'NNNN']], [[[3, 11, 2, 4, 6], 'NWNNW'], [[4, 1, 7], 'NNW'], [[3, 5, 11], 'NNW'], [[4, 2, 4, 2, 3, 2, 3, 9, 4], 'NNNNNNNWN'], [[4, 3, 4, 4], 'NNNN'], [[13, 3, 13, 3, 13, 4, 2], 'WNWNWNN'], [[3, 4, 3, 3, 3, 3, 4], 'NNNNNNN'], [[6, 2, 7, 2, 6], 'NNNNN']], [[[2, 4], 'NN'], [[4, 5, 4, 5, 3, 5], 'NNNNNN'], [[2, 5, 3, 5, 2], 'NNWNN'], [[11, 4, 4, 4, 3, 10], 'WNNNNW'], [[9, 3, 9, 4, 5], 'WNWNN'], [[3, 1, 7, 1, 3, 11, 3, 12], 'NNWNNWNW'], [[3, 3, 9, 4, 3, 4, 2], 'NNWNNNN'], [[3, 4, 3, 6, 4, 6, 11, 5], {'error': 'ambiguous', 'index': 7}]], [[[13, 3], 'NN'], [[5, 2, 4, 2, 4, 2], 'NNNNNN'], [[2], 'N'], [[4], 'N'], [[14, 2, 14, 2, 4], 'WNWNN'], [[4, 2, 10, 11, 5, 2, 5, 12, 9], 'NNWWNNNWW'], [[4, 3, 3], 'NNN'], [[11, 1, 4, 2, 11, 1], 'WNNWWN']], [[[10, 2], 'NN'], [[11, 2, 11], 'NNN'], [[4, 5, 10], 'NNW'], [[3], 'N'], [[8], 'N'], [[4, 4, 3, 3, 3], 'NNNNN'], [[4, 4, 4, 3, 4, 3, 3, 3], 'NNNNNNNN'], [[8, 1, 6], 'NNN']]]
labels = ["regression: separate bar and space thresholds", "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: separate bar and space thresholds 0NNNNWNNNNNNNWNNNPassed
repair trap 1WNNWNNPassed
combined fault 2WWNNNWNWWNNNWNPassed
control 3NNNNNNNNNNNNNNNNPassed
control 4WWNNNWWWWNNNWWPassed
boundary 5NNNWWNNNWWPassed
boundary 6NWNNNNNNNNWNNNNNNNPassed
control 7NNNNNNNNPassed

SHA-256 / d00aef575b344b48b4fd0b8ee76726f52e7d727fce146befe3fa02d50661f131

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

Case digest / c0154da785ea16f88888b4e3b2108eff5967517192f0c96742824460ca8cdc3d