FAILURE MAP
← Case archive

FA-81356 / MIDI event timing / Open access

Variable-length quantity delta encoder: zero delta encoded as no bytes · case 01

A zero delta between simultaneous events produces an empty byte list, so the next event byte is read as the delta.

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

ROOT CAUSE

The encoder emits the final group only when the value is nonzero.

VERIFIED REPAIR

Restore the zero delta step so that it reads `out = [x & 0x7F] x >>= 7`.

Unsuccessful approach: Emitting 0x80 for zero sets the continuation bit on the only byte, so the reader keeps consuming.

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] if x else []
    x >>= 7
    while x:
        out.append((x & 0x7F) | 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]), (129, [129, 1]), (255, [129, 127]), (8192, [192, 0])], [(0, [0]), (128, [129, 0]), (129, [129, 1]), (255, [129, 127]), (8192, [192, 0]), (16383, [255, 127]), (16384, [129, 128, 0]), (100000, [134, 141, 32])], [(0, [0]), (8192, [192, 0]), (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])], [(0, [0]), (100000, [134, 141, 32]), (2097151, [255, 255, 127]), (2097152, [129, 128, 128, 0]), (268435455, [255, 255, 255, 127]), (268435456, None), (-1, None), (True, None)], [(0, [0]), (268435455, [255, 255, 255, 127]), (268435456, None), (-1, None), (True, None), ('7', None), (480, [131, 96]), (960, [135, 64])]]
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 fixtureActualExpectedOutcome
oracle 0[][0]Failed
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, 1][129, 1]Passed
oracle 6[129, 127][129, 127]Passed
oracle 7[192, 0][192, 0]Passed

SHA-256 / f4154918761ec38cdc0f4e3892b0c1900acc6c1b01a73fc1b88524421399c777

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] if x else [0x80]
    x >>= 7
    while x:
        out.append((x & 0x7F) | 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]), (129, [129, 1]), (255, [129, 127]), (8192, [192, 0])], [(0, [0]), (128, [129, 0]), (129, [129, 1]), (255, [129, 127]), (8192, [192, 0]), (16383, [255, 127]), (16384, [129, 128, 0]), (100000, [134, 141, 32])], [(0, [0]), (8192, [192, 0]), (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])], [(0, [0]), (100000, [134, 141, 32]), (2097151, [255, 255, 127]), (2097152, [129, 128, 128, 0]), (268435455, [255, 255, 255, 127]), (268435456, None), (-1, None), (True, None)], [(0, [0]), (268435455, [255, 255, 255, 127]), (268435456, None), (-1, None), (True, None), ('7', None), (480, [131, 96]), (960, [135, 64])]]
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 fixtureActualExpectedOutcome
oracle 0[128][0]Failed
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, 1][129, 1]Passed
oracle 6[129, 127][129, 127]Passed
oracle 7[192, 0][192, 0]Passed

SHA-256 / 6a4dfd3bd63e7cdfdd900c542bc833f8a8556a293a702423b94a9e4355e7a998

3 / The verified repair

Exit 0
"""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) | 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]), (129, [129, 1]), (255, [129, 127]), (8192, [192, 0])], [(0, [0]), (128, [129, 0]), (129, [129, 1]), (255, [129, 127]), (8192, [192, 0]), (16383, [255, 127]), (16384, [129, 128, 0]), (100000, [134, 141, 32])], [(0, [0]), (8192, [192, 0]), (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])], [(0, [0]), (100000, [134, 141, 32]), (2097151, [255, 255, 127]), (2097152, [129, 128, 128, 0]), (268435455, [255, 255, 255, 127]), (268435456, None), (-1, None), (True, None)], [(0, [0]), (268435455, [255, 255, 255, 127]), (268435456, None), (-1, None), (True, None), ('7', None), (480, [131, 96]), (960, [135, 64])]]
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 fixtureActualExpectedOutcome
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, 1][129, 1]Passed
oracle 6[129, 127][129, 127]Passed
oracle 7[192, 0][192, 0]Passed

SHA-256 / b565b5c71cf681766ca545d5e78d2812f62c6e127efee0b894ee511abb88c1da

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.377327+00:00.

Case digest / 43f42426a182527d503a92022d5fab2b3034fd44baafaa23471b3bbeac14617e