FAILURE MAP
← Case archive

FA-48861 / PCM sample encoding / Open access

Subbyte code packer: bit position · case 01

Wire octets reverse the bit significance of packed fields.

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

ROOT CAUSE

Wire octets reverse the bit significance of packed fields.

VERIFIED REPAIR

Use the stated conversion contract at bit position.

Unsuccessful approach: Moving the high bit alone loses the last bit of each octet.

Case contract

Pack unsigned codes fitting width 1..7 most-significant bit first after an explicit bit prefix; return octets, significant-bit count and zero tail padding count.

Why this case matters

Offline PCM interchange uses these exact bounded packet and sample representation decisions.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(codes, width, prefix):
    bits = list(prefix)
    for code in codes:
        bits.extend((code >> shift) & 1 for shift in range(width-1,-1,-1))
    padding = (-len(bits)) % 8
    bits += [0] * padding
    out = []
    for start in range(0,len(bits),8):
        out.append(sum(bits[start+j] << j for j in range(8)))
    return [out, len(prefix)+len(codes)*width, padding]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7], 3, [1, 0])), [[129, 224], 11, 5])
check('oracle 2', solve(*([5, 2], 3, [])), [[168], 6, 2])
check('oracle 3', solve(*([], 3, [])), [[], 0, 0])
check('oracle 4', solve(*([15, 0], 4, [])), [[240], 8, 0])
check('oracle 5', solve(*([1], 1, [1, 1, 0])), [[208], 4, 4])
check('oracle 6', solve(*([0, 3, 2, 1], 2, [0])), [[28, 128], 9, 7])
check('oracle 7', solve(*([17, 3], 5, [1, 0, 1])), [[177, 24], 13, 3])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240], 20, 4])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120], 29, 3])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120, 60], 38, 2])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120, 60, 30], 47, 1])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120, 60, 30, 15], 56, 0])
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
oracle 1[[129, 7], 11, 5][[129, 224], 11, 5]Failed
oracle 2[[21], 6, 2][[168], 6, 2]Failed
oracle 3[[], 0, 0][[], 0, 0]Passed
oracle 4[[15], 8, 0][[240], 8, 0]Failed
oracle 5[[11], 4, 4][[208], 4, 4]Failed
oracle 6[[56, 1], 9, 7][[28, 128], 9, 7]Failed
oracle 7[[141, 24], 13, 3][[177, 24], 13, 3]Failed
variant packet 1[[129, 7, 15], 20, 4][[129, 224, 240], 20, 4]Failed

SHA-256 / 00bf4ac1450e5338c50a1c362dd8a031c1d99d1156d511fb78bcc8ef0207660b

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(codes, width, prefix):
    bits = list(prefix)
    for code in codes:
        bits.extend((code >> shift) & 1 for shift in range(width-1,-1,-1))
    padding = (-len(bits)) % 8
    bits += [0] * padding
    out = []
    for start in range(0,len(bits),8):
        out.append(sum(bits[start+j] << (6-j) if j<7 else 0 for j in range(8)))
    return [out, len(prefix)+len(codes)*width, padding]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7], 3, [1, 0])), [[129, 224], 11, 5])
check('oracle 2', solve(*([5, 2], 3, [])), [[168], 6, 2])
check('oracle 3', solve(*([], 3, [])), [[], 0, 0])
check('oracle 4', solve(*([15, 0], 4, [])), [[240], 8, 0])
check('oracle 5', solve(*([1], 1, [1, 1, 0])), [[208], 4, 4])
check('oracle 6', solve(*([0, 3, 2, 1], 2, [0])), [[28, 128], 9, 7])
check('oracle 7', solve(*([17, 3], 5, [1, 0, 1])), [[177, 24], 13, 3])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240], 20, 4])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120], 29, 3])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120, 60], 38, 2])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120, 60, 30], 47, 1])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120, 60, 30, 15], 56, 0])
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
oracle 1[[64, 112], 11, 5][[129, 224], 11, 5]Failed
oracle 2[[84], 6, 2][[168], 6, 2]Failed
oracle 3[[], 0, 0][[], 0, 0]Passed
oracle 4[[120], 8, 0][[240], 8, 0]Failed
oracle 5[[104], 4, 4][[208], 4, 4]Failed
oracle 6[[14, 64], 9, 7][[28, 128], 9, 7]Failed
oracle 7[[88, 12], 13, 3][[177, 24], 13, 3]Failed
variant packet 1[[64, 112, 120], 20, 4][[129, 224, 240], 20, 4]Failed

SHA-256 / c5ad6dfa0991a915915d800ab18d7285802c679a8c6a71f434282a0525e36491

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(codes, width, prefix):
    bits = list(prefix)
    for code in codes:
        bits.extend((code >> shift) & 1 for shift in range(width-1,-1,-1))
    padding = (-len(bits)) % 8
    bits += [0] * padding
    out = []
    for start in range(0,len(bits),8):
        out.append(sum(bits[start+j] << (7-j) for j in range(8)))
    return [out, len(prefix)+len(codes)*width, padding]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('oracle 1', solve(*([0, 1, 7], 3, [1, 0])), [[129, 224], 11, 5])
check('oracle 2', solve(*([5, 2], 3, [])), [[168], 6, 2])
check('oracle 3', solve(*([], 3, [])), [[], 0, 0])
check('oracle 4', solve(*([15, 0], 4, [])), [[240], 8, 0])
check('oracle 5', solve(*([1], 1, [1, 1, 0])), [[208], 4, 4])
check('oracle 6', solve(*([0, 3, 2, 1], 2, [0])), [[28, 128], 9, 7])
check('oracle 7', solve(*([17, 3], 5, [1, 0, 1])), [[177, 24], 13, 3])
if N == 1: check('variant packet 1', solve(*[[0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240], 20, 4])
if N == 2: check('variant packet 2', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120], 29, 3])
if N == 3: check('variant packet 3', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120, 60], 38, 2])
if N == 4: check('variant packet 4', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120, 60, 30], 47, 1])
if N == 5: check('variant packet 5', solve(*[[0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7, 0, 1, 7], 3, [1, 0]]), [[129, 224, 240, 120, 60, 30, 15], 56, 0])
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
oracle 1[[129, 224], 11, 5][[129, 224], 11, 5]Passed
oracle 2[[168], 6, 2][[168], 6, 2]Passed
oracle 3[[], 0, 0][[], 0, 0]Passed
oracle 4[[240], 8, 0][[240], 8, 0]Passed
oracle 5[[208], 4, 4][[208], 4, 4]Passed
oracle 6[[28, 128], 9, 7][[28, 128], 9, 7]Passed
oracle 7[[177, 24], 13, 3][[177, 24], 13, 3]Passed
variant packet 1[[129, 224, 240], 20, 4][[129, 224, 240], 20, 4]Passed

SHA-256 / 1a6bacfd1831f882754c5a37ea36bf06a700319d8b5d2e8b37722f9b529e9506

Verification & scope

Stipulated finite model; no claim of hardware timing or full file-format conformance. 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:44:54.651187+00:00.

Case digest / b70011bcd4215511cf6b1594044545cda8b8c46b3ba4ea1a4ccca8a350803792