Skip to main content
State machines model the persistent lifecycle of data objects — the progression of an order from pending to paid or cancelled, or a transcode job from queued through running to done or failed. You declare a state machine once and then apply its transitions inside transaction steps across any number of operations. The verifier tracks which states are reachable, enforces that transitions fire only from permitted source states, and connects transition side effects to the artifact and idempotency machinery the rest of the model uses.

State machine fields

Subject

The subject declaration ties the state machine to a concrete persistent object and a field in that object’s schema:
object must reference a DataObject declared in a data model. state is the field path in the object’s schema that holds the current state value. The state machine’s declared states are the valid values of that field.

States and initial state

states is the exhaustive list of valid state identifiers for this machine. initial names the state every freshly inserted object instance begins in. The verifier uses these declarations to check that transitions start from valid source states and arrive at valid target states.

Transitions

Each transition declares: A transition fires inside a transition transaction step. The operation that applies the transition selects the concrete object instance with a subject predicate.

Side effects

Transition side effects are effect declarations that are automatically established as effect intents when the transition fires inside a transaction. The operation declares a corresponding effect_intents entry to name the intent artifact, and supplies a effect_values derivation at the transition step that provides the payload for that intent.
When an operation applies transition.video.mark_ready, it must supply effect_values for effect.video.published in the transition step:
The operation must also declare an effect_intents entry that names the side effect’s intent. The artifact is then available through execute_effect_intent in the program.
Transition side effects are never executed directly with execute_effect. They are always established as intents by the transition step and executed later through execute_effect_intent. This ensures the intent payload is captured atomically with the state change.

How transitions appear in programs

A typical pattern for state-machine-driven operations is:
1

Apply the transition inside a transaction

The transition step changes the object’s state field and atomically establishes the side-effect intents.
2

Execute the side-effect intent

After the transaction commits, an execute_effect_intent step fires the publication or request effect whose payload was captured by the transition.
3

Terminate

A return or complete step ends the operation.

A complete two-machine example

The following is the pair of state machines from the video streaming fixture — one for the video record lifecycle and one for the transcode job lifecycle.

State machines in the visualization

When you run conseqa-viz model.yaml, the visualization renders each state machine as a labeled directed graph. States appear as nodes and transitions as edges. Side effects are annotated on the relevant transition edges, making it easy to trace which state changes trigger which publications or requests. Use the --verify flag to overlay verification verdicts on the diagram.