# Tasks: Hook-Based Reggaeton Melody ## Phase 1: Melody Engine Core - [x] 1.1 Create `src/composer/melody_engine.py` with `build_motif(key_root, key_minor, style, bars, seed)` → `list[MidiNote]` - [x] 1.2 Implement "hook" style: arch contour, chord tones on strong beats, 4–8 notes - [x] 1.3 Implement "stabs" style: 16th-duration hits on dembow positions [1.0, 2.5, 3.0, 3.5] per bar - [x] 1.4 Implement "smooth" style: stepwise scalar eighth-note motion - [x] 1.5 Implement `apply_variation(motif, shift_beats, transpose_semitones)` → `list[MidiNote]` - [x] 1.6 Implement `build_call_response(motif, bars, key_root, key_minor, seed)` → `list[MidiNote]` - [x] 1.7 Wire internal helpers: `_resolve_chord_tones()`, `_resolve_tension_notes()` ## Phase 2: Integration - [x] 2.1 Modify `build_lead_track()` in `scripts/compose.py` to delegate to `melody_engine.build_call_response()` - [x] 2.2 Pass seed through to melody engine calls - [x] 2.3 Keep `get_pentatonic()` and `CHORD_PROGRESSION` unchanged in compose.py ## Phase 3: Testing - [x] 3.1 Create `tests/test_melody_engine.py` with `test_motif_deterministic` (same seed = same output) - [x] 3.2 Test `test_motif_different_seeds_different_output` - [x] 3.3 Test `test_invalid_style_raises_value_error` - [x] 3.4 Test `test_hook_chord_tones_on_strong_beats` (≥70% ratio) - [x] 3.5 Test `test_stabs_grid_alignment` (all notes on dembow positions) - [x] 3.6 Test `test_smooth_stepwise_motion` (consecutive ≤2 semitones) - [x] 3.7 Test `test_variation_preserves_note_count_structure` - [x] 3.8 Test `test_call_ends_on_tension_response_ends_on_tonic` (V/VII → i) - [x] 3.9 Test `test_call_response_fills_bars` (motif repeats to fill section) - [x] 3.10 Update `test_melody_uses_pentatonic` in `tests/test_compose_integration.py` for hook structure ## Phase 4: Validation - [x] 4.1 Run full test suite: `pytest tests/ -x` — 247/248 pass (1 pre-existing failure, unrelated) - [ ] 4.2 Manual verification: generate .rpp with `--seed 42`, confirm lead clips contain repeating motif structure