A generic asynchronous Moore machine for building persistent AI agents that survive crashes, restarts, or migrations