Skip to content

fix(song): sanitize caged + guideTones on emit, not just decode (#544 follow-up) - #547

Merged
byrongamatos merged 1 commit into
mainfrom
fix/caged-guidetones-emit-guard
Jun 21, 2026
Merged

fix(song): sanitize caged + guideTones on emit, not just decode (#544 follow-up)#547
byrongamatos merged 1 commit into
mainfrom
fix/caged-guidetones-emit-guard

Conversation

@byrongamatos

Copy link
Copy Markdown
Contributor

Follow-up to #544. A post-merge Codex review found chord_template_to_wire emitted ct.caged / ct.guide_tones raw — so a directly-constructed ChordTemplate(caged="X") or guide_tones=[99] would write a schema-invalid value to the feedpak wire, even though the decoder already guards on input (spec: caged ∈ C/A/G/E/D, guideTones ∈ 0–11).

Fix

Run the same _sanitize_caged / _sanitize_guide_tones guards on emit: caged is written only when a valid enum value, guideTones only as the in-range ints (empty result → key omitted). Symmetric with the decode path; no valid value is dropped (boundary 0/11 preserved).

guideTones had the identical emit gap (Codex flagged only caged); both are fixed.

Tests

+1 (test_template_caged_guide_tones_sanitized_on_emit): invalid caged dropped, mixed guideTones filtered to the valid in-range subset, wholly-invalid list omitted. 154 song tests pass. Codex-reviewed: clean.

Part of #334.

🤖 Generated with Claude Code

…follow-up)

Post-merge Codex review of #544 found chord_template_to_wire emitted ct.caged and
ct.guide_tones raw — so a directly-constructed ChordTemplate(caged="X") or
guide_tones=[99] would write a schema-invalid value to the feedpak wire, even
though the decoder guards on input. The spec constrains caged to C/A/G/E/D and
guideTones to 0..11.

Run the same _sanitize_caged / _sanitize_guide_tones guards on emit: caged is
written only when a valid enum value, guideTones only as the in-range ints (empty
result -> key omitted). +1 test (invalid caged dropped, mixed guideTones filtered to
the valid in-range subset, wholly-invalid list omitted).

Codex-reviewed: clean. 154 song tests pass.

Part of #334.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos merged commit 73e3fe2 into main Jun 21, 2026
0 of 3 checks passed
@byrongamatos
byrongamatos deleted the fix/caged-guidetones-emit-guard branch June 21, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant