Notebook Format
Notebooks are JSON files with the.ipynb extension following the nbformat specification.
Basic Structure
Cell Types
Code Cells
Executable code with input and output.execution_count: Number assigned when cell executes (null if never executed)source: Array of source code linesoutputs: Array of output objectsmetadata: Cell-specific metadata
Markdown Cells
Formatted text using Markdown syntax.Raw Cells
Unformatted text passed through unchanged.Output Format
Code cells can produce multiple types of outputs:Stream Output
Stdout and stderr text streams.stdout or stderr
Display Data
Rich media outputs (images, HTML, etc.).Execute Result
Return value of the executed code.Error Output
Exception tracebacks.Metadata Extensions
nteract Desktop extends notebook metadata for environment and sync management.Environment Configuration
runt.env_id: Per-notebook identifier for environment isolationuv.dependencies: UV/pip package specificationsconda.dependencies: Conda package specificationsconda.channels: Conda channel priority
Inline dependencies make notebooks fully portable. Anyone opening the notebook gets the same environment.
Trust Signature
Dependencies are signed to prevent untrusted code execution:metadata.uv and metadata.conda using a per-machine HMAC key.
Widget State
ipywidgets state for restoring interactive controls:Notebook State in Memory
While the.ipynb file is the durable format, nteract Desktop maintains notebook state in an Automerge CRDT document for multi-window sync.
Automerge Document Schema
sourceuses AutomergeTexttype for character-level concurrent editingoutputsare manifest hashes (or inline JSON in older notebooks)- Cell
idis the primary identifier (stable across moves)
Cell Source Editing
When you edit cell source:- Local edit → Update Automerge Text CRDT
- Myers diff → Generate minimal character-level patch
- Sync to daemon → Send Automerge sync message
- Daemon persists → Write to
~/.cache/runt/notebook-docs/{hash}.automerge - Broadcast to peers → All other windows receive the change
- Merge conflicts → Automerge automatically resolves concurrent edits
Automerge uses operational transformation (OT) semantics for text, ensuring that concurrent edits from multiple users merge correctly without conflicts.
Output Storage
nteract Desktop uses a two-level system for outputs to avoid bloating the CRDT.Output Manifests
Outputs are described by manifests that reference content:ContentRef
Content can be inlined or referenced:- Below → inline in manifest
- Above → store in blob store
Blob Store
Content-addressed storage at~/.cache/runt/blobs/:
- Outputs don’t bloat Automerge sync
- Clearing outputs removes hashes, not large data
- Deduplication (same image used in multiple cells)
File Operations
Opening a Notebook
- Read .ipynb file → Parse JSON
- Load into Automerge → Populate cells, source, metadata
- Import outputs → Construct manifests, store blobs if needed
- Connect to room → Join notebook sync room in daemon
- Sync from peers → Receive any changes from other windows
Saving a Notebook
- Read from Automerge → Get current cell state
- Resolve outputs → Fetch manifests, inline or decode blobs
- Serialize to JSON → Construct valid nbformat structure
- Write .ipynb file → Atomic write (temp file + rename)
- Preserve metadata → Unknown keys are passed through unchanged
The
.ipynb file is always a valid Jupyter notebook. The blob store is an optimization, not a dependency.Auto-Save
When enabled, notebooks are automatically saved at intervals:- Default interval: 2 minutes
- Trigger: Cell execution, content changes
- Debouncing: Rapid changes are batched
Metadata Preservation
nteract Desktop preserves unknown metadata keys during round-trips: Input notebook:Notebook Migration
From Jupyter Lab/Classic
Notebooks created in other Jupyter environments work directly:- Open the
.ipynbfile - nteract reads existing outputs and displays them
- First execution may prompt for dependency trust
- Save writes back valid nbformat
Schema Versioning
The Automerge schema has a version field:"1"— Initial schema with inline JSON outputs"2"— Output manifest hashes (when implemented)
Best Practices
Keep notebooks under version control
Keep notebooks under version control
Notebooks are JSON text files that work well with Git:Tip: Consider using
nbstripout to remove outputs before committing for cleaner diffs.Use inline dependencies for portability
Use inline dependencies for portability
Inline dependencies make notebooks self-contained:
- Add packages via dependency panel
- Commit the notebook with metadata
- Share the file — recipients get the same environment
requirements.txt or environment.yml needed.Save before sharing
Save before sharing
Unsaved changes exist only in the Automerge document:
- Make edits
- Execute cells
- Save (Cmd+S / Ctrl+S)
- Share the
.ipynbfile
Clear sensitive outputs
Clear sensitive outputs
Outputs are stored in the notebook file:Clear outputs before committing if they contain secrets:
- Edit → Clear All Outputs
- Save
- Commit
Troubleshooting
Notebook won't open
Notebook won't open
Symptoms: Error message or blank screen when openingCauses:
- Corrupted JSON
- Invalid nbformat version
- Missing required fields
- Open in a text editor
- Validate JSON syntax
- Check
nbformatfield is 4 - Ensure
cellsarray exists
Changes not syncing between windows
Changes not syncing between windows
Check:
- Both windows connected to daemon (
runt daemon status) - Same
notebook_id(check daemon logs) - Network/IPC not blocked
Outputs missing after save
Outputs missing after save
Cause: Blob store cleared but notebook still references blobsSolution: Re-execute cells to regenerate outputs, then save.Prevention: Don’t manually delete
~/.cache/runt/blobs/ while notebooks are open.Next Steps
Synchronization
Learn about CRDT-based sync
Kernels
Understand kernel execution
Environments
Manage dependencies
Architecture
View system overview