{"abstract":"In F# major, key 65 is spelled F4 instead of the stipulated E#4.","category":"Music interval and transposition theory","checks":8,"contract":"Input [midi, fifths] with midi 0..127 and fifths -7..7. Use flat names when fifths < 0, sharp names otherwise; in keys with at least six sharps pitch class 5 is E#, with seven sharps pitch class 0 is B# of the previous octave, and with at least six flats pitch class 11 is Cb of the next octave. Octave -1 starts at key 0. Invalid input returns None.","evaluation_group":"w2-music-interval-midi-spelling-key","failed_approach":"Lowering the threshold to five sharps also respells F natural as E# in B major.","family":"w2-music-interval-midi-spelling-key-e-sharp-threshold","id":"FA-80886","implementations":{"attempt":{"sha256":"6f1957a4733def9cabc37ef16e6e22827a7d5ef96cafbef39d2b5c6d8e9d075b","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    if not isinstance(x, list) or len(x) != 2:\n        return None\n    m, f = x\n    if not isinstance(m, int) or m < 0 or m > 127:\n        return None\n    if not isinstance(f, int) or f < -7 or f > 7:\n        return None\n    sharps = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']\n    flats = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B']\n    table = flats if f < 0 else sharps\n    pc = m % 12\n    octave = m // 12 - 1\n    name = table[pc]\n    if f >= 5 and pc == 5:\n        name = 'E#'\n    if f == 7 and pc == 0:\n        name = 'B#'\n        octave -= 1\n    if f <= -6 and pc == 11:\n        name = 'Cb'\n        octave += 1\n    return name + str(octave)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[([60, 0], 'C4'), ([61, 0], 'C#4'), ([61, -1], 'Db4'), ([61, 1], 'C#4'), ([70, -2], 'Bb4'), ([70, 2], 'A#4'), ([65, 6], 'E#4'), ([65, 5], 'F4')], [([61, 1], 'C#4'), ([70, -2], 'Bb4'), ([70, 2], 'A#4'), ([65, 5], 'F4'), ([65, 7], 'E#4'), ([65, -6], 'F4'), ([60, 7], 'B#3'), ([5, 6], 'E#-1')], [([65, 6], 'E#4'), ([65, 5], 'F4'), ([65, 7], 'E#4'), ([65, -6], 'F4'), ([60, 7], 'B#3'), ([48, 7], 'B#2'), ([71, -6], 'Cb5'), ([71, -7], 'Cb5')], [([65, 5], 'F4'), ([48, 7], 'B#2'), ([71, -6], 'Cb5'), ([71, -7], 'Cb5'), ([59, -6], 'Cb4'), ([0, 0], 'C-1'), ([1, -3], 'Db-1'), ([5, 6], 'E#-1')], [([65, 6], 'E#4'), ([65, 5], 'F4'), ([59, -6], 'Cb4'), ([0, 0], 'C-1'), ([1, -3], 'Db-1'), ([11, 0], 'B-1'), ([127, 0], 'G9'), ([127, 7], 'G9')]]\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":"4864938c5e59e594b0e24b45920e1900e7c4ed82acf3d1b5fa8af89f985197c4","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    if not isinstance(x, list) or len(x) != 2:\n        return None\n    m, f = x\n    if not isinstance(m, int) or m < 0 or m > 127:\n        return None\n    if not isinstance(f, int) or f < -7 or f > 7:\n        return None\n    sharps = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']\n    flats = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B']\n    table = flats if f < 0 else sharps\n    pc = m % 12\n    octave = m // 12 - 1\n    name = table[pc]\n    if f == 7 and pc == 5:\n        name = 'E#'\n    if f == 7 and pc == 0:\n        name = 'B#'\n        octave -= 1\n    if f <= -6 and pc == 11:\n        name = 'Cb'\n        octave += 1\n    return name + str(octave)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[([60, 0], 'C4'), ([61, 0], 'C#4'), ([61, -1], 'Db4'), ([61, 1], 'C#4'), ([70, -2], 'Bb4'), ([70, 2], 'A#4'), ([65, 6], 'E#4'), ([65, 5], 'F4')], [([61, 1], 'C#4'), ([70, -2], 'Bb4'), ([70, 2], 'A#4'), ([65, 5], 'F4'), ([65, 7], 'E#4'), ([65, -6], 'F4'), ([60, 7], 'B#3'), ([5, 6], 'E#-1')], [([65, 6], 'E#4'), ([65, 5], 'F4'), ([65, 7], 'E#4'), ([65, -6], 'F4'), ([60, 7], 'B#3'), ([48, 7], 'B#2'), ([71, -6], 'Cb5'), ([71, -7], 'Cb5')], [([65, 5], 'F4'), ([48, 7], 'B#2'), ([71, -6], 'Cb5'), ([71, -7], 'Cb5'), ([59, -6], 'Cb4'), ([0, 0], 'C-1'), ([1, -3], 'Db-1'), ([5, 6], 'E#-1')], [([65, 6], 'E#4'), ([65, 5], 'F4'), ([59, -6], 'Cb4'), ([0, 0], 'C-1'), ([1, -3], 'Db-1'), ([11, 0], 'B-1'), ([127, 0], 'G9'), ([127, 7], 'G9')]]\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":"6b7f5e76a12887bbf0dd352d9cec27b1b8e078a3a1f0893a612007f902b251de","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    if not isinstance(x, list) or len(x) != 2:\n        return None\n    m, f = x\n    if not isinstance(m, int) or m < 0 or m > 127:\n        return None\n    if not isinstance(f, int) or f < -7 or f > 7:\n        return None\n    sharps = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']\n    flats = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B']\n    table = flats if f < 0 else sharps\n    pc = m % 12\n    octave = m // 12 - 1\n    name = table[pc]\n    if f >= 6 and pc == 5:\n        name = 'E#'\n    if f == 7 and pc == 0:\n        name = 'B#'\n        octave -= 1\n    if f <= -6 and pc == 11:\n        name = 'Cb'\n        octave += 1\n    return name + str(octave)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[([60, 0], 'C4'), ([61, 0], 'C#4'), ([61, -1], 'Db4'), ([61, 1], 'C#4'), ([70, -2], 'Bb4'), ([70, 2], 'A#4'), ([65, 6], 'E#4'), ([65, 5], 'F4')], [([61, 1], 'C#4'), ([70, -2], 'Bb4'), ([70, 2], 'A#4'), ([65, 5], 'F4'), ([65, 7], 'E#4'), ([65, -6], 'F4'), ([60, 7], 'B#3'), ([5, 6], 'E#-1')], [([65, 6], 'E#4'), ([65, 5], 'F4'), ([65, 7], 'E#4'), ([65, -6], 'F4'), ([60, 7], 'B#3'), ([48, 7], 'B#2'), ([71, -6], 'Cb5'), ([71, -7], 'Cb5')], [([65, 5], 'F4'), ([48, 7], 'B#2'), ([71, -6], 'Cb5'), ([71, -7], 'Cb5'), ([59, -6], 'Cb4'), ([0, 0], 'C-1'), ([1, -3], 'Db-1'), ([5, 6], 'E#-1')], [([65, 6], 'E#4'), ([65, 5], 'F4'), ([59, -6], 'Cb4'), ([0, 0], 'C-1'), ([1, -3], 'Db-1'), ([11, 0], 'B-1'), ([127, 0], 'G9'), ([127, 7], 'G9')]]\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 music notation or theory engine. 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-music-interval-midi-spelling-key-e-sharp-threshold","generated_at":"2026-09-29T14:49:57.988129+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Pitch spelling and interval arithmetic decide the notes that notation, transposition and analysis tools display or play.","repair":"Restore the E sharp threshold step so that it reads `f >= 6 and pc == 5`.","root_cause":"The E# respelling is guarded by the seven-sharp condition used for B#, not by six or more sharps.","sha256":"97a03a2f05393634c0e89ad913425d8a86039be4cfb3d2a45ff45bc7ba1271e2","title":"Key-aware MIDI note spelling: E sharp spelling limited to seven sharps · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":37.971,"exit_code":1,"observations":[{"actual":"C4","check":"oracle 0","expected":"C4","passed":true},{"actual":"C#4","check":"oracle 1","expected":"C#4","passed":true},{"actual":"Db4","check":"oracle 2","expected":"Db4","passed":true},{"actual":"C#4","check":"oracle 3","expected":"C#4","passed":true},{"actual":"Bb4","check":"oracle 4","expected":"Bb4","passed":true},{"actual":"A#4","check":"oracle 5","expected":"A#4","passed":true},{"actual":"E#4","check":"oracle 6","expected":"E#4","passed":true},{"actual":"E#4","check":"oracle 7","expected":"F4","passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"oracle 0\", \"actual\": \"C4\", \"expected\": \"C4\", \"passed\": true}, {\"check\": \"oracle 1\", \"actual\": \"C#4\", \"expected\": \"C#4\", \"passed\": true}, {\"check\": \"oracle 2\", \"actual\": \"Db4\", \"expected\": \"Db4\", \"passed\": true}, {\"check\": \"oracle 3\", \"actual\": \"C#4\", \"expected\": \"C#4\", \"passed\": true}, {\"check\": \"oracle 4\", \"actual\": \"Bb4\", \"expected\": \"Bb4\", \"passed\": true}, {\"check\": \"oracle 5\", \"actual\": \"A#4\", \"expected\": \"A#4\", \"passed\": true}, {\"check\": \"oracle 6\", \"actual\": \"E#4\", \"expected\": \"E#4\", \"passed\": true}, {\"check\": \"oracle 7\", \"actual\": \"E#4\", \"expected\": \"F4\", \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":37.337,"exit_code":1,"observations":[{"actual":"C4","check":"oracle 0","expected":"C4","passed":true},{"actual":"C#4","check":"oracle 1","expected":"C#4","passed":true},{"actual":"Db4","check":"oracle 2","expected":"Db4","passed":true},{"actual":"C#4","check":"oracle 3","expected":"C#4","passed":true},{"actual":"Bb4","check":"oracle 4","expected":"Bb4","passed":true},{"actual":"A#4","check":"oracle 5","expected":"A#4","passed":true},{"actual":"F4","check":"oracle 6","expected":"E#4","passed":false},{"actual":"F4","check":"oracle 7","expected":"F4","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"oracle 0\", \"actual\": \"C4\", \"expected\": \"C4\", \"passed\": true}, {\"check\": \"oracle 1\", \"actual\": \"C#4\", \"expected\": \"C#4\", \"passed\": true}, {\"check\": \"oracle 2\", \"actual\": \"Db4\", \"expected\": \"Db4\", \"passed\": true}, {\"check\": \"oracle 3\", \"actual\": \"C#4\", \"expected\": \"C#4\", \"passed\": true}, {\"check\": \"oracle 4\", \"actual\": \"Bb4\", \"expected\": \"Bb4\", \"passed\": true}, {\"check\": \"oracle 5\", \"actual\": \"A#4\", \"expected\": \"A#4\", \"passed\": true}, {\"check\": \"oracle 6\", \"actual\": \"F4\", \"expected\": \"E#4\", \"passed\": false}, {\"check\": \"oracle 7\", \"actual\": \"F4\", \"expected\": \"F4\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":38.328,"exit_code":0,"observations":[{"actual":"C4","check":"oracle 0","expected":"C4","passed":true},{"actual":"C#4","check":"oracle 1","expected":"C#4","passed":true},{"actual":"Db4","check":"oracle 2","expected":"Db4","passed":true},{"actual":"C#4","check":"oracle 3","expected":"C#4","passed":true},{"actual":"Bb4","check":"oracle 4","expected":"Bb4","passed":true},{"actual":"A#4","check":"oracle 5","expected":"A#4","passed":true},{"actual":"E#4","check":"oracle 6","expected":"E#4","passed":true},{"actual":"F4","check":"oracle 7","expected":"F4","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"oracle 0\", \"actual\": \"C4\", \"expected\": \"C4\", \"passed\": true}, {\"check\": \"oracle 1\", \"actual\": \"C#4\", \"expected\": \"C#4\", \"passed\": true}, {\"check\": \"oracle 2\", \"actual\": \"Db4\", \"expected\": \"Db4\", \"passed\": true}, {\"check\": \"oracle 3\", \"actual\": \"C#4\", \"expected\": \"C#4\", \"passed\": true}, {\"check\": \"oracle 4\", \"actual\": \"Bb4\", \"expected\": \"Bb4\", \"passed\": true}, {\"check\": \"oracle 5\", \"actual\": \"A#4\", \"expected\": \"A#4\", \"passed\": true}, {\"check\": \"oracle 6\", \"actual\": \"E#4\", \"expected\": \"E#4\", \"passed\": true}, {\"check\": \"oracle 7\", \"actual\": \"F4\", \"expected\": \"F4\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}