FA-81606 / MIDI event timing / Open access
Format 1 to format 0 track merge: simultaneous events ordered by name · case 01
Simultaneous events from different tracks are reordered alphabetically instead of by track, e.g. a tempo event after the notes it should govern.
ROOT CAUSE
Ties at equal ticks are broken by the event payload instead of track index and original position.
THE FAILURE
Ties at equal ticks are broken by the event payload instead of track index and original position.
Unsuccessful approach: Breaking ties by descending track index puts later tracks first.
Case contract
Input a list of tracks, each a list of [delta, event]. The event "eot" marks end of track and is not copied. Merge all events by absolute time; ties go to the lower track index, then original order. Output [delta, event] pairs followed by one final [delta, "eot"] at the latest end-of-track or last event time.
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
events = []
end = 0
for ti, track in enumerate(x):
tick = 0
for seq, (delta, ev) in enumerate(track):
tick += delta
if ev == 'eot':
end = max(end, tick)
continue
events.append((tick, ti, seq, ev))
events.sort(key=lambda e: (e[0], e[3]))
out = []
prev = 0
for tick, ti, seq, ev in events:
out.append([tick - prev, ev])
prev = tick
end = max(end, prev)
out.append([end - prev, 'eot'])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[0, 'a'], [10, 'b'], [0, 'eot']], [[5, 'c'], [20, 'eot']]], [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']]), ([[[0, 'tempo'], [0, 'eot']], [[0, 'n1'], [480, 'n2'], [0, 'eot']]], [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']]), ([[[0, 'x'], [100, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [50, 'eot']]), ([[[0, 'x'], [5, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [0, 'eot']]), ([[[3, 'p'], [3, 'q']], [[4, 'r']]], [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']]), ([[[0, 'eot']]], [[0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']])], [([[[0, 'tempo'], [0, 'eot']], [[0, 'n1'], [480, 'n2'], [0, 'eot']]], [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']]), ([[[10, 'z'], [0, 'eot']], [[10, 'a'], [0, 'eot']]], [[10, 'z'], [0, 'a'], [0, 'eot']]), ([[[3, 'p'], [3, 'q']], [[4, 'r']]], [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']]), ([[[0, 'eot']]], [[0, 'eot']]), ([], [[0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']]), ([[[20, 'late'], [0, 'eot']], [[1, 'early'], [2, 'eot']]], [[1, 'early'], [19, 'late'], [0, 'eot']])], [([[[0, 'a'], [10, 'b'], [0, 'eot']], [[5, 'c'], [20, 'eot']]], [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']]), ([[[0, 'tempo'], [0, 'eot']], [[0, 'n1'], [480, 'n2'], [0, 'eot']]], [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']]), ([[[10, 'z'], [0, 'eot']], [[10, 'a'], [0, 'eot']]], [[10, 'z'], [0, 'a'], [0, 'eot']]), ([[[0, 'x'], [100, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [50, 'eot']]), ([[[0, 'x'], [5, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']]), ([[[20, 'late'], [0, 'eot']], [[1, 'early'], [2, 'eot']]], [[1, 'early'], [19, 'late'], [0, 'eot']])], [([[[0, 'a'], [10, 'b'], [0, 'eot']], [[5, 'c'], [20, 'eot']]], [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']]), ([[[10, 'z'], [0, 'eot']], [[10, 'a'], [0, 'eot']]], [[10, 'z'], [0, 'a'], [0, 'eot']]), ([[[0, 'x'], [100, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [50, 'eot']]), ([[[0, 'x'], [5, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [0, 'eot']]), ([[[3, 'p'], [3, 'q']], [[4, 'r']]], [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']]), ([[[0, 'eot']]], [[0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']])], [([[[0, 'tempo'], [0, 'eot']], [[0, 'n1'], [480, 'n2'], [0, 'eot']]], [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']]), ([[[0, 'x'], [100, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [50, 'eot']]), ([[[0, 'x'], [5, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [0, 'eot']]), ([[[3, 'p'], [3, 'q']], [[4, 'r']]], [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']]), ([[[0, 'eot']]], [[0, 'eot']]), ([], [[0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']])]]
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 | [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']] | [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']] | Passed |
| oracle 1 | [[0, 'n1'], [0, 'tempo'], [480, 'n2'], [0, 'eot']] | [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']] | Failed |
| oracle 2 | [[0, 'x'], [50, 'y'], [50, 'eot']] | [[0, 'x'], [50, 'y'], [50, 'eot']] | Passed |
| oracle 3 | [[0, 'x'], [50, 'y'], [0, 'eot']] | [[0, 'x'], [50, 'y'], [0, 'eot']] | Passed |
| oracle 4 | [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']] | [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']] | Passed |
| oracle 5 | [[0, 'eot']] | [[0, 'eot']] | Passed |
| oracle 6 | [[5, 'k'], [0, 'm'], [2, 'j'], [3, 'n'], [27, 'eot']] | [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']] | Failed |
| oracle 7 | [[0, 'a'], [0, 'b'], [0, 'c'], [0, 'eot']] | [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']] | Failed |
SHA-256 / ee3d1731bdcd1e09af934523d303a18363c8816f212c8ed693d6ba24b0271b8d
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
events = []
end = 0
for ti, track in enumerate(x):
tick = 0
for seq, (delta, ev) in enumerate(track):
tick += delta
if ev == 'eot':
end = max(end, tick)
continue
events.append((tick, ti, seq, ev))
events.sort(key=lambda e: (e[0], -e[1]))
out = []
prev = 0
for tick, ti, seq, ev in events:
out.append([tick - prev, ev])
prev = tick
end = max(end, prev)
out.append([end - prev, 'eot'])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[0, 'a'], [10, 'b'], [0, 'eot']], [[5, 'c'], [20, 'eot']]], [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']]), ([[[0, 'tempo'], [0, 'eot']], [[0, 'n1'], [480, 'n2'], [0, 'eot']]], [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']]), ([[[0, 'x'], [100, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [50, 'eot']]), ([[[0, 'x'], [5, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [0, 'eot']]), ([[[3, 'p'], [3, 'q']], [[4, 'r']]], [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']]), ([[[0, 'eot']]], [[0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']])], [([[[0, 'tempo'], [0, 'eot']], [[0, 'n1'], [480, 'n2'], [0, 'eot']]], [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']]), ([[[10, 'z'], [0, 'eot']], [[10, 'a'], [0, 'eot']]], [[10, 'z'], [0, 'a'], [0, 'eot']]), ([[[3, 'p'], [3, 'q']], [[4, 'r']]], [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']]), ([[[0, 'eot']]], [[0, 'eot']]), ([], [[0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']]), ([[[20, 'late'], [0, 'eot']], [[1, 'early'], [2, 'eot']]], [[1, 'early'], [19, 'late'], [0, 'eot']])], [([[[0, 'a'], [10, 'b'], [0, 'eot']], [[5, 'c'], [20, 'eot']]], [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']]), ([[[0, 'tempo'], [0, 'eot']], [[0, 'n1'], [480, 'n2'], [0, 'eot']]], [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']]), ([[[10, 'z'], [0, 'eot']], [[10, 'a'], [0, 'eot']]], [[10, 'z'], [0, 'a'], [0, 'eot']]), ([[[0, 'x'], [100, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [50, 'eot']]), ([[[0, 'x'], [5, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']]), ([[[20, 'late'], [0, 'eot']], [[1, 'early'], [2, 'eot']]], [[1, 'early'], [19, 'late'], [0, 'eot']])], [([[[0, 'a'], [10, 'b'], [0, 'eot']], [[5, 'c'], [20, 'eot']]], [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']]), ([[[10, 'z'], [0, 'eot']], [[10, 'a'], [0, 'eot']]], [[10, 'z'], [0, 'a'], [0, 'eot']]), ([[[0, 'x'], [100, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [50, 'eot']]), ([[[0, 'x'], [5, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [0, 'eot']]), ([[[3, 'p'], [3, 'q']], [[4, 'r']]], [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']]), ([[[0, 'eot']]], [[0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']])], [([[[0, 'tempo'], [0, 'eot']], [[0, 'n1'], [480, 'n2'], [0, 'eot']]], [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']]), ([[[0, 'x'], [100, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [50, 'eot']]), ([[[0, 'x'], [5, 'eot']], [[50, 'y'], [0, 'eot']]], [[0, 'x'], [50, 'y'], [0, 'eot']]), ([[[3, 'p'], [3, 'q']], [[4, 'r']]], [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']]), ([[[0, 'eot']]], [[0, 'eot']]), ([], [[0, 'eot']]), ([[[5, 'm'], [5, 'n'], [0, 'eot']], [[5, 'k'], [0, 'eot']], [[7, 'j'], [30, 'eot']]], [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']]), ([[[0, 'b'], [0, 'a'], [0, 'eot']], [[0, 'c'], [0, 'eot']]], [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']])]]
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 | [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']] | [[0, 'a'], [5, 'c'], [5, 'b'], [15, 'eot']] | Passed |
| oracle 1 | [[0, 'n1'], [0, 'tempo'], [480, 'n2'], [0, 'eot']] | [[0, 'tempo'], [0, 'n1'], [480, 'n2'], [0, 'eot']] | Failed |
| oracle 2 | [[0, 'x'], [50, 'y'], [50, 'eot']] | [[0, 'x'], [50, 'y'], [50, 'eot']] | Passed |
| oracle 3 | [[0, 'x'], [50, 'y'], [0, 'eot']] | [[0, 'x'], [50, 'y'], [0, 'eot']] | Passed |
| oracle 4 | [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']] | [[3, 'p'], [1, 'r'], [2, 'q'], [0, 'eot']] | Passed |
| oracle 5 | [[0, 'eot']] | [[0, 'eot']] | Passed |
| oracle 6 | [[5, 'k'], [0, 'm'], [2, 'j'], [3, 'n'], [27, 'eot']] | [[5, 'm'], [0, 'k'], [2, 'j'], [3, 'n'], [27, 'eot']] | Failed |
| oracle 7 | [[0, 'c'], [0, 'b'], [0, 'a'], [0, 'eot']] | [[0, 'b'], [0, 'a'], [0, 'c'], [0, 'eot']] | Failed |
SHA-256 / 8b97b225a12a77d4bab49e5d45e6c3be536cff23781b20a2ac4a1c19dc20b89d
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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.484783+00:00.
Case digest / 6bc42f4ef6c2a2135401d21922a856ee8e10297aa4a3ef4cc5a83dae00d5f7bd