FAILURE MAP
← Case archive

FA-81831 / MIDI event timing / Open access

Event placement inside an audio render buffer: first sample of the next buffer rendered now · case 01

An event exactly at start+size is given offset size, one past the end of the current buffer.

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

ROOT CAUSE

The buffer end test is inclusive, so the next buffer's first sample is treated as in range.

VERIFIED REPAIR

Restore the buffer end step so that it reads `pos >= start + size`.

Unsuccessful approach: Ending the buffer one sample early pushes the last in-buffer sample to the future.

Case contract

Input [sample_rate, buffer_start_sample, buffer_size, event_times_us]. Each event maps to sample position us*rate/1000000 rounded half up. Positions before the buffer start are "late", positions at or after start+size are "future", otherwise the offset within the buffer. Invalid rate or size 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, list) or len(x) != 4:
        return None
    sr, start, size, events = x
    if sr <= 0 or size <= 0:
        return None
    out = []
    for us in events:
        pos = (2 * us * sr + 1000000) // 2000000
        if pos < start:
            out.append('late')
        elif pos > start + size:
            out.append('future')
        else:
            out.append(pos - start)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future'])], [([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([48000, 0, 0, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])]]
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, 48, 256, 256][0, 48, 'future', 'future']Failed
oracle 1[0, 0, 256, 256][0, 0, 'future', 'future']Failed
oracle 2[0, 0, 128, 128][0, 0, 'future', 'future']Failed
oracle 3[0, 512, 511, 0][0, 'future', 511, 0]Failed
oracle 4[0, 0, 4, 5][0, 0, 4, 'future']Failed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7[0, 1, 3, 4][0, 1, 3, 'future']Failed

SHA-256 / 5eb67586b512d22d0d4c852cbf1ea6f1bd9868a50845de0e6a00ceaf02e3c618

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) or len(x) != 4:
        return None
    sr, start, size, events = x
    if sr <= 0 or size <= 0:
        return None
    out = []
    for us in events:
        pos = (2 * us * sr + 1000000) // 2000000
        if pos < start:
            out.append('late')
        elif pos >= start + size - 1:
            out.append('future')
        else:
            out.append(pos - start)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future'])], [([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([48000, 0, 0, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])]]
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, 48, 'future', 'future'][0, 48, 'future', 'future']Passed
oracle 1[0, 0, 'future', 'future'][0, 0, 'future', 'future']Passed
oracle 2[0, 0, 'future', 'future'][0, 0, 'future', 'future']Passed
oracle 3[0, 'future', 'future', 0][0, 'future', 511, 0]Failed
oracle 4[0, 0, 'future', 'future'][0, 0, 4, 'future']Failed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7[0, 1, 'future', 'future'][0, 1, 3, 'future']Failed

SHA-256 / 3f0388cf7425d7f399b7925d255cc2fbb7f82eb323181f34f1b220dc3f35d53b

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, list) or len(x) != 4:
        return None
    sr, start, size, events = x
    if sr <= 0 or size <= 0:
        return None
    out = []
    for us in events:
        pos = (2 * us * sr + 1000000) // 2000000
        if pos < start:
            out.append('late')
        elif pos >= start + size:
            out.append('future')
        else:
            out.append(pos - start)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future'])], [([44100, 441, 128, [10000, 10011, 12902, 12903]], [0, 0, 'future', 'future']), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([48000, 0, 0, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([48000, 0, 64, [10, 11, 1333, 1343]], [0, 1, 'future', 'future']), ([8000, 100, 10, [12500, 12562, 13687, 13688]], [0, 0, 9, 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([96000, 960, 96, [10000, 10005, 10995, 11000]], [0, 0, 'future', 'future']), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])], [([48000, 0, 256, [0, 1000, 5333, 5334]], [0, 48, 'future', 'future']), ([48000, 480, 256, [10000, 10010, 15332, 15333]], [0, 0, 'future', 'future']), ([48000, 48000, 512, [1000000, 1010667, 1010656, 999990]], [0, 'future', 511, 0]), ([1000, 10, 5, [9500, 10000, 14499, 14500]], [0, 0, 4, 'future']), ([44100, 1024, 256, [23220, 23232, 29025, 29037]], [0, 1, 'future', 'future']), ([48000, 0, 0, [0]], None), ([0, 0, 10, [0]], None), ([1000, 0, 4, [499, 500, 3499, 3500]], [0, 1, 3, 'future'])]]
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, 48, 'future', 'future'][0, 48, 'future', 'future']Passed
oracle 1[0, 0, 'future', 'future'][0, 0, 'future', 'future']Passed
oracle 2[0, 0, 'future', 'future'][0, 0, 'future', 'future']Passed
oracle 3[0, 'future', 511, 0][0, 'future', 511, 0]Passed
oracle 4[0, 0, 4, 'future'][0, 0, 4, 'future']Passed
oracle 5NoneNonePassed
oracle 6NoneNonePassed
oracle 7[0, 1, 3, 'future'][0, 1, 3, 'future']Passed

SHA-256 / b953e539f0373153d0b6cd73dec74082c078c8a2eb81b84f071fc20caa7077fc

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

Case digest / ea605a7c05ff874887413e80bea89e918ad703e3087f6a922ebb9f1e70466aba