{"abstract":"Symbols at versions 9 and 26 are built with a count field two bits too wide and fail to decode.","category":"Barcode symbology encoding","checks":8,"contract":"Compute the length in bits of one QR segment: 4-bit mode indicator, a character count indicator whose width depends on mode and version band (1-9, 10-26, 27-40): numeric 10/12/14, alphanumeric 9/11/13, byte 8/16/16, and the data bits: numeric 10 bits per 3 digits plus 4 or 7 for a remainder of 1 or 2, alphanumeric 11 bits per pair plus 6 for a single, byte 8 bits per UTF-8 byte. Alphanumeric allows 0-9 A-Z space $ % * + - . / :. A count that does not fit the indicator is too-long. Errors: version, charset, mode, too-long.","evaluation_group":"w2-barcode-symbology-encoding-qr-segment-bits","failed_approach":"Extending the first band to version 10 gives version 10 the short indicator.","family":"w2-barcode-symbology-encoding-qr-segment-bits-version-band","id":"FA-79641","implementations":{"attempt":{"sha256":"40f79b14f1466ef8b7f7ebb84dc426b1a186c84dbd659693a932af45300300a3","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(mode, data, version):\n    if not 1 <= version <= 40:\n        return {'error': 'version'}\n    band = 0 if version <= 10 else (1 if version <= 26 else 2)\n    ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'\n    if mode == 'numeric':\n        if not all(c in '0123456789' for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 10 * (count // 3) + [0, 4, 7][count % 3]\n        cci = [10, 12, 14][band]\n    elif mode == 'alnum':\n        if not all(c in ALNUM for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 11 * (count // 2) + 6 * (count % 2)\n        cci = [9, 11, 13][band]\n    elif mode == 'byte':\n        count = len(data.encode('utf-8'))\n        bits = 8 * count\n        cci = [8, 16, 16][band]\n    else:\n        return {'error': 'mode'}\n    if count >= 1 << cci:\n        return {'error': 'too-long'}\n    return 4 + cci + bits\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[('numeric', '443978087443', 26), 56], [('numeric', '115232806735', 10), 56], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('byte', '1€11€é', 40), 108], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('byte', '€éa1a1 ', 9), 92]], [[('numeric', '7643868', 9), 38], [('alnum', '*::2Z%:*', 10), 59], [('numeric', '053142', 0), {'error': 'version'}], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('alnum', '+qB+', 0), {'error': 'version'}], [('byte', 'bé', 9), 36]], [[('alnum', '*Z+-', 9), 35], [('numeric', '9420', 10), 30], [('numeric', '37219', 5), 31], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('byte', '', 26), 20], [('numeric', '53', 26), 23]], [[('alnum', '$A.', 9), 30], [('byte', ' 11b€€', 10), 100], [('byte', 'abbbaaa', 26), 76], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('numeric', '2', 1), 18], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', ' *$$:*/Z$', 26), 65]], [[('alnum', '+Z2Z2B', 26), 48], [('alnum', '+', 10), 21], [('kanji', 'é ba', 40), {'error': 'mode'}], [('kanji', 'éb', 1), {'error': 'mode'}], [('byte', 'a€', 26), 52], [('alnum', '.', 5), 19], [('byte', '€é1', 27), 68], [('numeric', '14974', 9), 31]]]\nlabels = [\"regression: count indicator version band\", \"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":"cee5db9796c977a7f030ffdab5fed062e7b7d36c21061a3377f18d06b996507e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(mode, data, version):\n    if not 1 <= version <= 40:\n        return {'error': 'version'}\n    band = 0 if version < 9 else (1 if version < 26 else 2)\n    ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'\n    if mode == 'numeric':\n        if not all(c in '0123456789' for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 10 * (count // 3) + [0, 4, 7][count % 3]\n        cci = [10, 12, 14][band]\n    elif mode == 'alnum':\n        if not all(c in ALNUM for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 11 * (count // 2) + 6 * (count % 2)\n        cci = [9, 11, 13][band]\n    elif mode == 'byte':\n        count = len(data.encode('utf-8'))\n        bits = 8 * count\n        cci = [8, 16, 16][band]\n    else:\n        return {'error': 'mode'}\n    if count >= 1 << cci:\n        return {'error': 'too-long'}\n    return 4 + cci + bits\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[('numeric', '443978087443', 26), 56], [('numeric', '115232806735', 10), 56], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('byte', '1€11€é', 40), 108], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('byte', '€éa1a1 ', 9), 92]], [[('numeric', '7643868', 9), 38], [('alnum', '*::2Z%:*', 10), 59], [('numeric', '053142', 0), {'error': 'version'}], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('alnum', '+qB+', 0), {'error': 'version'}], [('byte', 'bé', 9), 36]], [[('alnum', '*Z+-', 9), 35], [('numeric', '9420', 10), 30], [('numeric', '37219', 5), 31], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('byte', '', 26), 20], [('numeric', '53', 26), 23]], [[('alnum', '$A.', 9), 30], [('byte', ' 11b€€', 10), 100], [('byte', 'abbbaaa', 26), 76], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('numeric', '2', 1), 18], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', ' *$$:*/Z$', 26), 65]], [[('alnum', '+Z2Z2B', 26), 48], [('alnum', '+', 10), 21], [('kanji', 'é ba', 40), {'error': 'mode'}], [('kanji', 'éb', 1), {'error': 'mode'}], [('byte', 'a€', 26), 52], [('alnum', '.', 5), 19], [('byte', '€é1', 27), 68], [('numeric', '14974', 9), 31]]]\nlabels = [\"regression: count indicator version band\", \"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":"6ed81e51989bc79dcd9a2d51ecfa1cc6ddce00939a48fc9d96c8f9e36742c056","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(mode, data, version):\n    if not 1 <= version <= 40:\n        return {'error': 'version'}\n    band = 0 if version <= 9 else (1 if version <= 26 else 2)\n    ALNUM = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:'\n    if mode == 'numeric':\n        if not all(c in '0123456789' for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 10 * (count // 3) + [0, 4, 7][count % 3]\n        cci = [10, 12, 14][band]\n    elif mode == 'alnum':\n        if not all(c in ALNUM for c in data):\n            return {'error': 'charset'}\n        count = len(data)\n        bits = 11 * (count // 2) + 6 * (count % 2)\n        cci = [9, 11, 13][band]\n    elif mode == 'byte':\n        count = len(data.encode('utf-8'))\n        bits = 8 * count\n        cci = [8, 16, 16][band]\n    else:\n        return {'error': 'mode'}\n    if count >= 1 << cci:\n        return {'error': 'too-long'}\n    return 4 + cci + bits\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[('numeric', '443978087443', 26), 56], [('numeric', '115232806735', 10), 56], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('byte', '1€11€é', 40), 108], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('byte', '€éa1a1 ', 9), 92]], [[('numeric', '7643868', 9), 38], [('alnum', '*::2Z%:*', 10), 59], [('numeric', '053142', 0), {'error': 'version'}], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('alnum', '+qB+', 0), {'error': 'version'}], [('byte', 'bé', 9), 36]], [[('alnum', '*Z+-', 9), 35], [('numeric', '9420', 10), 30], [('numeric', '37219', 5), 31], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('byte', '', 26), 20], [('numeric', '53', 26), 23]], [[('alnum', '$A.', 9), 30], [('byte', ' 11b€€', 10), 100], [('byte', 'abbbaaa', 26), 76], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('numeric', '2', 1), 18], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', ' *$$:*/Z$', 26), 65]], [[('alnum', '+Z2Z2B', 26), 48], [('alnum', '+', 10), 21], [('kanji', 'é ba', 40), {'error': 'mode'}], [('kanji', 'éb', 1), {'error': 'mode'}], [('byte', 'a€', 26), 52], [('alnum', '.', 5), 19], [('byte', '€é1', 27), 68], [('numeric', '14974', 9), 31]]]\nlabels = [\"regression: count indicator version band\", \"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-qr-segment-bits-version-band","generated_at":"2026-09-29T14:49:46.354713+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":"Versions 1-9, 10-26 and 27-40 form the three bands.","root_cause":"The band boundaries are exclusive, moving versions 9 and 26 into the next band.","sha256":"e6402eb38edbdf3ce10eaec74899197a84c877b60d0030572bc12b0edb6c4808","title":"Version 9 and 26 use the wider count indicator · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":43.639,"exit_code":1,"observations":[{"actual":56,"check":"regression: count indicator version band 0","expected":56,"passed":true},{"actual":54,"check":"repair trap 1","expected":56,"passed":false},{"actual":{"error":"version"},"check":"combined fault 2","expected":{"error":"version"},"passed":true},{"actual":19,"check":"control 3","expected":19,"passed":true},{"actual":19,"check":"control 4","expected":19,"passed":true},{"actual":108,"check":"boundary 5","expected":108,"passed":true},{"actual":{"error":"charset"},"check":"boundary 6","expected":{"error":"charset"},"passed":true},{"actual":92,"check":"control 7","expected":92,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: count indicator version band 0\", \"actual\": 56, \"expected\": 56, \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": 54, \"expected\": 56, \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": {\"error\": \"version\"}, \"expected\": {\"error\": \"version\"}, \"passed\": true}, {\"check\": \"control 3\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"control 4\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": 108, \"expected\": 108, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": {\"error\": \"charset\"}, \"expected\": {\"error\": \"charset\"}, \"passed\": true}, {\"check\": \"control 7\", \"actual\": 92, \"expected\": 92, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":42.933,"exit_code":1,"observations":[{"actual":58,"check":"regression: count indicator version band 0","expected":56,"passed":false},{"actual":56,"check":"repair trap 1","expected":56,"passed":true},{"actual":{"error":"version"},"check":"combined fault 2","expected":{"error":"version"},"passed":true},{"actual":19,"check":"control 3","expected":19,"passed":true},{"actual":19,"check":"control 4","expected":19,"passed":true},{"actual":108,"check":"boundary 5","expected":108,"passed":true},{"actual":{"error":"charset"},"check":"boundary 6","expected":{"error":"charset"},"passed":true},{"actual":100,"check":"control 7","expected":92,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: count indicator version band 0\", \"actual\": 58, \"expected\": 56, \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": 56, \"expected\": 56, \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": {\"error\": \"version\"}, \"expected\": {\"error\": \"version\"}, \"passed\": true}, {\"check\": \"control 3\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"control 4\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": 108, \"expected\": 108, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": {\"error\": \"charset\"}, \"expected\": {\"error\": \"charset\"}, \"passed\": true}, {\"check\": \"control 7\", \"actual\": 100, \"expected\": 92, \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":39.702,"exit_code":0,"observations":[{"actual":56,"check":"regression: count indicator version band 0","expected":56,"passed":true},{"actual":56,"check":"repair trap 1","expected":56,"passed":true},{"actual":{"error":"version"},"check":"combined fault 2","expected":{"error":"version"},"passed":true},{"actual":19,"check":"control 3","expected":19,"passed":true},{"actual":19,"check":"control 4","expected":19,"passed":true},{"actual":108,"check":"boundary 5","expected":108,"passed":true},{"actual":{"error":"charset"},"check":"boundary 6","expected":{"error":"charset"},"passed":true},{"actual":92,"check":"control 7","expected":92,"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: count indicator version band 0\", \"actual\": 56, \"expected\": 56, \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": 56, \"expected\": 56, \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": {\"error\": \"version\"}, \"expected\": {\"error\": \"version\"}, \"passed\": true}, {\"check\": \"control 3\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"control 4\", \"actual\": 19, \"expected\": 19, \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": 108, \"expected\": 108, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": {\"error\": \"charset\"}, \"expected\": {\"error\": \"charset\"}, \"passed\": true}, {\"check\": \"control 7\", \"actual\": 92, \"expected\": 92, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}