SPB Git

Repository Public

0003-code-is-canonical.md 1.9 KB

# ADR 0003 — The code is canonical; the studio stores overrides

Status: accepted (2026-11-24).

# Context

A composition is a program. The studio lets the user move a fader, drag a note or draw one. Writing those gestures back into arbitrary source (loops, functions, random choices) cannot be done faithfully in general: one statement can produce a thousand notes.

# Decision

  • The source is the only thing the compiler reads to produce the program.
  • A gesture in the studio becomes an override stored in studio.json beside the code (sonata_ir::Overrides): strip settings by strip name; note edits addressed by track name and the note's compile index, each carrying the original start and pitch of the note it edited; added notes.
  • The compiler applies overrides after compilation. An override whose fingerprint no longer matches (the code changed that note) is reported as a conflict and skipped. It is never applied to another note and never written into the source.
  • Every override is one undoable step, can be discarded per strip, per track or globally, and deleting studio.json returns the project to exactly what the code says.
  • Things that are naturally text (applying a diagnostic's fix, formatting, inserting a library snippet, accepting an assistant proposal) are text edits, undoable in the editor.

# Consequences

  • No silent rewriting of code, ever; the round trip code → studio → code cannot lose anything.
  • Visual edits do not appear in the source. This is stated in the UI ("studio edits") and the manual; "write overrides back into the code" would be a separate, explicit command.
  • The CLI applies a project's studio.json exactly as the app does (the same Overrides::apply), so both render the same thing; --no-studio compiles the code alone.
Files main
Menu

Theme