The authoring guides teach how to write Motive. Understand derives why those programs mean what they mean: which geometry owns behavior, how one stimulus becomes one commit, and which facts remain authoritative afterward.
Read the system beneath the API
A statechart is more than a convenient syntax for branching. It is a finite semantic model with explicit ownership, deterministic transition selection, atomic publication, typed completion, and stable structural identity. Those laws remain the same whether an instance runs in memory, in a browser, or under a durable cluster engine.
Use this section when the surface syntax is already recognizable but the consequence is not. It answers questions such as “which transition wins?”, “was that intermediate state observable?”, “what exactly completed?”, and “why did this edit produce a new chart identity?”
Choose the question you need to answer
The Diagnostics guide completes the section by locating refusals, typed failures, author defects, and operational failure at their owning boundaries.
See the authorities together
The small chart below keeps five related authorities visible without collapsing them:
- the chart is the declarative topology;
- a state owns one meaningful situation and its local data;
- an instance is one independently addressed run;
- a snapshot is that instance's committed state at one sequence;
- the engine owns execution, lifetime, and failure-model guarantees.
The source and controls address the same running instance. The diagram shows current topology; the diary shows committed macrosteps. Neither display invents an uncommitted intermediate world.
import { State, Statechart, StatechartEngine, States, Transitions } from "@motive/motive";
import { Layer, Schema } from "effect";
export const Toggle = Schema.TaggedStruct("Toggle", {});
export const Reset = Schema.TaggedStruct("Reset", {});
class Switch extends State.Compound<Switch>()("Switch") {
static states = States.make(() => [Off, On]);
}
class Off extends State.Atomic<Off>()("Off") {
static transitions = Transitions.make(this, ({ on }) => [on(Toggle, On)]);
}
class On extends State.Atomic<On>()("On") {
static transitions = Transitions.make(this, ({ on }) => [on(Toggle, Off), on(Reset, Off)]);
}
export const SwitchChart = Statechart.make(Switch);
export const SwitchLive = SwitchChart.toLayer().pipe(
Layer.provideMerge(StatechartEngine.layerMemory),
);
Starting the live chart…
Where understanding leads
Return to the authoring category that owns the construct when you need to change a model. Continue to Recipes when several established surfaces must become one application pattern, or use Reference when you already know the concept and need its exact owning module.