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

ClauseDescription
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

Edit this page on GitHub