{"abstract":"Payloads that fill all but a few bits get an extra codeword and the symbol is rejected as too long.","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":"Skipping the terminator for byte-aligned data starts padding immediately after the data.","family":"w2-barcode-symbology-encoding-qr-terminator-padding-terminator-trim","id":"FA-79696","implementations":{"attempt":{"sha256":"87a7ea1bab55194cd687d7614f8090fa868c8877b814a69726048c6595e92fa4","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)) if len(bits) % 8 else ''\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 = [[[('11110', 1), [240]], [('011111010101101111101000', 5), [125, 91, 232, 0, 236]], [('101011111101111010101001010011000', 4), None], [('001101110111100101001100111101010', 4), None], [('11000111110010110000011101', 7), [199, 203, 7, 64, 236, 17, 236]], [('100011010101010010101011001011100010011001011001110101101', 7), None], [('11100101110010101101110100001101011110011', 5), None], [('10111110000100110101101101110110', 4), [190, 19, 91, 118]]], [[('0110001100001', 2), [99, 8]], [('1010101101000100', 3), [171, 68, 0]], [('10110001011011111', 2), None], [('010111100111111111101011010111010101', 6), [94, 127, 235, 93, 80, 236]], [('00101010101111110010011110110010011100110', 5), None], [('1110111100000001110000101', 3), None], [('10110001001101011', 2), None], [('11001010100001101100111010101111110110110010001101011100', 7), [202, 134, 206, 175, 219, 35, 92]]], [[('10110101', 1), [181]], [('0110000101010010', 7), [97, 82, 0, 236, 17, 236, 17]], [('11010010000000100000001', 4), [210, 2, 2, 0]], [('10100010001101111', 2), None], [('111010111110010110000100101101100011001010010011111010111', 7), None], [('1100011111010101100100001111010111100110101001110', 6), None], [('110011111', 1), None], [('1110100000110001011011010010010', 4), [232, 49, 109, 36]]], [[('01110011101100110010100111000111100111011111110101101110', 7), [115, 179, 41, 199, 157, 253, 110]], [('0111001011100011', 5), [114, 227, 0, 236, 17]], [('0001101010100101110100100000001001110111000110110', 6), None], [('10001101000010011', 2), None], [('1010100000100110011011001000111101000001101100001', 6), None], [('0000101000111100101001100', 3), None], [('10110000110100000110100001110011111101000', 5), None], [('00011', 1), [24]]], [[('100100000001111010001', 3), [144, 30, 136]], [('1010010001000111', 3), [164, 71, 0]], [('0110100001000100000', 7), [104, 68, 0, 236, 17, 236, 17]], [('000101100', 1), None], [('100010101011001101000110110111110', 4), None], [('0100011110111010010001', 5), [71, 186, 68, 0, 236]], [('1011000001110101001101010100', 6), [176, 117, 53, 64, 236, 17]], [('1001000010101110001111000110111010001110', 5), [144, 174, 60, 110, 142]]]]\nlabels = [\"regression: terminator truncation at capacity\", \"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":"193e5b83ce12479a3324006881781a8d221a9e18d6585a2f03d7e020d4bf9857","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' * 4\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 = [[[('11110', 1), [240]], [('011111010101101111101000', 5), [125, 91, 232, 0, 236]], [('101011111101111010101001010011000', 4), None], [('001101110111100101001100111101010', 4), None], [('11000111110010110000011101', 7), [199, 203, 7, 64, 236, 17, 236]], [('100011010101010010101011001011100010011001011001110101101', 7), None], [('11100101110010101101110100001101011110011', 5), None], [('10111110000100110101101101110110', 4), [190, 19, 91, 118]]], [[('0110001100001', 2), [99, 8]], [('1010101101000100', 3), [171, 68, 0]], [('10110001011011111', 2), None], [('010111100111111111101011010111010101', 6), [94, 127, 235, 93, 80, 236]], [('00101010101111110010011110110010011100110', 5), None], [('1110111100000001110000101', 3), None], [('10110001001101011', 2), None], [('11001010100001101100111010101111110110110010001101011100', 7), [202, 134, 206, 175, 219, 35, 92]]], [[('10110101', 1), [181]], [('0110000101010010', 7), [97, 82, 0, 236, 17, 236, 17]], [('11010010000000100000001', 4), [210, 2, 2, 0]], [('10100010001101111', 2), None], [('111010111110010110000100101101100011001010010011111010111', 7), None], [('1100011111010101100100001111010111100110101001110', 6), None], [('110011111', 1), None], [('1110100000110001011011010010010', 4), [232, 49, 109, 36]]], [[('01110011101100110010100111000111100111011111110101101110', 7), [115, 179, 41, 199, 157, 253, 110]], [('0111001011100011', 5), [114, 227, 0, 236, 17]], [('0001101010100101110100100000001001110111000110110', 6), None], [('10001101000010011', 2), None], [('1010100000100110011011001000111101000001101100001', 6), None], [('0000101000111100101001100', 3), None], [('10110000110100000110100001110011111101000', 5), None], [('00011', 1), [24]]], [[('100100000001111010001', 3), [144, 30, 136]], [('1010010001000111', 3), [164, 71, 0]], [('0110100001000100000', 7), [104, 68, 0, 236, 17, 236, 17]], [('000101100', 1), None], [('100010101011001101000110110111110', 4), None], [('0100011110111010010001', 5), [71, 186, 68, 0, 236]], [('1011000001110101001101010100', 6), [176, 117, 53, 64, 236, 17]], [('1001000010101110001111000110111010001110', 5), [144, 174, 60, 110, 142]]]]\nlabels = [\"regression: terminator truncation at capacity\", \"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":"f92b400351c1b2dde877d9b16f48a6ad1d0e578ec9f7b2782553d5c6062d826b","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 = [[[('11110', 1), [240]], [('011111010101101111101000', 5), [125, 91, 232, 0, 236]], [('101011111101111010101001010011000', 4), None], [('001101110111100101001100111101010', 4), None], [('11000111110010110000011101', 7), [199, 203, 7, 64, 236, 17, 236]], [('100011010101010010101011001011100010011001011001110101101', 7), None], [('11100101110010101101110100001101011110011', 5), None], [('10111110000100110101101101110110', 4), [190, 19, 91, 118]]], [[('0110001100001', 2), [99, 8]], [('1010101101000100', 3), [171, 68, 0]], [('10110001011011111', 2), None], [('010111100111111111101011010111010101', 6), [94, 127, 235, 93, 80, 236]], [('00101010101111110010011110110010011100110', 5), None], [('1110111100000001110000101', 3), None], [('10110001001101011', 2), None], [('11001010100001101100111010101111110110110010001101011100', 7), [202, 134, 206, 175, 219, 35, 92]]], [[('10110101', 1), [181]], [('0110000101010010', 7), [97, 82, 0, 236, 17, 236, 17]], [('11010010000000100000001', 4), [210, 2, 2, 0]], [('10100010001101111', 2), None], [('111010111110010110000100101101100011001010010011111010111', 7), None], [('1100011111010101100100001111010111100110101001110', 6), None], [('110011111', 1), None], [('1110100000110001011011010010010', 4), [232, 49, 109, 36]]], [[('01110011101100110010100111000111100111011111110101101110', 7), [115, 179, 41, 199, 157, 253, 110]], [('0111001011100011', 5), [114, 227, 0, 236, 17]], [('0001101010100101110100100000001001110111000110110', 6), None], [('10001101000010011', 2), None], [('1010100000100110011011001000111101000001101100001', 6), None], [('0000101000111100101001100', 3), None], [('10110000110100000110100001110011111101000', 5), None], [('00011', 1), [24]]], [[('100100000001111010001', 3), [144, 30, 136]], [('1010010001000111', 3), [164, 71, 0]], [('0110100001000100000', 7), [104, 68, 0, 236, 17, 236, 17]], [('000101100', 1), None], [('100010101011001101000110110111110', 4), None], [('0100011110111010010001', 5), [71, 186, 68, 0, 236]], [('1011000001110101001101010100', 6), [176, 117, 53, 64, 236, 17]], [('1001000010101110001111000110111010001110', 5), [144, 174, 60, 110, 142]]]]\nlabels = [\"regression: terminator truncation at capacity\", \"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-terminator-trim","generated_at":"2026-09-29T14:49:46.946895+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":"Truncate the terminator to the remaining capacity.","root_cause":"The four-bit terminator is appended even when fewer than four bits remain.","sha256":"5a17d27b5f4d041892ceb1a86ff8083453fb368ae63d6327d67eccaf9a062641","title":"QR terminator overflows a nearly full symbol · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":42.134,"exit_code":1,"observations":[{"actual":[240],"check":"regression: terminator truncation at capacity 0","expected":[240],"passed":true},{"actual":[125,91,232,236,17],"check":"repair trap 1","expected":[125,91,232,0,236],"passed":false},{"actual":null,"check":"combined fault 2","expected":null,"passed":true},{"actual":null,"check":"control 3","expected":null,"passed":true},{"actual":[199,203,7,64,236,17,236],"check":"control 4","expected":[199,203,7,64,236,17,236],"passed":true},{"actual":null,"check":"boundary 5","expected":null,"passed":true},{"actual":null,"check":"boundary 6","expected":null,"passed":true},{"actual":[190,19,91,118],"check":"control 7","expected":[190,19,91,118],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: terminator truncation at capacity 0\", \"actual\": [240], \"expected\": [240], \"passed\": true}, {\"check\": \"repair trap 1\", \"actual\": [125, 91, 232, 236, 17], \"expected\": [125, 91, 232, 0, 236], \"passed\": false}, {\"check\": \"combined fault 2\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 3\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 4\", \"actual\": [199, 203, 7, 64, 236, 17, 236], \"expected\": [199, 203, 7, 64, 236, 17, 236], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 7\", \"actual\": [190, 19, 91, 118], \"expected\": [190, 19, 91, 118], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":37.146,"exit_code":1,"observations":[{"actual":[240,0],"check":"regression: terminator truncation at capacity 0","expected":[240],"passed":false},{"actual":[125,91,232,0,236],"check":"repair trap 1","expected":[125,91,232,0,236],"passed":true},{"actual":null,"check":"combined fault 2","expected":null,"passed":true},{"actual":null,"check":"control 3","expected":null,"passed":true},{"actual":[199,203,7,64,236,17,236],"check":"control 4","expected":[199,203,7,64,236,17,236],"passed":true},{"actual":null,"check":"boundary 5","expected":null,"passed":true},{"actual":null,"check":"boundary 6","expected":null,"passed":true},{"actual":[190,19,91,118,0],"check":"control 7","expected":[190,19,91,118],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: terminator truncation at capacity 0\", \"actual\": [240, 0], \"expected\": [240], \"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\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 3\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 4\", \"actual\": [199, 203, 7, 64, 236, 17, 236], \"expected\": [199, 203, 7, 64, 236, 17, 236], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 7\", \"actual\": [190, 19, 91, 118, 0], \"expected\": [190, 19, 91, 118], \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":41.119,"exit_code":0,"observations":[{"actual":[240],"check":"regression: terminator truncation at capacity 0","expected":[240],"passed":true},{"actual":[125,91,232,0,236],"check":"repair trap 1","expected":[125,91,232,0,236],"passed":true},{"actual":null,"check":"combined fault 2","expected":null,"passed":true},{"actual":null,"check":"control 3","expected":null,"passed":true},{"actual":[199,203,7,64,236,17,236],"check":"control 4","expected":[199,203,7,64,236,17,236],"passed":true},{"actual":null,"check":"boundary 5","expected":null,"passed":true},{"actual":null,"check":"boundary 6","expected":null,"passed":true},{"actual":[190,19,91,118],"check":"control 7","expected":[190,19,91,118],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: terminator truncation at capacity 0\", \"actual\": [240], \"expected\": [240], \"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\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 3\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 4\", \"actual\": [199, 203, 7, 64, 236, 17, 236], \"expected\": [199, 203, 7, 64, 236, 17, 236], \"passed\": true}, {\"check\": \"boundary 5\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"boundary 6\", \"actual\": null, \"expected\": null, \"passed\": true}, {\"check\": \"control 7\", \"actual\": [190, 19, 91, 118], \"expected\": [190, 19, 91, 118], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}