Repository Public
1<!--2ORIX Sonata3File: Documentation/adr/0003-code-is-canonical.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# ADR 0003 — The code is canonical; the studio stores overrides89Status: accepted (2026-11-24).1011## Context1213A composition is a program. The studio lets the user move a fader, drag a note or draw one.14Writing those gestures back into arbitrary source (loops, functions, random choices) cannot be15done faithfully in general: one statement can produce a thousand notes.1617## Decision1819- The source is the only thing the compiler reads to produce the program.20- A gesture in the studio becomes an **override** stored in `studio.json` beside the code21 (`sonata_ir::Overrides`): strip settings by strip name; note edits addressed by track name and22 the note's compile index, each carrying the original start and pitch of the note it edited;23 added notes.24- The compiler applies overrides after compilation. An override whose fingerprint no longer25 matches (the code changed that note) is **reported as a conflict and skipped**. It is never26 applied to another note and never written into the source.27- Every override is one undoable step, can be discarded per strip, per track or globally, and28 deleting `studio.json` returns the project to exactly what the code says.29- Things that are naturally text (applying a diagnostic's fix, formatting, inserting a library30 snippet, accepting an assistant proposal) are text edits, undoable in the editor.3132## Consequences3334- No silent rewriting of code, ever; the round trip code → studio → code cannot lose anything.35- Visual edits do not appear in the source. This is stated in the UI ("studio edits") and the36 manual; "write overrides back into the code" would be a separate, explicit command.37- The CLI applies a project's `studio.json` exactly as the app does (the same `Overrides::apply`),38 so both render the same thing; `--no-studio` compiles the code alone.39