FA-81361 / MIDI event timing / Open access
Variable-length quantity stream decoder: continuation flag kept in the value · case 01
Every multi-byte delta decodes too large, e.g. [129, 0] reads as 16512 instead of 128.
ROOT CAUSE
Bytes are appended to the accumulator without stripping the continuation bit.
THE FAILURE
Bytes are appended to the accumulator without stripping the continuation bit.
Unsuccessful approach: Stripping the flag but shifting by eight bits packs groups as bytes, so [129, 0] reads as 256.
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
count += 1
if b & 0x80:
if count == 4:
return None
continue
values.append(cur)
cur = 0
count = 0
if count:
return None
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]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([255, 255, 255, 255, 127], None), ([129], None), ([], [])], [([192, 0], [8192]), ([255, 255, 255, 127], [268435455]), ([129], None), ([0, 129, 0, 5], [0, 128, 5]), ([], []), ([256], None), ([-1], None), ([1, 2, 3], [1, 2, 3])], [([129, 0], [128]), ([192, 0], [8192]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([-1], None), ([1, 2, 3], [1, 2, 3])], [([192, 0], [8192]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([200, 1, 2], [9217, 2]), ([131, 255, 127, 0], [65535, 0]), ([128, 128, 128, 0], [0])], [([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([200, 1, 2], [9217, 2]), ([131, 255, 127, 0], [65535, 0]), ([128, 128, 128, 0], [0]), ([128, 0], [0]), ([129, 0, 129, 0, 129, 0], [128, 128, 128]), ([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 | [16512] | [128] | Failed |
| oracle 3 | [2113536] | [16384] | Failed |
| oracle 4 | [536870911] | [268435455] | Failed |
| oracle 5 | None | None | Passed |
| oracle 6 | None | None | Passed |
| oracle 7 | [] | [] | Passed |
SHA-256 / 1294c82d3084bc5c57b80fdc98fcd8ca5a96b69e261a8cf017d41b837f33a595
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 << 8) | (b & 0x7F)
count += 1
if b & 0x80:
if count == 4:
return None
continue
values.append(cur)
cur = 0
count = 0
if count:
return None
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]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([255, 255, 255, 255, 127], None), ([129], None), ([], [])], [([192, 0], [8192]), ([255, 255, 255, 127], [268435455]), ([129], None), ([0, 129, 0, 5], [0, 128, 5]), ([], []), ([256], None), ([-1], None), ([1, 2, 3], [1, 2, 3])], [([129, 0], [128]), ([192, 0], [8192]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([-1], None), ([1, 2, 3], [1, 2, 3])], [([192, 0], [8192]), ([129, 128, 0], [16384]), ([255, 255, 255, 127], [268435455]), ([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([200, 1, 2], [9217, 2]), ([131, 255, 127, 0], [65535, 0]), ([128, 128, 128, 0], [0])], [([0, 129, 0, 5], [0, 128, 5]), ([129, 0, 0, 129, 0], [128, 0, 128]), ([200, 1, 2], [9217, 2]), ([131, 255, 127, 0], [65535, 0]), ([128, 128, 128, 0], [0]), ([128, 0], [0]), ([129, 0, 129, 0, 129, 0], [128, 128, 128]), ([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 | [256] | [128] | Failed |
| oracle 3 | [65536] | [16384] | Failed |
| oracle 4 | [2139062143] | [268435455] | Failed |
| oracle 5 | None | None | Passed |
| oracle 6 | None | None | Passed |
| oracle 7 | [] | [] | Passed |
SHA-256 / b3b82f386bfe28ae7a10955ee9295ccd333ded9fb3d94e38a7d4e9e32504510a
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.413351+00:00.
Case digest / bd38e4c99913af7d2b45c0d35f02133ad1bea579364e0a0d505bcc0f0fd14891