System Overview
The system consists of three main components:Core Principles
1. Daemon as Source of Truth
The runtimed daemon owns all runtime state. Clients (UI, agents, CLI) are views into daemon state, not independent state holders.If the daemon restarts, clients automatically reconnect and resync their state.
- Clients subscribe to daemon state, they don’t maintain parallel copies
- State changes flow through the daemon, not peer-to-peer between clients
- Multiple windows editing the same notebook see each other’s changes in real-time
2. Automerge Document as Canonical State
The Automerge document is the source of truth for notebook content: cells, their sources, metadata, and structure. All clients sync to this shared document. Implications:- Cell source code lives in the Automerge doc
- To execute a cell: write it to the doc first, then request execution by
cell_id - The daemon reads from the doc when executing, never from ad-hoc request parameters
3. On-Disk Notebook as Checkpoint
The.ipynb file on disk is a checkpoint/snapshot that the daemon periodically saves. It is not the live state.
Flow:
- Daemon reads
.ipynbon first open, loads into Automerge doc - Daemon writes
.ipynbon explicit save or auto-save intervals - Unknown metadata keys in
.ipynbare preserved through round-trips - Crash recovery: last checkpoint + Automerge doc replay
4. Binary Separation via Manifests
Cell outputs are stored as content-addressed blobs with manifest references. This keeps large binary data (images, plots) out of the sync protocol. Benefits:- Output broadcasts contain blob hashes, not inline data
- Clients resolve blobs from the blob store (disk or HTTP)
- Large outputs don’t block document sync
- Manifest format allows lazy loading and deduplication
Multi-Process Design
Why Multiple Processes?
Each notebook window runs as a separate OS process. This provides:- Isolation: A crash in one notebook doesn’t affect others
- Resource management: OS can manage memory per-window
- Independent windowing: Each window is a full application instance
Coordination Challenge
Without coordination between processes:- Race conditions: Multiple windows try to claim the same prewarmed environment
- Wasted resources: Each window creates its own pool of environments
- Slow cold starts: First notebook waits for environment creation
- Lost state: Closing a window loses kernel state
Communication Protocol
All daemon communication goes through a single Unix socket (or named pipe on Windows) with channel-based routing.Handshake-Based Multiplexing
Connections start with a JSON handshake declaring their channel:| Channel | Purpose | Lifetime |
|---|---|---|
Pool | Environment pool operations | Short-lived |
SettingsSync | Automerge sync messages for settings | Long-lived |
NotebookSync | Automerge sync messages for notebooks | Long-lived |
Blob | Binary blob writes | Short-lived |
Framing Protocol
Platform Paths
The daemon uses platform-appropriate directories:| Platform | Cache Directory | Config Directory |
|---|---|---|
| Linux | ~/.cache/runt/ | ~/.config/runt/ |
| macOS | ~/Library/Caches/runt/ | ~/Library/Application Support/runt/ |
| Windows | %LOCALAPPDATA%\runt\ | %APPDATA%\runt\ |
Key Files
| File | Purpose |
|---|---|
daemon.lock | Singleton mutual exclusion |
daemon.json | Running daemon state (endpoint, PID, version) |
daemon.log | Daemon logs |
runtimed.sock | Unix socket for IPC |
settings.automerge | Settings CRDT document |
notebook-docs/{hash}.automerge | Notebook CRDT documents |
envs/ | Prewarmed environments |
blobs/ | Content-addressed blob store |
Service Management
The daemon runs as a user-level service:| Platform | Mechanism |
|---|---|
| macOS | launchd user agent (~/Library/LaunchAgents/io.nteract.runtimed.plist) |
| Linux | systemd user service (~/.config/systemd/user/runtimed.service) |
| Windows | VBS script in Startup folder |
CLI Commands
CLI Commands
Benefits of This Architecture
Instant Startup
Prewarmed environments mean notebooks open in milliseconds, not seconds.
Multi-Window Sync
Edit the same notebook in multiple windows with real-time synchronization.
Persistent State
Close a window and the kernel keeps running. Outputs are preserved.
Resource Efficiency
Share environment pools across all notebooks instead of duplicating.
Next Steps
Daemon
Learn about the runtimed background daemon
Environments
Understand environment management
Synchronization
Explore CRDT-based sync
Kernels
Deep dive into kernel management