FAILURE MAP
← Case archive

FA-81631 / MIDI event timing / Open access

Lookahead scheduler dispatch windows: dropped events reported every window · case 01

A stale event is added to the dropped list again in every later window.

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

ROOT CAUSE

Dropped events are not marked as handled.

VERIFIED REPAIR

Restore the dropped bookkeeping step so that it reads `sent.add(eid) dropped.append(eid)`.

Unsuccessful approach: Marking the event handled without recording it hides the drop from the report.

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:
                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': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']})], [([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[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': []}), ([[], [[0, 10]]], {'batches': [[]], 'dropped': []})], [([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[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': []}), ([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[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': []}), ([[[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': []}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']})]]
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', 'a']}{'batches': [[], []], 'dropped': ['a']}Failed
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': [[], ['r'], []], 'dropped': ['q', 'q', 'q']}{'batches': [[], ['r'], []], 'dropped': ['q']}Failed

SHA-256 / a443caf95a48f0858fcf3cfc42645bd0d860d7ab1a2600d25bb75ac66ef00e70

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)
            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': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']})], [([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[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': []}), ([[], [[0, 10]]], {'batches': [[]], 'dropped': []})], [([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[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': []}), ([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[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': []}), ([[[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': []}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']})]]
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': []}{'batches': [[]], 'dropped': ['a']}Failed
oracle 3{'batches': [[], []], 'dropped': []}{'batches': [[], []], 'dropped': ['a']}Failed
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': [[], ['r'], []], 'dropped': []}{'batches': [[], ['r'], []], 'dropped': ['q']}Failed

SHA-256 / e7662fe3b13c059df7d5e67d8003d5e303cd7f693884ad9267cae520397104ac

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': []}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']})], [([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[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': []}), ([[], [[0, 10]]], {'batches': [[]], 'dropped': []})], [([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[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': []}), ([[[5, 'a']], [[30, 10]]], {'batches': [[]], 'dropped': ['a']}), ([[[9, 'a']], [[30, 10], [40, 10]]], {'batches': [[], []], 'dropped': ['a']}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[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': []}), ([[[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': []}), ([[[0, 'a'], [100, 'b']], [[200, 10], [210, 10]]], {'batches': [[], []], 'dropped': ['a', 'b']}), ([[[15, 'q'], [70, 'r']], [[40, 20], [60, 20], [80, 20]]], {'batches': [[], ['r'], []], 'dropped': ['q']})]]
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': [[], ['r'], []], 'dropped': ['q']}{'batches': [[], ['r'], []], 'dropped': ['q']}Passed

SHA-256 / e4c4011fa1c9ed8fe45bacff6bafd08ce69b64b00b06523c6899273e23723c9c

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

Case digest / 9131fc5ea1d0b741250800617ab273388fbdcebe628cac46afd4ad817445a109