{"abstract":"Byte segments at versions 10-26 are written with a 12-bit count and misparse.","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":"Keeping 8 bits for the middle band cannot count more than 255 bytes.","family":"w2-barcode-symbology-encoding-qr-segment-bits-byte-band-width","id":"FA-79666","implementations":{"attempt":{"sha256":"4086d87b5b2b487615128a0fd67f4421647a5083b228dc1cfddc6d08496fd266","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, 8, 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 = [[[('byte', '1', 26), 28], [('byte', '11 ', 15), 44], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('byte', '1€11€é', 40), 108], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('byte', 'b1', 26), 36]], [[('byte', 'éé1 ébé1', 15), 116], [('byte', '€éaéaa', 15), 100], [('numeric', '053142', 0), {'error': 'version'}], [('numeric', '089405', 10), 36], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('byte', ' aa1', 10), 52]], [[('byte', '', 26), 20], [('numeric', '00575', 9), 31], [('numeric', '37219', 5), 31], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('numeric', '53', 26), 23], [('byte', '€a€', 10), 76]], [[('byte', '', 15), 20], [('byte', 'éb1€ ', 26), 84], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('numeric', '2', 1), 18], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', 'A:*éZA', 40), {'error': 'charset'}], [('byte', 'éb aa€a', 10), 100]], [[('byte', '1é', 26), 44], [('byte', '  éa ', 15), 68], [('kanji', 'é ba', 40), {'error': 'mode'}], [('kanji', 'éb', 1), {'error': 'mode'}], [('alnum', '.', 5), 19], [('byte', '€é1', 27), 68], [('numeric', '4813206244', 15), 50], [('byte', 'a1a', 15), 44]]]\nlabels = [\"regression: byte mode indicator widths\", \"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":"e8dc5f0a6705c487ed158348bd1d64bae5fe30df0b0bcd0d6b9ee33fdfd93ed8","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, 12, 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 = [[[('byte', '1', 26), 28], [('byte', '11 ', 15), 44], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('byte', '1€11€é', 40), 108], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('byte', 'b1', 26), 36]], [[('byte', 'éé1 ébé1', 15), 116], [('byte', '€éaéaa', 15), 100], [('numeric', '053142', 0), {'error': 'version'}], [('numeric', '089405', 10), 36], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('byte', ' aa1', 10), 52]], [[('byte', '', 26), 20], [('numeric', '00575', 9), 31], [('numeric', '37219', 5), 31], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('numeric', '53', 26), 23], [('byte', '€a€', 10), 76]], [[('byte', '', 15), 20], [('byte', 'éb1€ ', 26), 84], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('numeric', '2', 1), 18], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', 'A:*éZA', 40), {'error': 'charset'}], [('byte', 'éb aa€a', 10), 100]], [[('byte', '1é', 26), 44], [('byte', '  éa ', 15), 68], [('kanji', 'é ba', 40), {'error': 'mode'}], [('kanji', 'éb', 1), {'error': 'mode'}], [('alnum', '.', 5), 19], [('byte', '€é1', 27), 68], [('numeric', '4813206244', 15), 50], [('byte', 'a1a', 15), 44]]]\nlabels = [\"regression: byte mode indicator widths\", \"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":"929e34a52aef06d672b42dcce3197d5bb0a7553f77ab99adcc42bbd38f4d5520","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 = [[[('byte', '1', 26), 28], [('byte', '11 ', 15), 44], [('alnum', '-/$é+/%é+', 0), {'error': 'version'}], [('alnum', '-', 1), 19], [('alnum', '%', 1), 19], [('byte', '1€11€é', 40), 108], [('alnum', 'ééA- q', 9), {'error': 'charset'}], [('byte', 'b1', 26), 36]], [[('byte', 'éé1 ébé1', 15), 116], [('byte', '€éaéaa', 15), 100], [('numeric', '053142', 0), {'error': 'version'}], [('numeric', '089405', 10), 36], [('kanji', 'b1ab11', 5), {'error': 'mode'}], [('alnum', 'q+$ ', 40), {'error': 'charset'}], [('alnum', '++$:é1*.+', 10), {'error': 'charset'}], [('byte', ' aa1', 10), 52]], [[('byte', '', 26), 20], [('numeric', '00575', 9), 31], [('numeric', '37219', 5), 31], [('numeric', '', 40), 18], [('numeric', '716925614701', 5), 54], [('kanji', 'é b€b', 10), {'error': 'mode'}], [('numeric', '53', 26), 23], [('byte', '€a€', 10), 76]], [[('byte', '', 15), 20], [('byte', 'éb1€ ', 26), 84], [('byte', '€', 41), {'error': 'version'}], [('numeric', '', 0), {'error': 'version'}], [('numeric', '2', 1), 18], [('alnum', '%1.qZ-', 5), {'error': 'charset'}], [('alnum', 'A:*éZA', 40), {'error': 'charset'}], [('byte', 'éb aa€a', 10), 100]], [[('byte', '1é', 26), 44], [('byte', '  éa ', 15), 68], [('kanji', 'é ba', 40), {'error': 'mode'}], [('kanji', 'éb', 1), {'error': 'mode'}], [('alnum', '.', 5), 19], [('byte', '€é1', 27), 68], [('numeric', '4813206244', 15), 50], [('byte', 'a1a', 15), 44]]]\nlabels = [\"regression: byte mode indicator widths\", \"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-byte-band-width","generated_at":"2026-09-29T14:49:46.656267+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":"Byte mode uses 8 bits for versions 1-9 and 16 bits above.","root_cause":"The byte-mode widths are recorded as 8/12/16 instead of 8/16/16.","sha256":"e76398f51f59caad971ee74e34332802a1ce668e6afde4c4f63be9ab272b7f9d","title":"Byte mode count indicator follows the numeric progression · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":41.685,"exit_code":1,"observations":[{"actual":20,"check":"regression: byte mode indicator widths 0","expected":28,"passed":false},{"actual":36,"check":"repair trap 1","expected":44,"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":28,"check":"control 7","expected":36,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: byte mode indicator widths 0\", \"actual\": 20, \"expected\": 28, \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": 36, \"expected\": 44, \"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\": 28, \"expected\": 36, \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":40.326,"exit_code":1,"observations":[{"actual":24,"check":"regression: byte mode indicator widths 0","expected":28,"passed":false},{"actual":40,"check":"repair trap 1","expected":44,"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":32,"check":"control 7","expected":36,"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: byte mode indicator widths 0\", \"actual\": 24, \"expected\": 28, \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": 40, \"expected\": 44, \"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\": 32, \"expected\": 36, \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.706,"exit_code":0,"observations":[{"actual":28,"check":"regression: byte mode indicator widths 0","expected":28,"passed":true},{"actual":44,"check":"repair trap 1","expected":44,"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":36,"check":"control 7","expected":36,"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: byte mode indicator widths 0\", \"actual\": 28, \"expected\": 28, \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": 44, \"expected\": 44, \"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\": 36, \"expected\": 36, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}