Architecture

Architecture Atlas

A maintainer's map of Shoal: crate boundaries, evaluation flow, kernel sessions, execution, protocols, persistence, security, and design invariants.

For
Contributors and maintainers

This handbook records how Shoal fits together: the boundaries that matter, the invariants hidden behind them, and the paths a value takes from source text to a terminal, a journal entry, or an agent. It is written to make architectural drift visible before it becomes archaeology.

Browse the collection

Books and chapters

Book 01

Orientation

Composition roots, ownership boundaries, and the fastest paths into the codebase.

2 chapters
Book 02

Language & runtime

Parsing, evaluation, values, streams, and the invariants that connect them.

13 chapters
03 Language engineHow source becomes a mode-aware AST, how the evaluator assigns meaning, and where command and expression semantics meet. 04 AST model, spans, and serializationEvery syntax node, the byte-span contract, command structure, serde shape, AST version boundary, and safe evolution workflow. 05 Lexer, parser, and formatter internalsModal tokenization, statement dispatch, Pratt precedence, command grammar, ambiguity resolutions, incomplete-input classification, and canonical formatting. 06 Evaluator state and control flowA field-by-field map of the tree-walk evaluator, statement and expression flow, scope transitions, echo semantics, and host boundaries. 07 Calls, closures, modules, and namespacesCallable dispatch, strict argument binding, closure capture, module evaluation and caching, constructors, and synthetic namespace behavior. 08 Builtin registry and command dispatchThe complete builtin inventory, dispatch precedence, typed argument path, structured filesystem commands, special verbs, outcome wrapping, and safe addition workflow. 09 Language and conformance contractThe stable authority model for Shoal syntax and semantics, executable registries, error/render contracts, and the normative TOML corpus. 10 Values, streams, and executionThe runtime value algebra, lazy stream protocol, command outcomes, process capture, PTYs, cancellation, and byte boundaries. 11 Runtime value algebraEvery Value variant, equality and condition contracts, error anatomy, feed serialization, JSON projection, rendering, and lazy CAS bytes. 12 Value method dispatchDispatch precedence, complete method families, collection and string semantics, path effects, outcome forwarding, task methods, and extension workflow. 13 Streams, channels, and backpressureThe pull protocol, single-consumption state, every/watch/tail sources, lazy stages, tee queues, channel replay, sinks, cancellation, and overflow semantics. 18 Local shell hostHow the shoal binary assembles configuration, evaluator state, line editing, completion, prompt snapshots, jobs, history, and local journal behavior. 22 Reef, adapters, and configurationProject-scoped tool resolution, lock and drift semantics, executable views, polyglot runners, declarative CLI adapters, and their host integration.
Book 03

Execution & security

Process boundaries, host behavior, effects, policy, and best-available enforcement.

4 chapters
Book 04

Kernel & agents

Sessions, wire contracts, bounded values, tasks, events, and MCP projection.

3 chapters
Book 05

Storage & tooling

Reef, adapters, configuration, journal persistence, CAS, and durable reconstruction.

6 chapters
Book 06

Maintenance

Change boundaries, known debt, test ownership, quality gates, and release discipline.

5 chapters
Type to search every guide navigate open esc close
Diagram