Design Mandate
Status: Locked. This document defines the mission, philosophy, and design constraints for the Turn language. Every specification and implementation decision must align with the principles stated here.
What Turn Is
Turn is a systems language for agentic computation. It is not a wrapper around an existing language, and it is not a framework. Turn's execution model is purpose-built around the five realities of agentic software: long-lived processes, finite context capacity, stochastic inference, explicit effects, and durable state.
The language exists because current tools force developers to encode agentic behavior using loops, lists, async patterns, and ad-hoc state management. That approach produces fragile systems where critical constraints are implicit and mechanically unenforceable. Turn makes those constraints first-class language primitives with runtime guarantees.
TIP
Turn is object-oriented by capability and encapsulation. Value objects (structs with methods) and process objects (a PID with a mailbox and durable state) serve as the primary organizing units.
The Problems We Solve
When you build agentic software in existing languages, you encounter a set of recurring failure modes that stem from a fundamental mismatch between the programming model and the domain:
- Context is not first-class. Developers manage context with plain lists and manual trimming. Information gets lost in the middle of long conversations, and there is no runtime enforcement of capacity limits.
- Memory is not first-class. Agent memory lives in ad-hoc external stores with no standardized interface for remembering, recalling, or forgetting. Each project reinvents this from scratch.
- Turns and tool calls are not first-class. Agent loops are hand-rolled with
while Truepatterns and fake suspension mechanisms. There is no language-level concept of a "turn" as a unit of work. - State is smeared across variables and frameworks. It is difficult to reason about what the agent knows, what it has done, and what it will do next when state is scattered across closures, databases, and API responses.
- The mental model is wrong. You think in turns and context windows. You code in loops and lists. The gap between how you reason about agents and how you implement them is where bugs live.
Turn closes this gap by making the process, its context, its memory, its turn boundaries, and its effects explicit language constructs with runtime-enforced invariants.
What We Optimize For
| Dimension | Goal |
|---|---|
| Tokens | Bounded context by construction. The runtime enforces |context| ≤ N so that context overflow is impossible by design. |
| Performance | Rust bytecode VM from day one. No Python interpreter overhead, no JavaScript event loop contention. Single static binary. |
| Determinism | The core language is deterministic. Non-determinism is quarantined at effect boundaries (call, infer). Given the same inputs, you get the same state transitions. |
| Security | Governance is in scope from the start. Tool permissions, memory policies, and capability boundaries are language-level constructs, not afterthoughts. |
| Boilerplate | No hand-rolled agent loops. One turn, one context, one memory — the language wires the plumbing so you can focus on behavior. |
| Observability | Because turns and context are primitives, traces are structural and standard. No ad-hoc logging — the runtime knows what happened at every step. |
How the Spec Reflects This
Each specification document maps directly to a design constraint:
- Minimal Core defines the smallest set of primitives the language needs, so that every feature earns its place and there is no retrofit baggage.
- Grammar specifies one obvious way to form a turn and interact with context, memory, and tools. The syntax reflects the domain, not general-purpose traditions.
- Runtime Model defines a single configuration tuple with a single transition rule. State is serializable. Context is bounded. Execution is reproducible.
- Types and Errors introduces cognitive type safety for LLM inference and monadic error handling for stochastic failures.
IMPORTANT
Turn is built in Rust from day one as a bytecode VM. Not Python, not TypeScript. Those languages' runtime overhead contradicts the design goals. Rust provides native speed, minimal memory footprint, a single static binary, and true concurrency without a global interpreter lock.