FAILURE MAP
← Case archive

FA-81626 / MIDI event timing / Open access

Lookahead scheduler dispatch windows: slightly late events dropped · case 01

Events a few milliseconds late are dropped instead of being dispatched immediately.

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

ROOT CAUSE

Any event before now is treated as hopelessly late, ignoring the 20 ms tolerance.

VERIFIED REPAIR

Restore the late tolerance step so that it reads `t < now - 20`.

Unsuccessful approach: Including the boundary drops an event that is exactly 20 ms late.

Case contract

Input [events, windows]: events are [time_ms, id]; windows are [now, lookahead] processed in order. In each window, walk not-yet-handled events in time order: an event more than 20 ms late (time < now - 20) is dropped (reported once); an event with time < now + lookahead is dispatched in that window (late events within tolerance included). Return {"batches": ids per window, "dropped": ids}.

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) != 2:
        return None
    events, windows = x
    sent = set()
    batches = []
    dropped = []
    for now, ahead in windows:
        batch = []
        for t, eid in sorted(events):
            if eid in sent:
                continue
            if t < now:
                sent.add(eid)
                dropped.append(eid)
            elif t < now + ahead:
                sent.add(eid)
                batch.append(eid)
        batches.append(batch)
    return {'batches': batches, 'dropped': dropped}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[0, 'a'], [25, 'b'], [50, 'c']], [[0, 25], [25, 25], [50, 25]]], {'batches': [['a'], ['b'], ['c']], 'dropped': []}), ([[[10, 'a'], [30, 'b']], [[0, 30], [30, 30]]], {'batches': [['a'], ['b']], 'dropped': []}), ([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[100, 'x'], [0, 'y']], [[0, 50], [50, 100]]], {'batches': [['y'], ['x']], 'dropped': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []})], [([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[100, 'x'], [0, 'y']], [[0, 50], [50, 100]]], {'batches': [['y'], ['x']], 'dropped': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], 'dropped': []}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []})], [([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], 'dropped': []}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']}), ([[], [[0, 10]]], {'batches': [[]], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], 'dropped': []})], [([[[0, 'a'], [25, 'b'], [50, 'c']], [[0, 25], [25, 25], [50, 25]]], {'batches': [['a'], ['b'], ['c']], 'dropped': []}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']}), ([[], [[0, 10]]], {'batches': [[]], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], 'dropped': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], 'dropped': []})], [([[[0, 'a'], [25, 'b'], [50, 'c']], [[0, 25], [25, 25], [50, 25]]], {'batches': [['a'], ['b'], ['c']], 'dropped': []}), ([[[10, 'a'], [30, 'b']], [[0, 30], [30, 30]]], {'batches': [['a'], ['b']], 'dropped': []}), ([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], 'dropped': []})]]
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{'batches': [['a'], ['b'], ['c']], 'dropped': []}{'batches': [['a'], ['b'], ['c']], 'dropped': []}Passed
oracle 1{'batches': [['a'], ['b']], 'dropped': []}{'batches': [['a'], ['b']], 'dropped': []}Passed
oracle 2{'batches': [[]], 'dropped': ['a']}{'batches': [[]], 'dropped': ['a']}Passed
oracle 3{'batches': [[], []], 'dropped': ['a']}{'batches': [[], []], 'dropped': ['a']}Passed
oracle 4{'batches': [[]], 'dropped': ['a']}{'batches': [['a']], 'dropped': []}Failed
oracle 5{'batches': [['y'], ['x']], 'dropped': []}{'batches': [['y'], ['x']], 'dropped': []}Passed
oracle 6{'batches': [['a', 'b']], 'dropped': []}{'batches': [['a', 'b']], 'dropped': []}Passed
oracle 7{'batches': [[], []], 'dropped': ['late']}{'batches': [['late'], []], 'dropped': []}Failed

SHA-256 / 2a3ec9f782f57d0e3cae8d791d38165cc452a668a6a807fa888d0a89477c9500

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) != 2:
        return None
    events, windows = x
    sent = set()
    batches = []
    dropped = []
    for now, ahead in windows:
        batch = []
        for t, eid in sorted(events):
            if eid in sent:
                continue
            if t <= now - 20:
                sent.add(eid)
                dropped.append(eid)
            elif t < now + ahead:
                sent.add(eid)
                batch.append(eid)
        batches.append(batch)
    return {'batches': batches, 'dropped': dropped}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[0, 'a'], [25, 'b'], [50, 'c']], [[0, 25], [25, 25], [50, 25]]], {'batches': [['a'], ['b'], ['c']], 'dropped': []}), ([[[10, 'a'], [30, 'b']], [[0, 30], [30, 30]]], {'batches': [['a'], ['b']], 'dropped': []}), ([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[100, 'x'], [0, 'y']], [[0, 50], [50, 100]]], {'batches': [['y'], ['x']], 'dropped': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []})], [([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[100, 'x'], [0, 'y']], [[0, 50], [50, 100]]], {'batches': [['y'], ['x']], 'dropped': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], 'dropped': []}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []})], [([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], 'dropped': []}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']}), ([[], [[0, 10]]], {'batches': [[]], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], 'dropped': []})], [([[[0, 'a'], [25, 'b'], [50, 'c']], [[0, 25], [25, 25], [50, 25]]], {'batches': [['a'], ['b'], ['c']], 'dropped': []}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']}), ([[], [[0, 10]]], {'batches': [[]], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], 'dropped': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], 'dropped': []})], [([[[0, 'a'], [25, 'b'], [50, 'c']], [[0, 25], [25, 25], [50, 25]]], {'batches': [['a'], ['b'], ['c']], 'dropped': []}), ([[[10, 'a'], [30, 'b']], [[0, 30], [30, 30]]], {'batches': [['a'], ['b']], 'dropped': []}), ([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], 'dropped': []})]]
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{'batches': [['a'], ['b'], ['c']], 'dropped': []}{'batches': [['a'], ['b'], ['c']], 'dropped': []}Passed
oracle 1{'batches': [['a'], ['b']], 'dropped': []}{'batches': [['a'], ['b']], 'dropped': []}Passed
oracle 2{'batches': [[]], 'dropped': ['a']}{'batches': [[]], 'dropped': ['a']}Passed
oracle 3{'batches': [[], []], 'dropped': ['a']}{'batches': [[], []], 'dropped': ['a']}Passed
oracle 4{'batches': [[]], 'dropped': ['a']}{'batches': [['a']], 'dropped': []}Failed
oracle 5{'batches': [['y'], ['x']], 'dropped': []}{'batches': [['y'], ['x']], 'dropped': []}Passed
oracle 6{'batches': [['a', 'b']], 'dropped': []}{'batches': [['a', 'b']], 'dropped': []}Passed
oracle 7{'batches': [[], []], 'dropped': ['late']}{'batches': [['late'], []], 'dropped': []}Failed

SHA-256 / dfe84f6d50d0b0d083a32d836cbb46da929ee9c08bd8732ccb353d320b108840

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) != 2:
        return None
    events, windows = x
    sent = set()
    batches = []
    dropped = []
    for now, ahead in windows:
        batch = []
        for t, eid in sorted(events):
            if eid in sent:
                continue
            if t < now - 20:
                sent.add(eid)
                dropped.append(eid)
            elif t < now + ahead:
                sent.add(eid)
                batch.append(eid)
        batches.append(batch)
    return {'batches': batches, 'dropped': dropped}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[0, 'a'], [25, 'b'], [50, 'c']], [[0, 25], [25, 25], [50, 25]]], {'batches': [['a'], ['b'], ['c']], 'dropped': []}), ([[[10, 'a'], [30, 'b']], [[0, 30], [30, 30]]], {'batches': [['a'], ['b']], 'dropped': []}), ([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[100, 'x'], [0, 'y']], [[0, 50], [50, 100]]], {'batches': [['y'], ['x']], 'dropped': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []})], [([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[100, 'x'], [0, 'y']], [[0, 50], [50, 100]]], {'batches': [['y'], ['x']], 'dropped': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], 'dropped': []}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []})], [([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], 'dropped': []}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']}), ([[], [[0, 10]]], {'batches': [[]], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], 'dropped': []})], [([[[0, 'a'], [25, 'b'], [50, 'c']], [[0, 25], [25, 25], [50, 25]]], {'batches': [['a'], ['b'], ['c']], 'dropped': []}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']}), ([[], [[0, 10]]], {'batches': [[]], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], 'dropped': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], 'dropped': []})], [([[[0, 'a'], [25, 'b'], [50, 'c']], [[0, 25], [25, 25], [50, 25]]], {'batches': [['a'], ['b'], ['c']], 'dropped': []}), ([[[10, 'a'], [30, 'b']], [[0, 30], [30, 30]]], {'batches': [['a'], ['b']], 'dropped': []}), ([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[10, 'a']], [[30, 10]]], {'batches': [['a']], 'dropped': []}), ([[[5, 'late']], [[25, 5], [26, 5]]], {'batches': [['late'], []], 'dropped': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], 'dropped': []})]]
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{'batches': [['a'], ['b'], ['c']], 'dropped': []}{'batches': [['a'], ['b'], ['c']], 'dropped': []}Passed
oracle 1{'batches': [['a'], ['b']], 'dropped': []}{'batches': [['a'], ['b']], 'dropped': []}Passed
oracle 2{'batches': [[]], 'dropped': ['a']}{'batches': [[]], 'dropped': ['a']}Passed
oracle 3{'batches': [[], []], 'dropped': ['a']}{'batches': [[], []], 'dropped': ['a']}Passed
oracle 4{'batches': [['a']], 'dropped': []}{'batches': [['a']], 'dropped': []}Passed
oracle 5{'batches': [['y'], ['x']], 'dropped': []}{'batches': [['y'], ['x']], 'dropped': []}Passed
oracle 6{'batches': [['a', 'b']], 'dropped': []}{'batches': [['a', 'b']], 'dropped': []}Passed
oracle 7{'batches': [['late'], []], 'dropped': []}{'batches': [['late'], []], 'dropped': []}Passed

SHA-256 / 2f6cca44a263e2323388aff71612cf4e018785077197921c96074cc1d064a950

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

Case digest / f43e34a43df0c709a8c7d9666055bfefe33f13eaecf56b7d510dabcdcee25987