Forget the undo and the step will not run.
A TypeScript framework. A step cannot run without its undo, so a retry does not charge twice. Every run leaves a ledger you can read. When something fails, it stops and waits for you. Hosted here.
npx durable-sdk init my-appdurable-sdk deployWorking with an agent? Hand it /llms.txt.
Two lines Durable checks at the door: the key, which may not read the clock, and the step's undo, or the reason it has none. Get either wrong and a TypeError is thrown with its sentence: the key's when the workflow is defined, the step's when the run reaches it, before its body. durable-sdk explain step.inline.declares prints its trap and its remedy, offline.
One workflow, four moments
The file the card above excerpts, whole. A shopper's checkout: reserve the stock, capture the payment, create the order. Write it, run it, break it, then walk the chain it left.
import { defineWorkflow } from "@durable-sdk/core";import { cart, orders, payments, stock } from "./effects";export const checkoutComplete = defineWorkflow({ name: "checkout.complete", version: 1, describe: "Reserves the stock, captures the payment and creates the order.", key: ["checkoutId", "requestId"], example: { checkoutId: "chk_4f21", requestId: "q7c1" }, async run(ctx) { const { checkoutId, requestId } = ctx.input; const c = await ctx.step( "cart.read", (i) => cart.read(checkoutId, i.stop), { irreversible: "a read" }, ); const held = await ctx.step( "stock.reserve", (i) => stock.reserve(i.lines, i.stop), { undo: (_, out) => stock.release(out.reservationId), effect: "provider" }, { lines: c.lines }, ); const paid = await ctx.step( "payment.capture", (i) => payments.capture(i.checkoutId, i.amount, i.stop), { undo: (_, out) => payments.refund(out.paymentId), effect: "provider" }, { checkoutId, amount: c.amount }, ); const { orderId } = await ctx.step( "order.create", (i) => orders.create(i.checkoutId, i.paymentId, i.stop), { undo: (_, out) => orders.cancel(out.orderId), effect: "provider" }, { checkoutId, paymentId: paid.paymentId }, ); ctx.emit("order.placed", { orderId, checkoutId, requestId }); return { orderId }; },});| seq | step | op | before | after | hash |
|---|---|---|---|---|---|
| 1 | stock.reserve | create | {"lines":[{"sku":"TEE-M", | {"reservationId":"res_12", | 91d25f2 |
| 2 | payment.capture | create | {"checkoutId":"chk_4f21", | {"paymentId":"pay_7f3a", | 2538aba |
| 3 | order.create | create | {"checkoutId":"chk_4f21", | {"orderId":"ord_8841"} | c731798 |
| 4 | stock.reserve | create | {"lines":[{"sku":"TEE-M", | {"reservationId":"res_13", | 1676f67 |
| 5 | payment.capture | create | {"checkoutId":"chk_4f22", | {"paymentId":"pay_7f3b", | 0bafac0 |
| 6 | payment.capture | deletereverses 5 | {"paymentId":"pay_7f3b", | null | 5296b09 |
| 7 | stock.reserve | deletereverses 4 | {"reservationId":"res_13", | null | ae60543 |
- name
- checkout.complete, version 1
- key
- checkoutId and requestId: the same checkout twice is one run, one charge, and the key never reads the clock
- steps
- cart.read is a read and says so; stock.reserve, payment.capture and order.create each carry an undo and name their effect
- fact
- order.placed, emitted once the run completes; a listener delivers it to the merchant's installed apps
- refused
- the second sentence of the card above: neither undo nor reason, refused before the body; the lines under the source
A step with an undo and no effect is refused the same way; durable-sdk explain step.undo.effect prints the sentence, the trap and the remedy, offline.
- run
- checkout.complete
- status
- COMPLETED
- steps
- 4
- rows
- 3
- steps
- 1 cart.read, 2 stock.reserve, 3 payment.capture, 4 order.create, each COMPLETED, as the run page lists them
- again
- the same checkoutId and requestId answer the first run, reused: true; the card is charged once
- fact
- order.placed:chk_4f21:q7c1 on the outbox, once
- run
- checkout.complete
- status
- COMPENSATED
- error
- tax: 503 Service Unavailable
- compensation
- undone payment.capture, stock.reserve; irreversible none; failed none
- calls, in order
- orders.create threw tax: 503 Service Unavailable; payments.refund(pay_7f3b); stock.release(res_13)
- code
- Error: no status on the thrown value, so not transient: no auto-redrive, and limbo is a person's at once. A 503 carried as a status is coded http_5xx and redriven three times, at 2, 10 and 30 minutes, before limbo.
- export
- 7 rows and the head, one JSON object a line, in ledger.ndjson; the lines under the rows are two of them
- row 1
- its prevHash is the word genesis; every row after carries the hash before it
- verify
- walks the file offline, recomputes every hash from genesis and names the first row whose link broke
- head
- the scope's last seq and hash; a key signs each day's head, and --public walks the rows alone
The door's answer to a payment.capture with neither undo nor reason, the second sentence of the card above, as the refusals registry says it:
throws: TypeErrorsays: payment.capture: an inline step declares undo or irreversibleremedy: Pass { undo, effect } or { irreversible: '<reason>' } as the step's third argument.
| seq | step | op | before | after | hash |
|---|---|---|---|---|---|
| 1 | stock.reserve | create | {"lines":[{"sku":"TEE-M", | {"reservationId":"res_12", | 91d25f2 |
| 2 | payment.capture | create | {"checkoutId":"chk_4f21", | {"paymentId":"pay_7f3a", | 2538aba |
| 3 | order.create | create | {"checkoutId":"chk_4f21", | {"orderId":"ord_8841"} | c731798 |
Four steps, three rows: the read leaves none. A provider step lands its row once the body returned, the request as before, the answer as after. Each hash is sha256 of the row and the hash before it.
| seq | step | op | before | after | hash |
|---|---|---|---|---|---|
| 4 | stock.reserve | create | {"lines":[{"sku":"TEE-M", | {"reservationId":"res_13", | 1676f67 |
| 5 | payment.capture | create | {"checkoutId":"chk_4f22", | {"paymentId":"pay_7f3b", | 0bafac0 |
| 6 | payment.capture | deletereverses 5 | {"paymentId":"pay_7f3b", | null | 5296b09 |
| 7 | stock.reserve | deletereverses 4 | {"reservationId":"res_13", | null | ae60543 |
order.create threw. The saga ran the undos in reverse of the calls: the payment refunded, the stock released, each delete row naming the row it reverses. Nothing is charged twice. The run waits in limbo for a person, redrivable; it is on the console's Limbo view with its rows, and a redrive runs it again from them.
durable-sdk explain cmhb3q7p80002r7x4h1k8s3zd --api https://my-app.durablesdk.comdurable-sdk explain: run cmhb3q7p80002r7x4h1k8s3zd · checkout.complete · COMPENSATED at my-app.durablesdk.comerror: tax: 503 Service Unavailablelimbo: tax: 503 Service Unavailable · redrivablefailed step: order.create (attempt 1, seq 4) · code: Errorstep error: tax: 503 Service Unavailable
durable-sdk ledger export --out ledger.ndjsondurable-sdk ledger export: 7 rows, 1 heads, 0 day records of every scope written to ledger.ndjson
Row 1 and the head, as the file carries them.
{"kind":"row","id":"cmhb3q2k40003r7x4p2n6v1qa","seq":"1","runId":"cmhb3q2k10001r7x4a9d2m5we","step":"stock.reserve","scope":"app","actor":"api:checkout","resourceType":"provider","resourceId":"stock.reserve","operation":"create","before":{"lines":[{"sku":"TEE-M","qty":1}]},"after":{"reservationId":"res_12","stock":2},"reversesId":null,"chain":"v4","prevHash":"genesis","hash":"91d25f28b14b6a45430c818f2dec15d6bc078445d185785b7da302ba78a9126d","occurredAt":"2026-10-29T09:14:02.118Z","attempt":1}{"kind":"head","scope":"app","seq":"7","hash":"ae6054391f226d3ad0ea0c7fa0fe88c5b5a3759ae0c87c91dc22905a36bae991"}
durable-sdk ledger verify --file ledger.ndjson --publicdurable-sdk ledger verify: ledger.ndjsonapp: ok (7 rows, head at seq 7, 0 records)ok: 1 scopes, 7 rows, 0 records walked (records not checked: no key)
durable-sdk ledger verify --file ledger.ndjson --publicdurable-sdk ledger verify: ledger.ndjsonapp: broken at cmhb3q2k90004r7x4c7w0b8ym (7 rows walked, head at seq 7)not ok: 1 scope(s) broken, 0 record(s) refused
The table has no update and no delete, by interface and by trigger.
Five lines the moments prove
- The key is a list of fields, so it cannot read the clock; the same checkout twice is one run and one charge.
- It runsWriting a workflow
- A step says how to undo itself or why it cannot; one that says neither is refused at the door, before the body runs.
- Write itSteps and undo
- When the last step throws, the undos run in the reverse of the calls, each its own row naming the row it reverses.
- It failsA compensation
- Every row hashes the row before it, from genesis; ledger verify walks an export offline and names the first broken row.
- Verify itCLI usage
- A failed run waits in limbo, redrivable by a person once the engine's bounded redrives of a transient cause are spent; explain prints the cause, the limbo line and the failed step.
- It failsThe doctor
Four products as workflows
Each a file on the recipes page, compiled and run by the docs' own test.
- An order saga
- Reserve, charge, ship; a failed charge releases the stock and the run lands COMPENSATED.
- key: ["orderId"], three provider steps with undos
- A campaign send in batches
- A million recipients on a 300 s function: a chunk is a row, the resume point and the console's line.
- ctx.batch over a cursor, concurrency: 4, a webhook route whose deliveries are facts
- An intake with approval
- The run waits a week for a provider and holds no function meanwhile; a deadline fails it for a person.
- ctx.waitForApproval, a delayed fact, a cancel by key
- A booking with reminders
- Two reminders as delayed facts; a reschedule cancels them by key and emits new ones; a daily sweep polls for no-shows.
- emit with deliverAt, cancelScheduled, schedule, ctx.poll
The guides the moments stand on
The four pages the example keeps to, in the order you would read them.
- Writing a workflow
- One file under src/workflows, a name, a field-list key, describe and example, execute with a requestId.
- defineWorkflow, key, example, execute
- Steps and undo
- Undo with its effect or an irreversible reason; read before you write; an external write under a writeKey.
- undo, effect, irreversible, writeKey
- Testing
- The three cases over checkout.complete, and prove, the crash-and-resume proof at every boundary.
- testDurable, prove
- The doctor
- Every rule over the tree offline, a failed rule one line with its fix; explain answers a refusal, a code or a run id.
- durable-sdk doctor --host, durable-sdk explain
Four things you can check in the schema
Not claims about hosting: rows in your database and lines in your tree.
The ledger
Every write leaves the image it found and the image it left, each row hashed over the row before it. Append-only by interface, by retention and by a database trigger.
- 5payment.capture create{"checkoutId":"chk_4f22",
"amount":4200} → {"paymentId":"pay_7f3b", "amount":4200}prevHash 1676f67 hash 0bafac0 - 6payment.capture delete, reverses 5{"paymentId":"pay_7f3b",
"amount":4200} → nullprevHash 0bafac0 hash 5296b09
Rows 5 and 6 of the example’s ledger, the payment captured and refunded; row 6’s prevHash is row 5’s hash, and the undo row names the row it reverses.
durable-sdk ledger verify --file ledger.ndjsonrecomputes every chain and names the first broken link.- 5
The undo
Every step says how to undo itself or why it cannot. A failed run compensates in reverse, each undo its own ledger row, and waits in limbo for a person; nothing retries in the dark.
-found{"paymentId":"pay_7f3b","amount":4200}+leftnull The undo’s own row: the image the capture left as its before, null as its after, operation delete, and
reversesIdnaming the capture’s row.The doctor
Hundreds of rules over your tree and your configuration, offline, each a one-line finding with its fix. A key that reads the clock, a step with no undo, a secret in an output: found before a deploy.
$ durable-sdk doctor --host error workflow-identity/key-reads-no-clock app/workflows/checkout.ts:9 checkout.complete keys the same across an hour boundary: expected 'chk_4f21:1761696000' to be 'chk_4f21:1761692400' → put the moment in the input as requestId and key on the field list (ADR-0041) not ok: 1 finding (39 guard files, 39 in the manifest, 1 checks failed, 4222 passed, 0 skipped)
Your terminal, before a deploy; a hosted build runs the same check before it is promoted.
durable-sdk doctor --host --explain <rule>says a rule’s law and hazard.Legible to agents
Every refusal is a sentence with a code and a remedy, explained offline. The docs are plain text at /llms.txt, and the API is one OpenAPI document.
$ durable-sdk explain plane.auth.required durable-sdk explain: plane.auth.required · the CLI's copy of the plane's registry (HTTP 401) door: /api/v1 says: no credential: the request carries no key and no session trap: An unauthenticated read would name a tenant's apps to anyone. remedy: Run durable-sdk login, or set DURABLE_API_KEY to a key minted on the dashboard.
Your terminal, offline: every code the API answers, with its remedy;
--jsonon every verb answers the API’s own shape.
Vibe coding with a map
An AI coding agent asks the graph before it edits, instead of reading forty files.
What a door starts. Each step with its undo, or the reason it has none, and what it writes. What the run emits, who listens, and what runs next. What a change reaches, before it is made. One command prints the card, and every line that names a thing ends in the file and line to open next. The agent reads the lines. You read the picture. They are one answer.
The solid pill is where the walk starts. A pill drawn twice is a step with an undo. A dashed stub leaves a pill the walk reached and did not expand: the next question starts there. Press a pill to walk from it. Press Path, then two pills, for the first chain between them: durable-sdk graph path <from> <to>.
admits
A door judges from the rows as read and answers a refusal as a value before any run exists, and the step keeps the same guard as the race's backstop: two posts a moment apart both pass the door's reading and the step's compare-and-set refuses the second from the row as it stands, so the door's judgement is a courtesy to the phone, never the fence; the run the door admits is keyed by the input and a second post under the key answers the first run (reused).emit
One outbox row under the catalog's key, inserted with the run's commit and dispatched after it, a second emit under the key collapsing onto the row; with deliverAt the row does not exist for the dispatcher, the relay or retention until its moment, and a cancel by key before it leaves the row cancelled for good; ctx.emit sits after a step returns and never inside its body, a batch chunk or a hook handler (a step served from its row never runs its closure, so an in-step emit is refused at the door, emit.inside_step).ctx.step
One step row per call, started before the body and finished after it, the ledger rows the body appends under its effect; a crash between the body and the row's finish re-invokes the body on the next attempt (a provider call is replayed from its ledger row, a read is run again), and a redrive replays every finished row and re-runs the step that failed. A read step declared completion: "behind" (FP-011 as landed, opt-in) lands its COMPLETED row on the next boundary's statement or the finish instead of its own, one statement a step where there were two, at the price that a crash between its body's return and that statement leaves the row STARTED and the next attempt reads again; the default ("now") keeps the answer on its row before the body goes on, replayed after any crash (ADR-0063 B22).on: record
Records, never acts: on a peer's copy the row is recorded and the body never runs, on the origin the body runs as a keyed run per fact in partition order, and a body that reaches a scope resolver on a copy fails its run as a value (ActsOnRelayedCopy).calls
A provider call is reached through a connector by capability, never a provider's name (business code branches on the connector's capabilities, the connector modules alone import a client), takes a token from its account's bucket first and carries the step's stop so a cancel or a deadline aborts it in flight; it is never retried by the client when non-idempotent, and the call has no row of its own: once the step's row landed the call is replayed from it, and a crash between the call and the row's finish re-invokes the step on the next attempt and sends it again (the ctx.step row), so a call that must not be sent twice is read for first or made under a recordedWrite or an external step, whose row is written before it; a call the walk reads outside any step is a provider reached with no row to replay from, said as the body's.execute
A run keyed by the input: a second start under the key answers the first run (reused), a run that failed stays in limbo until a person redrives it or, for a transient cause under the bound policy, the engine's auto-redrive does (ADR-0084), and RunNotStarted and KeyCollision are the only throws, both before a run exists; everything after is a value.What the agent reads: one line per edge under its depth, the file and line to open next on every line that names a thing, the drawbacks folded, one sentence per primitive met, the registry’s own.
The card is the third verb: one node, whole. This one is real: the run that hands the CLI its key once, printed from the platform’s own app, the same way your app’s runs print.
durable-sdk explain cli.login.consumedurable-sdk explain: workflow:cli.login.consume · key [loginId, requestId] · version 1 @ src/durable/workflows/cli-login.ts:497 "The CLI's poll of a login: its status as a value, or, once approved and unconsumed, the sealed key opened and replied once; emits cli.login.completed."admitted by door:api:cli.login.token · POST @ src/app/api/v1/cli/logins/[id]/token/route.ts:36started by unknown · 4 bodies not indexedrefuses nonestep cli.login.consume.row · ctx.step · ledgered · cannot undo: a consumed login is over: the value crossed once · id consume @ src/durable/workflows/cli-login.ts:514 writes column:ApiKey.revokedAt, .revokedBy · no undo · key apikey.revoke.row:api_key · ledger api_key · via revokeKeyRow@src/durable/workflows/apikey.ts:265 → rowWrite@src/durable/workflows/rows.ts:76 @ src/durable/workflows/rows.ts:80 column:CliLogin.status, .consumedAt · no undo · key cli.login.consume.row:cli_login · ledger cli_login · via rowWrite@src/durable/workflows/rows.ts:76 @ src/durable/workflows/rows.ts:80 raw table:Credential · deleteMany · data none @ src/durable/workflows/cli-login.ts:545 table:CliLogin · updateMany · data lastPolledAt, intervalS @ src/durable/workflows/cli-login.ts:585 table:CliLogin · updateMany · data lastPolledAt @ src/durable/workflows/cli-login.ts:599 table:Credential · deleteMany · data none @ src/durable/workflows/cli-login.ts:644through module:src/durable/workflows/apikey.ts module:src/durable/workflows/credentials.ts module:src/durable/workflows/facts.ts module:src/durable/workflows/rows.ts (+5, --all)emits fact:apikey.revoked · parts tenantId, apiKeyId, requestId · key apikey.revoked:{tenantId}:{apiKeyId}:{requestId} · "An API key was revoked (ADR-0105 D04)." @ src/durable/events/catalog.ts:551 · also emitted by workflow:apikey.revoke, workflow:apikey.revoke_by_owner, workflow:member.leave, workflow:member.remove (+1, --all) listeners noneemits fact:cli.login.completed · parts tenantId, loginId, requestId · key cli.login.completed:{tenantId}:{loginId}:{requestId} · "A CLI login was consumed: its key crossed once (ADR-0105 D04)." @ src/durable/events/catalog.ts:562 listeners nonewaits nonestarts nonecalls none
- durable-sdk explain <subject>
- what a door admits, each step with its undo and its writes, what the run emits and who listens
- durable-sdk graph walk <subject>
- the closure from any node, one depth at a time
- durable-sdk graph impact --changed
- what the working tree's change reaches, and what to run for it
The picture is the storefront sample’s walk, the engine’s own over an index written for the sample in the generator’s shape, laid out a column a depth and printed by its own renderer. The card is the platform’s own, printed by the same command over its own app and held line for line to its committed map by a test. Nothing is typed. unknown under started by counts the four bodies the index did not read, the engine’s own; nothing is guessed.
Your terminal, offline, over the graph-index.json the template writes at the app’s root and every build regenerates. --json is the same answer as data; durable-sdk graph path <from> <to> is the first chain between two nodes and durable-sdk graph diff --base <ref> what the graph gained, lost and changed. A deployment answers the same walk at GET catalog/graph?from=<node>. The MCP is coming; its graph_explain, graph_impact and graph_walk tools answer the same card, radius and walk. Vibe coding with the graph walks four questions through the verbs, every answer real.
How hosting works
Your tree gets a project, a database and a hostname.
Your tree
durable-sdk deploy uploads the tree in parts from your laptop or your CI, under an API key. Or connect a repository from the app's settings: a push deploys a preview per pull request and production from the default branch.
A build on its own project
Every app is its own project with its own database. The build runs your migrations, a production build is checked by the doctor before it is promoted, a preview answers at once.
A hostname, a database beside
<app>.durablesdk.com, a preview at <app>-git-<branch>, your domain on Pro. The database is yours to read: a read-only connection string, rotated or revoked by one command.
Built for agents
An agent can read everything a person can, in a shape it can parse, and act with the same commands.
- /llms.txt
- The product in one paragraph, then every docs page with its summary; /llms-full.txt is every page's Markdown in order.
- Every page as Markdown
- GET /docs/<page>.md, or the page with Accept: text/markdown. Front matter stripped, links absolute.
- durable-sdk explain <code>
- Every refusal and every rule, its sentence and its remedy, offline; a door, a workflow or a Table.column, its card off the committed graph index; --json on every verb answers the API's own shape.
- The MCP (coming)
- durable-sdk mcp (DS-025) will read runs, the ledger and limbo and redrive a run, with tools derived from the console's contract, graph_explain, graph_impact and graph_walk among them; until then an agent reads the API's console proxy routes with a key.
- AGENTS.md in every app
- The app's shape in twenty lines, the commands, the rules an agent keeps, how to log in. CLAUDE.md is @AGENTS.md.
# Durable SDK> A TypeScript framework: keyed-by-intent sagas, every side effect a step that reads before it writes, can undo or says why not and is refused at the door otherwise, an append-only hash-chained ledger, a limbo a person clears; hosted on durablesdk.com.Every docs page is Markdown at its URL with `.md` appended (and under `Accept: text/markdown`); the plane API's OpenAPI document is at https://durablesdk.com/openapi.json; `durable-sdk explain <code>` answers every error code and refusal offline; `durable-sdk explain <subject>` prints what a door admits, each step with its undo and its writes, the facts and who listens, `durable-sdk graph walk <subject>` the closure from any node and `durable-sdk graph impact --changed` what a change reaches, offline over the committed graph-index.json the template writes, so ask the graph before an edit; `durable-sdk doctor --host` runs the tree's rules; every hosted app carries an `AGENTS.md`.## Reference first- [OpenAPI document](https://durablesdk.com/openapi.json): the plane API, every route with its scope, schemas and error codesThe file as served, wrapped here; every row after these is one docs page with its summary.
Pricing
Free is a real tier with a real database. Pro's prices are set with you until they are published.
Free
One app with its own database, for a team of three.
$0a month
- 1 app, production and preview
- 10,000 invocations a day
- 10 build minutes a build, 60 a day
- 0.25 CU database, 1 day of history
- Community support
Pro
Ten apps, custom domains, manual promotion; staging soon.
Talk to us
- 10 apps, unlimited environments
- 1,000,000 invocations a day included
- 45 build minutes a build, 1,000 a day
- Database up to 2 CU, 7 days of history
- Custom domains, email support; staging soon
Enterprise
Limits by contract, a sized database, an SLA.
Talk to us
- Apps, seats and previews by contract
- Database sized to the workload, 30 days of history
- Manual promotion, custom domains
- HIPAA on request for a regulated tenant
- Support under an SLA
Every limit, side by side: the whole table.
An app with a ledger before lunch.
Two commands to a hostname with a database beside it.
A minute from now: an app answering at its hostname, its database beside it, a sample workflow with its test, the first rows of its ledger, and an AGENTS.md your agent reads. Not sure yet? Why Durable shows the night it prevents.
npx durable-sdk init my-appdurable-sdk deploy