---
title: "Advanced Step Guarantees"
description: "What Dex saves for each Step method, when a method runs again or ends with an unknown outcome, how SYNC and ASYNC durability differ, and how cancellation, completion, and Step order work."
canonical_url: "https://docs.superdurable.io/evaluate-dex/correctness-and-expressiveness/advanced-step-guarantees/"
source: "docs/content/concepts/step/advanced-guarantees.mdx"
locale: "en"
---

> Index of every page for AI agents: https://docs.superdurable.io/llms.txt

# Advanced Step Guarantees

Read this page once Steps run in parallel, take a long time, or use ASYNC
durability. [Step](https://docs.superdurable.io/concepts/step.md) covers the guarantees every Step has.

<a id="what-dex-saves"></a>

## What Dex saves

In short: a method's writes are saved together, but they are not isolated from
other Steps and RPCs.

Dex saves each `WaitFor` or `Execute` call on its own. It saves the call's
Attribute writes and Channel publications together with its result, and only
when the method succeeds. Calls to external systems are not part of this save.

A method reads the state as of dispatch; Dex does not recheck it at commit. Two
methods that read then write one Attribute must both lock it. See
[Attribute locks](https://docs.superdurable.io/concepts/primitives/attribute.md#locking).

<a id="state-snapshot"></a>

### State snapshot

A method's **state snapshot** is the Flow state that Dex passes to it: every
ordinary Attribute, the size of every Channel, and the AttributeMap values and
pending Channel messages that its `StepOptions` select. Dex takes it when it
hands attempt 1 to a Worker. A retry of `Execute` reuses that snapshot, so it
does not see Attribute writes made since then. To wait for such a write, have
the writer publish a Channel message, and wait for it in the next Step's
`WaitFor`. Hard-delete Attributes are the exception: Dex reads them again on
every attempt. See
[Storing credentials](https://docs.superdurable.io/concepts/primitives/attribute.md#hard-delete-attributes).

A Step also keeps its declared locks through retry backoff and while a retry waits for a Worker. RPCs that need one of those keys can exhaust their lock wait before the retry runs.

<a id="failure-and-redelivery"></a>

<a id="heartbeats-not-acknowledged"></a>

<a id="same-attempt-redelivery"></a>

<a id="unknown-outcome"></a>

<a id="design-for-redelivery"></a>

<a id="failure-and-redelivery-summary"></a>

## Failure and redelivery

In short: when a method's outcome is uncertain, Dex runs the method again or tells you the outcome is unknown.

These cases repeat a method or leave its outcome unknown. They hold for every
SDK:

- **A Worker stops in the middle of a method.** The attempt fails, and the
  retry policy runs the method again. Its external calls may already have
  happened. A server restart or failover does the same to every attempt that
  a Worker had.
- **Heartbeats are fire-and-forget.** A heartbeat checkpoint can be lost, so a
  rerun can start from an older checkpoint. Key each external effect by a
  stable ID, never by the checkpoint alone.
- **An ASYNC Step can repeat an attempt.** See
  [SYNC and ASYNC Steps](https://docs.superdurable.io/evaluate-dex/correctness-and-expressiveness/advanced-step-guarantees.md#sync-and-async).
- **Retries can run out without an answer.** The recovery Step then learns
  that the work certainly did not run (`NOT_STARTED`) or that it may have
  run (`NOT_COMPLETED`). On `NOT_COMPLETED`, check the target system by
  the idempotency key before you repeat or report the effect.

Failure and redelivery in the SDK reference gives the exact rules for each
case: [Python](https://docs.superdurable.io/reference/python/failure-and-retries.md#failure-and-redelivery) ·
[Go](https://docs.superdurable.io/reference/go/failure-and-retries.md#failure-and-redelivery) ·
[Java](https://docs.superdurable.io/reference/java/failure-and-retries.md#failure-and-redelivery) ·
[TypeScript](https://docs.superdurable.io/reference/typescript/failure-and-retries.md#failure-and-redelivery) ·
[Rust](https://docs.superdurable.io/reference/rust/failure-and-retries.md#failure-and-redelivery).

<a id="sync-and-async"></a>

## SYNC and ASYNC Steps

A Step's **durability** chooses when Dex stores its progress.

- **SYNC** is the default. A SYNC Step waits for two log commits: the attempt
  start, before the Worker receives the task, and the result, before the Flow
  moves on. Each commit is one write to object storage. Dex groups the
  commands that are ready at the same moment into one commit, so a commit can
  carry the work of many Flows.
- **ASYNC** lets the Worker receive the task before Dex saves the attempt's
  start and lets the Flow move on before Dex saves the result. If a Dex Server
  node fails before the attempt start is saved, Dex can run the same attempt
  number again on a new state snapshot, so it can read different Attribute
  values. If the start was saved and its result was lost, an interrupted
  attempt can consume a retry, and a method retry reuses the ordinary snapshot.
  Keep ASYNC methods idempotent. See the default for
  [`commit.batchWindow`](https://docs.superdurable.io/reference/server/configuration.md#performance-tuning).
- **A lost ASYNC result reruns later work only up to the first SYNC Step.** Dex
  writes a Flow's commands to its log in order. Once a SYNC Step's start is
  stored, every earlier command of that Flow is stored too, so a SYNC Step that
  a Worker has received does not run again because of a lost ASYNC result.

Choose **SYNC** for effects that need the tightest guarantees. Choose
**ASYNC** for short Steps where latency matters and a rare rerun is
acceptable. Good ASYNC candidates are fast reads, internal bookkeeping, and
calls that a key already makes safe to repeat. Keep **SYNC** for a payment,
an email, or any call whose rerun on a newer snapshot could send different
arguments. A `StepOptions` setting picks the durability of one Step, and
`FlowConfig` sets it for a whole Flow.
[Performance](https://docs.superdurable.io/evaluate-dex/performance.md) gives measured
latency for both.

<a id="cancellation-completion-order"></a>

## Cancellation, completion, and order

Canceling a Step discards everything its current method has not saved: its
Attribute writes, its Channel publications, and its decision. What its
`WaitFor` already saved stays. A decision or an RPC never cancels the Steps that it
starts itself.
[Canceled Steps return consumed messages](https://docs.superdurable.io/reference/server/data-primitive-semantics.md#canceled-step-messages)
says what happens to the messages a canceled Step consumed.

A canceled method's code keeps running until the method returns, and its
external calls still take effect. The method should check for cancellation and
return. See
[Step cancellation](https://docs.superdurable.io/reference/server/step-and-flow-close.md#step-cancellation).

<a id="cancel-a-publishing-step"></a>A canceled Step publishes nothing, and
its failure route does not run. The Step or RPC that cancels it cannot publish
on its behalf either. Dex decides which Steps to cancel only when it saves the
result that cancels them. By then the canceled Step may already have
published. So do not cancel a Step whose publications other Steps depend on,
such as the token holder in a [Critical Section](https://docs.superdurable.io/design-patterns/parallel/critical-section.md).
To stop such a Step early, send it a stop request that it checks, such as an
Attribute that an RPC sets.

`GracefulComplete` ends its own branch and asks Dex to complete the Flow once no
Step is active. The request stays in force: a later branch that ends with
`DeadEnd` does not withdraw it. See
[Completion requests](https://docs.superdurable.io/reference/server/step-and-flow-close.md#completion-requests).

A Flow with no active Step keeps running until a `GracefulComplete` is pending, and an RPC can still start new Steps in it. End the last branch with a completing decision. If a Flow must not wait forever, set a Flow timeout.

Dex starts ready Steps roughly in the order they became ready, but not
strictly. Do not rely on the order in which parallel Steps start or finish.
Use a Channel or an Attribute lock when the order matters.

## Next

- [Failure transparency proof](https://docs.superdurable.io/evaluate-dex/correctness-and-expressiveness/failure-transparency-proof.md) proves that failures add only repeated external effects.
- [Attribute locks](https://docs.superdurable.io/concepts/primitives/attribute.md#locking) keep parallel writers from overwriting each other.
- [Failure Handling](https://docs.superdurable.io/design-patterns.md#failure-handling) routes a failed Step to a recovery Step.
- [Performance](https://docs.superdurable.io/evaluate-dex/performance.md) gives measured latency for SYNC and ASYNC Steps.
