/MRS-Specification-RFC#5-mrs-ops-the-mutation-protocol
Why Typed Operations?
Asking agents to emit complete MRS-S fragments creates failure modes:- Accidental omission: Agent returns less content → content silently deleted
- Calculation errors: Miscomputed
:atvalues, duration sums - Hallucinated references: IDs that don’t exist
- UUID management: Agent must generate valid, non-colliding UUIDs
- Explicit operations: Create, update, delete are distinct (no omission risk)
- Orchestrator-derived fields: Agent provides beat; orchestrator computes
:at - Temporary IDs: Agent uses tmp-ids; orchestrator assigns UUIDs
- Minimal surface: Only changed content in output
MRS-Ops Envelope
| Field | Required | Description |
|---|---|---|
:version | YES | Protocol version |
:scope-hash | YES | Hash of source Working Set (conflict detection) |
:base-revision | NO | Revision ID of source state |
:ops | YES | List of operations |
Operation Types
Create Event
| Field | Required | Description |
|---|---|---|
:tmp-id | YES | Temporary ID (orchestrator maps to UUID) |
:measure | YES | Target measure UUID |
:instrument | YES | Target instrument ID |
:voice | YES | Target voice |
:beat | YES | Beat position (rational, e.g., 0, 2+1/2) |
:pitch | YES | Pitch or chord or r for rest |
:duration | YES | Duration code (q, h, e, etc.) |
| Other properties | NO | :dyn, :art, :orn, :tech, etc. |
Update Event
| Field | Required | Description |
|---|---|---|
:id | YES | Existing event UUID |
:set | YES | List of (field value) pairs to update |
Delete Event
Create Span
- Existing UUIDs:
#uuid "018c3f2a-..." - Temporary IDs from same operation set:
"e1"
Update Span
:from, :to, :events) are immutable. To change endpoints, delete and recreate the span.
Delete Span
Create Measure
:number, and computes :beat-start.
Delete Measure
Instrument Change
Temporary ID Rules
- Tmp-ids MUST be strings starting with a letter:
"e1","span-a","m1" - Tmp-ids are scoped to a single MRS-Ops envelope
- Operations MAY reference each other’s tmp-ids within same envelope
- Orchestrator maps all tmp-ids to UUIDs before application
- Response includes the tmp-id → UUID mapping
Task-Adaptive Context Views
Context views provide task-relevant information beyond the edit scope. Unlike fixed rings, views are selected for the specific task.Melodic Reference
Harmonic Context
Orchestration Map
Phrase Structure
View Selection by Task Type
| Task Type | Typical Context Views |
|---|---|
| Compose | phrase-structure, harmonic-context, thematic-references |
| Countermelody | melodic-reference, harmonic-context |
| Orchestrate | orchestration-map, dynamics-profile |
| Harmonize | melodic-reference, phrase-structure |
| Dynamics | phrase-structure, dynamics-profile |
Example: Add Countermelody
Working Set Envelope (agent receives):Lane Bundles
Lane bundles grant permissions for common workflows:| Bundle | Lanes | Use Case |
|---|---|---|
orchestrate | notes, expression, technique | Full orchestration |
dynamics-pass | expression | Dynamics only |
notation-cleanup | notes, technique | Fix notation |
full-compose | all creative lanes | Full control |
Constraint Language
| Constraint | Description |
|---|---|
range | Notes within instrument range |
avoid | Prevent voice-leading errors |
prefer | Style preferences |
max-interval | Maximum melodic leap |
note-density | Notes per measure |