tentative generic state machine

will need nix's help with this