The Turn Book
The complete guide to Turn v0.5.0-alpha — from installation to building production-grade multi-agent systems.
Part 0 · Before You Start
Why Turn was built and how to get it running.
Part 1 · The Process
How Turn executes — the actor model, runtime, and core primitives.
Hello Turn
A step-by-step trace of your first Turn program: env, memory, context, call, and return.
Grammar
Formal syntax — statements, expressions, blocks, and type annotations.
Minimal Core
The smallest set of primitives the language needs to exist.
Runtime Model
VM execution model, actor scheduler, suspension/resumption, and durable state.
Part 2 · Intelligence
Turn's killer innovations — inference as a typed primitive, semantic memory, and context management.
The infer Primitive
Cognitive Type Safety — how infer generates schemas at compile time and validates LLM output.
Inference Providers
The Wasm sandbox architecture, official providers, and how to write your own driver.
Context Window
The Priority Stack, token budget, and Entropic Expansion Policy — bounded context by construction.
Memory & Recall
Persistent semantic memory backed by HNSW vectors and Ebbinghaus temporal decay.
Part 3 · Multi-Agent
Building swarms of coordinating, fault-tolerant agents.
Reference
Complete language reference.
Types & Errors
Type system, Result/Option monads, Uncertain<T>, and cognitive confidence traps.
Error Handling
Monadic error routing and stochastic failure patterns.
Modules
The module system, use declarations, and package management.
Design Mandate
The philosophy, constraints, and design principles of the Turn language.
Implementation
Compiler pipeline, bytecode instruction set, and VM internals.
LSP
Language Server Protocol integration and editor support.