{"abstract":"Elements just above the true midpoint are misread when min + max is odd.","category":"Barcode symbology encoding","checks":8,"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}.","evaluation_group":"w2-barcode-symbology-encoding-scanline-width-classes","failed_approach":"Rounding the midpoint up moves the error to the other side.","family":"w2-barcode-symbology-encoding-scanline-width-classes-threshold-rounding","id":"FA-79781","implementations":{"attempt":{"sha256":"bd230bf0b85746daaef6109bc050688190c35289a8580ba29e7a86c5ee6a56da","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(w):\n    out = [''] * len(w)\n    for parity in (0, 1):\n        idx = list(range(parity, len(w), 2))\n        if not idx:\n            continue\n        vals = [w[i] for i in idx]\n        lo, hi = min(vals), max(vals)\n        if hi * 2 < lo * 3:\n            for i in idx:\n                out[i] = 'N'\n            continue\n        t2 = (lo + hi + 1) // 2 * 2\n        for i in idx:\n            if w[i] * 2 == t2:\n                return {'error': 'ambiguous', 'index': i}\n            out[i] = 'W' if w[i] * 2 > t2 else 'N'\n    return ''.join(out)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[[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']]]\nlabels = [\"regression: integer threshold rounding\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"a5724f57f8cb55e8d5dea1f8202fd945fea919fb8256854ede492b24318fe4b5","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(w):\n    out = [''] * len(w)\n    for parity in (0, 1):\n        idx = list(range(parity, len(w), 2))\n        if not idx:\n            continue\n        vals = [w[i] for i in idx]\n        lo, hi = min(vals), max(vals)\n        if hi * 2 < lo * 3:\n            for i in idx:\n                out[i] = 'N'\n            continue\n        t2 = (lo + hi) // 2 * 2\n        for i in idx:\n            if w[i] * 2 == t2:\n                return {'error': 'ambiguous', 'index': i}\n            out[i] = 'W' if w[i] * 2 > t2 else 'N'\n    return ''.join(out)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[[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']]]\nlabels = [\"regression: integer threshold rounding\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"1bd105a553ac682b80c4a9692fb8d39e69884554d02688209af30bb4a2c8fb4c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(w):\n    out = [''] * len(w)\n    for parity in (0, 1):\n        idx = list(range(parity, len(w), 2))\n        if not idx:\n            continue\n        vals = [w[i] for i in idx]\n        lo, hi = min(vals), max(vals)\n        if hi * 2 < lo * 3:\n            for i in idx:\n                out[i] = 'N'\n            continue\n        t2 = lo + hi\n        for i in idx:\n            if w[i] * 2 == t2:\n                return {'error': 'ambiguous', 'index': i}\n            out[i] = 'W' if w[i] * 2 > t2 else 'N'\n    return ''.join(out)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[[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']]]\nlabels = [\"regression: integer threshold rounding\", \"repair trap\", \"combined fault\", \"control\", \"control\", \"boundary\", \"boundary\", \"control\"]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"%s %d\" % (labels[i % len(labels)], i), solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-barcode-symbology-encoding-scanline-width-classes-threshold-rounding","generated_at":"2026-09-29T14:49:47.608610+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"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.","repair":"Compare 2*width with min + max exactly.","root_cause":"The midpoint is floored to an integer before comparing doubled widths.","sha256":"f3e08b0205f94738a3dcdf8d5211c18e063d230dcf2d61e0e5217d2fbc74171f","title":"Width threshold is rounded to an integer · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":37.431,"exit_code":1,"observations":[{"actual":"NNNNWNNN","check":"regression: integer threshold rounding 0","expected":"NNNNWNNN","passed":true},{"actual":{"error":"ambiguous","index":1},"check":"repair trap 1","expected":"WWNNNWN","passed":false},{"actual":{"error":"ambiguous","index":1},"check":"combined fault 2","expected":"WWNNNNWW","passed":false},{"actual":"NNNNNNNN","check":"control 3","expected":"NNNNNNNN","passed":true},{"actual":"WWNNNWW","check":"control 4","expected":"WWNNNWW","passed":true},{"actual":"NNNWW","check":"boundary 5","expected":"NNNWW","passed":true},{"actual":"NWNNNNNNN","check":"boundary 6","expected":"NWNNNNNNN","passed":true},{"actual":{"error":"ambiguous","index":3},"check":"control 7","expected":"WNWWNWN","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: integer threshold rounding 0\", \"actual\": \"NNNNWNNN\", \"expected\": \"NNNNWNNN\", \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": {\"error\": \"ambiguous\", \"index\": 1}, \"expected\": \"WWNNNWN\", \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": {\"error\": \"ambiguous\", \"index\": 1}, \"expected\": \"WWNNNNWW\", \"passed\": false}, {\"check\": \"control 3\", \"actual\": \"NNNNNNNN\", \"expected\": \"NNNNNNNN\", \"passed\": true}, {\"check\": \"control 4\", \"actual\": \"WWNNNWW\", \"expected\": \"WWNNNWW\", \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": \"NNNWW\", \"expected\": \"NNNWW\", \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": \"NWNNNNNNN\", \"expected\": \"NWNNNNNNN\", \"passed\": true}, {\"check\": \"control 7\", \"actual\": {\"error\": \"ambiguous\", \"index\": 3}, \"expected\": \"WNWWNWN\", \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.97,"exit_code":1,"observations":[{"actual":{"error":"ambiguous","index":2},"check":"regression: integer threshold rounding 0","expected":"NNNNWNNN","passed":false},{"actual":{"error":"ambiguous","index":3},"check":"repair trap 1","expected":"WWNNNWN","passed":false},{"actual":{"error":"ambiguous","index":3},"check":"combined fault 2","expected":"WWNNNNWW","passed":false},{"actual":"NNNNNNNN","check":"control 3","expected":"NNNNNNNN","passed":true},{"actual":"WWNNNWW","check":"control 4","expected":"WWNNNWW","passed":true},{"actual":"NNNWW","check":"boundary 5","expected":"NNNWW","passed":true},{"actual":"NWNNNNNNN","check":"boundary 6","expected":"NWNNNNNNN","passed":true},{"actual":{"error":"ambiguous","index":1},"check":"control 7","expected":"WNWWNWN","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: integer threshold rounding 0\", \"actual\": {\"error\": \"ambiguous\", \"index\": 2}, \"expected\": \"NNNNWNNN\", \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": {\"error\": \"ambiguous\", \"index\": 3}, \"expected\": \"WWNNNWN\", \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": {\"error\": \"ambiguous\", \"index\": 3}, \"expected\": \"WWNNNNWW\", \"passed\": false}, {\"check\": \"control 3\", \"actual\": \"NNNNNNNN\", \"expected\": \"NNNNNNNN\", \"passed\": true}, {\"check\": \"control 4\", \"actual\": \"WWNNNWW\", \"expected\": \"WWNNNWW\", \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": \"NNNWW\", \"expected\": \"NNNWW\", \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": \"NWNNNNNNN\", \"expected\": \"NWNNNNNNN\", \"passed\": true}, {\"check\": \"control 7\", \"actual\": {\"error\": \"ambiguous\", \"index\": 1}, \"expected\": \"WNWWNWN\", \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":38.035,"exit_code":0,"observations":[{"actual":"NNNNWNNN","check":"regression: integer threshold rounding 0","expected":"NNNNWNNN","passed":true},{"actual":"WWNNNWN","check":"repair trap 1","expected":"WWNNNWN","passed":true},{"actual":"WWNNNNWW","check":"combined fault 2","expected":"WWNNNNWW","passed":true},{"actual":"NNNNNNNN","check":"control 3","expected":"NNNNNNNN","passed":true},{"actual":"WWNNNWW","check":"control 4","expected":"WWNNNWW","passed":true},{"actual":"NNNWW","check":"boundary 5","expected":"NNNWW","passed":true},{"actual":"NWNNNNNNN","check":"boundary 6","expected":"NWNNNNNNN","passed":true},{"actual":"WNWWNWN","check":"control 7","expected":"WNWWNWN","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: integer threshold rounding 0\", \"actual\": \"NNNNWNNN\", \"expected\": \"NNNNWNNN\", \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": \"WWNNNWN\", \"expected\": \"WWNNNWN\", \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": \"WWNNNNWW\", \"expected\": \"WWNNNNWW\", \"passed\": true}, {\"check\": \"control 3\", \"actual\": \"NNNNNNNN\", \"expected\": \"NNNNNNNN\", \"passed\": true}, {\"check\": \"control 4\", \"actual\": \"WWNNNWW\", \"expected\": \"WWNNNWW\", \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": \"NNNWW\", \"expected\": \"NNNWW\", \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": \"NWNNNNNNN\", \"expected\": \"NWNNNNNNN\", \"passed\": true}, {\"check\": \"control 7\", \"actual\": \"WNWWNWN\", \"expected\": \"WNWWNWN\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}