Understanding FTM: Finite State Machines in 8 Core Ideas
The core, in 8 ideas
-
Everything is an object. Files, batches, and payments are database rows. The
STATUScolumn stores each object’s state. A file with 100 payments represents 101 objects, all using shared state-machine definitions. -
Each kind of object has a state machine. The engine selects the right machine using
SUBTYPE. For example,STATEMENT_FILEhas 11 states, from Received to Done or Rejected. -
Only events move objects. A transition defines a current state, incoming event, next state, and action. For example,
E_StmtReceivedmoves a file from Received to Extracting and runsA_StmtRequestExtraction. -
Selectors and filters determine which objects are affected. The selector identifies eligible objects by subtype and status. A filter such as
T.ID IN $Context{TRANSMISSION}ensures only the intended file is processed. -
Actions perform work but never directly change state. Actions can call Claude, validate totals, or create lines. To change state, an action raises another event.
-
Parents wait for their children. Lines and files have separate state machines. Lines process at priority 1, while the file evaluates their results at priority 2. Once every line is Valid,
A_StmtCheckFileraisesE_StmtAllValid. -
Processing is all or nothing. An event, its transition, and its action run as one transactional unit. Failures roll back the work. After three unsuccessful attempts, the message enters the fail queue. Error records survive through a separate transaction.
-
Rules are data, not code. Definitions live in database tables such as
FSM_TRANSITION. TOML provides the readable configuration, while generated SQL loads those rules. Mini Bank and Statements can therefore share the same engine.
Two additional concepts
Event flags: Logging and messaging behavior can be configured per event. A frequent heartbeat might use log = false to avoid unnecessary log volume.
Alert states: Some states require operator intervention, such as Approve, Reject, or Fix.
What comes next
- Mappers and ISF: converting external formats into FTM’s standard document.
- Executing Statements actions in practice.
- Using the operations console for alerts and approvals.
- Timers and scheduler execution.
- Calendars, routing, and permissions.
Step 2 of Statements focuses on the first three topics.
Quick knowledge check
- A line becomes Invalid. Which object transitions first, the line or the file, and why?
A_StmtCheckFilediscovers all lines are Valid. Does it directly move the file to AI Review? What happens instead?