FA-81376 / MIDI event timing / Open access
Variable-length quantity stream decoder: truncated final quantity silently dropped · case 01
A stream ending in a byte with the continuation bit set, like [129], returns [] instead of None.
ROOT CAUSE
The decoder does not check for an unfinished quantity after the last byte.
THE FAILURE
The decoder does not check for an unfinished quantity after the last byte.
Unsuccessful approach: Emitting the partial value invents a delta from a truncated stream.
Case contract
Input a list of byte values. Decode consecutive variable-length quantities (7 data bits per byte, bit 7 = continuation, most significant first, at most 4 bytes each). Return the list of values; return None for a byte outside 0..255, a quantity whose fourth byte still has the continuation bit, or a truncated final quantity.
Why this case matters
MIDI sequencers, file readers and synth drivers depend on exact event ordering and tick/time arithmetic.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
if not isinstance(x, list):
return None
values = []
cur = 0
count = 0
for b in x:
if not isinstance(b, int) or b < 0 or b > 255:
return None
cur = (cur << 7) | (b & 0x7F)
count += 1
if b & 0x80:
if count == 4:
return None
continue
values.append(cur)
cur = 0
count = 0
return values
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0], [0]), ([127], [127]), ([129, 0], [128]), ([192, 0], [8192]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([255, 255, 255, 255, 127], None), ([129], None)], [([192, 0], [8192]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([255, 255, 255, 255, 127], None), ([129], None), ([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([200, 1, 2], [9217, 2])], [([255, 255, 255, 255, 127], None), ([129], None), ([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([200, 1, 2], [9217, 2]), ([], []), ([256], None), ([-1], None)], [([129], None), ([200, 1, 2], [9217, 2]), ([], []), ([256], None), ([-1], None), ([131, 255, 127, 0], [65535, 0]), ([128, 128, 128, 0], [0]), ([128, 0], [0])], [([129], None), ([-1], None), ([131, 255, 127, 0], [65535, 0]), ([128, 128, 128, 0], [0]), ([128, 0], [0]), ([129, 0, 129, 0, 129, 0], [128, 128, 128]), ([1, 2, 3], [1, 2, 3]), ([143, 255, 255, 127], [33554431])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("oracle %d" % i, solve(args), expected)
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| oracle 0 | [0] | [0] | Passed |
| oracle 1 | [127] | [127] | Passed |
| oracle 2 | [128] | [128] | Passed |
| oracle 3 | [8192] | [8192] | Passed |
| oracle 4 | [16384] | [16384] | Passed |
| oracle 5 | [268435455] | [268435455] | Passed |
| oracle 6 | None | None | Passed |
| oracle 7 | [] | None | Failed |
SHA-256 / 19b72e653580901491e104352a758c37f78f2f25f268671117e1d3348637cba9
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
if not isinstance(x, list):
return None
values = []
cur = 0
count = 0
for b in x:
if not isinstance(b, int) or b < 0 or b > 255:
return None
cur = (cur << 7) | (b & 0x7F)
count += 1
if b & 0x80:
if count == 4:
return None
continue
values.append(cur)
cur = 0
count = 0
if count:
values.append(cur)
return values
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([0], [0]), ([127], [127]), ([129, 0], [128]), ([192, 0], [8192]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([255, 255, 255, 255, 127], None), ([129], None)], [([192, 0], [8192]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([255, 255, 255, 255, 127], None), ([129], None), ([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([200, 1, 2], [9217, 2])], [([255, 255, 255, 255, 127], None), ([129], None), ([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([200, 1, 2], [9217, 2]), ([], []), ([256], None), ([-1], None)], [([129], None), ([200, 1, 2], [9217, 2]), ([], []), ([256], None), ([-1], None), ([131, 255, 127, 0], [65535, 0]), ([128, 128, 128, 0], [0]), ([128, 0], [0])], [([129], None), ([-1], None), ([131, 255, 127, 0], [65535, 0]), ([128, 128, 128, 0], [0]), ([128, 0], [0]), ([129, 0, 129, 0, 129, 0], [128, 128, 128]), ([1, 2, 3], [1, 2, 3]), ([143, 255, 255, 127], [33554431])]]
for i, (args, expected) in enumerate(fixtures[N-1]):
check("oracle %d" % i, solve(args), expected)
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| oracle 0 | [0] | [0] | Passed |
| oracle 1 | [127] | [127] | Passed |
| oracle 2 | [128] | [128] | Passed |
| oracle 3 | [8192] | [8192] | Passed |
| oracle 4 | [16384] | [16384] | Passed |
| oracle 5 | [268435455] | [268435455] | Passed |
| oracle 6 | None | None | Passed |
| oracle 7 | [1] | None | Failed |
SHA-256 / 71bb5c96d38b59e18e78f2e9ecc051989cf86d9da259faf5ad753d8166f2ee8a
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
A deterministic bounded teaching model with a stipulated toy contract; it is not a complete Standard MIDI File or MIDI 1.0/2.0 implementation. 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:50:02.492251+00:00.
Case digest / 71d8e80ff29efc716a90cfada1e6011a6933d2fe1b90189dd91bb7d84351d2ce