Repository Public
1<!--2ORIX Sonata3File: Documentation/adr/0001-architecture.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# ADR 0001 — Architecture and toolchain89Status: accepted (2026-11-24).1011## Context (measured on the build machine)1213MacBook Pro, Apple M5 Max (18 cores), 48 GB, macOS 27.0 (26A5425a), Xcode 27.2 (27B52),14Swift 6.4.2, Rust 1.95.0 (aarch64-apple-darwin only), XcodeGen, create-dmg, ffmpeg/ffprobe,15afinfo/afconvert. Signing identity present: `Developer ID Application: Simon-Pierre Boucher16(3YM54G49SN)`; notarytool keychain profile used by the other ORIX apps: `MacLustr-Notarize`.17No previous Sonata repository existed.1819## Decision2021- **Rust** for everything that defines the meaning of a program: lexer, parser, semantics,22 compiler, DSP, instruments, runtime, renderer, interchange, CLI, LSP. One staticlib23 (`sonata-ffi`) exposes a C ABI.24- **Swift 6 / SwiftUI + AppKit** for the app; TextKit 2 editor; **AVAudioEngine**25 (`AVAudioSourceNode`) pulls audio from the Rust `Processor` in the render callback;26 Core Graphics first for visualisations, **Metal** where measurement justifies it27 (spectrogram, 3D waterfall). Metal never runs in the audio callback.28- The Swift side holds no musical logic: timing, parameters, diagnostics and graph come from29 the Rust crates (JSON across the ABI for cold data; plain C structs and ring buffers for hot data).30- arm64 only for 0.1. universal2 is not attempted: no Intel machine is available to test on.31- macOS deployment target 15.0, like the other ORIX apps; verified only on macOS 27.32- Vectorisation: the DSP is written as tight scalar loops that LLVM auto-vectorises (NEON).33 Accelerate/vDSP is used on the Swift side for display-only analysis if profiling asks for it;34 the Rust FFT is the reference implementation so the CLI and the app agree.35- Dependencies: serde + serde_json only in the product crates; anything else is a recorded36 exception in `Documentation/DEPENDENCIES.md`.37- The compiled artefact for 0.1 is an **execution plan interpreted by the runtime**38 (prepared graph + event lists). No machine code is generated and none is claimed.3940## Consequences4142- The engine is testable headless (`cargo test`, `sonata` CLI) and the studio cannot diverge43 from the compiler.44- A Rust toolchain is required to build the app; `Scripts/build.sh` builds the staticlib first.45- Real-time and offline rendering run the same `Processor`, so parity is by construction.46