Re:Versioned Finite-State Machines with PostgreSQL (2019)
by wchargin on Thursday July 25, 2024 @04:25PM
(#41072991)
Hmm… consider the following. Your FSM is acyclic iff you can assign each state an integer depth such that a state at depth d only ever transitions to states at depths strictly greater than d. So consider the following tables:
Let's bang on it for a quick test. You can define a state machine; here's one that roughly matches the regex `^(AB|BA)$` (I know I'm being a bit sloppy):
And, as you need to modify it, you can increase a node's depth to make room for intervening nodes:
But you can't decrease a node's depth too far:
And you can't introduce transitions that don't increase depth:
Now, I don't know that I would immediately recommend this for high-throughput production use. You're storing "unnecessary" state not once but many times (each state's depth appears `1 + \deg(v)` times), plus additional indices and lookups. But I do think it meets the desired consistency goals!
[ Parent
| on HN ]
Re:Versioned Finite-State Machines with PostgreSQL (2019)
by zinclozenge on Saturday July 27, 2024 @11:19AM
(#41087135)
Amazing! I also learned about domains with your comment.