/MRS-Specification-RFC#12-orchestrator-contract
Orchestrator Architecture
Orchestrator Responsibilities
| Responsibility | Description |
|---|---|
| UUID minting | Maps tmp-ids to UUIDs; sole authority for ID creation |
| Derived fields | Computes :beat-start, :at, reconciles inherited state |
| Progressive validation | Validates operations in stages before application |
| Canonical state management | Maintains canonical score semantics; applies validated changes |
| Context generation | Creates task-adaptive context views |
| Conflict detection | Uses source-hash to detect concurrent modifications |
| Audit trail | Records all changes with attribution |
Edit Lanes
Lanes are permission boundaries that determine what an agent may modify.| Lane | Owns |
|---|---|
structure | Measure list, sections, movements |
temporal | Tempo map, time signatures |
harmonyPlan | Chord symbols, harmonic analysis |
notes | Pitches, durations, rests |
expression | Dynamics, hairpins, slurs |
technique | Articulations, playing techniques |
lyrics | Lyrics, syllables |
What Each Lane Controls
| Lane | Can Create/Modify | Cannot Touch |
|---|---|---|
structure | Measures, sections, movements, repeats | Event content |
temporal | Tempo, time signatures, metric modulations | Notes, spans |
harmonyPlan | Chord symbols, key areas, harmonic rhythm | Note pitches |
notes | Pitches, durations, rests, voice assignment | Dynamics, slurs |
expression | Dynamics, hairpins, slurs, phrasing | Pitches, technique |
technique | Articulations, playing techniques, ornaments | Pitches, dynamics |
lyrics | Lyric text, syllabification, alignment | Pitches |
Lane Bundles
Common workflows grant multiple related lanes:Bundle Selection by Task Type
| Task Type | Recommended Bundle |
|---|---|
| Compose melody | notes or full-compose |
| Add countermelody | orchestrate |
| Orchestrate sketch | orchestrate |
| Add dynamics | dynamics-pass |
| Shape phrases (slurs) | expression |
| Add articulations | technique |
| Write lyrics | lyrics-pass |
| Fix notation | notation-cleanup |
Progressive Validation
Operations are validated in stages before application:Stage 1: Syntax Validation
- Operation is well-formed
- Required fields present
- Types correct
Stage 2: Reference Validation
- All referenced UUIDs exist in source
- All tmp-ids are unique within envelope
- Cross-references between ops are valid
Stage 3: Permission Validation
- Operation within granted lanes
- Operation within granted scope
- Operation type is allowed
Stage 4: Musical Rule Validation
- Constraints satisfied (range, avoid parallel fifths)
- Duration sums correct
- Ties connect same pitches
/MRS-Specification-RFC#13-progressive-validation
Conflict Detection
The orchestrator uses source-hash to detect concurrent modifications:Conflict Resolution Options
| Option | When to Use |
|---|---|
| Reject | Default safe behavior; agent must retry with fresh envelope |
| Rebase | If operations can be transformed to apply on new state |
| Merge | If changes are in disjoint regions/lanes |
Transaction Model
Every change is recorded:- Audit trail: Who changed what, when
- Rollback: Revert to previous state
- Replay: Reconstruct state from transactions
Checkpoints and Locks
Lock approved decisions to prevent regression:- Agents cannot modify locked lanes
- Validation rejects operations that touch locked content
- Human approval required to unlock
Typical Checkpoint Flow
Operation Application
When validation passes, the orchestrator applies operations:- Map tmp-ids to UUIDs in deterministic order
- Compute derived fields (
:at,:beat-start) - Update canonical score state (and export MRS-S if needed)
- Update structural index if needed
- Record transaction in audit trail
- Return result with id-mapping
Application Order
Operations are applied in the order received. Dependencies must be satisfied:- Create measure before creating events in it
- Create events before creating spans that reference them
Partial Application
When some operations fail validation:- All-or-nothing: Reject entire batch if any operation fails
- Partial: Apply valid operations, return errors for invalid
- Interactive: Pause for human decision on errors
Human Review Gates
Certain operations should trigger human review by default:| Trigger | Reason |
|---|---|
| Structure changes | Form is foundational |
| Temporal changes | Affects timing across the score |
| Locked lane touched | Checkpoint protection |
| Conflict detected | Cannot auto-resolve safely |
- a rendered excerpt of the affected region, and/or
- a playback preview (e.g., MIDI/rendered audio)