FA-81636 / MIDI event timing / Open access
Lookahead scheduler dispatch windows: events dispatched in insertion order · case 01
Events inserted out of time order are dispatched out of order within a window.
ROOT CAUSE
The scheduler walks the event list as inserted instead of by time.
VERIFIED REPAIR
Restore the dispatch order step so that it reads `sorted(events)`.
Unsuccessful approach: Sorting by identifier is still not chronological.
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 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': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], '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': []}), ([[[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': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], 'dropped': []})], [([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], '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': []}), ([[[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': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], 'dropped': []}), ([[], [[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']}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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': [['b', 'a']], 'dropped': []} | {'batches': [['a', 'b']], 'dropped': []} | Failed |
| oracle 6 | {'batches': [['a', 'b']], 'dropped': []} | {'batches': [['b', 'a']], 'dropped': []} | Failed |
| oracle 7 | {'batches': [['z', 'y', 'x']], 'dropped': []} | {'batches': [['y', 'x', 'z']], 'dropped': []} | Failed |
SHA-256 / c26c6bd2176fef2bbd1756ff5798abb96d0b8fa5620a2a5ae789ac063224b7c5
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, key=lambda e: e[1]):
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': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], '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': []}), ([[[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': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], 'dropped': []})], [([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], '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': []}), ([[[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': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], 'dropped': []}), ([[], [[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']}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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': [['a', 'b']], 'dropped': []} | {'batches': [['a', 'b']], 'dropped': []} | Passed |
| oracle 6 | {'batches': [['a', 'b']], 'dropped': []} | {'batches': [['b', 'a']], 'dropped': []} | Failed |
| oracle 7 | {'batches': [['x', 'y', 'z']], 'dropped': []} | {'batches': [['y', 'x', 'z']], 'dropped': []} | Failed |
SHA-256 / 281410be477d37fb85abb7e73d0cabcaff72d485061fe78db6ee9e69bac3bdb2
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': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], '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': []}), ([[[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': []}), ([[[30, 'a'], [20, 'b']], [[0, 40]]], {'batches': [['b', 'a']], 'dropped': []}), ([[[5, 'z'], [1, 'y'], [3, 'x']], [[0, 10]]], {'batches': [['y', 'x', 'z']], 'dropped': []})], [([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], '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': []}), ([[[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': []}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], 'dropped': []}), ([[], [[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']}), ([[[30, 'b'], [20, 'a']], [[0, 40]]], {'batches': [['a', 'b']], 'dropped': []}), ([[[3, 'z'], [3, 'y']], [[0, 10]]], {'batches': [['y', 'z']], '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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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': [['a', 'b']], 'dropped': []} | {'batches': [['a', 'b']], 'dropped': []} | Passed |
| oracle 6 | {'batches': [['b', 'a']], 'dropped': []} | {'batches': [['b', 'a']], 'dropped': []} | Passed |
| oracle 7 | {'batches': [['y', 'x', 'z']], 'dropped': []} | {'batches': [['y', 'x', 'z']], 'dropped': []} | Passed |
SHA-256 / 8073675ea1fdaa912e38782b2a9f32d4b19fe2ec0ddb10efd70b1007a03528e3
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.924629+00:00.
Case digest / 4d92ceb4bd55052fe2315cca0d8f6a15237ddd6655f4fb87965ff7ed4d095f96