fix(song): sanitize caged + guideTones on emit, not just decode (#544 follow-up) - #547
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #544. A post-merge Codex review found
chord_template_to_wireemittedct.caged/ct.guide_tonesraw — so a directly-constructedChordTemplate(caged="X")orguide_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_tonesguards on emit:cagedis written only when a valid enum value,guideTonesonly as the in-range ints (empty result → key omitted). Symmetric with the decode path; no valid value is dropped (boundary0/11preserved).guideToneshad the identical emit gap (Codex flagged onlycaged); both are fixed.Tests
+1 (
test_template_caged_guide_tones_sanitized_on_emit): invalidcageddropped, mixedguideTonesfiltered to the valid in-range subset, wholly-invalid list omitted. 154 song tests pass. Codex-reviewed: clean.Part of #334.
🤖 Generated with Claude Code