FAILURE MAP
← Case archive

FA-79771 / Barcode symbology encoding / Open access

Uniform element widths are reported as ambiguous · case 01

Symbols whose spaces are all narrow fail to decode with an ambiguity error.

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

ROOT CAUSE

Without the ratio guard a class of equal widths puts every element exactly on the threshold.

VERIFIED REPAIR

Treat a class whose max is below 1.5 times its min as all narrow.

Unsuccessful approach: Handling only exactly equal widths still misclassifies 3-and-4 unit noise as N and W.

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 False:
            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 = [[[[4, 4, 4, 4, 3, 3, 3, 3], 'NNNNNNNN'], [[4, 5, 5, 4, 4, 5], 'NNNNNN'], [[6, 8, 4, 3, 3, 8, 7], 'WWNNNWW'], [[2, 5, 2, 10, 9], 'NNNWW'], [[6, 2, 4, 2, 3, 5, 7], 'WNNNNWW'], [[7, 10, 3, 5, 8, 10], 'WWNNWW'], [[13, 2, 5, 1, 5, 2, 5], 'WWNNNWN'], [[6, 11, 6, 3, 6, 4, 6, 3, 5], 'NWNNNNNNN']], [[[3, 5, 11], 'NNW'], [[6, 3, 5, 2, 5, 9], 'NNNNNW'], [[5, 4, 10, 3, 10, 4], 'NNWNWN'], [[5, 2, 11, 2, 11, 6, 11, 2], 'NNWNWWWN'], [[3, 11, 2, 4, 6], 'NWNNW'], [[2, 6, 2, 3, 13, 6], 'NWNNWW'], [[8, 1, 8, 8, 6, 1, 6, 1, 5], 'WNWWNNNNN'], [[4, 2, 4, 2, 3, 2, 3, 9, 4], 'NNNNNNNWN']], [[[9, 3, 9, 4, 5], 'WNWNN'], [[4, 5, 4, 5, 3, 5], 'NNNNNN'], [[2, 12, 13, 12, 12, 13, 13], 'NNWNWNW'], [[3, 1, 7, 1, 3, 11, 3, 12], 'NNWNNWNW'], [[2, 9, 2, 4, 8, 9, 7, 10, 8], 'NWNNWWWWW'], [[8, 2, 9, 13, 4, 13], 'WNWWNW'], [[4, 6, 8, 5, 5, 2, 5, 5, 4], 'NWWWNNNWN'], [[12, 4, 4, 4], 'WNNN']], [[[13, 4, 5, 3, 12, 4, 6, 4, 6], 'WNNNWNNNN'], [[4, 3, 3], 'NNN'], [[12, 3, 3, 4, 2, 3, 3, 3, 12], 'WNNNNNNNW'], [[4, 2, 11, 6, 5, 6, 10], 'NNWWNWW'], [[3, 7, 10, 2, 4, 7], 'NWWNNW'], [[3, 6, 8, 4], 'NWWN'], [[14, 10, 3, 1], 'WWNN'], [[6, 1, 5, 1, 6], 'NNNNN']], [[[4, 5, 10], 'NNW'], [[4, 4, 3, 3, 3], 'NNNNN'], [[3, 3, 4, 4, 3, 4, 4, 4, 3], 'NNNNNNNNN'], [[3, 9, 9, 5, 4, 9], 'NWWNNW'], [[14, 12, 6, 2, 5], 'WWNNN'], [[13, 2, 5, 7], 'WNNW'], [[10, 3, 6, 12], 'WNNW'], [[8, 1, 6], 'NNN']]]
labels = ["regression: all-narrow ratio guard", "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: all-narrow ratio guard 0WWWWNNNNNNNNNNNNFailed
repair trap 1NWWNNWNNNNNNFailed
combined fault 2WWNNNWWWWNNNWWPassed
control 3NNNWWNNNWWPassed
control 4WNNNNWWWNNNNWWPassed
boundary 5WWNNWWWWNNWWPassed
boundary 6WWNNNWNWWNNNWNPassed
control 7WWWNWNWNNNWNNNNNNNFailed

SHA-256 / 0c8d225a009c9010e7a98620fbd41c5baf99fb758b7b21fe8e4ca66e8add8411

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 == lo:
            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 = [[[[4, 4, 4, 4, 3, 3, 3, 3], 'NNNNNNNN'], [[4, 5, 5, 4, 4, 5], 'NNNNNN'], [[6, 8, 4, 3, 3, 8, 7], 'WWNNNWW'], [[2, 5, 2, 10, 9], 'NNNWW'], [[6, 2, 4, 2, 3, 5, 7], 'WNNNNWW'], [[7, 10, 3, 5, 8, 10], 'WWNNWW'], [[13, 2, 5, 1, 5, 2, 5], 'WWNNNWN'], [[6, 11, 6, 3, 6, 4, 6, 3, 5], 'NWNNNNNNN']], [[[3, 5, 11], 'NNW'], [[6, 3, 5, 2, 5, 9], 'NNNNNW'], [[5, 4, 10, 3, 10, 4], 'NNWNWN'], [[5, 2, 11, 2, 11, 6, 11, 2], 'NNWNWWWN'], [[3, 11, 2, 4, 6], 'NWNNW'], [[2, 6, 2, 3, 13, 6], 'NWNNWW'], [[8, 1, 8, 8, 6, 1, 6, 1, 5], 'WNWWNNNNN'], [[4, 2, 4, 2, 3, 2, 3, 9, 4], 'NNNNNNNWN']], [[[9, 3, 9, 4, 5], 'WNWNN'], [[4, 5, 4, 5, 3, 5], 'NNNNNN'], [[2, 12, 13, 12, 12, 13, 13], 'NNWNWNW'], [[3, 1, 7, 1, 3, 11, 3, 12], 'NNWNNWNW'], [[2, 9, 2, 4, 8, 9, 7, 10, 8], 'NWNNWWWWW'], [[8, 2, 9, 13, 4, 13], 'WNWWNW'], [[4, 6, 8, 5, 5, 2, 5, 5, 4], 'NWWWNNNWN'], [[12, 4, 4, 4], 'WNNN']], [[[13, 4, 5, 3, 12, 4, 6, 4, 6], 'WNNNWNNNN'], [[4, 3, 3], 'NNN'], [[12, 3, 3, 4, 2, 3, 3, 3, 12], 'WNNNNNNNW'], [[4, 2, 11, 6, 5, 6, 10], 'NNWWNWW'], [[3, 7, 10, 2, 4, 7], 'NWWNNW'], [[3, 6, 8, 4], 'NWWN'], [[14, 10, 3, 1], 'WWNN'], [[6, 1, 5, 1, 6], 'NNNNN']], [[[4, 5, 10], 'NNW'], [[4, 4, 3, 3, 3], 'NNNNN'], [[3, 3, 4, 4, 3, 4, 4, 4, 3], 'NNNNNNNNN'], [[3, 9, 9, 5, 4, 9], 'NWWNNW'], [[14, 12, 6, 2, 5], 'WWNNN'], [[13, 2, 5, 7], 'WNNW'], [[10, 3, 6, 12], 'WNNW'], [[8, 1, 6], 'NNN']]]
labels = ["regression: all-narrow ratio guard", "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: all-narrow ratio guard 0WWWWNNNNNNNNNNNNFailed
repair trap 1NWWNNWNNNNNNFailed
combined fault 2WWNNNWWWWNNNWWPassed
control 3NNNWWNNNWWPassed
control 4WNNNNWWWNNNNWWPassed
boundary 5WWNNWWWWNNWWPassed
boundary 6WWNNNWNWWNNNWNPassed
control 7WWWNWNWNNNWNNNNNNNFailed

SHA-256 / e7f7a531e24b2901be123f9e318835df184fa48ab6e4ac6b00dcecab617ac2f6

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 = [[[[4, 4, 4, 4, 3, 3, 3, 3], 'NNNNNNNN'], [[4, 5, 5, 4, 4, 5], 'NNNNNN'], [[6, 8, 4, 3, 3, 8, 7], 'WWNNNWW'], [[2, 5, 2, 10, 9], 'NNNWW'], [[6, 2, 4, 2, 3, 5, 7], 'WNNNNWW'], [[7, 10, 3, 5, 8, 10], 'WWNNWW'], [[13, 2, 5, 1, 5, 2, 5], 'WWNNNWN'], [[6, 11, 6, 3, 6, 4, 6, 3, 5], 'NWNNNNNNN']], [[[3, 5, 11], 'NNW'], [[6, 3, 5, 2, 5, 9], 'NNNNNW'], [[5, 4, 10, 3, 10, 4], 'NNWNWN'], [[5, 2, 11, 2, 11, 6, 11, 2], 'NNWNWWWN'], [[3, 11, 2, 4, 6], 'NWNNW'], [[2, 6, 2, 3, 13, 6], 'NWNNWW'], [[8, 1, 8, 8, 6, 1, 6, 1, 5], 'WNWWNNNNN'], [[4, 2, 4, 2, 3, 2, 3, 9, 4], 'NNNNNNNWN']], [[[9, 3, 9, 4, 5], 'WNWNN'], [[4, 5, 4, 5, 3, 5], 'NNNNNN'], [[2, 12, 13, 12, 12, 13, 13], 'NNWNWNW'], [[3, 1, 7, 1, 3, 11, 3, 12], 'NNWNNWNW'], [[2, 9, 2, 4, 8, 9, 7, 10, 8], 'NWNNWWWWW'], [[8, 2, 9, 13, 4, 13], 'WNWWNW'], [[4, 6, 8, 5, 5, 2, 5, 5, 4], 'NWWWNNNWN'], [[12, 4, 4, 4], 'WNNN']], [[[13, 4, 5, 3, 12, 4, 6, 4, 6], 'WNNNWNNNN'], [[4, 3, 3], 'NNN'], [[12, 3, 3, 4, 2, 3, 3, 3, 12], 'WNNNNNNNW'], [[4, 2, 11, 6, 5, 6, 10], 'NNWWNWW'], [[3, 7, 10, 2, 4, 7], 'NWWNNW'], [[3, 6, 8, 4], 'NWWN'], [[14, 10, 3, 1], 'WWNN'], [[6, 1, 5, 1, 6], 'NNNNN']], [[[4, 5, 10], 'NNW'], [[4, 4, 3, 3, 3], 'NNNNN'], [[3, 3, 4, 4, 3, 4, 4, 4, 3], 'NNNNNNNNN'], [[3, 9, 9, 5, 4, 9], 'NWWNNW'], [[14, 12, 6, 2, 5], 'WWNNN'], [[13, 2, 5, 7], 'WNNW'], [[10, 3, 6, 12], 'WNNW'], [[8, 1, 6], 'NNN']]]
labels = ["regression: all-narrow ratio guard", "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: all-narrow ratio guard 0NNNNNNNNNNNNNNNNPassed
repair trap 1NNNNNNNNNNNNPassed
combined fault 2WWNNNWWWWNNNWWPassed
control 3NNNWWNNNWWPassed
control 4WNNNNWWWNNNNWWPassed
boundary 5WWNNWWWWNNWWPassed
boundary 6WWNNNWNWWNNNWNPassed
control 7NWNNNNNNNNWNNNNNNNPassed

SHA-256 / bd5e1a9ae11242b0ac2fcdf9313ce5e1cb50a1f30e0a4c2c15f9066842343904

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

Case digest / 388a856a20f138534a87332cb7fb5dca81e5fb9c373bf5102cb1a75018d1254c