---
title: "Runtime"
description: "Execution model, ABI, memory, scheduling, suspension, and host integration."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.atoll.workreef.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Runtime

The Atoll runtime executes compiler-generated continuation code, isolates live
Unit instances, owns their arenas and host resources, and connects local
execution to debugging, deployment, and optional Raft-replicated services.

This section documents the current implementation. It distinguishes frozen ABI
layouts from changeable policy and calls out incomplete subsystems where the
repository contains design substrate but not an end-to-end guarantee.

## Mental model

```text
Program
├─ immutable link-group artifacts
├─ Unit manifest and ABI metadata
└─ Store fleet
   └─ Store reactor
      ├─ Wasmtime Store
      │  └─ link-group Instances and memories
      └─ UnitInstance cache
         ├─ persistent arena
         ├─ root task tree
         ├─ invocation frames
         └─ host I/O and resources
```

The most important distinctions are:

| Term | Meaning |
|---|---|
| Program | immutable compiled deployment snapshot |
| link group | one linked Wasm module, memory, and raw allocator |
| Store | one reactor thread that owns a Wasmtime Store |
| Wasm Instance | instantiated code and memory for one link group |
| Unit | compiled service definition and method table |
| Unit instance | live mutable state container for one Unit |
| arena | persistent flat allocation region owned by one Unit instance |
| frame region | temporary invocation storage inside that arena |

A runtime Unit instance is not a Wasm Instance, and an arena is not a
per-function scratch buffer. Those two distinctions explain most of the
runtime's routing, memory, and migration behavior.

## Execution

- [Architecture](https://docs.atoll.workreef.dev/runtime/architecture/) defines Program, group, Store, routing,
  concurrency, and failure boundaries.
- [Units](https://docs.atoll.workreef.dev/runtime/units/) defines Unit and Unit-instance identity, placement,
  lifecycle, eviction, and migration.
- [Execution](https://docs.atoll.workreef.dev/runtime/execution/) follows one invocation through CPS
  scheduling, task trees, suspension, cancellation, and completion.
- [ABI](https://docs.atoll.workreef.dev/runtime/abi/) records the frame header, the instance context, the
  continuation signature and its tags, and the module file.
- [Host I/O](https://docs.atoll.workreef.dev/runtime/host-io/) explains operation slots, resource handles,
  buffer pinning, and cancellation.

## Memory

[Memory](https://docs.atoll.workreef.dev/runtime/memory/) introduces the complete memory hierarchy:

- [Arenas](https://docs.atoll.workreef.dev/runtime/memory/arenas/) covers growth, relocation, generations,
  snapshots, and failure cleanup.
- [Flat Values](https://docs.atoll.workreef.dev/runtime/memory/flat/) covers canonical offset-based value and
  collection layouts.
- [Ownership](https://docs.atoll.workreef.dev/runtime/memory/ownership/) covers compiler ownership modes,
  reference counting, reuse, and precise cycle collection.

## Operations

- [Deployment](https://docs.atoll.workreef.dev/runtime/deployment/) covers link-group topology, atomic
  cutover, selective Store replacement, state-preserving redeploy, migration,
  and draining.
- [Debugger](https://docs.atoll.workreef.dev/runtime/debugger/) covers DAP sessions, source safepoints,
  continuation-aware stepping, paused-instance isolation, stacks, and
  variables.
- [Clustering](https://docs.atoll.workreef.dev/runtime/clustering/) covers Raft proposals, database apply,
  follower forwarding, watermarks, subscriptions, and current limitations.

## Guarantees

The runtime provides:

- single-mutator execution for one Unit instance;
- bounded invocation and cluster-writer queues;
- arena-relative state that survives memory relocation;
- explicit suspension and resume through generated continuations;
- generation-checked host resource handles;
- isolated Program snapshots during redeploy;
- explicit compatibility rejection for unsafe state migration.

The runtime does not turn instance memory into durable storage, make local
singleton placement cluster-wide, or roll back arbitrary external effects after
timeout or cancellation.

## Status language

Pages use these terms consistently:

- **ABI contract** means compiler and runtime must change together.
- **runtime invariant** means the implementation depends on the property for
  correctness.
- **policy** means a configurable or replaceable current choice.
- **current limit** means the end-to-end behavior is not implemented even when
  supporting types or design documents exist.

In particular, clustering currently recovers through log replay rather than
nonempty Raft snapshots, and workflow event-await integration is incomplete.

## Sources

The primary implementations are `atoll-abi`, `atoll-runtime`,
`atoll-hosts`, `atoll-heap`, `atoll-heap-wasm`, `atoll-dap`, and
`atoll-cluster`. `atoll-runtime-wasm`, the previous host, is deleted. The
layout constants in `atoll-abi` and their compile-time assertions take
precedence over stale legacy documentation.

Source: https://docs.atoll.workreef.dev/runtime/index.mdx
