FAILURE MAP
← Case archive

FA-81451 / MIDI event timing / Open access

Note-on and note-off pairing into durations: notes ordered by release time · case 01

A long note that starts first is listed after shorter notes that start later.

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

ROOT CAUSE

The result is sorted primarily by end tick rather than start tick.

VERIFIED REPAIR

Restore the output ordering step so that it reads `key=lambda e: (e[0], e[3], e[2], e[1])`.

Unsuccessful approach: Sorting by pitch first groups notes by key and loses chronological order.

Case contract

Input time-ordered events [tick, kind, channel, note, velocity] with kind on or off. A note-on with velocity 0 acts as a note-off. Each off ends the earliest still-open note with the same channel and note (FIFO); unmatched offs are ignored. Notes still open at the end end at the last event tick. Return [start, end, channel, note, on-velocity] sorted by start, note, channel, end.

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):
        return None
    active = {}
    done = []
    last = 0
    for tick, kind, ch, note, vel in x:
        last = max(last, tick)
        key = (ch, note)
        if kind == 'on' and vel > 0:
            active.setdefault(key, []).append((tick, vel, ch, note))
        elif kind in ('on', 'off'):
            if active.get(key):
                start, v, c, n = active[key].pop(0)
                done.append([start, tick, c, n, v])
    for stack in active.values():
        for start, v, c, n in stack:
            done.append([start, last, c, n, v])
    done.sort(key=lambda e: (e[1], e[0], e[3], e[2]))
    return done
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [10, 'on', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [5, 'on', 0, 60, 80], [10, 'off', 0, 60, 0], [20, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]]), ([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [30, 'on', 0, 64, 90]], [[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]), ([[0, 'off', 0, 60, 0], [5, 'on', 0, 62, 70], [9, 'off', 0, 62, 40]], [[5, 9, 0, 62, 70]]), ([[0, 'on', 0, 64, 100], [0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0], [12, 'off', 0, 64, 0]], [[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]])], [([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [30, 'on', 0, 64, 90]], [[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]), ([[0, 'off', 0, 60, 0], [5, 'on', 0, 62, 70], [9, 'off', 0, 62, 40]], [[5, 9, 0, 62, 70]]), ([[0, 'on', 0, 64, 100], [0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0], [12, 'off', 0, 64, 0]], [[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]]), ([[0, 'on', 2, 60, 100], [4, 'on', 2, 60, 90], [8, 'on', 2, 60, 0], [9, 'on', 2, 60, 0]], [[0, 8, 2, 60, 100], [4, 9, 2, 60, 90]]), ([[0, 'on', 0, 60, 1], [3, 'off', 0, 60, 64]], [[0, 3, 0, 60, 1]]), ([], []), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]])], [([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 2, 60, 100], [4, 'on', 2, 60, 90], [8, 'on', 2, 60, 0], [9, 'on', 2, 60, 0]], [[0, 8, 2, 60, 100], [4, 9, 2, 60, 90]]), ([[0, 'on', 0, 60, 1], [3, 'off', 0, 60, 64]], [[0, 3, 0, 60, 1]]), ([], []), ([[0, 'on', 0, 60, 100], [5, 'off', 0, 60, 64], [6, 'on', 0, 60, 100], [9, 'off', 0, 60, 64]], [[0, 5, 0, 60, 100], [6, 9, 0, 60, 100]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]), ([[1, 'on', 0, 60, 100], [3, 'on', 0, 60, 50], [7, 'off', 0, 60, 0], [9, 'on', 0, 72, 10]], [[1, 7, 0, 60, 100], [3, 9, 0, 60, 50], [9, 9, 0, 72, 10]]), ([[0, 'on', 0, 60, 100], [2, 'on', 1, 60, 50], [4, 'off', 0, 60, 0], [6, 'off', 1, 60, 0]], [[0, 4, 0, 60, 100], [2, 6, 1, 60, 50]])], [([[0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [10, 'on', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [5, 'off', 0, 60, 64], [6, 'on', 0, 60, 100], [9, 'off', 0, 60, 64]], [[0, 5, 0, 60, 100], [6, 9, 0, 60, 100]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]), ([[1, 'on', 0, 60, 100], [3, 'on', 0, 60, 50], [7, 'off', 0, 60, 0], [9, 'on', 0, 72, 10]], [[1, 7, 0, 60, 100], [3, 9, 0, 60, 50], [9, 9, 0, 72, 10]]), ([[0, 'on', 0, 60, 100], [2, 'on', 1, 60, 50], [4, 'off', 0, 60, 0], [6, 'off', 1, 60, 0]], [[0, 4, 0, 60, 100], [2, 6, 1, 60, 50]]), ([[0, 'on', 3, 70, 100], [1, 'on', 4, 70, 100], [5, 'off', 3, 70, 0], [6, 'off', 4, 70, 0]], [[0, 5, 3, 70, 100], [1, 6, 4, 70, 100]])], [([[0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [10, 'on', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [5, 'on', 0, 60, 80], [10, 'off', 0, 60, 0], [20, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]]), ([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [30, 'on', 0, 64, 90]], [[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]), ([[0, 'off', 0, 60, 0], [5, 'on', 0, 62, 70], [9, 'off', 0, 62, 40]], [[5, 9, 0, 62, 70]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]), ([[0, 'on', 3, 70, 100], [1, 'on', 4, 70, 100], [5, 'off', 3, 70, 0], [6, 'off', 4, 70, 0]], [[0, 5, 3, 70, 100], [1, 6, 4, 70, 100]])]]
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, 10, 0, 60, 100]][[0, 10, 0, 60, 100]]Passed
oracle 1[[0, 10, 0, 60, 100]][[0, 10, 0, 60, 100]]Passed
oracle 2[[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]][[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]]Passed
oracle 3[[5, 10, 1, 60, 80], [0, 20, 0, 60, 100]][[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]Failed
oracle 4[[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]][[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]Passed
oracle 5[[5, 9, 0, 62, 70]][[5, 9, 0, 62, 70]]Passed
oracle 6[[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]][[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]]Passed
oracle 7[[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]][[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]Passed

SHA-256 / 836e803859365bc8945da49a4a0ff2d052ef55a9659f4f2d83da9a7454ccb01e

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):
        return None
    active = {}
    done = []
    last = 0
    for tick, kind, ch, note, vel in x:
        last = max(last, tick)
        key = (ch, note)
        if kind == 'on' and vel > 0:
            active.setdefault(key, []).append((tick, vel, ch, note))
        elif kind in ('on', 'off'):
            if active.get(key):
                start, v, c, n = active[key].pop(0)
                done.append([start, tick, c, n, v])
    for stack in active.values():
        for start, v, c, n in stack:
            done.append([start, last, c, n, v])
    done.sort(key=lambda e: (e[3], e[0], e[2], e[1]))
    return done
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [10, 'on', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [5, 'on', 0, 60, 80], [10, 'off', 0, 60, 0], [20, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]]), ([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [30, 'on', 0, 64, 90]], [[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]), ([[0, 'off', 0, 60, 0], [5, 'on', 0, 62, 70], [9, 'off', 0, 62, 40]], [[5, 9, 0, 62, 70]]), ([[0, 'on', 0, 64, 100], [0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0], [12, 'off', 0, 64, 0]], [[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]])], [([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [30, 'on', 0, 64, 90]], [[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]), ([[0, 'off', 0, 60, 0], [5, 'on', 0, 62, 70], [9, 'off', 0, 62, 40]], [[5, 9, 0, 62, 70]]), ([[0, 'on', 0, 64, 100], [0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0], [12, 'off', 0, 64, 0]], [[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]]), ([[0, 'on', 2, 60, 100], [4, 'on', 2, 60, 90], [8, 'on', 2, 60, 0], [9, 'on', 2, 60, 0]], [[0, 8, 2, 60, 100], [4, 9, 2, 60, 90]]), ([[0, 'on', 0, 60, 1], [3, 'off', 0, 60, 64]], [[0, 3, 0, 60, 1]]), ([], []), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]])], [([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 2, 60, 100], [4, 'on', 2, 60, 90], [8, 'on', 2, 60, 0], [9, 'on', 2, 60, 0]], [[0, 8, 2, 60, 100], [4, 9, 2, 60, 90]]), ([[0, 'on', 0, 60, 1], [3, 'off', 0, 60, 64]], [[0, 3, 0, 60, 1]]), ([], []), ([[0, 'on', 0, 60, 100], [5, 'off', 0, 60, 64], [6, 'on', 0, 60, 100], [9, 'off', 0, 60, 64]], [[0, 5, 0, 60, 100], [6, 9, 0, 60, 100]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]), ([[1, 'on', 0, 60, 100], [3, 'on', 0, 60, 50], [7, 'off', 0, 60, 0], [9, 'on', 0, 72, 10]], [[1, 7, 0, 60, 100], [3, 9, 0, 60, 50], [9, 9, 0, 72, 10]]), ([[0, 'on', 0, 60, 100], [2, 'on', 1, 60, 50], [4, 'off', 0, 60, 0], [6, 'off', 1, 60, 0]], [[0, 4, 0, 60, 100], [2, 6, 1, 60, 50]])], [([[0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [10, 'on', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [5, 'off', 0, 60, 64], [6, 'on', 0, 60, 100], [9, 'off', 0, 60, 64]], [[0, 5, 0, 60, 100], [6, 9, 0, 60, 100]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]), ([[1, 'on', 0, 60, 100], [3, 'on', 0, 60, 50], [7, 'off', 0, 60, 0], [9, 'on', 0, 72, 10]], [[1, 7, 0, 60, 100], [3, 9, 0, 60, 50], [9, 9, 0, 72, 10]]), ([[0, 'on', 0, 60, 100], [2, 'on', 1, 60, 50], [4, 'off', 0, 60, 0], [6, 'off', 1, 60, 0]], [[0, 4, 0, 60, 100], [2, 6, 1, 60, 50]]), ([[0, 'on', 3, 70, 100], [1, 'on', 4, 70, 100], [5, 'off', 3, 70, 0], [6, 'off', 4, 70, 0]], [[0, 5, 3, 70, 100], [1, 6, 4, 70, 100]])], [([[0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [10, 'on', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [5, 'on', 0, 60, 80], [10, 'off', 0, 60, 0], [20, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]]), ([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [30, 'on', 0, 64, 90]], [[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]), ([[0, 'off', 0, 60, 0], [5, 'on', 0, 62, 70], [9, 'off', 0, 62, 40]], [[5, 9, 0, 62, 70]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]), ([[0, 'on', 3, 70, 100], [1, 'on', 4, 70, 100], [5, 'off', 3, 70, 0], [6, 'off', 4, 70, 0]], [[0, 5, 3, 70, 100], [1, 6, 4, 70, 100]])]]
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, 10, 0, 60, 100]][[0, 10, 0, 60, 100]]Passed
oracle 1[[0, 10, 0, 60, 100]][[0, 10, 0, 60, 100]]Passed
oracle 2[[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]][[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]]Passed
oracle 3[[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]][[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]Passed
oracle 4[[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]][[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]Passed
oracle 5[[5, 9, 0, 62, 70]][[5, 9, 0, 62, 70]]Passed
oracle 6[[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]][[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]]Passed
oracle 7[[2, 8, 0, 60, 100], [0, 4, 0, 62, 100]][[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]Failed

SHA-256 / 51f65383b5a85f137adec94449a2ad8b641c3e028704c69abbc370086f611489

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):
        return None
    active = {}
    done = []
    last = 0
    for tick, kind, ch, note, vel in x:
        last = max(last, tick)
        key = (ch, note)
        if kind == 'on' and vel > 0:
            active.setdefault(key, []).append((tick, vel, ch, note))
        elif kind in ('on', 'off'):
            if active.get(key):
                start, v, c, n = active[key].pop(0)
                done.append([start, tick, c, n, v])
    for stack in active.values():
        for start, v, c, n in stack:
            done.append([start, last, c, n, v])
    done.sort(key=lambda e: (e[0], e[3], e[2], e[1]))
    return done
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [10, 'on', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [5, 'on', 0, 60, 80], [10, 'off', 0, 60, 0], [20, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]]), ([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [30, 'on', 0, 64, 90]], [[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]), ([[0, 'off', 0, 60, 0], [5, 'on', 0, 62, 70], [9, 'off', 0, 62, 40]], [[5, 9, 0, 62, 70]]), ([[0, 'on', 0, 64, 100], [0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0], [12, 'off', 0, 64, 0]], [[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]])], [([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [30, 'on', 0, 64, 90]], [[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]), ([[0, 'off', 0, 60, 0], [5, 'on', 0, 62, 70], [9, 'off', 0, 62, 40]], [[5, 9, 0, 62, 70]]), ([[0, 'on', 0, 64, 100], [0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0], [12, 'off', 0, 64, 0]], [[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]]), ([[0, 'on', 2, 60, 100], [4, 'on', 2, 60, 90], [8, 'on', 2, 60, 0], [9, 'on', 2, 60, 0]], [[0, 8, 2, 60, 100], [4, 9, 2, 60, 90]]), ([[0, 'on', 0, 60, 1], [3, 'off', 0, 60, 64]], [[0, 3, 0, 60, 1]]), ([], []), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]])], [([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 2, 60, 100], [4, 'on', 2, 60, 90], [8, 'on', 2, 60, 0], [9, 'on', 2, 60, 0]], [[0, 8, 2, 60, 100], [4, 9, 2, 60, 90]]), ([[0, 'on', 0, 60, 1], [3, 'off', 0, 60, 64]], [[0, 3, 0, 60, 1]]), ([], []), ([[0, 'on', 0, 60, 100], [5, 'off', 0, 60, 64], [6, 'on', 0, 60, 100], [9, 'off', 0, 60, 64]], [[0, 5, 0, 60, 100], [6, 9, 0, 60, 100]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]), ([[1, 'on', 0, 60, 100], [3, 'on', 0, 60, 50], [7, 'off', 0, 60, 0], [9, 'on', 0, 72, 10]], [[1, 7, 0, 60, 100], [3, 9, 0, 60, 50], [9, 9, 0, 72, 10]]), ([[0, 'on', 0, 60, 100], [2, 'on', 1, 60, 50], [4, 'off', 0, 60, 0], [6, 'off', 1, 60, 0]], [[0, 4, 0, 60, 100], [2, 6, 1, 60, 50]])], [([[0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [10, 'on', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [5, 'off', 0, 60, 64], [6, 'on', 0, 60, 100], [9, 'off', 0, 60, 64]], [[0, 5, 0, 60, 100], [6, 9, 0, 60, 100]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]), ([[1, 'on', 0, 60, 100], [3, 'on', 0, 60, 50], [7, 'off', 0, 60, 0], [9, 'on', 0, 72, 10]], [[1, 7, 0, 60, 100], [3, 9, 0, 60, 50], [9, 9, 0, 72, 10]]), ([[0, 'on', 0, 60, 100], [2, 'on', 1, 60, 50], [4, 'off', 0, 60, 0], [6, 'off', 1, 60, 0]], [[0, 4, 0, 60, 100], [2, 6, 1, 60, 50]]), ([[0, 'on', 3, 70, 100], [1, 'on', 4, 70, 100], [5, 'off', 3, 70, 0], [6, 'off', 4, 70, 0]], [[0, 5, 3, 70, 100], [1, 6, 4, 70, 100]])], [([[0, 'on', 0, 60, 100], [10, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [10, 'on', 0, 60, 0]], [[0, 10, 0, 60, 100]]), ([[0, 'on', 0, 60, 100], [5, 'on', 0, 60, 80], [10, 'off', 0, 60, 0], [20, 'off', 0, 60, 0]], [[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]]), ([[0, 'on', 0, 60, 100], [5, 'on', 1, 60, 80], [10, 'off', 1, 60, 0], [20, 'off', 0, 60, 0]], [[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]), ([[0, 'on', 0, 60, 100], [30, 'on', 0, 64, 90]], [[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]), ([[0, 'off', 0, 60, 0], [5, 'on', 0, 62, 70], [9, 'off', 0, 62, 40]], [[5, 9, 0, 62, 70]]), ([[0, 'on', 0, 62, 100], [2, 'on', 0, 60, 100], [4, 'off', 0, 62, 0], [8, 'off', 0, 60, 0]], [[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]), ([[0, 'on', 3, 70, 100], [1, 'on', 4, 70, 100], [5, 'off', 3, 70, 0], [6, 'off', 4, 70, 0]], [[0, 5, 3, 70, 100], [1, 6, 4, 70, 100]])]]
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, 10, 0, 60, 100]][[0, 10, 0, 60, 100]]Passed
oracle 1[[0, 10, 0, 60, 100]][[0, 10, 0, 60, 100]]Passed
oracle 2[[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]][[0, 10, 0, 60, 100], [5, 20, 0, 60, 80]]Passed
oracle 3[[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]][[0, 20, 0, 60, 100], [5, 10, 1, 60, 80]]Passed
oracle 4[[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]][[0, 30, 0, 60, 100], [30, 30, 0, 64, 90]]Passed
oracle 5[[5, 9, 0, 62, 70]][[5, 9, 0, 62, 70]]Passed
oracle 6[[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]][[0, 10, 0, 60, 100], [0, 12, 0, 64, 100]]Passed
oracle 7[[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]][[0, 4, 0, 62, 100], [2, 8, 0, 60, 100]]Passed

SHA-256 / e64af1139a23dc68caa50f7865669fc3e6cc129669fd0a401ca17c81263448d6

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

Case digest / f53379e8fb1c47ec039babde02ed9df37287c97be120a282cf0390018ef9fd3d