/MRS-Specification-RFC#7-working-set-envelope
Protocol Overview
Extraction (MRS-S → Working Set)
Extraction Parameters
Extraction Algorithm
Self-Containment
The extracted:content MUST be parseable as standalone MRS-S:
- Instrument definitions included
- Time/key/tempo state declared
- Spans have both endpoints or boundary markers
Application (MRS-Ops → MRS-S)
Application Algorithm
Conflict Detection
The orchestrator uses source-hash for conflict detection:Conflict Resolution Options
| Option | Description |
|---|---|
| Reject | Return error; agent must request fresh envelope |
| Rebase | Transform operations to apply on new state (if possible) |
| Merge | Combine changes if in disjoint regions/lanes |
Progressive Validation
Operations are validated in stages:Stage 1: Syntax
- Operation type recognized
- Required fields present
- Field types correct
Stage 2: References
- All UUIDs exist in source
- All tmp-ids unique within envelope
- Cross-references valid (e.g., span “from” references “e1” that exists)
Stage 3: Permissions
- Operation type in
:allowed-ops - Content within granted
:bundlelanes - Scope within granted
:scope
Stage 4: Musical Rules
- Constraints satisfied (range, parallel fifths, etc.)
- Duration sums correct
- Ties connect same pitches
Derived Field Computation
The orchestrator computes derived fields::at (Absolute Beat Position)
For each event:
:at; orchestrator computes it.
:beat-start (Measure Start)
When measures are inserted:
Operation Ordering
Operations are applied in order. Dependencies must be respected:- Create measure before creating events in it
- Create events before creating spans referencing them
Partial Application
When some operations fail validation:- All-or-nothing: Reject entire batch on any failure
- Partial: Apply valid ops, report failures
- Interactive: Pause for human decision