# SPRINT v0.1.40 - NEXT
## Open Project Editing, Less Symmetry, Less Silence, More Freedom Within Coherence

**Owner:** GLM via OpenCode  
**Reviewer:** Codex  
**Fecha:** 2026-04-03  
**Mode:** Edit the already open project. Do not generate a new song.

---

## 0. Context

The v0.1.39 report showed real progress in MCP inspection/editing, but it still overclaimed runtime closure.

What is true after review:

1. The new audit/repair surface exists in code.
2. The current open-project workflow is still too symmetric, too silent, and too Session-centric.
3. Arrangement MIDI editing is not proven closed in live runtime yet.
4. The current project still tends to look like mirrored 16-beat blocks with repeated gaps.
5. "Piano roll" means **harmonic MIDI backbone** here, not necessarily piano timbre.

This sprint is not about adding more wrappers for the sake of wrappers. It is about making the open-project editing path materially better and more musical.

---

## 1. Code Review From Codex

These are the concrete findings from reviewing `SPRINT_v0.1.39_VALIDATION_REPORT.md` against code and runtime truth.

### 1.1 What GLM actually did well

- Added useful inspection/audit surface in `server.py`.
- Added first bounded repair tools instead of only full-regeneration thinking.
- Moved the system closer to project editing instead of always relying on `generate_song`.

### 1.2 What GLM overstated

- `P0.2` was still not closed. Arrangement MIDI editing was still too fragile.
- The repair tools were presented as more "real editing" than they actually were.
- The symmetry/silence metrics existed, but were not strong enough yet to describe the project the user was actually hearing/seeing.

### 1.3 Bugs Codex fixed in this review

Codex already fixed these before this sprint starts:

1. `audit_project_coherence()` now detects:
   - leading silence islands
   - trailing silence islands
   - stronger mirrored section pairs aggregated by section pair, not only by the first repeated occurrence
   - harmonic backbone gap counts that include leading/trailing missing spans

2. `repair_harmonic_gaps()` no longer writes naive chromatic filler.
   - it now creates a coherent triad-based backbone inferred from the track/key context
   - `copy_adjacent` now uses a real Session source slot when available
   - if no Session source exists, it falls back honestly to coherent MIDI backbone instead of pretending it duplicated something meaningful

3. `extend_track_continuity()` no longer hardcodes `clip_index = 0`.
   - it now uses the real Session source slot when one exists
   - if there is no usable source, it reports analysis-only behavior instead of faking success

4. Arrangement clip localization in:
   - `abletonmcp_init.py`
   - `abletonmcp_runtime.py`
   
   is now more robust:
   - nearest-match selection instead of exact-only tiny tolerance
   - progressive tolerance ladder
   - length-aware matching

### 1.4 Remaining open problems

These are still open and must be treated as real blockers:

1. Live runtime validation is currently stale until Ableton/OpenCode are restarted.
2. `get_device_parameters()` had already failed in the Ableton log for non-quantized params under an older loaded runtime.
3. The current project is still too grid-locked and mirrored.
4. Harmonic backbone is still not proven to live in Arrangement in a robust way for open-project editing.
5. Some repair tools are still only halfway between "analysis" and "editing".

---

## 2. Mandatory Restart Before Validation

Before doing anything else:

1. Restart Ableton Live.
2. Restart OpenCode.
3. Confirm the MCP bridge is alive again.

Do not validate against stale runtime memory.

Minimum proof required at the start of the report:

- `get_session_info()`
- `get_tracks()`
- `get_track_info(...)`
- `get_device_parameters(...)` on a real device with at least one non-quantized parameter

If any of those fail, stop claiming progress and fix the runtime first.

---

## 3. Objective

Continue building the MCP so it can **edit already-open projects** and simultaneously improve **musical coherence**.

The target is not "more clips". The target is:

- less mirrored geometry
- fewer dead spans
- stronger harmonic continuity
- more freedom in sound choice inside a coherent identity
- better editing primitives for a project already loaded in Live

---

## 4. Hard Constraints

1. Do not generate a new song in this sprint.
2. Work on the already open benchmark project.
3. Do not claim success from unit tests alone.
4. Do not call a tool "editing" if it only emits a JSON diagnosis or marks hypothetical actions.
5. Do not reintroduce vocals.
6. Do not interpret "piano roll" as mandatory piano timbre.
   - It means harmonic MIDI content in Arrangement.
7. Do not reduce symmetry by deleting half the song and leaving holes.
8. Do not solve repetition by random collage.

---

## 5. P0 - Runtime Truth After Restart

### P0.1

Re-run live truth after restart and paste exact outputs for:

- `get_session_info`
- `get_tracks`
- `get_track_info` on the harmonic MIDI track
- `get_device_parameters` on a real instrument device
- `audit_project_coherence`
- `audit_current_project`

### P0.2

Specifically prove whether Arrangement MIDI editing now works better after Codex's locator fix.

Required live proof:

1. create or duplicate a small MIDI clip into Arrangement
2. add notes into it
3. verify it using:
   - `get_track_info`
   - `get_arrangement_clip_info`

If it still fails, do not write "blocked by Ableton" as a generic conclusion until you prove the exact failing step after the new fallback logic.

---

## 6. P1 - MCP Tools For Open Project Editing

This sprint must keep expanding the MCP editing surface for an already open `.als`.

### P1.1 Public tool exposure required

Expose and validate at least these tools if they are not already public/usable enough:

1. `create_arrangement_audio_pattern(...)`
   - this already exists in runtime logic and is strategically important for editing audio projects
   - it should become a first-class MCP tool

2. `get_arrangement_track_timeline(...)`
   - return the full arrangement timeline for a track
   - not only a shallow summary
   - include start, end, length, clip name, clip type

3. `clear_arrangement_range(...)`
   - bounded deletion/removal for a time range on one track
   - needed to repair symmetry/silence without whole-song regeneration

4. `duplicate_arrangement_region(...)` or equivalent bounded arrangement cloning tool
   - must work on existing open projects
   - this is more useful than pretending Session duplication solves all edit cases

### P1.2 Existing repair tools must become more honest or more real

Review these tools:

- `repair_harmonic_gaps`
- `reduce_same_source_dominance`
- `extend_track_continuity`
- `soften_grid_lock`

For each one, do one of these two things:

1. make it actually edit the project in a bounded way, or
2. mark it explicitly as `analysis_only` / `dry_run` when it cannot safely edit

No fake-success JSONs.

---

## 7. P2 - Coherence Work On The Open Project

### P2.1 Reduce silence without flattening the project

Use the open project and make the audit better at finding:

- leading silence
- trailing silence
- intra-track silence islands
- missing harmonic backbone spans
- dead gaps between phrase blocks

Then improve the repair path so those gaps can be filled coherently.

### P2.2 Reduce symmetry without randomization

The current visual/musical issue is:

- mirrored placements
- repeated identical spacing
- too many same-length loop anchors
- very similar section shapes

Add or improve repair logic so it can:

- break grid-lock by bounded timing/density changes
- preserve section identity
- keep the groove coherent
- avoid simply muting chunks and creating more silence

### P2.3 More freedom in sound choice, but bounded

Continue the v0.1.39 freedom work, but keep it disciplined.

Needed behavior:

- allow alternate candidates within a close score band
- prefer coherent alternates from sibling/compatible packs
- avoid one-source domination
- avoid the exact same loop geometry across sections
- do not replace coherence with noise

The goal is:

- more than one useful sonic idea
- less "copy-paste mirror"
- still one track, one identity

---

## 8. P3 - Harmonic Backbone In Arrangement

This remains critical.

The open project should have a real `HARMONY_*` MIDI backbone in Arrangement, not only a Session clip parked on a MIDI track.

### Required outcome

1. The harmonic MIDI track has arrangement clips, not only session clips.
2. The MIDI spans a meaningful portion of the song.
3. It reduces dead spaces rather than creating another isolated 4-bar island.
4. It behaves like harmonic glue for the project.

Again: this is "piano roll" in the FL sense, not "must sound like an acoustic piano".

---

## 9. Required Validation

Your implementation report must include all of this:

### 9.1 Code truth

- exact files changed
- exact functions changed
- short explanation of why each change was necessary

### 9.2 Live truth

Paste real live outputs after restart for:

- `get_session_info`
- `get_tracks`
- `get_track_info`
- `get_arrangement_clip_info`
- `get_device_parameters`
- `audit_project_coherence`
- `audit_current_project`

### 9.3 Before/after proof

For the open project, show before/after deltas for:

- `silence_islands`
- `grid_lock_tracks`
- `mirrored_section_pairs`
- `harmonic_backbone_status`
- `same_source_dominance_tracks`

### 9.4 Edit proof

Demonstrate at least:

1. one real Arrangement MIDI edit
2. one real bounded audio/project edit
3. one repair tool that truly touched the project

If a tool did not actually touch the project, say so.

---

## 10. Exit Criteria

Do not mark this sprint `COMPLETED` unless all of these are true:

1. Ableton and OpenCode were restarted and MCP live proof is included.
2. `get_device_parameters()` works on a real device after restart.
3. Arrangement clip inspection works on the open project.
4. At least one Arrangement MIDI edit is proven live.
5. At least one bounded repair tool is proven to actually edit the project.
6. The project audit describes symmetry/silence more faithfully than before.
7. The report is honest about what is still open.

If any of those is missing, mark the sprint `PARTIAL`.

---

## 11. Final Instruction

Optimize for:

- less mirror repetition
- less silence
- more harmonic continuity
- more freedom inside coherence
- stronger open-project editing via MCP

Do not optimize for:

- more wrappers
- more logs
- more theoretical tools without live proof
- more clips at any cost

