Skip to main content

RFC 0001 — Version 1.0

Status: Draft
Created: 2025-12-12
Updated: 2026-01-17
Authors: MRS Working Group
License: CC BY 4.0

Abstract

This document specifies MRS (Music Representation), a model and protocol suite for encoding and safely editing musical scores in AI-assisted composition and orchestration workflows at professional scale. MRS is built on three core architectural principles:
  1. Separation of storage and mutation formats: MRS-S is the canonical storage format; MRS-Ops is the typed operation protocol for agent mutations
  2. Player-Instrument-Staff model: Professional orchestration semantics with instrument doubling and switching
  3. Task-adaptive context: Dynamic context views tailored to specific editing tasks, not fixed reduction rings
The key insight is that reliable AI-assisted composition requires different optimizations for reading scores (complete, archival MRS-S) versus writing changes (typed, validated operations). Agents read MRS-S fragments with task-appropriate context views; agents write typed operations that the orchestrator validates progressively and applies deterministically. Every musical object carries a stable UUID identifier. The orchestrator is the sole authority for UUID minting, derived field computation, and canonical state management. This eliminates entire classes of agent errors (hallucinated references, calculation mismatches, accidental deletions) while maintaining full semantic fidelity.

Table of Contents

  1. Introduction
  2. Design Principles
  3. Architecture Overview
  4. MRS-S: The Canonical Storage Format
  5. MRS-Ops: The Mutation Protocol
  6. Players, Instruments, and Staves
  7. Working Set Envelope
  8. Task-Adaptive Context Views
  9. Structural Index
  10. Analytical Overlays
  11. Data Model
  12. Orchestrator Contract
  13. Progressive Validation
  14. Query Resolution
  15. Extension Mechanisms
  16. MIME Types and File Extensions
  17. Security Considerations
  18. Appendix A: Complete Grammar
  19. Appendix B: Quick Reference
  20. Appendix C: Glossary

1. Introduction

1.1 Motivation

AI cannot currently compose or edit full orchestral scores reliably. Three fundamental challenges block progress: Scale: A full orchestral score (~1.5M tokens) exceeds any context window. Editing measure 847 should not require loading measures 1-846. Context: Musical decisions require understanding surrounding material. An agent writing a countermelody needs phrase boundaries, harmonic rhythm, and thematic relationships—not just the target measures. Reliability: Existing approaches ask AI to emit complete, structurally-valid score fragments. This creates high failure rates from:
  • Accidental omissions (agent returns less than given)
  • Calculation errors (duration sums, absolute positions)
  • Hallucinated references (IDs that don’t exist)
  • Format violations (malformed syntax)
MRS solves these through architectural separation:
  • MRS-S (storage): Complete, archival-quality encoding with stable UUIDs
  • MRS-Ops (mutation): Typed operation protocol with orchestrator-derived fields
  • Task-adaptive context: Dynamic views tailored to specific editing tasks
  • Progressive validation: Operations validated before application
  • Orchestrator authority: Single source of truth for UUIDs, derived fields, and state

1.2 Goals

  1. Semantic completeness: Encode everything a professional engraver needs (Dorico-level granularity)
  2. Reliable agent output: Typed operations with progressive validation minimize repair loops
  3. Structural stability: UUIDs survive insertions, deletions, and reorderings
  4. Professional orchestration: Player/instrument model supports doubling, switching, condensing
  5. Task-appropriate context: Agents receive information relevant to their specific task
  6. Deterministic reconciliation: Operations produce predictable, auditable results
  7. Human-auditable: Operations are semantic diffs; humans review intent, not syntax

1.3 Non-Goals

  1. Encoding visual layout (page breaks, staff spacing, collision avoidance)
  2. Providing a programming language (no loops, conditionals, macros)
  3. Defining audio synthesis or playback behavior
  4. Replacing domain-specific formats (MIDI, audio, engraving source)

1.4 Terminology

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

2. Design Principles

2.1 Separation of Concerns: Storage vs Mutation

MRS uses different representations optimized for different purposes: Rationale: Asking agents to emit complete, valid score fragments creates high failure rates. Typed operations with orchestrator-derived fields eliminate entire error classes.

2.2 Orchestrator Authority

The orchestrator is the sole authority for:
  • UUID minting (agents use temporary IDs)
  • Derived field computation (:at, :beat-start, :sec-start)
  • Canonical state management
  • Validation and application of changes
Rationale: Centralized authority eliminates coordination failures. Agents cannot create invalid references or miscalculate derived fields.

2.3 Stable Identity Over Positional Reference

Every measure, event, and span carries a stable UUIDv7 identifier. Measure numbers are display properties for human navigation, not structural identity. Rationale: Positional references break when content is inserted or deleted. UUID references survive structural changes.

2.4 Progressive Validation

Operations are validated in stages before application:
  1. Syntax: Operation is well-formed
  2. References: All referenced IDs exist (or are valid tmp-ids)
  3. Permissions: Operation is within granted lanes/scope
  4. Musical rules: Content satisfies constraints
  5. Application: State mutation (guaranteed to succeed after validation)
Rationale: Errors caught before state mutation enable specific feedback and partial acceptance.

2.5 Task-Adaptive Context

Agents receive context views tailored to their specific task, not fixed “near/far” rings. Context is information needed to make correct decisions, not just nearby measures. Rationale: Fixed rings may include irrelevant content and omit critical content. Task-adaptive views provide what’s actually needed.

2.6 Professional Orchestration Semantics

The Player → Instrument → Staff model supports:
  • Instrument doubling (Flute 2 / Piccolo)
  • Mid-score instrument changes
  • Transposition handling across changes
  • Percussion kits
  • Condensing and divisi
Rationale: Arrangers and orchestrators work with players and instrument changes constantly. This is not an edge case.

3. Architecture Overview

3.1 System Architecture

3.2 Data Flow

3.3 The Scale Problem

No context window can hold a full orchestral score. MRS solves this through bounded extraction with task-adaptive context.

4. MRS-S: The Canonical Storage Format

MRS-S is an S-expression format optimized for complete semantic fidelity, human readability, and archival quality.

4.1 Document Structure

All top-level sections except overlays, alternatives, and layout are REQUIRED. Sections MUST appear in the order shown.

4.2 Version Declaration

The version number follows semantic versioning (MAJOR.MINOR). Parsers MUST reject documents with unsupported major versions.

4.3 Metadata Section

Required Metadata Fields

Optional Metadata Fields

4.4 Measures Section

Measure Attributes

4.5 Event Syntax

Note: The :at field (absolute position) is NOT required in storage. It is computed by the orchestrator when needed:
This eliminates a class of calculation errors and reduces storage size.

Pitch Expression

Duration Codes

Dotted: append . (e.g., q. = 3/2 beats) Double-dotted: append .. (e.g., q.. = 7/4 beats)

Rational Beat Positions

Beat positions MUST be exact rationals. The canonical form is:
Decimal literals (e.g., 2.5) are NOT permitted.

Event Properties

4.6 Spans Section

Spans define relationships between events across time.

Span Types

4.7 Tuplet Syntax

4.8 Grace Notes

4.9 Directions

4.10 Movements

4.11 Alternatives (Ossia, Variants)

4.12 Layout Hints (Optional)

Layout hints are NON-NORMATIVE suggestions for rendering engines.

5. MRS-Ops: The Mutation Protocol

MRS-Ops is the typed operation protocol for agent mutations. Agents read MRS-S but write MRS-Ops.

5.1 Design Rationale

Asking agents to emit complete MRS-S fragments creates failure modes:
  • Accidental omission: Agent returns less content than given → content deleted
  • Calculation errors: Miscomputed :at values, duration sums
  • Hallucinated references: IDs that don’t exist
  • UUID management: Agent must generate valid, non-colliding UUIDs
MRS-Ops eliminates these by:
  • 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

5.2 Operation Envelope

5.3 Operation Types

5.3.1 Create Event

5.3.2 Update Event

5.3.3 Delete Event

5.3.4 Create Span

Span endpoints can reference:
  • Existing UUIDs: #uuid "018c3f2a-..."
  • Temporary IDs from same operation set: "e1"

5.3.5 Update Span

Note: Span endpoints (:from, :to, :events) are immutable after creation. To change endpoints, delete and recreate the span.

5.3.6 Delete Span

5.3.7 Create Measure

The orchestrator:
  • Assigns UUID and :number
  • Computes :beat-start based on position
  • Updates subsequent measures if needed

5.3.8 Delete Measure

Warning: Deleting a measure deletes all events within it. Spans with endpoints in the deleted measure become invalid.

5.3.9 Instrument Change

5.4 Temporary ID Rules

  1. Temporary IDs MUST be strings starting with a letter: "e1", "span-a", "m1"
  2. Temporary IDs are scoped to a single MRS-Ops envelope
  3. Operations within the same envelope MAY reference each other’s tmp-ids
  4. The orchestrator maps all tmp-ids to UUIDs before application
  5. Responses include the tmp-id → UUID mapping

5.5 Operation Ordering

Operations are applied in order. Dependencies must be respected:
  • Create measure before creating events in it
  • Create events before creating spans that reference them
The orchestrator MAY reorder operations to satisfy dependencies if unambiguous.

5.6 Example: Add Countermelody

Agent receives Working Set with clarinet part (empty) and violin melody (in context). Agent returns:
Orchestrator response:

6. Players, Instruments, and Staves

MRS uses a three-level model for professional orchestration semantics.

6.1 The Model

Player: A human performer. May play multiple instruments (doubling). Instrument: A specific sound source with fixed transposition, range, and technique set. Staff: Visual representation. An instrument may use multiple staves (piano) or share a staff (condensed scores).

6.2 Players Section

6.3 Instruments Section

6.4 Transposition Specification

6.5 Instrument Changes

When a player switches instruments mid-score:
The orchestrator:
  • Validates the player owns the target instrument
  • Handles transposition changes automatically
  • Updates display (instrument name in score)

6.6 Percussion Kits

6.7 Referencing in Measures

In measure content, use instrument ID (not player ID):

7. Working Set Envelope

The Working Set Envelope provides agents with bounded MRS-S content plus task-appropriate context.

7.1 Envelope Structure

7.2 Envelope Fields

Required Fields

Scope Specification

Scope uses UUIDs for structural stability. Display hints are for human orientation only.

Permission Fields

Optional Fields

7.3 Content Self-Containment

The :content of a Working Set Envelope MUST be parseable as standalone MRS-S:
  • Instrument definitions MUST be included
  • Time/key/tempo state at extraction start MUST be declared
  • Spans MUST have both endpoints within scope OR be marked with boundary markers

7.4 Boundary-Crossing Spans

When a span crosses the envelope boundary:
Boundary-marked spans are read-only at their boundary endpoints. Agents MAY NOT modify :from, :to, or :events of boundary-marked spans.

8. Task-Adaptive Context Views

Context views provide task-relevant information beyond the edit scope. Unlike fixed “near/far” rings, views are selected and shaped for the specific task.

8.1 Design Rationale

Different tasks need different context:
  • Countermelody: The melody being responded to, harmonic rhythm
  • Orchestration: What other instruments are playing, texture density
  • Dynamics: Phrase structure, existing dynamics, climax points
  • Slur shaping: Articulation context, phrase groupings
Fixed rings waste tokens on irrelevant content and may omit critical content. Task-adaptive views provide what’s actually needed.

8.2 Context View Types

8.2.1 Melodic Reference

Provides the melody line(s) the agent should respond to:

8.2.2 Harmonic Context

Provides harmonic information (chord symbols, key areas):

8.2.3 Orchestration Map

Shows what instruments are active and their texture:

8.2.4 Phrase Structure

Provides phrase boundaries and form:

8.2.5 Dynamics Profile

Provides dynamics trajectory:

8.2.6 Thematic References

Provides motif/theme information:

8.3 View Selection by Task Type

The orchestrator selects context views based on task type:

8.4 Available Queries

Agents may request additional context via queries:
Query request (in agent response):
The orchestrator may grant or deny queries based on scope and permissions.

9. Structural Index

The Structural Index provides global awareness without loading the full score.

9.1 Index Structure

9.2 Index Fields

9.3 Index Derivation

The structural index can be:
  • Derived automatically from the score (partial)
  • Enhanced by overlays (harmonic analysis, thematic analysis)
  • Manually annotated (form labels, section names)

10. Analytical Overlays

Overlays attach analytical metadata to score regions without modifying the score itself.

10.1 Overlay Structure

10.2 Overlay Types

10.3 Overlay Lifecycle

Overlays may be:
  • Persistent: Stored with the score
  • Session: Valid only for current editing session
  • Derived: Recomputed after score changes

11. Data Model

11.1 Core Types

11.2 Identifier Rules

  1. UUIDs: All measures, events, and spans carry UUIDv7 identifiers under :id
  2. Instrument IDs: Match regex [a-z][a-z0-9-]* (e.g., flute-1, clarinet-bb)
  3. Player IDs: Match regex [a-z][a-z0-9-]* (e.g., woodwind-2, percussion-1)
  4. Voice IDs: v1 through v4, or :rh/:lh for keyboard
  5. Temporary IDs: Strings starting with letter, scoped to operation envelope

11.3 Immutability Rules

Once assigned:
  • :id is immutable for the lifetime of the object
  • Span endpoints (:from, :to, :events) are immutable
  • Measure :beat-start is orchestrator-managed (not directly editable)

11.4 Rational Number Representation

All temporal positions use exact rationals:
Implementations MUST treat rationals as exact; no floating-point approximation.

12. Orchestrator Contract

The orchestrator is the central coordinator that makes AI-assisted composition and orchestration safe and reliable.

12.1 Orchestrator Responsibilities

12.2 Edit Lanes

Lanes are permission boundaries that determine what an agent may modify.

12.3 Lane Bundles

Common workflows grant multiple related lanes:

12.4 Conflict Detection

The orchestrator uses source-hash to detect conflicts:

12.5 Transaction Model

All changes are recorded in an append-only transaction log.

12.6 Checkpoints and Locks

Lock approved decisions to prevent regression:
After checkpoint, agents cannot modify locked lanes.

13. Progressive Validation

Operations are validated in stages before application.

13.1 Validation Pipeline

13.2 Validation Stages

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, etc.)
  • Duration sums correct
  • Ties connect same pitches

13.3 Validation Results

13.4 Partial Application

When some operations fail validation:
The orchestrator MAY apply valid operations and reject invalid ones, or reject the entire batch (configurable policy).

13.5 Validation Rules

Structural Rules

Musical Rules

Permission Rules


14. Query Resolution

The orchestrator translates human-friendly references to UUIDs.

14.1 Query Types

Measure number resolution:
Rehearsal mark resolution:
Rehearsal mark with offset:
Range resolution:

14.2 Reverse Resolution

UUID to display information:

15. Extension Mechanisms

15.1 Custom Properties

Events, spans, and directions support custom properties with x- prefix:

15.2 Namespace Extensions


16. MIME Types and File Extensions

16.1 MIME Types

16.2 File Extensions

16.3 Encoding

MRS documents MUST be encoded in UTF-8. BOM SHOULD NOT be used.

17. Security Considerations

17.1 Input Validation

Parsers MUST validate:
  • Maximum document size
  • Maximum nesting depth
  • Maximum event count per measure
  • Valid Unicode in strings

17.2 Denial of Service Protection

Implementations SHOULD protect against:
  • Deeply nested structures
  • Very large measure numbers
  • Excessive span counts
  • Malformed UTF-8

17.3 Information Disclosure

Working Set Envelopes may expose:
  • Source document structure
  • Source document hash
  • Creator/modifier identity
Implementations SHOULD allow redaction of sensitive metadata.

Appendix A: Complete Grammar

A.1 MRS-S Key Productions

A.2 MRS-Ops Key Productions


Appendix B: Quick Reference

B.1 Duration Codes

B.2 Dynamics

B.3 Articulations

B.4 Ornaments

B.5 Lane Bundles

B.6 Context View Types


Appendix C: Glossary


End of Specification