State machines
A state machine declares states, transitions, and terminal conditions. The compiler verifies reachability and detects deadlocks at build time.
Declaration
cleat
state PRReview { initial: Pending Pending -> InReview { when: assigned } InReview -> Approved { when: approved && ci_green } InReview -> ChangesRequested { when: changes_needed } Approved -> Merged { when: merge_complete } any -> Cancelled { when: closed } terminal: Merged, Cancelled }
Clauses
| Clause | Description |
|---|---|
initial: | Starting state |
From -> To { when: condition } | Transition with guard condition |
any -> | Matches all source states |
terminal: | States where the machine can stop |
Compiler enforcement
- Reachability: every state must be reachable from
initial - Deadlock detection: non-terminal states must have outgoing transitions
- Terminal states: at least one terminal state required