Skip to main content

Module runtime

Module runtime 

Source
Expand description

Deterministic cooperative task scheduling (spec section 9.5, FND-005).

Tasks are boxed closure state machines: each poll runs one step and returns a TaskState telling the scheduler what to do next. The executor is deliberately std-only and single-threaded — no tokio, no worker threads — because a production runtime schedules on OS threads and reads the real clock, which would make runs irreproducible. When several tasks are ready, the runtime’s seeded SimRng picks the next one, so the seed fixes the interleaving.

crate::scenario::Scenario builds process crash/restart on top: crashing a node drops its task bodies (volatile state) while the node’s VirtualDisk keeps exactly the fsynced prefix.

Structs§

NodeContext
The single-node view handed to a task step: virtual time, a seeded stream, the network, the node’s disk, and the scenario event log.
Runtime
The cooperative executor: a clock, a seeded stream, and the tasks.

Enums§

TaskState
What a task wants after a step.

Type Aliases§

TaskBody
One step of a cooperative state machine. Captured variables are the task’s volatile state: they vanish when the owning process crashes.
TaskId
A task handle within a Runtime.