FAILURE MAP
← Case archive

FA-81461 / MIDI event timing / Open access

Absolute events to delta-time serialisation: note-on emitted before simultaneous note-off · case 01

A repeated note whose off and next on share a tick is emitted on-then-off, so a receiver cuts the new note immediately.

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

ROOT CAUSE

The tie-break ranks note-ons ahead of note-offs at equal ticks.

VERIFIED REPAIR

Restore the same-tick priority step so that it reads `0 if x[i][1] == 'off' else 1`.

Unsuccessful approach: Removing the priority keeps input order, which still places an on before an off when listed that way.

Case contract

Input a list of [tick, kind, note] with kind on or off in any order. Emit events sorted by tick; at equal ticks note-offs precede note-ons, and otherwise input order is kept. Each output is [delta from the previous emitted event (the first from tick 0), kind, note]. A negative tick returns None.

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
    for e in x:
        if e[0] < 0:
            return None
    order = sorted(range(len(x)), key=lambda i: (x[i][0], 0 if x[i][1] == 'on' else 1, i))
    out = []
    prev = 0
    for i in order:
        tick, kind, note = x[i]
        out.append([tick - prev, kind, note])
        prev = tick
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[3, 'on', 1], [3, 'on', 2], [3, 'on', 3]], [[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]), ([], []), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[100, 'on', 60], [50, 'on', 61], [75, 'off', 61]], [[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]])], [([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([], []), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[100, 'on', 60], [50, 'on', 61], [75, 'off', 61]], [[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]]), ([[-1, 'on', 60]], None), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]]), ([[12, 'on', 70]], [[12, 'on', 70]])], [([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]]), ([[12, 'on', 70]], [[12, 'on', 70]])], [([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[3, 'on', 1], [3, 'on', 2], [3, 'on', 3]], [[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]])], [([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[3, 'on', 1], [3, 'on', 2], [3, 'on', 3]], [[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]), ([], []), ([[100, 'on', 60], [50, 'on', 61], [75, 'off', 61]], [[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]]), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]])]]
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, 'on', 60], [10, 'off', 60]][[0, 'on', 60], [10, 'off', 60]]Passed
oracle 1[[0, 'on', 60], [10, 'on', 62], [0, 'off', 60]][[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]Failed
oracle 2[[5, 'on', 60], [10, 'off', 60]][[5, 'on', 60], [10, 'off', 60]]Passed
oracle 3[[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]][[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]Failed
oracle 4[[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]][[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]Passed
oracle 5[][]Passed
oracle 6[[7, 'on', 60], [0, 'off', 60], [0, 'off', 61]][[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]Failed
oracle 7[[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]][[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]]Passed

SHA-256 / 0c63e475088da1bc9199c4fe1c5473abf5e823987b9f0d569c87e7572fd9fe72

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
    for e in x:
        if e[0] < 0:
            return None
    order = sorted(range(len(x)), key=lambda i: (x[i][0], 0, i))
    out = []
    prev = 0
    for i in order:
        tick, kind, note = x[i]
        out.append([tick - prev, kind, note])
        prev = tick
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[3, 'on', 1], [3, 'on', 2], [3, 'on', 3]], [[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]), ([], []), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[100, 'on', 60], [50, 'on', 61], [75, 'off', 61]], [[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]])], [([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([], []), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[100, 'on', 60], [50, 'on', 61], [75, 'off', 61]], [[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]]), ([[-1, 'on', 60]], None), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]]), ([[12, 'on', 70]], [[12, 'on', 70]])], [([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]]), ([[12, 'on', 70]], [[12, 'on', 70]])], [([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[3, 'on', 1], [3, 'on', 2], [3, 'on', 3]], [[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]])], [([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[3, 'on', 1], [3, 'on', 2], [3, 'on', 3]], [[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]), ([], []), ([[100, 'on', 60], [50, 'on', 61], [75, 'off', 61]], [[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]]), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]])]]
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, 'on', 60], [10, 'off', 60]][[0, 'on', 60], [10, 'off', 60]]Passed
oracle 1[[0, 'on', 60], [10, 'on', 62], [0, 'off', 60]][[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]Failed
oracle 2[[5, 'on', 60], [10, 'off', 60]][[5, 'on', 60], [10, 'off', 60]]Passed
oracle 3[[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]][[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]Failed
oracle 4[[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]][[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]Passed
oracle 5[][]Passed
oracle 6[[7, 'off', 60], [0, 'on', 60], [0, 'off', 61]][[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]Failed
oracle 7[[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]][[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]]Passed

SHA-256 / 571d69e9cbdf3d7d0d51419b2352132538b51175c41a17b5e4ad11ed38075b2d

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
    for e in x:
        if e[0] < 0:
            return None
    order = sorted(range(len(x)), key=lambda i: (x[i][0], 0 if x[i][1] == 'off' else 1, i))
    out = []
    prev = 0
    for i in order:
        tick, kind, note = x[i]
        out.append([tick - prev, kind, note])
        prev = tick
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[3, 'on', 1], [3, 'on', 2], [3, 'on', 3]], [[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]), ([], []), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[100, 'on', 60], [50, 'on', 61], [75, 'off', 61]], [[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]])], [([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([], []), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[100, 'on', 60], [50, 'on', 61], [75, 'off', 61]], [[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]]), ([[-1, 'on', 60]], None), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]]), ([[12, 'on', 70]], [[12, 'on', 70]])], [([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]]), ([[12, 'on', 70]], [[12, 'on', 70]])], [([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[10, 'on', 62], [10, 'off', 60], [0, 'on', 60]], [[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[3, 'on', 1], [3, 'on', 2], [3, 'on', 3]], [[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]), ([[7, 'off', 60], [7, 'on', 60], [7, 'off', 61]], [[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]])], [([[0, 'on', 60], [10, 'off', 60]], [[0, 'on', 60], [10, 'off', 60]]), ([[5, 'on', 60], [15, 'off', 60]], [[5, 'on', 60], [10, 'off', 60]]), ([[20, 'on', 64], [0, 'on', 60], [20, 'off', 60]], [[0, 'on', 60], [20, 'off', 60], [0, 'on', 64]]), ([[0, 'on', 60], [0, 'on', 64], [0, 'off', 59]], [[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]), ([[3, 'on', 1], [3, 'on', 2], [3, 'on', 3]], [[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]), ([], []), ([[100, 'on', 60], [50, 'on', 61], [75, 'off', 61]], [[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]]), ([[30, 'on', 60], [30, 'off', 60], [40, 'off', 60]], [[30, 'off', 60], [0, 'on', 60], [10, 'off', 60]])]]
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, 'on', 60], [10, 'off', 60]][[0, 'on', 60], [10, 'off', 60]]Passed
oracle 1[[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]][[0, 'on', 60], [10, 'off', 60], [0, 'on', 62]]Passed
oracle 2[[5, 'on', 60], [10, 'off', 60]][[5, 'on', 60], [10, 'off', 60]]Passed
oracle 3[[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]][[0, 'off', 59], [0, 'on', 60], [0, 'on', 64]]Passed
oracle 4[[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]][[3, 'on', 1], [0, 'on', 2], [0, 'on', 3]]Passed
oracle 5[][]Passed
oracle 6[[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]][[7, 'off', 60], [0, 'off', 61], [0, 'on', 60]]Passed
oracle 7[[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]][[50, 'on', 61], [25, 'off', 61], [25, 'on', 60]]Passed

SHA-256 / 1179f034d5ba0e3dabdbaad3f53a8953e42939d80b65d2b36c61db012067f5e2

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

Case digest / d34a4b03ef193ebe51da35b141a2349591998409ae50767e34418c1fe816ce3d