[PATCH 3/6] flow: Clarify and enforce flow state transitions