FAILURE MAP
← Case archive

FA-81741 / MIDI event timing / Open access

Same-pitch and monophonic overlap truncation: mono mode truncates only same-pitch overlaps · case 01

In mono mode a held note keeps sounding under the next note of a different pitch.

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

ROOT CAUSE

The truncation partner test ignores the mode and always requires the same pitch.

VERIFIED REPAIR

Restore the mono scope step so that it reads `(mode == 'mono' or p2 == p)`.

Unsuccessful approach: Testing for poly instead of mono inverts the modes: poly truncates across pitches and mono does not.

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 = 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 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]])], [([[[0, 10, 60], [5, 15, 62]], 'mono'], [[0, 5, 60], [5, 15, 62]]), ([[[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]])], [([[[0, 10, 60], [5, 15, 62]], 'poly'], [[0, 10, 60], [5, 15, 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, 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]]), ([[[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, 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]]), ([[[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]], '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, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[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, 10, 60], [5, 15, 62]][[0, 5, 60], [5, 15, 62]]Failed
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, 10, 62], [4, 6, 60]][[0, 4, 62], [4, 6, 60]]Failed

SHA-256 / a65d083f7fd4d4b41838e301fcc5958828c28052ec96f9c183985fc2cce0d54d

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[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 == 'poly' 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]])], [([[[0, 10, 60], [5, 15, 62]], 'mono'], [[0, 5, 60], [5, 15, 62]]), ([[[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]])], [([[[0, 10, 60], [5, 15, 62]], 'poly'], [[0, 10, 60], [5, 15, 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, 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]]), ([[[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, 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]]), ([[[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]], '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, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[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, 5, 60], [5, 15, 62]][[0, 10, 60], [5, 15, 62]]Failed
oracle 2[[0, 10, 60], [5, 15, 62]][[0, 5, 60], [5, 15, 62]]Failed
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, 10, 62], [4, 6, 60]][[0, 4, 62], [4, 6, 60]]Failed

SHA-256 / 9912c18e0106304af7dbcaeb622fcf1c23cab2ab9e1c981a8846ad9cd4923646

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]])], [([[[0, 10, 60], [5, 15, 62]], 'mono'], [[0, 5, 60], [5, 15, 62]]), ([[[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]])], [([[[0, 10, 60], [5, 15, 62]], 'poly'], [[0, 10, 60], [5, 15, 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, 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]]), ([[[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, 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]]), ([[[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]], '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, 20, 60], [2, 4, 62], [6, 8, 64]], 'mono'], [[0, 2, 60], [2, 4, 62], [6, 8, 64]]), ([[[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 / a23299fe9e56d65824c39b06541adf479158c9a9daa994670fc9d3af3bc56738

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

Case digest / 2a71bd1043e7cbdc3f9555b79684cf5832b59b95aa8634d9ea12a612baad7117