/MRS-Specification-RFC#13-progressive-validation
Validation Pipeline
Stage 1: Syntax Validation
Verifies operations are well-formed.| Check | Description |
|---|---|
| Operation type | Recognized operation (create-event, update-event, etc.) |
| Required fields | All required fields present |
| Field types | Values have correct types |
| Rational format | Beat positions are valid rationals |
Syntax Errors
| Code | Description |
|---|---|
| SYN-001 | Unknown operation type |
| SYN-002 | Missing required field |
| SYN-003 | Invalid field type |
| SYN-004 | Malformed rational number |
| SYN-005 | Invalid tmp-id format |
Stage 2: Reference Validation
Verifies all references are valid.| Check | Description |
|---|---|
| UUID existence | Referenced UUIDs exist in source |
| Tmp-id uniqueness | All tmp-ids unique within envelope |
| Cross-references | Ops can reference each other’s tmp-ids |
| Measure reference | Target measure exists |
Reference Errors
| Code | Description |
|---|---|
| REF-001 | UUID not found in source |
| REF-002 | Duplicate tmp-id |
| REF-003 | Tmp-id referenced but not defined |
| REF-004 | Circular reference |
Stage 3: Permission Validation
Verifies operations are within granted permissions.| Check | Description |
|---|---|
| Operation allowed | Op type in :allowed-ops list |
| Lane permission | Content within granted lanes |
| Scope bounds | Targets within granted scope |
| Lock respect | Not modifying locked lanes |
Permission Errors
| Code | Description |
|---|---|
| PERM-001 | Operation type not allowed |
| PERM-002 | Lane not granted |
| PERM-003 | Outside granted scope |
| PERM-004 | Modifying locked lane |
Stage 4: Musical Rule Validation
Verifies musical constraints are satisfied.Structural Rules
| Rule | Severity | Description |
|---|---|---|
| STRUCT-001 | ERROR | Would create duplicate UUID |
| STRUCT-002 | ERROR | Invalid measure number |
| STRUCT-003 | ERROR | Beat position out of bounds |
| STRUCT-004 | ERROR | Duration overflow (exceeds measure) |
| STRUCT-005 | WARNING | Gap in measure numbering |
Musical Rules
| Rule | Severity | Description |
|---|---|---|
| MUSIC-001 | ERROR | Tie connects different pitches |
| MUSIC-002 | ERROR | Span endpoints reversed (from > to) |
| MUSIC-003 | WARNING | Pitch out of instrument range |
| MUSIC-004 | WARNING | Parallel fifths/octaves |
| MUSIC-005 | WARNING | Voice crossing |
| MUSIC-006 | WARNING | Large melodic leap (> octave) |
Constraint Rules
| Rule | Severity | Description |
|---|---|---|
| CONST-001 | ERROR | Violates range constraint |
| CONST-002 | WARNING | Violates avoid constraint |
| CONST-003 | INFO | Does not satisfy prefer constraint |
Severity Levels
| Level | Meaning | Action |
|---|---|---|
| ERROR | Invalid; cannot apply | Operation rejected |
| WARNING | Suspicious; may be intentional | Apply with warning |
| INFO | Informational; style suggestion | Apply; log info |
Validation Results
All Pass
Errors Found
Warnings Only
Constraint Validation
Constraints from the Working Set Envelope are checked in Stage 4.Range Constraint
Avoid Constraint
Prefer Constraint
Density Constraint
Partial Application
When some operations fail:| Policy | Behavior |
|---|---|
all-or-nothing | Reject entire batch on any error |
partial | Apply valid ops; return errors for invalid |
interactive | Pause and await human decision |
Best Practices
For Agent Implementers
- Validate operations locally before sending
- Use tmp-ids consistently within envelope
- Respect constraints from Working Set
- Handle partial success gracefully
For Orchestrator Implementers
- Run all stages; collect all errors
- Provide specific, actionable error messages
- Include operation index in errors
- Support configurable severity thresholds