A statechart engine for Go
fate computes state and never performs side effects. Hierarchical states, parallel regions and history, with no dependencies beyond the standard library.
In the myth, three Fates spin, measure and cut the thread of a life. A statechart does the same to a process, and fate is the part that does it the same way every time.
Write down every state and transition up front. CreateMachine validates the config and returns an immutable machine. Nothing about it changes at runtime.
Send dispatches an event and the engine computes the next configuration. No I/O, no clock, no randomness. Delays and invocations surface as data for an adapter to carry out.
A final state ends the run. At any point before it, Persist writes the actor to JSON and it restores byte for byte, so the thread can be picked up anywhere.
The same machine driven by the same sequence of operations always reaches the same active configuration and produces the same persisted bytes.
Compound and parallel states, deep and shallow history, guards, actions, and final states.
The engine imports only the standard library. The Temporal integration is a separate module.
An Actor serialises to JSON and restores byte for byte, which makes replay exact.
Delays and invocations surface as pending effects. An adapter performs them.
No side effects in the engine, so a machine survives workflow replay unchanged.
Render any machine to ASCII, Mermaid, or graph JSON, and diff two snapshots.