Skip to main content

Module state

Module state 

Source
Expand description

Run state: the named values a graph writes, and how writes combine (docs/specs/SPEC_DRONE_GENERAL_AUTOMATION_2026_11_11.md §3.2).

Module B of the engine, with checkpoint.rs. The types and the cap are fixed here; RunState::write and the rest are the module’s job. Its acceptance tests are state_acceptance_tests.rs.

§Reducers

A variable declares how its writes combine. A name with no declaration is replace. The reducer decides the value, and merged_bits decides the taint bits of the result (the same rule for every reducer: none clears a bit).

ReducerFirst writeNext write w onto current cType error when
replacewwnever
append[w]c with w pushed as one element (a list w is one element)c is not a list
mergewshallow merge, w’s keys winc or w is not an object
addwc + w; integers stay integers (1 + 2 is 3)c or w is not a number

Structs§

RunState
StateSnapshot
What a checkpoint stores of the state: every value with its bits, and the reducer each name declared.

Enums§

Reducer
StateError

Constants§

STATE_CAP_BYTES
The state of a run is at most this many bytes of JSON (§3.2).

Functions§

add_numbers 🔒
The sum of two JSON numbers, keeping integers integers where it can.
add_value 🔒
add: numbers only; two integers stay an integer, any float makes a float.
append_value 🔒
append: the first write makes [w]; after that w is one more element.
check_name 🔒
Refuse a name that cannot be a variable: empty, with a dot, or with whitespace.
integer_of 🔒
The integer a JSON number holds, signed or unsigned, as an i128.
kind 🔒
What a value is, for the got half of a StateError::Type.
merge_value 🔒
merge: a shallow object merge, w’s keys winning. A merge channel holds objects, so the first write must be one too.
merged_bits
The bits a write leaves on a variable: no reducer clears a bit (spec 4.1 “a reducer cannot clear taint”, 4.2 “tainted if any contributing write is tainted”). With nothing there yet they are the write’s; after that they are join of the current value and the write, replace included: a clean write over a tainted value leaves it tainted, because a person cannot tell from the variable which text is still in it.
snapshot_len 🔒
The JSON length of a snapshot, the measure STATE_CAP_BYTES bounds.
type_error 🔒