Skip to content
State machine (FSM) templates

Teaching Case — A Machine and a Coin Toss

Two transitions leave `Review` on the same event and nothing tells them apart. The document does not say which one runs, so this is not a state machine: it is a state machine and a coin toss, and it draws as two perfectly ordinary arrows leaving one box. The engine also refuses the false positive next door — the fork out of `Draft` carries a guard on each branch, which makes it deterministic, and the engine says nothing about it.

Template previewState machine (FSM)
Review workflow5 states · 6 transitions · 4 eventssubmit [complete]submit [incomplete] / list gapsdecidedecideescalate [over threshold]overrideDraftReviewApprovedRejectedEscalated1 statement in this machine cannot be true of any run.ERROR`Review` has 2 transitions on "decide", to `Approved` and `Rejected`, and none of them carries a guard. Nothing in the document says which one runs, so this is a machine and a coin toss — andit draws as 2 perfectly ordinary arrows.OKAll 5 states are reachable from `Draft`.OKEvery run from `Draft` can reach a final state.OKAll 6 transitions name states that exist, so every arrow in the figure is drawn.

Make it your own.

title "Review workflow"

state Draft
state Review
state Approved final
state Rejected final
state Escalated

initial Draft

transition Draft  -> Review    on "submit" [complete]
transition Draft  -> Draft     on "submit" [incomplete] / list gaps
transition Review -> Approved  on "decide"
transition Review -> Rejected  on "decide"
transition Review -> Escalated on "escalate" [over threshold]
transition Escalated -> Approved on "override"