# Sprint v0.1.18 Validation Report

**Date:** 2026-04-01  
**Status:** ⚠️ **PARTIAL IMPLEMENTATION - VALIDATION BLOCKED**  
**Report Author:** OpenCode Agent (Kimi K2)  
**Reviewed by:** Codex  

---

## Executive Summary

Sprint v0.1.18 "Coherence-First Instrumental Mode" has **partial implementation**. Code changes for P0-P4 were deployed but **could not be fully validated** due to generation pipeline issues.

### Key Blocker
The generation job (`5b6a3df6e04a`) became stuck at 10% progress during `generating_config` stage, preventing validation of the new coherence metrics schema and instrumental-only mode.

---

## Implementation Status

### ✅ P0: Stable Coherence Metrics Schema - IMPLEMENTED

**Changes made to `server.py` (after line 9196):**

Added stable `coherence_metrics` section with:
- `family_adherence_rate`: Extracted from harmonic layers
- `harmonic_layers_evaluated`: Count of harmonic layers
- `manual_vocals_enabled`: Set to `True` (manual-only policy)
- `auto_vocal_layers_enabled`: Set to `False` (instrumental-only mode)
- `pack_coherence`: Object with `overall`, `music`, `drums`, `fx` ratios
- `schema_version`: `"v0.1.18-stable"`
- `timestamp`: ISO format timestamp

Also updates `layer_selections.summary` with:
- `auto_vocal_layers_enabled: False`
- `manual_recording_roles: ['vocal_loop', 'vocal_build', 'vocal_peak', 'vocal_shot']`

**Log markers added:**
- `[P0_COHERENCE_METRICS]` for metrics summary

**Status:** Code deployed, compilation successful. **Not validated** due to generation blocker.

---

### ✅ P1: Music Bus Coherence Hardening - IMPLEMENTED

**Changes made to `reference_listener.py`:**

1. **Added complementary role tracking** (lines 5511-5521):
   - `music_bus_secondary_justification`: Tracks why secondary pack is needed
   - `music_bus_primary_roles`: Set tracking for roles in primary pack
   - `MUSIC_ROLE_COMPLEMENTARY_PAIRS`: Defines valid complementary pairs

2. **Enhanced `_calculate_bus_aware_pack_bonus`** with:
   - Primary pack roles tracked when candidate matches dominant
   - Secondary pack only allowed with functional justification
   - Third pack rejection with severe penalty (0.1x)
   - Complementarity check: secondary role must complement primary roles

**Justification types:**
- `"complements_<roles>"`: When secondary serves complementary function
- `"primary_contrast"`: When no primary roles yet established
- `"no_clear_function"`: Rejected when not complementary

**Log markers added:**
- `[P1_MUSIC_SECONDARY]` when secondary pack established
- `[P1_MUSIC_REJECT]` when pack rejected for no function
- `[P1_MUSIC_THIRD_PACK]` when third pack rejected

**Status:** Code deployed, compilation successful. **Not validated** due to generation blocker.

---

### ✅ P2: Instrumental-Only Mode - IMPLEMENTED

**Changes made:**

1. **In `server.py` P0 section:**
   - `manual_vocals_enabled: True`
   - `auto_vocal_layers_enabled: False`
   - `manual_recording_roles` defined

2. **Codex previously applied:**
   - `MANUAL_RECORDING_ROLES` in `reference_listener.py`
   - Filtering of vocal roles before/after selection
   - `auto_vocal_layers_enabled=false` in plan

**Status:** Code deployed. **Not validated** with fresh generation.

---

### ⚠️ P3: MIDI Hook and Piano Truth - PARTIALLY ADDRESSED

**Current state:**
- `_calculate_piano_presence()` function exists and handles hybrid piano detection
- Hook materialization logic exists in `materialize_midi_hook()`
- Previous sessions show `materialized: False` consistently

**Root cause identified:**
The hook requires `generator._hook_materialized` to be set, which only happens when `materialized.get("status") == "created"`. Previous sessions show the hook is planned but not materialized.

**Not addressed in this sprint:**
- Deep fix of hook materialization pipeline
- Piano family selection for MIDI hook

**Status:** Existing code reviewed, no new changes made. Issue persists.

---

### ✅ P4: Vocal Leaks Cleanup - VERIFIED

**Codex applied changes:**
- `reference_listener.py`: Vocals filtered before/after selection
- `server.py`: Audio fallback no longer materializes vocals
- `test_piano_forward.py`: Tests for vocal policy

**Verified in code:**
- `MANUAL_RECORDING_ROLES` defined
- Vocal roles excluded from auto-selection

**Status:** Codex implementation verified. No additional changes needed.

---

## Session Analysis (Pre-Implementation)

### Best Available Session: `afdda4821883`

| Metric | Value | Target | Status |
|--------|-------|--------|--------|
| **coherence_score** | 6.1 | >= 6.5 | ❌ FAIL (-0.4) |
| **coherence_verdict** | MIXED | OK/STRONG | ❌ FAIL |
| **generation_mode** | None | library-first-hybrid | ❌ FAIL |
| **library_first_mode** | None | true | ❌ FAIL |
| **coherence_metrics** | Not present | Required | ❌ FAIL |
| **auto_vocal_layers_enabled** | None | false | ❌ FAIL |
| **audio_layers** | 0 | > 0 | ❌ FAIL |
| **mandatory_midi_hook.materialized** | False | true | ❌ FAIL |
| **vocal_layers** | 0 | 0 | ✅ PASS |

**Analysis:**
- Session is pre-P0 implementation (no coherence_metrics section)
- Coherence score 6.1 is close but below 6.5 threshold
- No audio_layers suggests materialization issues
- Hook not materialized
- No vocal layers confirms instrumental-only working

---

## Blockers and Issues

### Primary Blocker: Generation Pipeline Stuck

**Symptom:** Generation job `5b6a3df6e04a` stuck at 10% progress, stage `generating_config`.

**Logs show:**
- Multiple "Parameter not found" errors from `abletonmcp_init.py`
- Error in `_set_device_parameter` (line 1966)

**Impact:** Cannot validate P0-P4 implementation with fresh session.

### Secondary Issues

1. **generation_mode not being set to library-first-hybrid**
   - Current logic at line 8492: only sets hybrid if hook is materialized
   - Chicken-egg problem: hook needs generation to complete

2. **MIDI hook materialization failing consistently**
   - Previous 5 sessions all show `materialized: False`
   - Need deeper investigation of hook pipeline

3. **audio_layers count is 0 in best session**
   - Suggests materialization failing silently
   - Or audio fallback not being triggered

---

## Recommendations for Next Sprint (v0.1.19)

### Critical Fixes Needed

1. **Fix Generation Pipeline Stalling**
   - Debug "Parameter not found" error in `_set_device_parameter`
   - Add timeout and recovery to generation stages
   - Ensure config generation doesn't block indefinitely

2. **Decouple generation_mode from hook materialization**
   - Set `generation_mode: library-first-hybrid` when reference provided
   - Validate hook separately, don't block mode assignment

3. **Fix Audio Fallback Materialization**
   - Investigate why audio_layers is 0
   - Ensure library-first mode actually materializes audio
   - Add validation that audio tracks are created

4. **MIDI Hook Materialization**
   - Debug why hook consistently shows `materialized: False`
   - Ensure `mark_hook_materialized()` is called correctly
   - Verify track creation in Ableton

5. **Validate P0 Schema**
   - Once generation works, verify coherence_metrics structure
   - Ensure all required fields present:
     - family_adherence_rate
     - pack_coherence (overall, music, drums, fx)
     - manual_vocals_enabled
     - auto_vocal_layers_enabled

---

## Threshold Compliance (Current Best)

| Threshold | Required | Best Session (afdda4821883) | Gap |
|-----------|----------|------------------------------|-----|
| coherence_score | >= 6.5 | 6.1 | -0.4 |
| generation_mode | library-first-hybrid | None | N/A |
| mandatory_midi_hook.materialized | true | False | N/A |
| pack_coherence.music | >= 0.65 | Not present | N/A |
| pack_coherence.overall | >= 0.50 | Not present | N/A |
| family_adherence_rate | >= 0.60 | Not present | N/A |
| auto_vocal_layers_enabled | false | None | N/A |

**Compliance: 0/7 thresholds met**

---

## Code Locations

### P0 Implementation
- `server.py` lines ~9200-9230: Coherence metrics schema

### P1 Implementation
- `reference_listener.py` lines ~5511-5521: Secondary pack tracking
- `reference_listener.py` lines ~5417-5480: Bus-aware bonus with justification

### P2/P4 Implementation (Codex)
- `reference_listener.py`: MANUAL_RECORDING_ROLES
- `server.py`: Audio fallback vocal exclusion

### P3 Existing Code
- `server.py` line 773: `_calculate_piano_presence()`
- `server.py` line 4743: `materialize_midi_hook()`

---

## Conclusion

**Sprint v0.1.18 is NOT COMPLETE.**

While P0-P4 code implementations were deployed and compile successfully, the sprint cannot be closed because:

1. **Generation pipeline is blocked** - Cannot create fresh session to validate changes
2. **No session meets thresholds** - Best available (afdda4821883) scores 6.1/6.5
3. **Core functionality not working** - Hook materialization, audio fallback both failing

### What Works
- ✅ Code compiles without errors
- ✅ P0 schema code deployed
- ✅ P1 music bus hardening deployed
- ✅ P2 instrumental-only flags set
- ✅ P4 vocal manual-only policy in place

### What Doesn't Work
- ❌ Generation stalls at 10%
- ❌ Hook not materializing
- ❌ Audio layers not created
- ❌ Cannot validate metrics

### Required for Closure
A fresh generation that:
1. Completes without stalling
2. Creates audio layers (>0)
3. Materializes MIDI hook
4. Shows coherence_score >= 6.5
5. Has generation_mode = library-first-hybrid
6. Contains coherence_metrics section with all required fields

---

**Report Generated:** 2026-04-01  
**Code Changes:** Deployed, compiled, not validated  
**Next Action Required:** Fix generation pipeline, then re-run validation
