FAILURE MAP
← Case archive

FA-81746 / MIDI event timing / Open access

Same-pitch and monophonic overlap truncation: overlaps resolved in input order · case 01

When notes are listed out of time order, the later-listed earlier note is never truncated by the note that follows it in time.

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

ROOT CAUSE

Notes are processed in their input order instead of sorted by start.

VERIFIED REPAIR

Restore the processing order step so that it reads `sorted(notes, key=lambda n: (n[0], n[2]))`.

Unsuccessful approach: Sorting by end time does not order notes by when they start.

Case contract

Input [notes, mode] where notes are [start, end, pitch] in any order and mode is poly or mono. Sort by start then pitch. Each note ends no later than the start of the next note that starts strictly later and has the same pitch (poly) or any pitch (mono). Notes whose length becomes zero or negative are removed. Return the notes in sorted order; unknown mode 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) or len(x) != 2:
        return None
    notes, mode = x
    if mode not in ('poly', 'mono'):
        return None
    order = list(notes)
    out = []
    for i, (s, e, p) in enumerate(order):
        for s2, e2, p2 in order[i + 1:]:
            if s2 > s and (mode == 'mono' or p2 == p):
                e = min(e, s2)
                break
        if e > s:
            out.append([s, e, p])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[0, 10, 60], [5, 15, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 10, 60], [5, 15, 62]], 'poly'], [[0, 10, 60], [5, 15, 62]]), ([[[0, 10, 60], [5, 15, 62]], 'mono'], [[0, 5, 60], [5, 15, 62]]), ([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 4, 60], [2, 3, 60]], 'poly'], [[0, 2, 60], [2, 3, 60]]), ([[[0, 10, 60], [0, 10, 64]], 'mono'], [[0, 10, 60], [0, 10, 64]]), ([[[0, 10, 60], [10, 20, 60]], 'poly'], [[0, 10, 60], [10, 20, 60]]), ([[[0, 10, 62], [4, 6, 60]], 'mono'], [[0, 4, 62], [4, 6, 60]])], [([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 10, 60], [0, 10, 64]], 'mono'], [[0, 10, 60], [0, 10, 64]]), ([[[0, 10, 60], [10, 20, 60]], 'poly'], [[0, 10, 60], [10, 20, 60]]), ([[[0, 5, 60], [5, 6, 62]], 'mono'], [[0, 5, 60], [5, 6, 62]]), ([[[0, 1, 60], [0, 8, 60], [1, 9, 60]], 'poly'], [[0, 1, 60], [0, 1, 60], [1, 9, 60]]), ([[[3, 3, 60]], 'poly'], []), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 9, 70], [1, 5, 72], [2, 4, 70]], 'poly'], [[0, 2, 70], [1, 5, 72], [2, 4, 70]])], [([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 4, 60], [2, 3, 60]], 'poly'], [[0, 2, 60], [2, 3, 60]]), ([[[0, 1, 60], [0, 8, 60], [1, 9, 60]], 'poly'], [[0, 1, 60], [0, 1, 60], [1, 9, 60]]), ([[[3, 3, 60]], 'poly'], []), ([[[0, 10, 60]], 'legato'], None), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 2, 60], [1, 9, 60], [3, 5, 60]], 'poly'], [[0, 1, 60], [1, 3, 60], [3, 5, 60]]), ([[[1, 2, 60], [2, 3, 60], [3, 4, 60]], 'poly'], [[1, 2, 60], [2, 3, 60], [3, 4, 60]])], [([[[0, 10, 60], [5, 15, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 4, 60], [2, 3, 60]], 'poly'], [[0, 2, 60], [2, 3, 60]]), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 2, 60], [1, 9, 60], [3, 5, 60]], 'poly'], [[0, 1, 60], [1, 3, 60], [3, 5, 60]]), ([[[0, 10, 62], [4, 6, 60]], 'mono'], [[0, 4, 62], [4, 6, 60]]), ([[[1, 2, 60], [2, 3, 60], [3, 4, 60]], 'poly'], [[1, 2, 60], [2, 3, 60], [3, 4, 60]]), ([[[0, 9, 70], [1, 5, 72], [2, 4, 70]], 'poly'], [[0, 2, 70], [1, 5, 72], [2, 4, 70]])], [([[[0, 10, 60], [5, 15, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 10, 60], [5, 15, 62]], 'poly'], [[0, 10, 60], [5, 15, 62]]), ([[[0, 10, 60], [5, 15, 62]], 'mono'], [[0, 5, 60], [5, 15, 62]]), ([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 2, 60], [1, 9, 60], [3, 5, 60]], 'poly'], [[0, 1, 60], [1, 3, 60], [3, 5, 60]]), ([[[0, 10, 62], [4, 6, 60]], 'mono'], [[0, 4, 62], [4, 6, 60]]), ([[[0, 9, 70], [1, 5, 72], [2, 4, 70]], 'poly'], [[0, 2, 70], [1, 5, 72], [2, 4, 70]])]]
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, 5, 60], [5, 15, 60]][[0, 5, 60], [5, 15, 60]]Passed
oracle 1[[0, 10, 60], [5, 15, 62]][[0, 10, 60], [5, 15, 62]]Passed
oracle 2[[0, 5, 60], [5, 15, 62]][[0, 5, 60], [5, 15, 62]]Passed
oracle 3[[5, 15, 60], [0, 10, 60]][[0, 5, 60], [5, 15, 60]]Failed
oracle 4[[0, 2, 60], [2, 3, 60]][[0, 2, 60], [2, 3, 60]]Passed
oracle 5[[0, 10, 60], [0, 10, 64]][[0, 10, 60], [0, 10, 64]]Passed
oracle 6[[0, 10, 60], [10, 20, 60]][[0, 10, 60], [10, 20, 60]]Passed
oracle 7[[0, 4, 62], [4, 6, 60]][[0, 4, 62], [4, 6, 60]]Passed

SHA-256 / 5fb60bf1f13e79520b10549b08303f84fe914f16fbf74e9aa51de3beb64980c5

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
    notes, mode = x
    if mode not in ('poly', 'mono'):
        return None
    order = sorted(notes, key=lambda n: n[1])
    out = []
    for i, (s, e, p) in enumerate(order):
        for s2, e2, p2 in order[i + 1:]:
            if s2 > s and (mode == 'mono' or p2 == p):
                e = min(e, s2)
                break
        if e > s:
            out.append([s, e, p])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[0, 10, 60], [5, 15, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 10, 60], [5, 15, 62]], 'poly'], [[0, 10, 60], [5, 15, 62]]), ([[[0, 10, 60], [5, 15, 62]], 'mono'], [[0, 5, 60], [5, 15, 62]]), ([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 4, 60], [2, 3, 60]], 'poly'], [[0, 2, 60], [2, 3, 60]]), ([[[0, 10, 60], [0, 10, 64]], 'mono'], [[0, 10, 60], [0, 10, 64]]), ([[[0, 10, 60], [10, 20, 60]], 'poly'], [[0, 10, 60], [10, 20, 60]]), ([[[0, 10, 62], [4, 6, 60]], 'mono'], [[0, 4, 62], [4, 6, 60]])], [([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 10, 60], [0, 10, 64]], 'mono'], [[0, 10, 60], [0, 10, 64]]), ([[[0, 10, 60], [10, 20, 60]], 'poly'], [[0, 10, 60], [10, 20, 60]]), ([[[0, 5, 60], [5, 6, 62]], 'mono'], [[0, 5, 60], [5, 6, 62]]), ([[[0, 1, 60], [0, 8, 60], [1, 9, 60]], 'poly'], [[0, 1, 60], [0, 1, 60], [1, 9, 60]]), ([[[3, 3, 60]], 'poly'], []), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 9, 70], [1, 5, 72], [2, 4, 70]], 'poly'], [[0, 2, 70], [1, 5, 72], [2, 4, 70]])], [([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 4, 60], [2, 3, 60]], 'poly'], [[0, 2, 60], [2, 3, 60]]), ([[[0, 1, 60], [0, 8, 60], [1, 9, 60]], 'poly'], [[0, 1, 60], [0, 1, 60], [1, 9, 60]]), ([[[3, 3, 60]], 'poly'], []), ([[[0, 10, 60]], 'legato'], None), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 2, 60], [1, 9, 60], [3, 5, 60]], 'poly'], [[0, 1, 60], [1, 3, 60], [3, 5, 60]]), ([[[1, 2, 60], [2, 3, 60], [3, 4, 60]], 'poly'], [[1, 2, 60], [2, 3, 60], [3, 4, 60]])], [([[[0, 10, 60], [5, 15, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 4, 60], [2, 3, 60]], 'poly'], [[0, 2, 60], [2, 3, 60]]), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 2, 60], [1, 9, 60], [3, 5, 60]], 'poly'], [[0, 1, 60], [1, 3, 60], [3, 5, 60]]), ([[[0, 10, 62], [4, 6, 60]], 'mono'], [[0, 4, 62], [4, 6, 60]]), ([[[1, 2, 60], [2, 3, 60], [3, 4, 60]], 'poly'], [[1, 2, 60], [2, 3, 60], [3, 4, 60]]), ([[[0, 9, 70], [1, 5, 72], [2, 4, 70]], 'poly'], [[0, 2, 70], [1, 5, 72], [2, 4, 70]])], [([[[0, 10, 60], [5, 15, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 10, 60], [5, 15, 62]], 'poly'], [[0, 10, 60], [5, 15, 62]]), ([[[0, 10, 60], [5, 15, 62]], 'mono'], [[0, 5, 60], [5, 15, 62]]), ([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 2, 60], [1, 9, 60], [3, 5, 60]], 'poly'], [[0, 1, 60], [1, 3, 60], [3, 5, 60]]), ([[[0, 10, 62], [4, 6, 60]], 'mono'], [[0, 4, 62], [4, 6, 60]]), ([[[0, 9, 70], [1, 5, 72], [2, 4, 70]], 'poly'], [[0, 2, 70], [1, 5, 72], [2, 4, 70]])]]
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, 5, 60], [5, 15, 60]][[0, 5, 60], [5, 15, 60]]Passed
oracle 1[[0, 10, 60], [5, 15, 62]][[0, 10, 60], [5, 15, 62]]Passed
oracle 2[[0, 5, 60], [5, 15, 62]][[0, 5, 60], [5, 15, 62]]Passed
oracle 3[[0, 5, 60], [5, 15, 60]][[0, 5, 60], [5, 15, 60]]Passed
oracle 4[[2, 3, 60], [0, 4, 60]][[0, 2, 60], [2, 3, 60]]Failed
oracle 5[[0, 10, 60], [0, 10, 64]][[0, 10, 60], [0, 10, 64]]Passed
oracle 6[[0, 10, 60], [10, 20, 60]][[0, 10, 60], [10, 20, 60]]Passed
oracle 7[[4, 6, 60], [0, 10, 62]][[0, 4, 62], [4, 6, 60]]Failed

SHA-256 / 59c1275d3ee8b25556f689c65c5aa59754c0c0d620e965f9c060094a77a5b1d3

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
    notes, mode = x
    if mode not in ('poly', 'mono'):
        return None
    order = sorted(notes, key=lambda n: (n[0], n[2]))
    out = []
    for i, (s, e, p) in enumerate(order):
        for s2, e2, p2 in order[i + 1:]:
            if s2 > s and (mode == 'mono' or p2 == p):
                e = min(e, s2)
                break
        if e > s:
            out.append([s, e, p])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[[0, 10, 60], [5, 15, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 10, 60], [5, 15, 62]], 'poly'], [[0, 10, 60], [5, 15, 62]]), ([[[0, 10, 60], [5, 15, 62]], 'mono'], [[0, 5, 60], [5, 15, 62]]), ([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 4, 60], [2, 3, 60]], 'poly'], [[0, 2, 60], [2, 3, 60]]), ([[[0, 10, 60], [0, 10, 64]], 'mono'], [[0, 10, 60], [0, 10, 64]]), ([[[0, 10, 60], [10, 20, 60]], 'poly'], [[0, 10, 60], [10, 20, 60]]), ([[[0, 10, 62], [4, 6, 60]], 'mono'], [[0, 4, 62], [4, 6, 60]])], [([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 10, 60], [0, 10, 64]], 'mono'], [[0, 10, 60], [0, 10, 64]]), ([[[0, 10, 60], [10, 20, 60]], 'poly'], [[0, 10, 60], [10, 20, 60]]), ([[[0, 5, 60], [5, 6, 62]], 'mono'], [[0, 5, 60], [5, 6, 62]]), ([[[0, 1, 60], [0, 8, 60], [1, 9, 60]], 'poly'], [[0, 1, 60], [0, 1, 60], [1, 9, 60]]), ([[[3, 3, 60]], 'poly'], []), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 9, 70], [1, 5, 72], [2, 4, 70]], 'poly'], [[0, 2, 70], [1, 5, 72], [2, 4, 70]])], [([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 4, 60], [2, 3, 60]], 'poly'], [[0, 2, 60], [2, 3, 60]]), ([[[0, 1, 60], [0, 8, 60], [1, 9, 60]], 'poly'], [[0, 1, 60], [0, 1, 60], [1, 9, 60]]), ([[[3, 3, 60]], 'poly'], []), ([[[0, 10, 60]], 'legato'], None), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 2, 60], [1, 9, 60], [3, 5, 60]], 'poly'], [[0, 1, 60], [1, 3, 60], [3, 5, 60]]), ([[[1, 2, 60], [2, 3, 60], [3, 4, 60]], 'poly'], [[1, 2, 60], [2, 3, 60], [3, 4, 60]])], [([[[0, 10, 60], [5, 15, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 4, 60], [2, 3, 60]], 'poly'], [[0, 2, 60], [2, 3, 60]]), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 2, 60], [1, 9, 60], [3, 5, 60]], 'poly'], [[0, 1, 60], [1, 3, 60], [3, 5, 60]]), ([[[0, 10, 62], [4, 6, 60]], 'mono'], [[0, 4, 62], [4, 6, 60]]), ([[[1, 2, 60], [2, 3, 60], [3, 4, 60]], 'poly'], [[1, 2, 60], [2, 3, 60], [3, 4, 60]]), ([[[0, 9, 70], [1, 5, 72], [2, 4, 70]], 'poly'], [[0, 2, 70], [1, 5, 72], [2, 4, 70]])], [([[[0, 10, 60], [5, 15, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 10, 60], [5, 15, 62]], 'poly'], [[0, 10, 60], [5, 15, 62]]), ([[[0, 10, 60], [5, 15, 62]], 'mono'], [[0, 5, 60], [5, 15, 62]]), ([[[5, 15, 60], [0, 10, 60]], 'poly'], [[0, 5, 60], [5, 15, 60]]), ([[[0, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[0, 2, 60], [1, 9, 60], [3, 5, 60]], 'poly'], [[0, 1, 60], [1, 3, 60], [3, 5, 60]]), ([[[0, 10, 62], [4, 6, 60]], 'mono'], [[0, 4, 62], [4, 6, 60]]), ([[[0, 9, 70], [1, 5, 72], [2, 4, 70]], 'poly'], [[0, 2, 70], [1, 5, 72], [2, 4, 70]])]]
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, 5, 60], [5, 15, 60]][[0, 5, 60], [5, 15, 60]]Passed
oracle 1[[0, 10, 60], [5, 15, 62]][[0, 10, 60], [5, 15, 62]]Passed
oracle 2[[0, 5, 60], [5, 15, 62]][[0, 5, 60], [5, 15, 62]]Passed
oracle 3[[0, 5, 60], [5, 15, 60]][[0, 5, 60], [5, 15, 60]]Passed
oracle 4[[0, 2, 60], [2, 3, 60]][[0, 2, 60], [2, 3, 60]]Passed
oracle 5[[0, 10, 60], [0, 10, 64]][[0, 10, 60], [0, 10, 64]]Passed
oracle 6[[0, 10, 60], [10, 20, 60]][[0, 10, 60], [10, 20, 60]]Passed
oracle 7[[0, 4, 62], [4, 6, 60]][[0, 4, 62], [4, 6, 60]]Passed

SHA-256 / 793780ffd1b9b6f540ca80be1165b607f8f598a2337a7f5e548c69598a56c605

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

Case digest / 806294cb84fab5d60094c84e92dd882170c7f8a746697a1e7633ef62067057d7