Guarantees
Exactly once, at least once, what the ledger proves, what the engine never does.
Generated from the SDK's own source (
packages/durable-core/README.md) at build; edit there.
Stated precisely, because the difference between them is the whole point. Each carries its status tag.
Exactly once.
- One run per key, for as long as the key lives.
executecreates the run and its key in one transaction; a concurrent second caller either getsin_progressor the first run's result. A key under another workflow's name is aKeyCollision, thrown before any run exists. The key lives for as long as its run isRUNNING,FAILED,COMPENSATEDorUNDONE, for 14 days after an unledgeredCOMPLETEDrun (deleted with the run) and 30 days after a ledgered one;undoreleases it on purpose. After that, or after an undo, the same intent starts a new run. Inside the window the memo is by content: an intent A, then B, then A again (the same order, edited and edited back) is skipped the second time; put a version or request id in the input when that matters (ADR-0041 "keys live with their run"). - One completion per run.
finishis fenced by(runId, attempt), so an attempt that lost its lease cannot finish; the same fence holds on step records and ledger appends, and the lease'ssignalfires inside a step (ADR-0041 wave 3). - One fact per key. A fact is inserted-if-absent under the key your
descriptor returns; the engine adds nothing to it. Put the attempt (or a
request id) in the key when a redrive of the same intent is a new fact,
and leave it out when it is the same fact (step 4
shows both). Facts of an attempt that threw are dropped and only
run.failedis written; facts of a run that calledctx.fail()are written with statusFAILED.emit()outside a run reportscollapsed: truewhen the key already exists, and commits on its own: a host write that must commit with its fact belongs inside a workflow, whose fact is written with the run's final status (ADR-0046 §C as landed). - One landing per relayed fact. A copy lands under
relay:<origin>:<key>by insert-if-absent; a resend collapses; a copy is never relayed again, for every peer of the mesh (ADR-0046 §H). - One child per key under a fan-out, one decrement per child.
ctx.fanOutinserts its children parked through one statement per chunk, idempotent on the children's keys (a chunk run again after a crash lands nothing twice), and each child's finish decrements the parent's join counter in that finish statement and clears its pointer, so a landing counts once however many attempts the child took; the finish that brings the counter to zero, or the failures past the tolerance, fires the join in the same statement (ADR-0076 FP-037).
At least once.
- Step bodies. A step may run again after a crash between its write and
its record, which is why every step reads before it writes and no-ops
when the world already matches. That makes an absolute desired state
idempotent; a relative change (a counter, "+qty") is not, and needs
its own keyed row (step 5).
A step replays from its stored output;
defineExternalStepreconciles the pending record from the storeddesired, andretry: { idempotent: false }is never repeated automatically (ADR-0041 wave 3). Its result names two ids apart by type:resourceId(the ledger's,LedgerResourceId) andproviderId(the provider's,ProviderId, read from the image under the spec'sproviderIdKey);idis a deprecated alias ofresourceId(2026-09-26), kept while a stored output of the previous release (idalone) can still replay: the saga upgrades such an output on the memo hit (replayedExternalResult). - Lightweight runs (ADR-0076 FP-038). A body that reads and computes
and never writes may declare
lightweight: trueondefineWorkflowor onon(…): one run row and no step row, everyctx.stepareadkept in memory and landed on the run row'sstepOutputswith the finish (schema version 29), the facts in the finish statement and the key as on every run. A crash before the landing re-runs the body whole on the wake, so the door refuses by name a step with an undo or an irreversible reason, a recorded write or an external step, a wait, a child, a batch, a poll, a hook with a handler andcancelScheduled(thelightweight.*rows ofREFUSALS), and the double-run proof judges such a definition at the finish boundary alone, a provider or host write inside it its finding. The run detail sayslightweightwith the outputs off the run row (API 2.142). - Listener delivery. A listener run is keyed
listener.<name>:<outboxId>, so redelivery is harmless. Delivery is bounded: at mostMAX_ATTEMPTStransport attempts (8, spelled once insrc/events/limits.ts) with backoff, then the row is parked; a reaction whose run fails parks the row on that first failure. A parked row is listed on the console's Events page and counted on/health; a person's Reset (re-arm the row) or Redrive (the listener's own run) is the only way back (ADR-0031; the backoff onretryAt, ADR-0041 wave 2). Since ADR-0076 FP-028 a listener may declare its own policy on the registration,retry: { maxReceiveCount, backoff, maxAge }(the row exhausts at its own limit, written onto it asattemptLimit, or past its age, under the throwing listener's name,exhaustedBy) andconcurrency: { max, key }(the listener workflow's cap), and one listener's exhausted rows are its dead-letter queue:GET events?exhausted=<listener>lists them and the operator actionevents.redrive { listener, since, velocity }puts them back oldest first at a velocity, attempts at zero, the moment kept. Since FP-027 a delivered fact stays replayablearchiveDaysfrom its own moment (retention moves it intoOutboxArchivein place of deleting it atoutboxDays, and prunes it there atarchiveDays; 0 is the archive off), and the operator actionevent.replay { since, until, listener?, partition?, execute? }re-delivers a window's rows from the outbox and the archive to one listener or every record listener as new runs keyedlistener.<name>:<id>:replay:<requestId>, the payload'srequestIdunder thereplay:prefix, so keyed work starts afresh and a host's loop guard fires no rule twice. Since FP-029debounce: { key, period, mode, maxDelay }folds one key's emits into one run per window on the engine's own rows (a settings row by compare-and-set and the delayed factevent.debounced) andthrottle: { limit, period, burst, key }is a token bucket on the settings rows that parks the excess in emit order, never a drop and never an attempt charged. - Relay transport. Batches are claimed, posted, acknowledged by id and reclaimed after a lease; order is preserved per origin and per partition, never globally: one lease per peer, one batch in flight under it, with a sequence number the receiver checks (ADR-0046 §H).
What the ledger proves.
- For every scope, the sequence of before/after images of every write the
engine made, each row carrying the run, the step, the actor and
hash = sha256(prevHash + content).verifyrecomputes every chain and names the first broken link: an edited image, a re-dated row, a deleted tail or a deleted partition; each row carries the attempt that wrote it (ADR-0041 wave 3). - A compensation that changed state has its own
<step>.undorow with the image it found and the image it restored; a step that could not undo says why (irreversible: '<reason>'), soCOMPENSATEDmeans every compensable step was undone and the run's error names what was not (the operator's Undo writesundorows the same way; the per-step outcomes and thecompensateXORirreversibletype are ADR-0041 wave 3's). - The ledger is never updated or deleted: by interface (no such method) and
by retention (no rule may name it) and by the Postgres trigger
ledger_append_only(ADR-0041 wave 3). - Each app's chain head is recorded in every peer's ledger, so a tamper on
one app is detectable from any other (ADR-0046 §H,
ledger.head).
Never.
- A failed run is never retried by code; only a person's
redrivemoves it (ADR-0031). - A secret never lands in a row or a log line: every stored copy goes
through one serializer under a redaction policy, and a
Secret<T>value is refused by the serializer and the logger. A one-time value is handed back withctx.reply()and never stored (ADR-0041 wave 1). - A database credential never crosses apps; only the facts you publish do, under a publication policy per peer (ADR-0046 §H).