FAILURE MAP
← Case archive

FA-81546 / MIDI event timing / Open access

Strength-weighted grid quantisation: backward moves rounded away from zero · case 01

Partial quantisation of late notes moves them one tick further than the requested strength.

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

ROOT CAUSE

Floor division of a negative displacement rounds toward minus infinity instead of truncating toward zero.

VERIFIED REPAIR

Restore the displacement truncation step so that it reads `step = abs(move) // 100 out.append(t + step if move >= 0 else t - step)`.

Unsuccessful approach: Rounding to nearest moves notes too far whenever the fractional displacement exceeds one half.

Case contract

Input [ticks, grid, strength] with grid > 0 and strength 0..100 percent. Each tick moves toward its nearest grid line (exact halves go to the later line) by strength percent of the distance, with the displacement truncated toward zero. Invalid parameters return 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) != 3:
        return None
    ticks, grid, strength = x
    if grid <= 0 or not 0 <= strength <= 100:
        return None
    out = []
    for t in ticks:
        target = (2 * t + grid) // (2 * grid) * grid
        move = (target - t) * strength
        out.append(t + move // 100)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 10, 50, 110, 120], 120, 100], [0, 0, 0, 120, 120]), ([[60, 180], 120, 100], [120, 240]), ([[59, 61], 120, 100], [0, 120]), ([[10, 110], 120, 50], [5, 115]), ([[10, 110], 120, 75], [3, 117]), ([[5, 115], 120, 0], [5, 115]), ([[5, 115], 120, 100], [0, 120]), ([[239, 241], 240, 50], [239, 241])], [([[10, 110], 120, 50], [5, 115]), ([[7, 113], 120, 33], [5, 115]), ([[5, 115], 120, 0], [5, 115]), ([[5, 115], 120, 100], [0, 120]), ([[5], 120, 101], None), ([[5], 0, 50], None), ([[1, 2, 3, 4], 3, 50], [1, 2, 3, 4]), ([[44, 76], 30, 90], [32, 88])], [([[5], 120, 101], None), ([[5], 0, 50], None), ([[5], 120, -1], None), ([[239, 241], 240, 50], [239, 241]), ([[45, 75], 30, 100], [60, 90]), ([[44, 76], 30, 90], [32, 88]), ([[1000, 1030], 120, 80], [968, 1070]), ([[125], 120, 99], [121])], [([[10, 110], 120, 75], [3, 117]), ([[7, 113], 120, 33], [5, 115]), ([[239, 241], 240, 50], [239, 241]), ([[1, 2, 3, 4], 3, 50], [1, 2, 3, 4]), ([[45, 75], 30, 100], [60, 90]), ([[44, 76], 30, 90], [32, 88]), ([[1000, 1030], 120, 80], [968, 1070]), ([[125], 120, 99], [121])], [([[0, 10, 50, 110, 120], 120, 100], [0, 0, 0, 120, 120]), ([[60, 180], 120, 100], [120, 240]), ([[10, 110], 120, 75], [3, 117]), ([[7, 113], 120, 33], [5, 115]), ([[239, 241], 240, 50], [239, 241]), ([[1, 2, 3, 4], 3, 50], [1, 2, 3, 4]), ([[44, 76], 30, 90], [32, 88]), ([[125], 120, 99], [121])]]
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, 0, 0, 120, 120][0, 0, 0, 120, 120]Passed
oracle 1[120, 240][120, 240]Passed
oracle 2[0, 120][0, 120]Passed
oracle 3[5, 115][5, 115]Passed
oracle 4[2, 117][3, 117]Failed
oracle 5[5, 115][5, 115]Passed
oracle 6[0, 120][0, 120]Passed
oracle 7[239, 240][239, 241]Failed

SHA-256 / 4375eaeaa2e4ff439cdbaecbc0ee8249c7a69a5dc35e3d91bc6a368cae608f72

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) != 3:
        return None
    ticks, grid, strength = x
    if grid <= 0 or not 0 <= strength <= 100:
        return None
    out = []
    for t in ticks:
        target = (2 * t + grid) // (2 * grid) * grid
        move = (target - t) * strength
        out.append(t + round(move / 100))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 10, 50, 110, 120], 120, 100], [0, 0, 0, 120, 120]), ([[60, 180], 120, 100], [120, 240]), ([[59, 61], 120, 100], [0, 120]), ([[10, 110], 120, 50], [5, 115]), ([[10, 110], 120, 75], [3, 117]), ([[5, 115], 120, 0], [5, 115]), ([[5, 115], 120, 100], [0, 120]), ([[239, 241], 240, 50], [239, 241])], [([[10, 110], 120, 50], [5, 115]), ([[7, 113], 120, 33], [5, 115]), ([[5, 115], 120, 0], [5, 115]), ([[5, 115], 120, 100], [0, 120]), ([[5], 120, 101], None), ([[5], 0, 50], None), ([[1, 2, 3, 4], 3, 50], [1, 2, 3, 4]), ([[44, 76], 30, 90], [32, 88])], [([[5], 120, 101], None), ([[5], 0, 50], None), ([[5], 120, -1], None), ([[239, 241], 240, 50], [239, 241]), ([[45, 75], 30, 100], [60, 90]), ([[44, 76], 30, 90], [32, 88]), ([[1000, 1030], 120, 80], [968, 1070]), ([[125], 120, 99], [121])], [([[10, 110], 120, 75], [3, 117]), ([[7, 113], 120, 33], [5, 115]), ([[239, 241], 240, 50], [239, 241]), ([[1, 2, 3, 4], 3, 50], [1, 2, 3, 4]), ([[45, 75], 30, 100], [60, 90]), ([[44, 76], 30, 90], [32, 88]), ([[1000, 1030], 120, 80], [968, 1070]), ([[125], 120, 99], [121])], [([[0, 10, 50, 110, 120], 120, 100], [0, 0, 0, 120, 120]), ([[60, 180], 120, 100], [120, 240]), ([[10, 110], 120, 75], [3, 117]), ([[7, 113], 120, 33], [5, 115]), ([[239, 241], 240, 50], [239, 241]), ([[1, 2, 3, 4], 3, 50], [1, 2, 3, 4]), ([[44, 76], 30, 90], [32, 88]), ([[125], 120, 99], [121])]]
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, 0, 0, 120, 120][0, 0, 0, 120, 120]Passed
oracle 1[120, 240][120, 240]Passed
oracle 2[0, 120][0, 120]Passed
oracle 3[5, 115][5, 115]Passed
oracle 4[2, 118][3, 117]Failed
oracle 5[5, 115][5, 115]Passed
oracle 6[0, 120][0, 120]Passed
oracle 7[239, 241][239, 241]Passed

SHA-256 / fb1354c58701b57e880e85aa895a9c88bf7c1a34ed2b2437edd7e98579b9e099

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) != 3:
        return None
    ticks, grid, strength = x
    if grid <= 0 or not 0 <= strength <= 100:
        return None
    out = []
    for t in ticks:
        target = (2 * t + grid) // (2 * grid) * grid
        move = (target - t) * strength
        step = abs(move) // 100
        out.append(t + step if move >= 0 else t - step)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[([[0, 10, 50, 110, 120], 120, 100], [0, 0, 0, 120, 120]), ([[60, 180], 120, 100], [120, 240]), ([[59, 61], 120, 100], [0, 120]), ([[10, 110], 120, 50], [5, 115]), ([[10, 110], 120, 75], [3, 117]), ([[5, 115], 120, 0], [5, 115]), ([[5, 115], 120, 100], [0, 120]), ([[239, 241], 240, 50], [239, 241])], [([[10, 110], 120, 50], [5, 115]), ([[7, 113], 120, 33], [5, 115]), ([[5, 115], 120, 0], [5, 115]), ([[5, 115], 120, 100], [0, 120]), ([[5], 120, 101], None), ([[5], 0, 50], None), ([[1, 2, 3, 4], 3, 50], [1, 2, 3, 4]), ([[44, 76], 30, 90], [32, 88])], [([[5], 120, 101], None), ([[5], 0, 50], None), ([[5], 120, -1], None), ([[239, 241], 240, 50], [239, 241]), ([[45, 75], 30, 100], [60, 90]), ([[44, 76], 30, 90], [32, 88]), ([[1000, 1030], 120, 80], [968, 1070]), ([[125], 120, 99], [121])], [([[10, 110], 120, 75], [3, 117]), ([[7, 113], 120, 33], [5, 115]), ([[239, 241], 240, 50], [239, 241]), ([[1, 2, 3, 4], 3, 50], [1, 2, 3, 4]), ([[45, 75], 30, 100], [60, 90]), ([[44, 76], 30, 90], [32, 88]), ([[1000, 1030], 120, 80], [968, 1070]), ([[125], 120, 99], [121])], [([[0, 10, 50, 110, 120], 120, 100], [0, 0, 0, 120, 120]), ([[60, 180], 120, 100], [120, 240]), ([[10, 110], 120, 75], [3, 117]), ([[7, 113], 120, 33], [5, 115]), ([[239, 241], 240, 50], [239, 241]), ([[1, 2, 3, 4], 3, 50], [1, 2, 3, 4]), ([[44, 76], 30, 90], [32, 88]), ([[125], 120, 99], [121])]]
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, 0, 0, 120, 120][0, 0, 0, 120, 120]Passed
oracle 1[120, 240][120, 240]Passed
oracle 2[0, 120][0, 120]Passed
oracle 3[5, 115][5, 115]Passed
oracle 4[3, 117][3, 117]Passed
oracle 5[5, 115][5, 115]Passed
oracle 6[0, 120][0, 120]Passed
oracle 7[239, 241][239, 241]Passed

SHA-256 / 36b09b5c2fe82d56615a967658f214c06fc3dc785752fa0ca313b0fa5beb71c5

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

Case digest / eee0695260bafa123a3536ae45dcba40049ddddbe5de011ef76c912dfa609a86