Skip to content
Duoduo Mediaevidence to decision

Package 31 · Section 11.2

Durable Orchestration and State

Make long-running decision cases survive restarts, duplicate events, approvals and partial failures without losing evidence or repeating side effects.

Track
I · Agentic decision systems
Level
Practitioner
Version
v1.0
Status
In validation · catalog only
Explanation depthDepth

Learning objectives

  • Model a decision case as a typed state machine with explicit terminal states.
  • Persist checkpoints before and after side effects and resume from them safely.
  • Handle external events, timeouts and approvals as durable transitions.

In brief

Decision cases often run for hours or days, wait for approvals and depend on external events. Durable orchestration treats each case as a typed state machine that persists checkpoints, survives restarts, deduplicates events and ends only with a recorded terminal reason.

Core concepts

31.1Required state

A case state holds identity (case, run and parent run IDs), the decision contract, observations, the validated plan, the evidence ledger, the decision model, the proposal, the risk record, the action log and the outcome.

Each field has an owner and a lifecycle. Summaries can be derived from state but never replace it.

31.2The orchestration loop

The orchestrator loads or creates state, records the triggering event, validates the contract and then loops: enforce budgets, select the next step, execute it and persist state. Step kinds are PLAN, RETRIEVE, MODEL_DECISION, GATE, ACT and MONITOR.

A gate can end the loop early by blocking the case or checkpointing it for approval. Resuming later reloads the exact state that was approved.

31.3Checkpoints and side effects

Persist state immediately before and after any side effect. If the process dies between execute and confirm, recovery checks the idempotency record instead of executing again.

Events carry IDs and ordering rules so duplicates are ignored and out-of-order events are buffered or rejected.

31.4Replay

A replay re-runs a case with pinned workflow, prompt, model, tool, index and policy versions and recorded inputs. Diffing the replay against the original trace shows whether a change in behavior came from code, data or the model.

Worked example

An approval that waits three days

Situation: A policy exception case reaches the approval gate on Friday. The service is redeployed twice over the weekend and the approver responds on Monday.

  1. 1At the gate the orchestrator persists the proposal, its action fingerprint, evidence versions and remaining budget, then returns WAITING_FOR_APPROVAL.
  2. 2Both redeploys start fresh processes with no memory of the case.
  3. 3The approval event arrives with the case ID and fingerprint; the orchestrator loads state and checks the fingerprint matches.
  4. 4Execution continues from the ACT step with the approved proposal and records the terminal reason.

Outcome: The case resumes exactly where it stopped. Nothing was recomputed, so the approver approved the same action that was executed.

Decision rules

  • Persist after every step and around every side effect.
  • Every event has an ID; duplicates are no-ops.
  • Every terminal run has a reason, a trace and a reproducibility manifest.
  • Budgets for time, tokens, cost and tool calls are enforced inside the loop, not after it.

Common pitfalls

  • Keeping case state in process memory or chat history.
  • Recomputing the proposal after approval.
  • Processing the same webhook twice.
  • Ending runs without a terminal reason.

Key vocabulary

Checkpoint
A persisted snapshot of case state from which execution can resume.
Terminal state
A state that ends the run, such as completed, blocked, insufficient or budget exhausted.
Replay
Re-executing a run with pinned versions and recorded inputs to reproduce or compare behavior.
Parent run
The run from which a replay or revision was derived.

Tutorial outline

  1. 31.1Required state fields: identity, contract, observations, plan, evidence ledger, decision model, proposal, risk record, action log and outcome.
  2. 31.2The generic orchestration loop and how each step kind updates state.
  3. 31.3Replay with pinned versions, parent runs and comparison runs.

Required artifacts

Executable workflow graph, state schema and replay test.

Evaluation evidence

Restart survival, replay fidelity, duplicate-event safety and terminal-reason coverage.