Skip to main content

Module checkpoint

Module checkpoint 

Source
Expand description

A checkpoint: what the engine writes after every node so a run can resume (docs/specs/SPEC_DRONE_GENERAL_AUTOMATION_2026_11_11.md §3.3).

Module B of the engine, with state.rs. The types and the limits are fixed here; encode, decode, diff and apply are the module’s job. Its acceptance tests are state_acceptance_tests.rs.

A checkpoint is stored as a diff from the one before it (§3.3, the retention paragraph); step 0 has nothing before it and is stored whole. The ceiling is MAX_STEPS checkpoints per run.

The taint bits are part of the state, and a restore never clears one: decoding then re-encoding gives back the same bits, and a value whose bits are missing in the bytes is an error (see value::Tv).

Structs§

Checkpoint
CheckpointDiff
What changed from one checkpoint to the next. Fields that did not change are absent. Variables removed are listed in removed_vars.
Fork
Where a replaying run came from: the run and the step it started at, and whether its blocks that have effects run for real. Never changes inside a run.
Frontier
The nodes of the graph by where they stand.
GraphRef
The graph version a run started on: its number and the hash of its graph (versions::graph_hash). A run keeps this however the drone is edited.
Position
Where the scheduler stands inside the graph, besides the frontier: which edges are decided, which blocks are done this pass of their loop, what each block has spent. Small, so a diff carries it whole when it changed.

Enums§

CheckpointError

Constants§

MAX_STEPS
A run has at most this many checkpoints (§3.3).
SCHEMA_VERSION
The format of an encoded checkpoint. A reader refuses a version it does not know (CheckpointError::UnsupportedVersion), so an upgrade never resumes a run from bytes it would misread.

Functions§

apply
prev with d applied: equal to the next the diff was made from.
changed_counters 🔒
The loop counters that changed. A counter for a loop guard never disappears while the run lasts (its graph is pinned), so an entry can only be added or raised, and the changed entries alone are enough to restore the map.
changed_map 🔒
The entries of next that are new or different from prev’s.
changed_state 🔒
The variables and reducers that are new or different in next.
decode
The checkpoint in bytes. A newer schema_version is CheckpointError::UnsupportedVersion (checked before the rest is read); anything else wrong is CheckpointError::Unreadable. A restored value has exactly the bits it was saved with.
diff
What changed from prev to next (next.step == prev.step + 1, same run).
encode
A checkpoint as bytes (UTF-8 JSON, so a person can read one in a bug report). Refuses step >= MAX_STEPS with CheckpointError::TooManySteps.