[PATCH v5 01/19] flow: Clarify and enforce flow state transitions