FA-81341 / MIDI event timing / Open access
Variable-length quantity delta encoder: leading bytes emitted without continuation flag · case 01
Delta 128 is written as [1, 0], which a reader decodes as two separate deltas 1 and 0.
ROOT CAUSE
Leading groups are masked to seven bits but never tagged with the continuation bit.
THE FAILURE
Leading groups are masked to seven bits but never tagged with the continuation bit.
Unsuccessful approach: Tagging without masking lets high bits of the remaining value leak into leading bytes for deltas of 16384 and above.
Case contract
Input a delta-time integer 0..0x0FFFFFFF (booleans rejected). Encode as 7-bit groups, most significant group first, with bit 7 set on every byte except the last. Zero encodes as [0]. Out-of-range or non-integer input returns None.
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, int) or isinstance(x, bool) or x < 0 or x > 0x0FFFFFFF:
return None
out = [x & 0x7F]
x >>= 7
while x:
out.append(x & 0x7F)
x >>= 7
return out[::-1]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(0, [0]), (1, [1]), (64, [64]), (127, [127]), (128, [129, 0]), (255, [129, 127]), (100000, [134, 141, 32]), (268435455, [255, 255, 255, 127])], [(127, [127]), (129, [129, 1]), (8192, [192, 0]), (2097151, [255, 255, 127]), (268435456, None), (-1, None), (True, None), (2097152, [129, 128, 128, 0])], [(128, [129, 0]), (129, [129, 1]), (255, [129, 127]), (16383, [255, 127]), (2097152, [129, 128, 128, 0]), (True, None), ('7', None), (1000000, [189, 132, 64])], [(129, [129, 1]), (255, [129, 127]), (8192, [192, 0]), (16383, [255, 127]), (16384, [129, 128, 0]), (100000, [134, 141, 32]), (2097151, [255, 255, 127]), (268435455, [255, 255, 255, 127])], [(16383, [255, 127]), (16384, [129, 128, 0]), (100000, [134, 141, 32]), (2097151, [255, 255, 127]), (2097152, [129, 128, 128, 0]), (268435455, [255, 255, 255, 127]), (480, [131, 96]), (2097152, [129, 128, 128, 0])]]
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 | [1] | [1] | Passed |
| oracle 2 | [64] | [64] | Passed |
| oracle 3 | [127] | [127] | Passed |
| oracle 4 | [1, 0] | [129, 0] | Failed |
| oracle 5 | [1, 127] | [129, 127] | Failed |
| oracle 6 | [6, 13, 32] | [134, 141, 32] | Failed |
| oracle 7 | [127, 127, 127, 127] | [255, 255, 255, 127] | Failed |
SHA-256 / 8c16a726d1cca84dc8fcf30bcc0a9ee8cf5daaecd4bd5885bc2f1775f6ccb446
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, int) or isinstance(x, bool) or x < 0 or x > 0x0FFFFFFF:
return None
out = [x & 0x7F]
x >>= 7
while x:
out.append(x | 0x80)
x >>= 7
return out[::-1]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(0, [0]), (1, [1]), (64, [64]), (127, [127]), (128, [129, 0]), (255, [129, 127]), (100000, [134, 141, 32]), (268435455, [255, 255, 255, 127])], [(127, [127]), (129, [129, 1]), (8192, [192, 0]), (2097151, [255, 255, 127]), (268435456, None), (-1, None), (True, None), (2097152, [129, 128, 128, 0])], [(128, [129, 0]), (129, [129, 1]), (255, [129, 127]), (16383, [255, 127]), (2097152, [129, 128, 128, 0]), (True, None), ('7', None), (1000000, [189, 132, 64])], [(129, [129, 1]), (255, [129, 127]), (8192, [192, 0]), (16383, [255, 127]), (16384, [129, 128, 0]), (100000, [134, 141, 32]), (2097151, [255, 255, 127]), (268435455, [255, 255, 255, 127])], [(16383, [255, 127]), (16384, [129, 128, 0]), (100000, [134, 141, 32]), (2097151, [255, 255, 127]), (2097152, [129, 128, 128, 0]), (268435455, [255, 255, 255, 127]), (480, [131, 96]), (2097152, [129, 128, 128, 0])]]
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 | [1] | [1] | Passed |
| oracle 2 | [64] | [64] | Passed |
| oracle 3 | [127] | [127] | Passed |
| oracle 4 | [129, 0] | [129, 0] | Passed |
| oracle 5 | [129, 127] | [129, 127] | Passed |
| oracle 6 | [134, 909, 32] | [134, 141, 32] | Failed |
| oracle 7 | [255, 16383, 2097151, 127] | [255, 255, 255, 127] | Failed |
SHA-256 / 41547662132ca5d96de534c9397621fd2a90cc619f1c4aa4a10eabe78c677381
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.023933+00:00.
Case digest / b0aa71f4db4c015713ca0c05940c4fa62bbbf183edbcccc9d6a181e5c74717e8