FAILURE MAP
← Case archive

FA-81136 / Music interval and transposition theory / Open access

Transposing instrument written and concert pitch: input pitch above MIDI range accepted · case 01

An input pitch of 128 is converted (to 126 for Bb clarinet) instead of being rejected.

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

ROOT CAUSE

The input guard enforces only the lower MIDI bound.

VERIFIED REPAIR

Restore the input range step so that it reads `not 0 <= pitch <= 127`.

Unsuccessful approach: Checking only the upper bound lets negative written pitches through.

Case contract

Input [instrument, pitch, direction]. Each instrument has a stipulated sounding offset in semitones (concert = written + offset): Bb clarinet -2, A clarinet -3, F horn -7, Eb alto sax -9, Bb tenor sax -14, Eb baritone sax -21, guitar -12, piccolo +12, D trumpet +2, flute 0. direction to_concert adds the offset, to_written subtracts it. pitch and result must be MIDI 0..127; otherwise, or for unknown instrument or direction, return None.

Why this case matters

Score and part generators convert between written and sounding pitch for every transposing instrument.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    table = {'Bb clarinet': -2, 'A clarinet': -3, 'F horn': -7, 'Eb alto sax': -9, 'Bb tenor sax': -14, 'Eb baritone sax': -21, 'guitar': -12, 'piccolo': 12, 'D trumpet': 2, 'flute': 0}
    if not isinstance(x, list) or len(x) != 3:
        return None
    inst, pitch, direction = x
    if inst not in table or not isinstance(pitch, int) or not 0 <= pitch:
        return None
    if direction == 'to_concert':
        out = pitch + table[inst]
    elif direction == 'to_written':
        out = pitch - table[inst]
    else:
        return None
    if out < 0 or out > 127:
        return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['Bb clarinet', 62, 'to_concert'], 60), (['Bb clarinet', 60, 'to_written'], 62), (['F horn', 67, 'to_concert'], 60), (['F horn', 60, 'to_written'], 67), (['Eb alto sax', 69, 'to_concert'], 60), (['Eb alto sax', 60, 'to_written'], 69), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['F horn', 60, 'to_written'], 67), (['Eb alto sax', 69, 'to_concert'], 60), (['Eb alto sax', 60, 'to_written'], 69), (['Bb tenor sax', 74, 'to_concert'], 60), (['Bb tenor sax', 60, 'to_written'], 74), (['piccolo', 60, 'to_concert'], 72), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['Bb tenor sax', 74, 'to_concert'], 60), (['Bb tenor sax', 60, 'to_written'], 74), (['piccolo', 60, 'to_concert'], 72), (['piccolo', 72, 'to_written'], 60), (['D trumpet', 60, 'to_concert'], 62), (['D trumpet', 62, 'to_written'], 60), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['piccolo', 72, 'to_written'], 60), (['D trumpet', 60, 'to_concert'], 62), (['D trumpet', 62, 'to_written'], 60), (['guitar', 64, 'to_concert'], 52), (['flute', 60, 'to_concert'], 60), (['flute', 60, 'to_written'], 60), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['guitar', 64, 'to_concert'], 52), (['flute', 60, 'to_concert'], 60), (['flute', 60, 'to_written'], 60), (['flute', 127, 'to_concert'], 127), (['piccolo', 115, 'to_concert'], 127), (['Eb baritone sax', 10, 'to_concert'], None), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)]]
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 06060Passed
oracle 16262Passed
oracle 26060Passed
oracle 36767Passed
oracle 46060Passed
oracle 56969Passed
oracle 6126NoneFailed
oracle 7NoneNonePassed

SHA-256 / 6bf96c4f2a320db5f86c1753c53156c3a86646f290124a04c0c9772ec62d3833

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    table = {'Bb clarinet': -2, 'A clarinet': -3, 'F horn': -7, 'Eb alto sax': -9, 'Bb tenor sax': -14, 'Eb baritone sax': -21, 'guitar': -12, 'piccolo': 12, 'D trumpet': 2, 'flute': 0}
    if not isinstance(x, list) or len(x) != 3:
        return None
    inst, pitch, direction = x
    if inst not in table or not isinstance(pitch, int) or not pitch <= 127:
        return None
    if direction == 'to_concert':
        out = pitch + table[inst]
    elif direction == 'to_written':
        out = pitch - table[inst]
    else:
        return None
    if out < 0 or out > 127:
        return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['Bb clarinet', 62, 'to_concert'], 60), (['Bb clarinet', 60, 'to_written'], 62), (['F horn', 67, 'to_concert'], 60), (['F horn', 60, 'to_written'], 67), (['Eb alto sax', 69, 'to_concert'], 60), (['Eb alto sax', 60, 'to_written'], 69), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['F horn', 60, 'to_written'], 67), (['Eb alto sax', 69, 'to_concert'], 60), (['Eb alto sax', 60, 'to_written'], 69), (['Bb tenor sax', 74, 'to_concert'], 60), (['Bb tenor sax', 60, 'to_written'], 74), (['piccolo', 60, 'to_concert'], 72), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['Bb tenor sax', 74, 'to_concert'], 60), (['Bb tenor sax', 60, 'to_written'], 74), (['piccolo', 60, 'to_concert'], 72), (['piccolo', 72, 'to_written'], 60), (['D trumpet', 60, 'to_concert'], 62), (['D trumpet', 62, 'to_written'], 60), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['piccolo', 72, 'to_written'], 60), (['D trumpet', 60, 'to_concert'], 62), (['D trumpet', 62, 'to_written'], 60), (['guitar', 64, 'to_concert'], 52), (['flute', 60, 'to_concert'], 60), (['flute', 60, 'to_written'], 60), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['guitar', 64, 'to_concert'], 52), (['flute', 60, 'to_concert'], 60), (['flute', 60, 'to_written'], 60), (['flute', 127, 'to_concert'], 127), (['piccolo', 115, 'to_concert'], 127), (['Eb baritone sax', 10, 'to_concert'], None), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)]]
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 06060Passed
oracle 16262Passed
oracle 26060Passed
oracle 36767Passed
oracle 46060Passed
oracle 56969Passed
oracle 6NoneNonePassed
oracle 71NoneFailed

SHA-256 / d4362f2f96a2bd19d1c717be2f93dc4a07d839244051a1959a0501c804208e6d

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    table = {'Bb clarinet': -2, 'A clarinet': -3, 'F horn': -7, 'Eb alto sax': -9, 'Bb tenor sax': -14, 'Eb baritone sax': -21, 'guitar': -12, 'piccolo': 12, 'D trumpet': 2, 'flute': 0}
    if not isinstance(x, list) or len(x) != 3:
        return None
    inst, pitch, direction = x
    if inst not in table or not isinstance(pitch, int) or not 0 <= pitch <= 127:
        return None
    if direction == 'to_concert':
        out = pitch + table[inst]
    elif direction == 'to_written':
        out = pitch - table[inst]
    else:
        return None
    if out < 0 or out > 127:
        return None
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[(['Bb clarinet', 62, 'to_concert'], 60), (['Bb clarinet', 60, 'to_written'], 62), (['F horn', 67, 'to_concert'], 60), (['F horn', 60, 'to_written'], 67), (['Eb alto sax', 69, 'to_concert'], 60), (['Eb alto sax', 60, 'to_written'], 69), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['F horn', 60, 'to_written'], 67), (['Eb alto sax', 69, 'to_concert'], 60), (['Eb alto sax', 60, 'to_written'], 69), (['Bb tenor sax', 74, 'to_concert'], 60), (['Bb tenor sax', 60, 'to_written'], 74), (['piccolo', 60, 'to_concert'], 72), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['Bb tenor sax', 74, 'to_concert'], 60), (['Bb tenor sax', 60, 'to_written'], 74), (['piccolo', 60, 'to_concert'], 72), (['piccolo', 72, 'to_written'], 60), (['D trumpet', 60, 'to_concert'], 62), (['D trumpet', 62, 'to_written'], 60), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['piccolo', 72, 'to_written'], 60), (['D trumpet', 60, 'to_concert'], 62), (['D trumpet', 62, 'to_written'], 60), (['guitar', 64, 'to_concert'], 52), (['flute', 60, 'to_concert'], 60), (['flute', 60, 'to_written'], 60), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)], [(['guitar', 64, 'to_concert'], 52), (['flute', 60, 'to_concert'], 60), (['flute', 60, 'to_written'], 60), (['flute', 127, 'to_concert'], 127), (['piccolo', 115, 'to_concert'], 127), (['Eb baritone sax', 10, 'to_concert'], None), (['Bb clarinet', 128, 'to_concert'], None), (['Bb clarinet', -1, 'to_written'], None)]]
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 06060Passed
oracle 16262Passed
oracle 26060Passed
oracle 36767Passed
oracle 46060Passed
oracle 56969Passed
oracle 6NoneNonePassed
oracle 7NoneNonePassed

SHA-256 / 6ea967ebd0fbcde6357318bd207bfd4203dc5abe3286bd6d11cbe8f9e2e13ec2

Verification & scope

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.

Observations recorded using Python 3.12.14 at 2026-09-29T14:50:00.206791+00:00.

Case digest / 8e599c6124d024dbb01f85112fbf06ae9734f4b0b4a593183c67c6a21ed9864b