Skip to content

Rules of Workflows

Idempotency

Ensure API calls with side effects are idempotent to prevent duplicates.

Granular Steps

Break workflows into small, self-contained units of work.

State Management

Store state through step outputs, not in-memory variables.

Event Immutability

Never mutate incoming events, create new state instead.

Before performing non-idempotent operations (e.g., payments), verify the operation hasn’t already been completed. This is crucial for handling potential retries correctly. See Retry Policies.

Each step should perform a single, cohesive unit of work that can be retried independently. See Developing Workflows for more on structuring steps.

Store state exclusively through step outputs rather than local variables that exist only in memory. The engine persists the output of completed steps (flow.do).

Never mutate incoming events. Create and return new state when changes are needed. This aligns with Event-Sourced Architecture principles.

Give each step a stable, unique identifier rather than one based on timestamps or randomness. This supports Deterministic Execution.

Granularity

Divide workflows into small, self-contained steps.

Idempotency

Check before performing non-idempotent operations.

State Management

Persist state only via step outputs.

Immutability

Treat events as immutable, return new state for changes.