Make a long-running workflow restartable: apply events idempotently, checkpoint state, and reject impossible transitions.
Required APIdef apply_workflow_events(events):
return {'status': ..., 'effects': [...], 'applied': [...], 'errors': [...]} BehaviorThink through the mechanism first if you want the extra reasoning step. It never blocks the editor.
apply_workflow_events([{'id': 's', 'type': 'start'}, {'id': 'c', 'type': 'charge'}, {'id': 'c', 'type': 'charge'}, {'id': 'd', 'type': 'complete'}])replay does not duplicate a side effect
apply_workflow_events([{'id': 'd', 'type': 'complete'}])['errors']a workflow cannot skip its state contract
2 hidden edge tests run after the visible contract passes.
Run Tests to see the contract verdicts here.