FAILURE MAP
← Case archive

FA-3696 / Binary formats / Open access

Bit packing puts padding before the data · case 01

Bit packing puts padding before the data.

Verified by executionVariant 1 · 4 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The implementation applies an operation whose text or grammar semantics violate this contract: Pack a bit list MSB-first, right-padding the final byte with zeros.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Pack a bit list MSB-first, right-padding the final byte with zeros.

Unsuccessful approach: The attempted repair handles the primary example but still violates a separate boundary of the same contract.

Case contract

Pack a bit list MSB-first, right-padding the final byte with zeros.

Why this case matters

A local executable model for consumers of structured text; oracle values are authored literals, not outputs copied from the repaired implementation.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return list(int(''.join(map(str,x)) or '0',2).to_bytes((len(x)+7)//8,'big'))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve([1]), [128])
check('boundary 2', solve([1, 0, 1]), [160])
check('boundary 3', solve([1, 1, 1, 1, 1, 1, 1, 1, 1]), [255, 128])
check('boundary 4', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
boundary 1[1][128]Failed
boundary 2[5][160]Failed
boundary 3[1, 255][255, 128]Failed
boundary 4[][]Passed

SHA-256 / 14c06355b5eade97f1813de3122a8ce84bcb03d00108e53c3b41691a86848624

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return [sum(v<<i for i,v in enumerate(x[j:j+8])) for j in range(0,len(x),8)]
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve([1]), [128])
check('boundary 2', solve([1, 0, 1]), [160])
check('boundary 3', solve([1, 1, 1, 1, 1, 1, 1, 1, 1]), [255, 128])
check('boundary 4', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
boundary 1[1][128]Failed
boundary 2[5][160]Failed
boundary 3[255, 1][255, 128]Failed
boundary 4[][]Passed

SHA-256 / 2e4c263bed3ce9df2e6b4bfb4d9178b948bd6368a2e4cec7df6010a08ca8f1d6

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return [sum(v<<(7-i) for i,v in enumerate(x[j:j+8])) for j in range(0,len(x),8)]
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve([1]), [128])
check('boundary 2', solve([1, 0, 1]), [160])
check('boundary 3', solve([1, 1, 1, 1, 1, 1, 1, 1, 1]), [255, 128])
check('boundary 4', solve([]), [])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
boundary 1[128][128]Passed
boundary 2[160][160]Passed
boundary 3[255, 128][255, 128]Passed
boundary 4[][]Passed

SHA-256 / 924c2da842ae8d75f52f69123d0882fbb55d9648ceac155f96c8e113fd8a8f54

Verification & scope

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.

Observations recorded using Python 3.12.14 at 2026-09-29T14:37:29.566178+00:00.

Case digest / b9186e52b6f88ab0dfa98b13a0b590026de673eb649d8007799e6204ab3d89a6