``` Step 14 — COMPLETE: reusable explicit pitch/chord and exact polyphonic attacks Date: 2026-10-20 RESULT Implemented and verified the internal foundation, with actual MIDI and .griff publication/read-back. Ready for Step15 work after review. No full lane parser, public score tool, arbitrary chord-prose claim, slide semantics, later prompt, application manipulation, commit, delegation, dependency or version change. Package version remains the accepted 0.1.1. No release artifacts refreshed. READ / PRESERVATION Read step_14, current plan, accepted reports11-13, schemas, composer, profiles, compiler, service/native fallback policy, native writer/validator and tests. Pre-edit phrase/composer baseline: 87 passed in 1.10s. Preserved the existing dirty accepted 0.1.1 changes rather than resetting them. 85 existing tracked source/test/doc/manifest and report files were hashed before edits; 82 remain identical. Only these baseline files changed: src\riff_groove_builder\schemas.py src\riff_groove_builder\compose.py docs\architecture.md Added pitch.py, test_pitch.py, test_explicit_plan.py, test_explicit_music.py, and this report. Existing profiles/tunings, compiler/native/service behavior, public tool schemas/descriptions, version, dependencies and old tests remain unchanged by this step. Preservation manifests and pre-edit status: .test-artifacts\step14\preservation-before.json .test-artifacts\step14\preservation-after.json .test-artifacts\step14\status-before.txt REUSABLE INTERNAL APIS riff_groove_builder.pitch: PitchToken(letter, accidental="", octave=None) ChordSymbol(root, quality="major", add4=False, bass=None) ExplicitVoicing(notes: tuple[PitchToken, ...]) NotationToken(value, text, start, end, leading_space) ResolvedVoicing(pitches: tuple[int, ...], assumptions: tuple[str, ...]) parse_pitch(text) -> PitchToken parse_chord(text) -> ChordSymbol | ExplicitVoicing tokenize_notation(text, *, kind="note" | "chord") -> tuple[NotationToken, ...] resolve_voicing(value, profile) -> ResolvedVoicing validate_voicing(pitches, profile) -> None riff_groove_builder.schemas: ExplicitAttack extends TimedNote: start, duration, technique, optional intensity, unique MIDI pitches ExplicitAttackPlan: part, duration, ordered attacks, optional disclosed assumptions MusicalIntent.explicit_plan: optional internal plan, separate from legacy low-tonic PhrasePlan Existing compose_score(intent, profiles, ppq=960) consumes explicit plans. compile_score, write_midi, write_riffer, saved-file validators and the real GenerationService publication/fallback path are reused, not replaced. Integration tests inject an internal DescriptionResolution to reach that path; this is explicitly NOT evidence of public chord/lane prose parsing. Architecture documentation describes APIs, policy and this boundary. PITCH / CHORD / TOKEN POLICIES - Uppercase A-G, optional one ASCII #/b, optional signed octave. C4=60, E4=64, G4=67; C-1=0, G9=127; C+4=60. Accidental rollover is correct: Cb4=59, B#3=60. Enharmonic spellings preserve numerical meaning, not forced sharp spelling. Malformed/double/Unicode accidentals and out-of-MIDI explicit notes fail. Missing octave stays None; accessing .midi before resolution fails. - Bare root means major; m/min means minor. Root octave follows quality. F# -> [42,46,49], D -> [38,42,45], Bb -> [46,50,53] on target lead. F#3 -> [54,58,61]; Bb2 -> [46,50,53]; Em4 -> [64,67,71]. Major intervals [0,4,7]; minor [0,3,7]. Parenthesized (add4) adds interval5, retaining third and fifth: Em(add4) -> [40,43,45,47] Em4(add4) -> [64,67,69,71] E4(add4) -> [64,68,69,71] Digits are octaves, not seventh/extension qualities. Unsupported quality syntax is rejected rather than guessed. - Missing note/root octave chooses the playable root nearest MIDI40 for the selected profile range/tuning; lower wins ties. The exact MIDI choice and profile are disclosed in ResolvedVoicing.assumptions. The root is selected BEFORE constructing the chord: no alternate octave search to rescue a chord. - Em4/B2 and Em4OverB2 -> [47,64,67,71]. Em4/B and Em4OverB -> [59,64,67,71]. Missing bass octave means the nearest matching pitch STRICTLY BELOW the lowest upper-chord tone; the MIDI59 default is reported. Explicit equal/higher bass (Em4/E4, Em4/B4) fails, never gets moved. - Explicit [C3 E3 G3] -> [48,52,55]; pitches are sorted without changing octaves. Explicit duplicate/enharmonic duplicate pitches are rejected. Computed chord pitches are deduplicated. No key-based correction exists. - A complete voicing must fit MIDI/profile bounds and individually evidenced tuning positions. No dropped tone, arbitrary revoicing, octave spreading, key retuning or fabricated native success. Simultaneous physical allocation remains native preflight's responsibility. - Deterministic compact lexing handles F#F#, DD, BbBb, CEG, C4E4G4 and concatenated qualified chord atoms. Exact offsets and leading whitespace preserve boundaries/spacing; spacing is NOT interpreted as duration. Note mode and chord mode are separate: C4 means a note versus major root. Unknown/ambiguous leftovers fail; notation input is bounded to 4000 chars. No whole-example match or canned musical-output branch was introduced. PLAN / COMPOSITION POLICIES - Exact reduced nonnegative rational starts and positive rational durations; unique 0-127 integer pitch sets, finite optional intensity0-1, techniques normal/palm_mute/pinch_harmonic only. - One pitched part per plan; sole selected part, sufficient bars/meter, no competing legacy phrase or global rhythm/technique instruction. - Start-ordered attacks, score-bounded ends, maximum16384 quarter beats. Independent same-pitch overlaps fail; half-open adjacent repeats are valid. Different pitches may overlap with compatible shared technique. Conflicting simultaneous profile-wide techniques fail rather than silently changing. - All chord tones become independent simultaneous PitchedNotes, keeping exact start/duration and explicit pitches even when outside the intent's key. Explicit intensity wins; otherwise existing seeded intensity policy uses one draw per attack, shared by chord tones, with the existing bass offset. - Gaps represent silence and one attack's duration represents uninterrupted sustain. Rest/continuation lane tokens are not parsed or guessed. Later continuation parsing must extend the original attack, not retrigger. - Expanded note-on/off pairs share the100000 scheduled-event budget. Explicit composition invokes the authoritative compiler to include actual articulation controls, not merely count chord tokens. Tests prove six tones consume12 events on the standard profile and14 with the target's selector; the latter fails a test ceiling12. Seven tones already exceed12 before controls. Existing explicit-CC combined-budget enforcement is retained. - Grids, real selected-profile techniques, mutated-plan revalidation and profile range/tuning are checked; slides remain unsupported. ACTUAL MIDI / NATIVE MUSIC CHECKS Four independently published original plans cover / and Over aliases, each with explicit B2 or default B3 bass. Intent is D minor, but the F# major chord's [66,70,73] is preserved exactly; there is no key correction. Attack MIDI960 on/off Native480 Begin/End Pitches Em4/B2 or OverB2 0 / 640 0 / 320 47,64,67,71 Em4/B or OverB 0 / 640 0 / 320 59,64,67,71 [C3 E3 G3] PM 960 / 1280 480 / 640 48,52,55 F#4 major normal 1280 / 1920 640 / 960 66,70,73 C4 single PH 1920 / 3840 960 / 1920 60 Each saved plan has exactly: 4 attacks, 11 independent musical tones, 11 native Note elements. 4 MIDI selector-ons: (tick,pitch)=(0,24),(960,26),(1280,24),(1920,31). Selector velocity100 and gate30 ticks;15 total MIDI note-ons. 30 scheduled events including all musical/selector note-offs. Musical velocities95,32,110,127 by attack. Zero CC/program events and no fake native CC lane. MIDI type1, PPQ960, Conductor/Lead tracks, common EOT3840. Native Riff AME, key Dm, PPQ480, loopEnd1920, Sus/PM/Sus/PH labels. Exact thirds, uninterrupted PH ending at score end, no dropped chord tone. Independent Mido and ElementTree parsing compares saved numerical pitches, begins/ends/velocities/labels against authored expectations. Native checks derive every pitch from the unchanged tuning plus fret, enforce frets0-22, no occupancy overlap per physical string, and four distinct strings for the opening four-tone chord. Producer saved-file validators also pass. Actual opening physical assignments, written as pitch=string/fret: B2 case: 47=5/4, 64=3/11, 67=2/10, 71=1/9 B3 case: 59=2/2, 64=4/16, 67=3/14, 71=1/9 Remaining assignments: [48,52,55] -> 4/0,5/9,3/2 [66,70,73] -> 2/9,3/17,1/11 60 -> 2/3 No vendor tuning/map changed to make these fit. Persistent final full-suite evidence under .test-artifacts\step14\: explicit-e9b2540d542d48c4b041af85459c0a63 — Em4/B2 explicit-33adb31397b541e6a79ce9606fd63485 — Em4OverB2 explicit-0701890c8372424e9b460098fc86d3a0 — Em4/B explicit-487d819893344859b4297c551dda8901 — Em4OverB Each contains chords\chords.mid, chords\chords_lead.griff and evidence.json with actual pitch/time/string/fret/count/size/SHA256 values. All MIDI files178bytes; all griff files2018bytes. B2 / and Over aliases have identical bytes: MIDI d3f7b10e92a1ca228602a94add3cc6eec1a4f7d482b8527d23d936d98100a9d1 griff1547b32fb666f8006547cf89f391ea613db05c4e78273f940f4542e354115a60 B3 / and Over aliases have identical bytes: MIDI 38a3b247bdee334f04c072f651645d205588dc820fb2ce84ae4202482c5f5f02 griff80c3a770a45accbd2de371063f2f92cd34b1b9f7a4a55b558c301112b15de838 Redundant earlier-run copies were removed; final verified evidence retained. ERROR / FALLBACK / NO-OVERWRITE CHECKS - Explicit [36,37,38] is individually in range but needs three simultaneous notes on only the lowest physical string. Existing native preflight reports no_physical_string_assignment. Fallback=false fails before publication. Fallback=true returns midi_fallback and one MIDI artifact with fallback_for ["lead"], containing ALL THREE exact pitches and their complete durations. No .griff with omitted tones is produced. - [35,60,64] fails as out-of-map for BOTH fallback settings, publishes nothing and leaves a preexisting sentinel unchanged. This is not native fallback. - Reusing a successful basename fails OutputExistsError and both actual MIDI/griff byte strings remain unchanged. OLD 0.1.1 OUTPUT PRESERVATION Real source and independently installed-wheel stdio tests still assert the accepted musical byte baselines, including the original PM-triplet-PH phrase: phrase-original.mid168bytes: c1967e698a50b8c22a22e458c3e2dd02d04407d1ad1d61f8a462d790b0810e62 phrase-original_lead.griff1701bytes: e8195e74c60ac93b1a4c92967a0834a64b2a2ebd74f453d6d3640ea465c4104c text-recovered.mid117bytes: 922d4c30e4618b6cce61a2ecebb36193773ca3884e56db80f7c18fe18e813f26 text-recovered_lead.griff1014bytes: 213adde1c4785dccd2289e6888328c16bca720fb8d2786edb4df34f3863d1c2f Original phrase remains nine musical MIDI40 notes, eight PM plus one PH, with the same exact starts, cross-bar PH duration and native string6/fret4. Ordinary/native/CC/stdio/schema/service/error/atomic-write regressions pass. EXECUTED VALIDATION Interpreter: repository .venv\Scripts\python.exe, Python3.13.13. No claim of executing other supported Python versions. 1. New foundation coverage:150 unit +8 integration tests, all passing in the final focused/full runs;158 additional tests over the accepted1503. 2. Focused new + relevant composer/phrase/text-feedback/stdio regressions: pytest tests\unit\test_pitch.py tests\unit\test_explicit_plan.py tests\integration\test_explicit_music.py tests\unit\test_phrase_timing.py tests\unit\test_compose.py tests\integration\test_phrase_stdio.py tests\integration\test_text_feedback.py -q PASS:247 passed in3.68s. 3. Full current suite: python -m pytest -q PASS:1661 passed in68.52s; zero failures/skips. Includes existing offline isolated distribution and real installed-wheel stdio checks. Those tests build/install only test-scoped project packages; no release wheel/sdist, editable metadata or dependency was refreshed. 4. python -m ruff check . — PASS. 5. python -m ruff format --check . — PASS,99 files already formatted. 6. python -m mypy --strict src tests — PASS,54 source files/no issues. 7. Editor diagnostics on all six changed/new Python files — no errors. 8. git diff --check — PASS. Logs: .test-artifacts\step14\focused-suite.txt, full-suite.txt, strict-types.txt, lint.txt, format.txt. ISSUES ENCOUNTERED / RESOLVED - Editor test runner found no tests; actual configured-venv pytest was used. - Initial integration fixture incorrectly expected fallback_for=["griff"]. Corrected to the preserved public contract's PART ["lead"], without altering service policy or dropping the exact-pitch MIDI assertion. - Used the existing narrow Mido import-untyped annotation convention rather than adding stubs/dependencies. Initial lint/format findings were corrected. - No unresolved implementation blocker. Optional genuine local SD3-template acceptance was not configured in this run; ordinary synthetic/native SD3 regressions passed. No user template, application, LM Studio chat/config, DAW, plugin/audio or external output directory was manipulated. STEP15 READINESS / STOP Ready: strict pitch/chord atoms and deterministic lexical tokens can feed the exact internal attack plan, which reaches working polyphonic MIDI/native output with truthful existing fallback and byte-preserved legacy behavior. Still intentionally absent: full Counts/Events/Chords/Notes lane parsing, spacing-to-time inference, public score input, arbitrary prose and slides. Later authorized parsing must propagate register assumptions, encode rests/continuations without guessed attacks, and preserve these constraints. Stopped after Step14 verification/report. No Step15 prompt read or created. ```