
Runecraft
The realtime floor: shared contracts, realtime safety, process isolation and logging.
Runecraft is the component that holds the shared contracts and the realtime and cross-process primitives every other component builds on. It is part of Signals & Sorcery, a coherent set of Rust audio building blocks for audio apps, plugins, players and DAWs.
| Repository | github.com/shiehn/runecraft-audio-core |
|---|---|
| License | MIT, free for commercial and closed-source use |
| Status | In preparation |
| Layer | The floor (how the layers stack) |
| Crates (planned names) | runecraft |
What it is
Every audio component needs the same small, sharp set of tools: types that two crates (or two processes) agree on, a way to prove the audio thread never allocates, a way to hand data to and from that thread without locks, and a way to talk to a helper process without sharing its fate. Runecraft is that set, written once, with every unsafe block in one place and every safety contract written down.
It has four parts:
- Shared contracts. Plain data types and traits with no dependencies and no unsafe code: log records and levels (the enabled check is one relaxed atomic load, safe on the audio thread), a fixed 64-byte realtime event record, and a state digest trait. Audio buffers, channel layouts, timestamped events, parameter ids and the processor lifecycle are planned.
- Realtime safety. An allocation guard for debug and test builds (allocate inside a
RealtimeScopeand the process stops with a clear message), a wired arena of locked memory with a deferred free, loom-checked handoffs (a single-slot mailbox and SPSC rings), a one-word realtime lock, flush-to-zero floating-point scopes, thread priority and memory calls, a host clock, and a stderr writer that never panics on a closed pipe. - Process isolation. Unlinked shared memory accessed only through bounds-checked atomics, a doorbell the audio thread rings without allocating, child processes with process groups and parent watch, a control channel split into owned send and receive halves that can pass descriptors, and peer credentials.
- Realtime-safe logging. Non-realtime code formats only after the level check and sends to a bounded queue that drops and counts when full. Realtime threads push fixed records into their own rings. One drainer writes rotating JSON Lines files.
Usage example
Most users meet Runecraft through a component above it. You use it directly when you write your own realtime code and want the same guarantees.
Illustrative sketch
This is the planned shape of the public API, taken from the README. It is not final.
use runecraft::alloc_guard::{GuardedAlloc, RealtimeScope};
use runecraft::fpu::FzScope;
use runecraft::handoff::ring;
// Opt in to the allocation guard (it only checks in debug and test builds).
#[global_allocator]
static ALLOC: GuardedAlloc = GuardedAlloc;
// A ring from the control thread to the audio thread.
let (mut to_audio, mut from_control) = ring::<ParamChange>(4096);
// Control thread: push changes; a full ring is the caller's decision, never a wait.
to_audio.push(ParamChange { id, value })?;
// Audio callback:
fn callback(&mut self, out: &mut [f32]) {
let _rt = RealtimeScope::enter(); // any allocation in here now stops the process in tests
let _fz = FzScope::enter(); // denormals flush to zero, restored on return
from_control.drain(|change| self.apply(change));
self.render(out);
}
A supervisor of a helper process uses the isolation part:
use runecraft::ipc::{channel_pair, Mapping, spawn};
let (region, fd) = Mapping::create(region_len)?; // unlinked shared memory
let (parent, child_end) = channel_pair()?; // the control channel
let child = spawn(&program, &args, child_end)?; // the child gets its end, nothing else
let (mut tx, mut rx) = parent.bind(child.pid())?; // owned halves for two threads
tx.send(&hello_frame, &[&fd.into()])?; // hand the region to the child
How it fits in the ecosystem
Runecraft is the bottom row, the floor, next to Orrery. Dependencies point down, never up.
Below it: nothing. It depends on no other component. The realtime floor depends on libc (and windows-sys on Windows). The contracts depend on nothing.
Above it: everything else may depend on it.
- Summoner (repo) uses the contracts, the realtime helpers and the whole process-isolation part today.
- Leyline (repo) will use the arena and the handoffs to publish new graphs without locks.
- Aethergate (repo) will use the floating-point scopes and thread calls in its device callbacks.
- Cantrips, Scriptorium, Tapestry and Procession will build on its rules and handoffs.
- Grimoire (repo) will install the log and wire every component's records to it.
Because unsafe code lives here and only here, the components above can be #![forbid(unsafe_code)].
What it deliberately doesn't do: no audio processing (not even a gain), no devices, files or projects, no async runtime, and no competing with good crates. Where rtrb, basedrop or assert_no_alloc does the job, use it; Runecraft's parts exist so the components share one set of rules.
| Component | Repository | Role | Status |
|---|---|---|---|
| Runecraft | runecraft-audio-core | Shared contracts, realtime safety, process isolation and realtime-safe logging: the floor every other component stands on | In preparation |
| Orrery | orrery-musical-time | Tempo and meter, transports, bar, beat and sample maths, timed MIDI | In preparation |
| Summoner | summoner-plugin-host | Out-of-process VST3 and Audio Unit plugin hosting with crash isolation | In preparation |
| Aethergate | aethergate-audio-platform | Audio devices (cpal, CoreAudio, a fake device for tests) and shared-memory meters | Planned |
| Leyline | leyline-audio-graph | A realtime audio graph with delay compensation, and a compiler from an edit model to a graph | Planned |
| Cantrips | cantrips-audio-dsp | Built-in mixer DSP: sampler, fader, pan, meters, compressor | Planned |
| Scriptorium | scriptorium-audio-media | Decode and encode, a sample store, streaming voices, crash-safe recording | Planned |
| Tapestry | tapestry-session-model | Tracks, clips, lanes and scenes; edits with undo; a crash-safe project store | Planned |
| Procession | procession-timeline-engine | What plays in each block: regions, notes, automation, launches | Planned |
| Grimoire | grimoire-daw-engine | The assembled engine and its headless JSON-RPC protocol | Planned |
| Familiar | familiar-plugin-sdk | An SDK for plugins and panels that extend a Signals & Sorcery engine | Planned |
| Glyphwork | glyphwork-audio-ui | Audio UI widgets: meters, knobs, faders, waveforms | Planned |
Status
In preparation. The parts described above exist and are tested, but they live in another repository today, under working crate names. Published names and some signatures may change before the first release.
| Part | macOS | Linux | Windows |
|---|---|---|---|
| Shared contracts | yes | yes | yes |
| Realtime safety | yes, used daily on Apple silicon | code paths exist, compile-checked | code paths exist |
| Process isolation | yes | compile-checked; the doorbell falls back to polling for now | planned |
| Logging | yes | not yet tested | not yet tested |
Links
- Repository: github.com/shiehn/runecraft-audio-core (README, LICENSE)
- Beside it on the floor: orrery-musical-time
- Used by: summoner-plugin-host, aethergate-audio-platform, leyline-audio-graph, cantrips-audio-dsp, scriptorium-audio-media, tapestry-session-model, procession-timeline-engine, grimoire-daw-engine
- All twelve components · For agents · llms.txt