Build harnesses/agents with State Machines
[https://youtu.be/uMvTAF280so](https://youtu.be/uMvTAF280so)
If you can flowchart it, you can use a FSM/statechart for it.
^(Bias alert: I have contributed to David's XState long ago, & have my own FSM solutions in JS.)