Concepts
A quick map between statechart vocabulary and the fate API. For the why behind it, read Background & the problem and How it works.
Statechart concept → fate
| Statechart concept | fate |
|---|---|
| Atomic / compound / parallel / final state | NodeAtomic / NodeCompound / NodeParallel / NodeFinal |
| History (shallow / deep) | NodeHistory with HistoryShallow / HistoryDeep |
| Guarded transition | TransitionConfig.Guard (+ And / Or / Not / StateIn combinators) |
| Entry/exit & transition actions | Assign, Raise, Log, EnqueueActions |
Delayed (after) transitions | StateNodeConfig.After, driven by an adapter via PendingTimers / FireTimer |
| Invoked work / spawned child machines | StateNodeConfig.Invoke, driven via PendingInvocations / ResolveInvocation |
| Snapshot persistence | Actor.Persist / NewActorFromSnapshot |
| Visualisation | RenderASCII, RenderMermaid, RenderGraphJSON |
The vocabulary
Machine — the immutable, validated definition. Build once, share everywhere.
Actor — one running instance of a machine. Holds context + active configuration.
Active configuration — the set of states active together (hierarchy + parallelism mean it's a tree, not a single value). Rendered by StateValue.Path().
Context — your typed data carried alongside the state, mutated by Assign actions. A Go type of your choosing, via generics.
Event — your typed trigger. Also your own Go type.
Guard — a pure predicate gating a transition. Composable with And/Or/Not and StateIn. No side effects, no clock.
Action — what runs on entry, exit, or a transition: Assign (update context), Raise (enqueue an internal event), Log, EnqueueActions.
Effect — an intent the engine records as data: a pending timer (After) or a pending invocation (Invoke). An adapter performs it and reports the outcome back.
Building blocks at a glance
CreateMachine(MachineConfig[Ctx, Evt]) (*Machine, error)— validate & construct.NewActor(m)/NewActorFromSnapshot[Ctx, Evt](m, blob)— instantiate.Actor.Start(ctx)/Actor.Send(ctx, evt)— run the initial entry / dispatch.Actor.Snapshot()/Actor.Subscribe(...)— read / observe.Actor.Persist()— serialise to JSON.RenderASCII/RenderMermaid/RenderGraphJSON— visualisem.Describe().
Next
- Examples — each concept as runnable code.
- Per-symbol reference on pkg.go.dev.
- The studio to see configurations light up as events fire.