The doctor

durable-sdk doctor --host runs every rule over the tree offline and prints a failed rule as one line with its fix; --explain says a rule's law and hazard; durable-sdk explain answers a refusal, an error code or a run id.

Open in CursorView as Markdown

This page is the doctor and explain: the two offline answers to "is this file right" and "what does this sentence mean". The commands it teaches are durable-sdk doctor --host, durable-sdk doctor --host --explain <rule id>, durable-sdk doctor --core, durable-sdk doctor --definitions, durable-sdk explain <code|id|runId> and durable-sdk explain --json.

doctor --host#

durable-sdk doctor --host

Runs every guard rule the app's durable.guards.ts names over the tree: the core pack (the engine's rules) and the template's route convention, no database and no network. A green run prints the rule count and exits 0. A red run prints one line per finding and exits 1:

error  step-bodies/clock-outside-step  src/workflows/digest.ts:14  a run body reads Date.now() between steps  → read the moment inside a step, or take it from the input as requestId  (ADR-0044)

Two spaces between the columns: the severity, the rule id, the file and line, the sentence, the fix after the arrow, the record the rule comes from. Paste the rule id into --explain for the law.

The rules the doctor holds a workflow to, in short: a key never reads the clock; a step has an undo with its effect or an irreversible reason; a write is a compare-and-set on what it read; a secret is never in a step output, a log line or an input; a run body reads the world inside a step; a wait in a loop has an id; a listener lives in src/listeners.ts; every workflow file is in the loader durable.config.ts names; nothing calls the engine's internals (beginRun, finishRun, appendLedger) by hand. The whole list with each rule's law and hazard is the generated page Rules.

--json prints the findings as data on stdout, the shape a CI step or an agent reads:

durable-sdk doctor --host --json

--explain <rule id>#

durable-sdk doctor --host --explain step-bodies/clock-outside-step

Prints the rule's id, then its law, its hazard (one of race, doubled write, leaked secret, lost fence, lost intent), its drawback (what the rule costs you), its fix and its record, one per line. No tree is read.

--core and --definitions#

durable-sdk doctor --core runs the engine's own pack alone, nothing of the app's guards. durable-sdk doctor --definitions loads every registered definition and judges its describe, its example and its key with no run and no store write: a missing sentence, an example that does not key, one that keys elsewhere once stored, a scope or tags off their shape, a schedule whose slots share a run, each a finding with its remedy.

explain#

durable-sdk explain step.undo.effect
durable-sdk explain StaleWrite
durable-sdk explain http_5xx
durable-sdk explain plane.deploy.check_failed

explain takes one of five things and answers offline from the same tables the doors read:

  • A refusal id (step.undo.effect, workflow.name.grammar, continue.inside_step): the sentence as a door throws it, the trap it closes, the remedy, the record. Every sentence a door throws is one of these rows; the id is in the sentence's registry entry and on Refusals.
  • An error code (StaleWrite, http_5xx, NonIdempotentWriteFailed:http_5xx, a family X:*): what the step's row means by it, whether it is transient, and the remedy.
  • A platform code (plane.deploy.check_failed, plane.app.slug_taken): the sentence, the remedy and the docs link, the same row the API answered under error.code (API errors).
  • A graph subject (checkout/complete, checkout.complete, Receipt.sentAt, order.placed, a module's path): the card off the app root's graph-index.json, what a door admits, every step with its writes, the facts and who listens; Vibe coding with the graph walks four questions through it and the two graph verbs.
  • A run id, with --api <url>: the failed step glossed with its code's meaning, and every log name the run captured with its catalog row. On the hosted platform the console tab shows the same under the run.

explain --json prints the row as data on stdout.

Reading a finding#

  1. The rule id names the file of the guard and the rule: step-bodies/clock-outside-step is the step-bodies file's rule about the clock.
  2. The sentence says what the line does; the fix after → says what to write instead.
  3. --explain says why: the hazard is what goes wrong in production if the line ships (a race, a doubled write, a leaked secret, a lost fence, a lost intent).
  4. Fix the line, run durable-sdk doctor --host again. A finding that stays is the next one in the file.

A rule is never skipped and never silenced in code: the doctor is the law the engine keeps and the one the template's CI runs before durable-sdk test --pr. The hosted deploy runs durable-sdk platform check against the staged deployment before it promotes, so a tree the doctor refuses never reaches a hostname (Deploy).

For an agent#

Run durable-sdk doctor --host before and after every edit. A sentence a door throws is a refusal id: run durable-sdk explain <id> and follow the remedy, never guess around the door. The template's AGENTS.md says the same in twenty lines, and MCP and agents lists every other surface an agent reads.