Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 2.25 KB

File metadata and controls

43 lines (34 loc) · 2.25 KB

State — where it lives outside this repo

Cited, real implementations to study (or point an agent at) when designing or reviewing state-machine code.

Python standard library

Libraries built on the pattern

  • transitions (pytransitions) — the most-used Python FSM library: declarative tables, guards ("conditions"), callbacks, hierarchical machines — this module's StateMachine grown to production size. github.com/pytransitions/transitions (unverified)
  • django-fsm / viewflow.fsm — lifecycle guards on Django model fields: @transition(source, target) decorators putting the table next to the model it rules. github.com/viewflow/django-fsm (unverified)

The classic specification

  • TCP's connection diagram (RFC 9293 §3.3.2) — LISTEN, SYN-SENT, ESTABLISHED, TIME-WAIT... the state machine every networked program rides on, specified as exactly a transition table. rfc-editor.org/rfc/rfc9293 (unverified)

What to notice across all of them

The serious ones publish their table (TCP's diagram, pytransitions' declaration) rather than burying motion rules in methods — the machine you can read whole is the feature. And each distinguishes state from data: asyncio keeps a task's result out of its state set the same way a guard keeps amount_paid out of an order's.