Expand description
The behavior virtual machine: an authored Behavior
compiled to slot-resolved form, and the evaluator that runs it.
compile resolves every authored name to a dense slot once, producing a
Program; exec runs a program’s body against a View of what the
body may read this tick. Evaluation mutates nothing: it appends Effects
the caller applies afterwards, which is what lets bodies run concurrently
without observing each other’s writes.
BehaviorSystem is what drives the two over a world each tick: it gathers
the view, runs the bodies, and applies their effects. Nothing below reads a
clock, a file, or a device, which is why the whole of it sits in the
vocabulary rather than in a host. Where persisted state is kept
(BehaviorStore) and how a tick’s runs fan out (EvalScheduler) are the
host’s to supply; a world with neither runs its behaviors serially and
persists nothing.
Structs§
- Behavior
State - The behavior state a world carries between runs.
- Behavior
System - Runs a world’s
Behaviorcomponents: their firing rules, their bodies, and the effects those produce. - CNode
- A slot-resolved node with its compile-assigned identity:
idis the node’s pre-order position across the whole body, indexing the program’spathstable so execution tracing can address the node the way the world checker’s faults do. - Eval
Bucket - One worker’s share of a tick’s evaluation: a contiguous slice of the tick’s job list, its own effect and trace buffers, and its own binding scratch. Opaque to a scheduler, which only hands each bucket to the closure it was given. Everything inside keeps its capacity across ticks.
- Program
- One compiled behavior.
- Spawn
Effect - A requested copy of a template.
- VarTable
- The world’s variables, in slot order: shared across behaviors, so slots are
assigned once across the whole set. A name the world’s
Variablesasset declares carries that declaration’s type and starting value; any other name a behavior mentions is an integer starting at zero. - View
- What a behavior may read this tick.
Enums§
- Arith
- How two numbers combine.
- CExpr
- A slot-resolved expression.
- COp
- A slot-resolved node operation.
- Cmp
- How two values compare.
- Effect
- One world change a behavior asked for, in body order.
- Val
- A value flowing through a behavior body.
Traits§
- Behavior
Store - Where a host keeps persisted behavior state.
- Eval
Scheduler - Runs a tick’s evaluation buckets, in any order and on any thread.
Functions§
- compile
- Compile one authored behavior against the world’s shared variable table,
interning any variable name it mentions that no
Variablesasset declared. - def_
hash - Content hash of a behavior definition. Asset identity is excluded (its serde skip), so a restored fired flag applies to the behavior it was saved for and to no other.
- exec
- Run a compiled body against
view, appending what it asked for toout.