{"abstract":"Material before the first tempo event is timed at that later tempo instead of the default 120 BPM.","category":"MIDI event timing","checks":8,"contract":"Input [ppq, changes, tick] where changes are [tick, microseconds_per_quarter] in any order (a later entry at the same tick overrides an earlier one). Before the first change the tempo is 500000. Each tempo applies from its tick onward. Sum the exact time of each segment and floor once at the end. Invalid ppq or negative tick returns None.","evaluation_group":"w2-midi-event-timing-tempo-map-time","failed_approach":"Using the first listed change instead is the same mistake and also depends on input order.","family":"w2-midi-event-timing-tempo-map-time-initial-tempo","id":"FA-81476","implementations":{"attempt":{"sha256":"1ef4085bfbebb6129f81ed3183e11a3c5c4d35f90e979361768b9fdf90ee505d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    if not isinstance(x, list) or len(x) != 3:\n        return None\n    ppq, changes, target = x\n    if ppq <= 0 or target < 0:\n        return None\n    tempo_at = {}\n    for t, us in changes:\n        tempo_at[t] = us\n    points = sorted(tempo_at.items())\n    total = Fraction(0)\n    tick = 0\n    tempo = changes[0][1] if changes else 500000\n    for t, us in points:\n        if t >= target:\n            break\n        total += Fraction((t - tick) * tempo, ppq)\n        tick = t\n        tempo = us\n    total += Fraction((target - tick) * tempo, ppq)\n    return int(total)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[([480, [], 480], 500000), ([480, [], 1], 1041), ([96, [[0, 600000]], 96], 600000), ([480, [[480, 250000]], 960], 750000), ([7, [[3, 333333]], 10], 547618), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[0, 400000], [0, 300000]], 480], 300000), ([0, [], 10], None)], [([480, [[960, 1000000], [480, 250000]], 1440], 1750000), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[0, 400000], [0, 300000]], 480], 300000), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([0, [], 10], None), ([480, [], -1], None), ([480, [[0, 1000000], [480, 500000]], 720], 1250000), ([480, [[0, 300000], [0, 400000]], 480], 400000)], [([480, [[480, 250000]], 960], 750000), ([480, [[960, 1000000], [480, 250000]], 1440], 1750000), ([7, [[3, 333333]], 10], 547618), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([3, [[1, 1000]], 2], 167000), ([480, [[0, 1000000], [480, 500000]], 720], 1250000), ([480, [[0, 300000], [0, 400000]], 480], 400000)], [([480, [[960, 1000000], [480, 250000]], 1440], 1750000), ([7, [[3, 333333]], 10], 547618), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([3, [[1, 1000]], 2], 167000), ([480, [[480, 250000]], 480], 500000), ([480, [[100, 100000]], 50], 52083), ([11, [[5, 777777], [9, 123457]], 13], 554994)], [([480, [], 480], 500000), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([3, [[1, 1000]], 2], 167000), ([480, [[480, 250000]], 480], 500000), ([480, [[100, 100000]], 50], 52083), ([11, [[5, 777777], [9, 123457]], 13], 554994), ([7, [[2, 300001], [2, 400003]], 6], 371430), ([13, [[4, 499999], [8, 333337]], 12], 410257)]]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"oracle %d\" % i, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"1dcc9d028e7c58740da2026c1819498132b1ca19964708ed10dd5340f0a2f070","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    if not isinstance(x, list) or len(x) != 3:\n        return None\n    ppq, changes, target = x\n    if ppq <= 0 or target < 0:\n        return None\n    tempo_at = {}\n    for t, us in changes:\n        tempo_at[t] = us\n    points = sorted(tempo_at.items())\n    total = Fraction(0)\n    tick = 0\n    tempo = points[0][1] if points else 500000\n    for t, us in points:\n        if t >= target:\n            break\n        total += Fraction((t - tick) * tempo, ppq)\n        tick = t\n        tempo = us\n    total += Fraction((target - tick) * tempo, ppq)\n    return int(total)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[([480, [], 480], 500000), ([480, [], 1], 1041), ([96, [[0, 600000]], 96], 600000), ([480, [[480, 250000]], 960], 750000), ([7, [[3, 333333]], 10], 547618), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[0, 400000], [0, 300000]], 480], 300000), ([0, [], 10], None)], [([480, [[960, 1000000], [480, 250000]], 1440], 1750000), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[0, 400000], [0, 300000]], 480], 300000), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([0, [], 10], None), ([480, [], -1], None), ([480, [[0, 1000000], [480, 500000]], 720], 1250000), ([480, [[0, 300000], [0, 400000]], 480], 400000)], [([480, [[480, 250000]], 960], 750000), ([480, [[960, 1000000], [480, 250000]], 1440], 1750000), ([7, [[3, 333333]], 10], 547618), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([3, [[1, 1000]], 2], 167000), ([480, [[0, 1000000], [480, 500000]], 720], 1250000), ([480, [[0, 300000], [0, 400000]], 480], 400000)], [([480, [[960, 1000000], [480, 250000]], 1440], 1750000), ([7, [[3, 333333]], 10], 547618), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([3, [[1, 1000]], 2], 167000), ([480, [[480, 250000]], 480], 500000), ([480, [[100, 100000]], 50], 52083), ([11, [[5, 777777], [9, 123457]], 13], 554994)], [([480, [], 480], 500000), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([3, [[1, 1000]], 2], 167000), ([480, [[480, 250000]], 480], 500000), ([480, [[100, 100000]], 50], 52083), ([11, [[5, 777777], [9, 123457]], 13], 554994), ([7, [[2, 300001], [2, 400003]], 6], 371430), ([13, [[4, 499999], [8, 333337]], 12], 410257)]]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"oracle %d\" % i, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"5176afe559e2f98e8418bff941fbd63673b178e4ce77a6908c3eaf98540ff3bd","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    if not isinstance(x, list) or len(x) != 3:\n        return None\n    ppq, changes, target = x\n    if ppq <= 0 or target < 0:\n        return None\n    tempo_at = {}\n    for t, us in changes:\n        tempo_at[t] = us\n    points = sorted(tempo_at.items())\n    total = Fraction(0)\n    tick = 0\n    tempo = 500000\n    for t, us in points:\n        if t >= target:\n            break\n        total += Fraction((t - tick) * tempo, ppq)\n        tick = t\n        tempo = us\n    total += Fraction((target - tick) * tempo, ppq)\n    return int(total)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[([480, [], 480], 500000), ([480, [], 1], 1041), ([96, [[0, 600000]], 96], 600000), ([480, [[480, 250000]], 960], 750000), ([7, [[3, 333333]], 10], 547618), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[0, 400000], [0, 300000]], 480], 300000), ([0, [], 10], None)], [([480, [[960, 1000000], [480, 250000]], 1440], 1750000), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[0, 400000], [0, 300000]], 480], 300000), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([0, [], 10], None), ([480, [], -1], None), ([480, [[0, 1000000], [480, 500000]], 720], 1250000), ([480, [[0, 300000], [0, 400000]], 480], 400000)], [([480, [[480, 250000]], 960], 750000), ([480, [[960, 1000000], [480, 250000]], 1440], 1750000), ([7, [[3, 333333]], 10], 547618), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([3, [[1, 1000]], 2], 167000), ([480, [[0, 1000000], [480, 500000]], 720], 1250000), ([480, [[0, 300000], [0, 400000]], 480], 400000)], [([480, [[960, 1000000], [480, 250000]], 1440], 1750000), ([7, [[3, 333333]], 10], 547618), ([7, [[1, 100001], [2, 200003]], 5], 171430), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([3, [[1, 1000]], 2], 167000), ([480, [[480, 250000]], 480], 500000), ([480, [[100, 100000]], 50], 52083), ([11, [[5, 777777], [9, 123457]], 13], 554994)], [([480, [], 480], 500000), ([480, [[240, 300000], [240, 200000]], 480], 350000), ([3, [[1, 1000]], 2], 167000), ([480, [[480, 250000]], 480], 500000), ([480, [[100, 100000]], 50], 52083), ([11, [[5, 777777], [9, 123457]], 13], 554994), ([7, [[2, 300001], [2, 400003]], 6], 371430), ([13, [[4, 499999], [8, 333337]], 12], 410257)]]\nfor i, (args, expected) in enumerate(fixtures[N-1]):\n    check(\"oracle %d\" % i, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-midi-event-timing-tempo-map-time-initial-tempo","generated_at":"2026-09-29T14:50:03.196444+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"MIDI sequencers, file readers and synth drivers depend on exact event ordering and tick/time arithmetic.","repair":"Restore the initial tempo step so that it reads `tempo = 500000`.","root_cause":"The starting tempo is taken from the earliest tempo change rather than the default.","sha256":"af9a32ff9a054ed366609be6a9b981ed69a786c3f2258022fb4aba20e26f8448","title":"Tick to microsecond conversion through a tempo map: first tempo applied from tick zero · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.169,"exit_code":1,"observations":[{"actual":500000,"check":"oracle 0","expected":500000,"passed":true},{"actual":1041,"check":"oracle 1","expected":1041,"passed":true},{"actual":600000,"check":"oracle 2","expected":600000,"passed":true},{"actual":500000,"check":"oracle 3","expected":750000,"passed":false},{"actual":476190,"check":"oracle 4","expected":547618,"passed":false},{"actual":114287,"check":"oracle 5","expected":171430,"passed":false},{"actual":300000,"check":"oracle 6","expected":300000,"passed":true},{"actual":null,"check":"oracle 7","expected":null,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"oracle 0\", \"actual\": 500000, \"expected\": 500000, \"passed\": true}, {\"check\": \"oracle 1\", \"actual\": 1041, \"expected\": 1041, \"passed\": true}, {\"check\": \"oracle 2\", \"actual\": 600000, \"expected\": 600000, \"passed\": true}, {\"check\": \"oracle 3\", \"actual\": 500000, \"expected\": 750000, \"passed\": false}, {\"check\": \"oracle 4\", \"actual\": 476190, \"expected\": 547618, \"passed\": false}, {\"check\": \"oracle 5\", \"actual\": 114287, \"expected\": 171430, \"passed\": false}, {\"check\": \"oracle 6\", \"actual\": 300000, \"expected\": 300000, \"passed\": true}, {\"check\": \"oracle 7\", \"actual\": null, \"expected\": null, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":43.247,"exit_code":1,"observations":[{"actual":500000,"check":"oracle 0","expected":500000,"passed":true},{"actual":1041,"check":"oracle 1","expected":1041,"passed":true},{"actual":600000,"check":"oracle 2","expected":600000,"passed":true},{"actual":500000,"check":"oracle 3","expected":750000,"passed":false},{"actual":476190,"check":"oracle 4","expected":547618,"passed":false},{"actual":114287,"check":"oracle 5","expected":171430,"passed":false},{"actual":300000,"check":"oracle 6","expected":300000,"passed":true},{"actual":null,"check":"oracle 7","expected":null,"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"oracle 0\", \"actual\": 500000, \"expected\": 500000, \"passed\": true}, {\"check\": \"oracle 1\", \"actual\": 1041, \"expected\": 1041, \"passed\": true}, {\"check\": \"oracle 2\", \"actual\": 600000, \"expected\": 600000, \"passed\": true}, {\"check\": \"oracle 3\", \"actual\": 500000, \"expected\": 750000, \"passed\": false}, {\"check\": \"oracle 4\", \"actual\": 476190, \"expected\": 547618, \"passed\": false}, {\"check\": \"oracle 5\", \"actual\": 114287, \"expected\": 171430, \"passed\": false}, {\"check\": \"oracle 6\", \"actual\": 300000, \"expected\": 300000, \"passed\": true}, {\"check\": \"oracle 7\", \"actual\": null, \"expected\": null, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.086,"exit_code":0,"observations":[{"actual":500000,"check":"oracle 0","expected":500000,"passed":true},{"actual":1041,"check":"oracle 1","expected":1041,"passed":true},{"actual":600000,"check":"oracle 2","expected":600000,"passed":true},{"actual":750000,"check":"oracle 3","expected":750000,"passed":true},{"actual":547618,"check":"oracle 4","expected":547618,"passed":true},{"actual":171430,"check":"oracle 5","expected":171430,"passed":true},{"actual":300000,"check":"oracle 6","expected":300000,"passed":true},{"actual":null,"check":"oracle 7","expected":null,"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"oracle 0\", \"actual\": 500000, \"expected\": 500000, \"passed\": true}, {\"check\": \"oracle 1\", \"actual\": 1041, \"expected\": 1041, \"passed\": true}, {\"check\": \"oracle 2\", \"actual\": 600000, \"expected\": 600000, \"passed\": true}, {\"check\": \"oracle 3\", \"actual\": 750000, \"expected\": 750000, \"passed\": true}, {\"check\": \"oracle 4\", \"actual\": 547618, \"expected\": 547618, \"passed\": true}, {\"check\": \"oracle 5\", \"actual\": 171430, \"expected\": 171430, \"passed\": true}, {\"check\": \"oracle 6\", \"actual\": 300000, \"expected\": 300000, \"passed\": true}, {\"check\": \"oracle 7\", \"actual\": null, \"expected\": null, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}