{"abstract":"Symbols with an odd number of data codewords start padding with 0x11.","category":"Barcode symbology encoding","checks":8,"contract":"Finish a QR data bit stream for a symbol with `capacity` data codewords: data longer than capacity*8 bits returns None; append a terminator of up to four 0 bits (truncated if capacity is reached), pad with 0 bits to a byte boundary, split into codewords, then append pad codewords alternating 0xEC, 0x11 starting with 0xEC until the capacity is filled.","evaluation_group":"w2-barcode-symbology-encoding-qr-terminator-padding","failed_approach":"Shifting the index by one breaks the even-length case instead.","family":"w2-barcode-symbology-encoding-qr-terminator-padding-pad-parity","id":"FA-79711","implementations":{"attempt":{"sha256":"1783eea3d14e216f3b4bcab8ecc9d1a3b05adee3c8db724e002cf0363af89859","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(bits, capacity):\n    cap = capacity * 8\n    if len(bits) > cap:\n        return None\n    bits += '0' * min(4, cap - len(bits))\n    bits += '0' * (-len(bits) % 8)\n    words = [int(bits[i:i + 8], 2) for i in range(0, len(bits), 8)]\n    pads = [0xEC, 0x11]\n    k = 0\n    while len(words) < capacity:\n        words.append(pads[(len(words) + 1) % 2])\n        k += 1\n    return words\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[('00001110010101111011010001101111', 6), [14, 87, 180, 111, 0, 236]], [('011111010101101111101000', 5), [125, 91, 232, 0, 236]], [('11110', 1), [240]], [('10111110000100110101101101110110', 4), [190, 19, 91, 118]], [('010010001010011000110010101000', 4), [72, 166, 50, 160]], [('01110101', 1), [117]], [('0101100111101', 2), [89, 232]], [('0111110011111101', 5), [124, 253, 0, 236, 17]]], [[('010111100111111111101011010111010101', 6), [94, 127, 235, 93, 80, 236]], [('1001000010010100100111111101111110011111', 7), [144, 148, 159, 223, 159, 0, 236]], [('10110001011011111', 2), None], [('00101010101111110010011110110010011100110', 5), None], [('000100', 1), [16]], [('0110001100001', 2), [99, 8]], [('1110111100000001110000101', 3), None], [('', 4), [0, 236, 17, 236]]], [[('', 3), [0, 236, 17]], [('00110011', 7), [51, 0, 236, 17, 236, 17, 236]], [('10110101', 1), [181]], [('1011011', 1), [182]], [('011000110111001010011001100110101001', 5), [99, 114, 153, 154, 144]], [('0101101001011000000111111001001110110111010010101000', 7), [90, 88, 31, 147, 183, 74, 128]], [('11010010000000100000001', 4), [210, 2, 2, 0]], [('0110000101010010', 7), [97, 82, 0, 236, 17, 236, 17]]], [[('10110100010010101010', 6), [180, 74, 160, 236, 17, 236]], [('011101111111100011100011', 7), [119, 248, 227, 0, 236, 17, 236]], [('00011', 1), [24]], [('0001101010100101110100100000001001110111000110110', 6), None], [('01000011', 2), [67, 0]], [('10110010', 2), [178, 0]], [('0011011001010010110110011110111001111101', 5), [54, 82, 217, 238, 125]], [('0011001110001010', 6), [51, 138, 0, 236, 17, 236]]], [[('1111000000101011111011101010001011', 7), [240, 43, 238, 162, 192, 236, 17]], [('00110110', 5), [54, 0, 236, 17, 236]], [('101000101010111110000010011010001', 4), None], [('010001110011110110111010011110011100001110101010100001101', 7), None], [('1001000010101110001111000110111010001110', 5), [144, 174, 60, 110, 142]], [('000101100', 1), None], [('10111101', 1), [189]], [('', 2), [0, 236]]]]\nlabels = [\"regression: pad alternation index\", \"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":"9a0e53c4ec8498cca7c171c6981fc628bb479b949b924df5a8f27841914499e2","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(bits, capacity):\n    cap = capacity * 8\n    if len(bits) > cap:\n        return None\n    bits += '0' * min(4, cap - len(bits))\n    bits += '0' * (-len(bits) % 8)\n    words = [int(bits[i:i + 8], 2) for i in range(0, len(bits), 8)]\n    pads = [0xEC, 0x11]\n    k = 0\n    while len(words) < capacity:\n        words.append(pads[len(words) % 2])\n        k += 1\n    return words\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[('00001110010101111011010001101111', 6), [14, 87, 180, 111, 0, 236]], [('011111010101101111101000', 5), [125, 91, 232, 0, 236]], [('11110', 1), [240]], [('10111110000100110101101101110110', 4), [190, 19, 91, 118]], [('010010001010011000110010101000', 4), [72, 166, 50, 160]], [('01110101', 1), [117]], [('0101100111101', 2), [89, 232]], [('0111110011111101', 5), [124, 253, 0, 236, 17]]], [[('010111100111111111101011010111010101', 6), [94, 127, 235, 93, 80, 236]], [('1001000010010100100111111101111110011111', 7), [144, 148, 159, 223, 159, 0, 236]], [('10110001011011111', 2), None], [('00101010101111110010011110110010011100110', 5), None], [('000100', 1), [16]], [('0110001100001', 2), [99, 8]], [('1110111100000001110000101', 3), None], [('', 4), [0, 236, 17, 236]]], [[('', 3), [0, 236, 17]], [('00110011', 7), [51, 0, 236, 17, 236, 17, 236]], [('10110101', 1), [181]], [('1011011', 1), [182]], [('011000110111001010011001100110101001', 5), [99, 114, 153, 154, 144]], [('0101101001011000000111111001001110110111010010101000', 7), [90, 88, 31, 147, 183, 74, 128]], [('11010010000000100000001', 4), [210, 2, 2, 0]], [('0110000101010010', 7), [97, 82, 0, 236, 17, 236, 17]]], [[('10110100010010101010', 6), [180, 74, 160, 236, 17, 236]], [('011101111111100011100011', 7), [119, 248, 227, 0, 236, 17, 236]], [('00011', 1), [24]], [('0001101010100101110100100000001001110111000110110', 6), None], [('01000011', 2), [67, 0]], [('10110010', 2), [178, 0]], [('0011011001010010110110011110111001111101', 5), [54, 82, 217, 238, 125]], [('0011001110001010', 6), [51, 138, 0, 236, 17, 236]]], [[('1111000000101011111011101010001011', 7), [240, 43, 238, 162, 192, 236, 17]], [('00110110', 5), [54, 0, 236, 17, 236]], [('101000101010111110000010011010001', 4), None], [('010001110011110110111010011110011100001110101010100001101', 7), None], [('1001000010101110001111000110111010001110', 5), [144, 174, 60, 110, 142]], [('000101100', 1), None], [('10111101', 1), [189]], [('', 2), [0, 236]]]]\nlabels = [\"regression: pad alternation index\", \"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":"cea271e31cfa5fe3a4c77c69d8f726422be0ebdc634778c6b85fd22e02bb438c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(bits, capacity):\n    cap = capacity * 8\n    if len(bits) > cap:\n        return None\n    bits += '0' * min(4, cap - len(bits))\n    bits += '0' * (-len(bits) % 8)\n    words = [int(bits[i:i + 8], 2) for i in range(0, len(bits), 8)]\n    pads = [0xEC, 0x11]\n    k = 0\n    while len(words) < capacity:\n        words.append(pads[k % 2])\n        k += 1\n    return words\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[[('00001110010101111011010001101111', 6), [14, 87, 180, 111, 0, 236]], [('011111010101101111101000', 5), [125, 91, 232, 0, 236]], [('11110', 1), [240]], [('10111110000100110101101101110110', 4), [190, 19, 91, 118]], [('010010001010011000110010101000', 4), [72, 166, 50, 160]], [('01110101', 1), [117]], [('0101100111101', 2), [89, 232]], [('0111110011111101', 5), [124, 253, 0, 236, 17]]], [[('010111100111111111101011010111010101', 6), [94, 127, 235, 93, 80, 236]], [('1001000010010100100111111101111110011111', 7), [144, 148, 159, 223, 159, 0, 236]], [('10110001011011111', 2), None], [('00101010101111110010011110110010011100110', 5), None], [('000100', 1), [16]], [('0110001100001', 2), [99, 8]], [('1110111100000001110000101', 3), None], [('', 4), [0, 236, 17, 236]]], [[('', 3), [0, 236, 17]], [('00110011', 7), [51, 0, 236, 17, 236, 17, 236]], [('10110101', 1), [181]], [('1011011', 1), [182]], [('011000110111001010011001100110101001', 5), [99, 114, 153, 154, 144]], [('0101101001011000000111111001001110110111010010101000', 7), [90, 88, 31, 147, 183, 74, 128]], [('11010010000000100000001', 4), [210, 2, 2, 0]], [('0110000101010010', 7), [97, 82, 0, 236, 17, 236, 17]]], [[('10110100010010101010', 6), [180, 74, 160, 236, 17, 236]], [('011101111111100011100011', 7), [119, 248, 227, 0, 236, 17, 236]], [('00011', 1), [24]], [('0001101010100101110100100000001001110111000110110', 6), None], [('01000011', 2), [67, 0]], [('10110010', 2), [178, 0]], [('0011011001010010110110011110111001111101', 5), [54, 82, 217, 238, 125]], [('0011001110001010', 6), [51, 138, 0, 236, 17, 236]]], [[('1111000000101011111011101010001011', 7), [240, 43, 238, 162, 192, 236, 17]], [('00110110', 5), [54, 0, 236, 17, 236]], [('101000101010111110000010011010001', 4), None], [('010001110011110110111010011110011100001110101010100001101', 7), None], [('1001000010101110001111000110111010001110', 5), [144, 174, 60, 110, 142]], [('000101100', 1), None], [('10111101', 1), [189]], [('', 2), [0, 236]]]]\nlabels = [\"regression: pad alternation index\", \"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-terminator-padding-pad-parity","generated_at":"2026-09-29T14:49:46.986999+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":"Alternate from the first pad codeword regardless of how many data codewords precede it.","root_cause":"The pad byte is selected by the absolute codeword index rather than by the pad count.","sha256":"a3fca129fac97fe17619daa847247e1de259a7eaacc8dd94afb3801475ac5038","title":"Pad alternation keyed on codeword position · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.326,"exit_code":1,"observations":[{"actual":[14,87,180,111,0,236],"check":"regression: pad alternation index 0","expected":[14,87,180,111,0,236],"passed":true},{"actual":[125,91,232,0,17],"check":"repair trap 1","expected":[125,91,232,0,236],"passed":false},{"actual":[240],"check":"combined fault 2","expected":[240],"passed":true},{"actual":[190,19,91,118],"check":"control 3","expected":[190,19,91,118],"passed":true},{"actual":[72,166,50,160],"check":"control 4","expected":[72,166,50,160],"passed":true},{"actual":[117],"check":"boundary 5","expected":[117],"passed":true},{"actual":[89,232],"check":"boundary 6","expected":[89,232],"passed":true},{"actual":[124,253,0,236,17],"check":"control 7","expected":[124,253,0,236,17],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: pad alternation index 0\", \"actual\": [14, 87, 180, 111, 0, 236], \"expected\": [14, 87, 180, 111, 0, 236], \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [125, 91, 232, 0, 17], \"expected\": [125, 91, 232, 0, 236], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": [240], \"expected\": [240], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [190, 19, 91, 118], \"expected\": [190, 19, 91, 118], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [72, 166, 50, 160], \"expected\": [72, 166, 50, 160], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [117], \"expected\": [117], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [89, 232], \"expected\": [89, 232], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [124, 253, 0, 236, 17], \"expected\": [124, 253, 0, 236, 17], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":38.475,"exit_code":1,"observations":[{"actual":[14,87,180,111,0,17],"check":"regression: pad alternation index 0","expected":[14,87,180,111,0,236],"passed":false},{"actual":[125,91,232,0,236],"check":"repair trap 1","expected":[125,91,232,0,236],"passed":true},{"actual":[240],"check":"combined fault 2","expected":[240],"passed":true},{"actual":[190,19,91,118],"check":"control 3","expected":[190,19,91,118],"passed":true},{"actual":[72,166,50,160],"check":"control 4","expected":[72,166,50,160],"passed":true},{"actual":[117],"check":"boundary 5","expected":[117],"passed":true},{"actual":[89,232],"check":"boundary 6","expected":[89,232],"passed":true},{"actual":[124,253,0,17,236],"check":"control 7","expected":[124,253,0,236,17],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: pad alternation index 0\", \"actual\": [14, 87, 180, 111, 0, 17], \"expected\": [14, 87, 180, 111, 0, 236], \"passed\": false}, {\"check\": \"repair trap 1\", \"actual\": [125, 91, 232, 0, 236], \"expected\": [125, 91, 232, 0, 236], \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": [240], \"expected\": [240], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [190, 19, 91, 118], \"expected\": [190, 19, 91, 118], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [72, 166, 50, 160], \"expected\": [72, 166, 50, 160], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [117], \"expected\": [117], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [89, 232], \"expected\": [89, 232], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [124, 253, 0, 17, 236], \"expected\": [124, 253, 0, 236, 17], \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.212,"exit_code":0,"observations":[{"actual":[14,87,180,111,0,236],"check":"regression: pad alternation index 0","expected":[14,87,180,111,0,236],"passed":true},{"actual":[125,91,232,0,236],"check":"repair trap 1","expected":[125,91,232,0,236],"passed":true},{"actual":[240],"check":"combined fault 2","expected":[240],"passed":true},{"actual":[190,19,91,118],"check":"control 3","expected":[190,19,91,118],"passed":true},{"actual":[72,166,50,160],"check":"control 4","expected":[72,166,50,160],"passed":true},{"actual":[117],"check":"boundary 5","expected":[117],"passed":true},{"actual":[89,232],"check":"boundary 6","expected":[89,232],"passed":true},{"actual":[124,253,0,236,17],"check":"control 7","expected":[124,253,0,236,17],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: pad alternation index 0\", \"actual\": [14, 87, 180, 111, 0, 236], \"expected\": [14, 87, 180, 111, 0, 236], \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [125, 91, 232, 0, 236], \"expected\": [125, 91, 232, 0, 236], \"passed\": true}, {\"check\": \"combined fault 2\", \"actual\": [240], \"expected\": [240], \"passed\": true}, {\"check\": \"control 3\", \"actual\": [190, 19, 91, 118], \"expected\": [190, 19, 91, 118], \"passed\": true}, {\"check\": \"control 4\", \"actual\": [72, 166, 50, 160], \"expected\": [72, 166, 50, 160], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": [117], \"expected\": [117], \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": [89, 232], \"expected\": [89, 232], \"passed\": true}, {\"check\": \"control 7\", \"actual\": [124, 253, 0, 236, 17], \"expected\": [124, 253, 0, 236, 17], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}