FAILURE MAP
← Case archive

FA-81621 / MIDI event timing / Open access

Lookahead scheduler dispatch windows: event on the window edge dispatched early · case 01

An event exactly at now + lookahead is sent in the current window and the next window misses nothing, so it fires one window early.

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

ROOT CAUSE

The dispatch window is closed at its end instead of half-open.

VERIFIED REPAIR

Restore the window end step so that it reads `t < now + ahead`.

Unsuccessful approach: Shrinking the window by one millisecond defers events that are inside the half-open window.

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 - 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': []}), ([[[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': []}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], 'dropped': []})], [([[[10, 'a'], [30, 'b']], [[0, 30], [30, 30]]], {'batches': [['a'], ['b']], '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': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']}), ([[[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': []}), ([[[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': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], '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']}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], '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': []}), ([[[100, 'x'], [0, 'y']], [[0, 50], [50, 100]]], {'batches': [['y'], ['x']], 'dropped': []}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], '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': []}Failed
oracle 1{'batches': [[]], 'dropped': ['a']}{'batches': [[]], 'dropped': ['a']}Passed
oracle 2{'batches': [[], []], 'dropped': ['a']}{'batches': [[], []], 'dropped': ['a']}Passed
oracle 3{'batches': [['a']], 'dropped': []}{'batches': [['a']], 'dropped': []}Passed
oracle 4{'batches': [['y'], ['x']], 'dropped': []}{'batches': [['y'], ['x']], 'dropped': []}Passed
oracle 5{'batches': [['a', 'b']], 'dropped': []}{'batches': [['a', 'b']], 'dropped': []}Passed
oracle 6{'batches': [['a', 'b']], 'dropped': []}{'batches': [['a']], 'dropped': []}Failed
oracle 7{'batches': [['m'], ['n']], 'dropped': []}{'batches': [[], ['m']], 'dropped': []}Failed

SHA-256 / e60459939fa7fd9931440311479cb62640365688629929151333374e7b583c31

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 - 1:
                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': []}), ([[[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': []}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], 'dropped': []})], [([[[10, 'a'], [30, 'b']], [[0, 30], [30, 30]]], {'batches': [['a'], ['b']], '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': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']}), ([[[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': []}), ([[[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': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], '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']}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], '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': []}), ([[[100, 'x'], [0, 'y']], [[0, 50], [50, 100]]], {'batches': [['y'], ['x']], 'dropped': []}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], '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': [[]], 'dropped': ['a']}{'batches': [[]], 'dropped': ['a']}Passed
oracle 2{'batches': [[], []], 'dropped': ['a']}{'batches': [[], []], 'dropped': ['a']}Passed
oracle 3{'batches': [['a']], 'dropped': []}{'batches': [['a']], 'dropped': []}Passed
oracle 4{'batches': [['y'], ['x']], 'dropped': []}{'batches': [['y'], ['x']], 'dropped': []}Passed
oracle 5{'batches': [['a', 'b']], 'dropped': []}{'batches': [['a', 'b']], 'dropped': []}Passed
oracle 6{'batches': [[]], 'dropped': []}{'batches': [['a']], 'dropped': []}Failed
oracle 7{'batches': [[], []], 'dropped': []}{'batches': [[], ['m']], 'dropped': []}Failed

SHA-256 / ad37356de955797d55365deef1309fc5f9fce06f7e54324258057dc0ecfa9999

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': []}), ([[[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': []}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], 'dropped': []})], [([[[10, 'a'], [30, 'b']], [[0, 30], [30, 30]]], {'batches': [['a'], ['b']], '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': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']}), ([[[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': []}), ([[[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': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], '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']}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], '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': []}), ([[[100, 'x'], [0, 'y']], [[0, 50], [50, 100]]], {'batches': [['y'], ['x']], 'dropped': []}), ([[[49, 'a'], [50, 'b']], [[0, 50]]], {'batches': [['a']], 'dropped': []}), ([[[60, 'm'], [61, 'n']], [[0, 60], [60, 1]]], {'batches': [[], ['m']], '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': [[]], 'dropped': ['a']}{'batches': [[]], 'dropped': ['a']}Passed
oracle 2{'batches': [[], []], 'dropped': ['a']}{'batches': [[], []], 'dropped': ['a']}Passed
oracle 3{'batches': [['a']], 'dropped': []}{'batches': [['a']], 'dropped': []}Passed
oracle 4{'batches': [['y'], ['x']], 'dropped': []}{'batches': [['y'], ['x']], 'dropped': []}Passed
oracle 5{'batches': [['a', 'b']], 'dropped': []}{'batches': [['a', 'b']], 'dropped': []}Passed
oracle 6{'batches': [['a']], 'dropped': []}{'batches': [['a']], 'dropped': []}Passed
oracle 7{'batches': [[], ['m']], 'dropped': []}{'batches': [[], ['m']], 'dropped': []}Passed

SHA-256 / 1da32f9ab57292f36d7019b258e6fe2e0e95ff97c31ba4865b831ec0021d3aa4

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

Case digest / eccd32d47cd20235e8e6e782a93fd0e5afb46b93480e6a6d57e4270dc58f1ccf