Data and primitivesWorkflow definitions and effects

Workflow definitions and effects

Derive application state from authorized transitions and control deferred effects.

Use a workflow to derive application state from authorized transitions and defer effects until reconciliation.

Define and validate the state machine

Define the initial state, terminal states, actions, editor requirements, guards, and conflict policy. Validate before use. Validation finds inconsistent definitions but cannot enforce every business rule. State names are application values, not Platform roles.

The guard can check form data and transition context. The receiver must derive the actor and authority from verified evidence. A client-supplied role label is not authorization.

Derive rather than overwrite

Retain transitions in an append-only hash chain and derive state by replaying accepted events against the definition. Preserve form data identity, actor, states, action, time, and predecessor evidence required by the event contract.

Receiver-side event validation checks application authority. State derivation does not persist an event or distribute it.

Handle concurrent offline decisions

Two peers can transition from the same state while disconnected. Apply the definition's deterministic conflict policy after synchronization. Derivation reports applied and skipped events, including stale transitions, undefined transitions, validation rejection, and conflict losers.

Use the workflow definition's transition semantics when resolving conflicts. Do not trust a publisher's assertion that its own transition is an approval or rejection. Preserve losing events as required by the history contract rather than silently rewriting their source.

The local UI can show a pending decision before reconciliation. It must distinguish that view from a confirmed effect.

Keep effects separate from replay

Queue effects until their transition wins the required conflict-resolution boundary. Discard effects from losing transitions. Retain failed effects with their failure result rather than erasing the transition.

A derived transition does not authorize arbitrary hardware control or prove an external action succeeded. The application owns effect handlers, credentials, idempotency, operator policy, and external acknowledgments. Replaying history must not blindly repeat irreversible actions.

Custom effect handlers and validation traits are Rust composition surfaces. Managed bindings expose only their supported workflow operations. The workflow reference owns the primitive declarations and effect states.

A workflow history event is not the same object as a low-latency notification event. An application can publish a notification about a transition without making that notification its authoritative workflow history.