Build with Lumen
A run is a durable record with a declared lifecycle, an append-only event log, and refusals when you ask for something it will not do. Everything below is the surface that actually ships — the states, the routes, and the fields the server reads.
11 states, and the table that governs them
There is no conditional logic deciding what a run may do next. Every legal move is declared once, and anything absent from the table is refused.
Waiting for a worker
queuedAccepted and waiting for a worker to pick it up.
In flight
runningA worker holds the run and is making progress.
resumingTransient on the way back. It exists so that "resumed" is an observable event rather than an absence.
Parked — carries a reason
waitingParked on something outside the run. Carries a reason.
suspendedPaused deliberately. Can resume, and can go back on the queue.
waiting_userBlocked on a person who was asked something.
waiting_approvalBlocked on an approval. An approval is this run paused, never a replacement for it.
control_requiredA human holds the machine. Separate from an approval on purpose: nothing is being asked, so "yes" would be the wrong unblock.
Settled
completedTerminal. A finished run is a receipt, and reopening it would let a late event rewrite history.
terminalfailedRetryable. It can go back to running or queued, or be cancelled to close it out.
cancelledTerminal, and deliberately not retryable.
terminal
Legal transitions
queuedrunningwaitingsuspendedwaiting_userwaiting_approvalcontrol_requiredresumingcompletedfailedcancelledCreate a run
A run carries a task graph. Dependencies must name tasks in the same run, and the graph must be acyclic — both are checked at creation rather than discovered at dispatch. The surface below is served under /api/runs by a self-mounting router, so it can be mounted and tested without starting the rest of the server.
const response = await fetch('/api/durability/runs', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
title: 'Compare these sources',
agent: 'researcher',
inputs: { sources: ['https://example.com/a', 'https://example.com/b'] },
tasks: [
{ id: 'gather', title: 'Gather and read', owner: 'researcher', inputs: {} },
{ id: 'compare', title: 'Compare vendors', owner: 'analyst', inputs: {}, dependencies: ['gather'] },
],
}),
})
const { run } = await response.json()Run endpoints
GET/api/durability/statesThe run states, legal transitions, and input-request types enforced by the durable-run store.POST/api/durability/runsCreate a durable run and its task graph. Dependencies must name tasks in the same run, and the graph must be acyclic.GET/api/durability/runsList durable runs from the event log.GET/api/durability/runs/:idRead a run snapshot projected from its event log, including the current cursor.GET/api/durability/runs/:id/eventsRead events from a cursor so a client can reconnect and catch up.POST/api/durability/runs/:id/transitionMove a run to { to }. Illegal transitions are refused with the allowed states.POST/api/durability/runs/:id/cancelCancel a run. Cancellation is terminal and deliberately not retryable.POST/api/durability/runs/:id/requestPark the same run while it waits for a user input or approval request.POST/api/durability/runs/:id/requests/:requestId/resolveResolve a pending request on its run; repeated keyed requests replay the recorded outcome.POST/api/durability/runs/requests/:requestId/resolveResolve a pending request when the request id is known but its run id is not.POST/api/durability/runs/:id/requests/:requestId/cancelCancel an outstanding request without cancelling its run.POST/api/durability/runs/:id/resumeResume a run that was waiting, suspended, or parked for control.POST/api/durability/runs/:id/tool-callsRecord a tool call against a run before its receipt is attached.POST/api/durability/runs/:id/tool-calls/:toolCallId/receiptAttach the execution receipt to a recorded tool call.GET/api/durability/runs/:id/receiptsRead the receipts recorded for a run.POST/api/durability/runs/:id/retryableRecord the run as retryable after a failed attempt.
What a client can rely on
The table is the policy
Every legal move is declared once in RUN_TRANSITIONS. Nothing infers legality from prose or from the order handlers happen to run in, and a move the table does not list is refused before any state is written.
A refusal explains itself
An illegal transition is a 409 carrying the states that were actually allowed — not a 400 with a guess. Every error carries a machine-readable code and a detail, so a client branches on why something was refused instead of matching on English.
Events are the source of truth
A run is projected from its event log, not stored as a mutable row. State is a fold, so a replay is not an approximation of the history — it is the history.
The machine is published
GET /api/durability/states returns the states and transition table the durable-run router enforces, so a client can check a move before discovering the answer from a 409.
For developers
What is being built for developers now. None of it is available yet.
- In development
Public API v1
Scoped, revocable API keys and versioned endpoints to start runs, follow their events and read results.
- In development
Channels
Start and continue work from messaging apps, beginning with Telegram. Approvals arrive as buttons in the chat.
- In development
API reference
An OpenAPI description and reference docs, published together with the API.
Start a run and watch it survive
The point of a durable run is that closing your laptop is not a state transition.