Can i build somehow a finite-state machine for plug flow?

Basically all the question is in the topic. Is there an ability to decide what plug will next run?

‘a plug’ is in essence nothing more than a function (or a module exposing one ‘main’ function) that is called with the information of a certain request when it is made.

When you specify plugs in a pipeine in your routes file, these will be executed top-to-bottom. But there is nothing stopping you from writing a plug that internally calls certain other plugs, depending on some conditions. So yes, this is very possible.

Plugs are just functions. You can call them whenever and however you like.