# Vibe coding with the graph

This page is the graph asked, not read: what an AI coding agent, or you, runs before editing a tree it has not read whole. The commands it teaches are `durable-sdk explain <subject>`, `durable-sdk graph walk <subject>`, `durable-sdk graph path <from> <to>`, `durable-sdk graph impact --changed`, `durable-sdk graph diff --base <ref>` and `durable-sdk index`, with `--json`, `--all` and `--api <url>`.

## What the graph is

The engine knows the shape of an app: every door and the workflow it admits, every workflow with its key and its steps, each step's door, its effect, its undo or the reason it has none, the writes with their table and columns, every fact with its parts and its key, who listens and what each listener starts, the providers a step calls through its connector, the refusals a door or a step answers as values. `durable-sdk index` walks the tree and writes that down as `graph-index.json` at the app's root, beside `workflow-index.json`. The template writes both on `durable-sdk init`, the build runs the walk again so a deployment's graph is current by construction, and the test tiers check the file on every pull request and every push to main, `durable-sdk test --changed` and `durable-sdk test --pr` each running `durable-sdk index --check` first. The verbs read the file, and the refs file beside it where one stands, and nothing else. No database, no network, no run.

An agent that reads forty files to answer "what happens when this door is posted" is guessing at the end. One that asks the graph gets a card, and every line of it that names a thing ends in the `file:line` to open next.

## Every answer here is real

durablesdk.com is itself a Durable app. Its two indexes and its map are committed in the engine's tree under the app's own directory, and every answer below is what the verb printed there, cut only between sections: the three cards of the platform's app before their `holds` line, the radius from `bodies` on, the walk and the path before their `drawbacks:` line, and the tenant card at the end whole. A test holds each excerpt to the committed card and to the renderer, so a line that drifts fails before it is published.

## What happens when the CLI polls for its key

```bash
durable-sdk explain cli.login.token
```

```text
durable-sdk explain: door:api:cli.login.token · POST @ src/app/api/v1/cli/logins/[id]/token/route.ts:36
judges    none
refuses   refusal:plane:plane.login.consumed · "the login's key was already taken" · judged row @ src/app/api/v1/cli/logins/[id]/token/route.ts:53
          refusal:plane:plane.login.consumed · "the login's key was already taken" · judged row @ src/app/api/v1/cli/logins/[id]/token/route.ts:78
          refusal:plane:plane.login.consumed · "the login's key was already taken" · judged row @ src/app/api/v1/cli/logins/[id]/token/route.ts:92
          refusal:plane:plane.login.consumed · "the login's key was already taken" · judged row @ src/app/api/v1/cli/logins/[id]/token/route.ts:94 (+7, --all)
admits    workflow:cli.login.consume @ src/durable/workflows/cli-login.ts:497
  key     [loginId, requestId] · version 1
          "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."
  refuses none
  step    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:644
  through 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 none
  emits   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 none
  waits   none
  starts  none
  calls   none
starts    none
```

The first line is the door: its method and its file. `judges` is the function that reads the rows before any run; this door has none. `refuses` is every sentence the door answers as a value, each with the line it is thrown on; the list folds at four and `--all` prints the rest. `admits` is the run the door starts in its own answer, whole: the key the run is held under, each step with its door, its effect and its undo or its reason, the columns each write sets with its ledger resource, the raw mutations beside the recorded ones, the modules the fold went through, the facts the run emits with their parts and their keys, and under each fact who listens. `listeners none` is proved, not assumed: the index carries every registration. The last `starts` is what the door hands past its own answer; none here. A subject is spelled as the thing itself: a door's path, a workflow's or a fact's name, `Model.column`, a module's path, `kind.capability`, a refusal's slug, or a node id such as `door:api:cli.login.token`.

## What writes `ApiKey.expiresAt`

```bash
durable-sdk explain ApiKey.expiresAt
```

```text
durable-sdk explain: column:ApiKey.expiresAt · DateTime? · no default @ prisma/schema.prisma:535
written by step:apikey.mint:apikey.mint.row · ctx.step · ledgered · undo · id mint @ src/durable/workflows/apikey.ts:219
  writes  column:ApiKey.id, .tenantId, .name, .kind, .prefix, .hash, .scope, .owner, .createdBy, .expiresAt · key <expression> · ledger api_key · via mintKeyRow@src/durable/workflows/apikey.ts:106 → rowWrite@src/durable/workflows/rows.ts:76 @ src/durable/workflows/rows.ts:80
  admitted by none
  started by unknown · 4 bodies not indexed
  emits   fact:apikey.minted · listeners none
          step:cli.login.approve:cli.login.approve.key · ctx.step · ledgered · undo · id key @ src/durable/workflows/cli-login.ts:346
  writes  column:ApiKey.id, .tenantId, .name, .kind, .prefix, .hash, .scope, .owner, .createdBy, .expiresAt · key <expression> · ledger api_key · via mintKeyRow@src/durable/workflows/apikey.ts:106 → rowWrite@src/durable/workflows/rows.ts:76 @ src/durable/workflows/rows.ts:80
  admitted by none
  started by unknown · 4 bodies not indexed
  emits   none
raw       none
reads     module:src/durable/workflows/apikey.ts · data @ src/durable/workflows/apikey.ts:157
          module:src/durable/workflows/apikey.ts · typed @ src/durable/workflows/apikey.ts:169
          module:src/lib/dashboard/home.server.ts · where @ src/lib/dashboard/home.server.ts:126
          module:src/lib/dashboard/members.server.ts · where @ src/lib/dashboard/members.server.ts:124 (+1, --all)
mentions  module:src/app/api/v1/cli/logins/[id]/token/route.ts · by text · +1 lines @ src/app/api/v1/cli/logins/[id]/token/route.ts:49
          module:src/durable/workflows/apikey.ts · by text · +7 lines @ src/durable/workflows/apikey.ts:56
          module:src/durable/workflows/cli-login.ts · by text · +12 lines @ src/durable/workflows/cli-login.ts:95
          module:src/lib/api/read.ts · by text @ src/lib/api/read.ts:490 (+5, --all)
not       column:CliLogin.expiresAt @ prisma/schema.prisma:568
          column:Upload.expiresAt @ prisma/schema.prisma:666
```

Two writers, both through the one helper that mints a key row, each with the door that admits its workflow where the index found one, `none` here: both runs are started from a page's action and the keys route, a start the index does not read as a door's; then the starters the index could not read, the columns the write sets and the ledger resource its images land under. `raw` is every mutation of the table outside a recorded write; none here. `reads` is who reads the column and how, by the call's section; `mentions` the modules that merely spell it, by text, never a read. `not` names the same-named columns under other models, so nobody confuses them. `unknown · 4 bodies not indexed` under `started by` means the list is empty while four bodies the index never read stand, the engine's own; `none` means proved empty.

## What a change reaches

```bash
durable-sdk graph impact --files src/durable/workflows/cli-login.ts
```

Above the lines below, the answer names the changed module with its exports, its twins and its importers with the import closure counted by root. The lines from `bodies` on:

```text
bodies    4 in module:src/durable/workflows/cli-login.ts (their own module): workflow:cli.login.approve, workflow:cli.login.consume, workflow:cli.login.deny, workflow:cli.login.start
          +50 in the closure's modules by module alone, their folds never reaching the change (counted, never claimed)
doors     door:api:cli.login.open · admits workflow:cli.login.start @ src/app/api/v1/cli/logins/route.ts:19
          door:api:cli.login.token · admits workflow:cli.login.consume @ src/app/api/v1/cli/logins/[id]/token/route.ts:36
facts     fact:apikey.revoked → none · emitted by workflow:cli.login.consume
          fact:cli.login.completed → none · emitted by workflow:cli.login.consume
tables    column:ApiKey.createdBy · written by step:cli.login.approve:cli.login.approve.key
          column:ApiKey.expiresAt · written by step:cli.login.approve:cli.login.approve.key
          column:ApiKey.hash · written by step:cli.login.approve:cli.login.approve.key
          column:ApiKey.id · read by module:src/durable/workflows/cli-login.ts (where) · written by step:cli.login.approve:cli.login.approve.key
          column:ApiKey.kind · written by step:cli.login.approve:cli.login.approve.key
          column:ApiKey.name · written by step:cli.login.approve:cli.login.approve.key
          column:ApiKey.owner · written by step:cli.login.approve:cli.login.approve.key
          column:ApiKey.prefix · written by step:cli.login.approve:cli.login.approve.key
          column:ApiKey.revokedAt · written by step:cli.login.consume:cli.login.consume.row
          column:ApiKey.revokedBy · written by step:cli.login.consume:cli.login.consume.row
          column:ApiKey.scope · written by step:cli.login.approve:cli.login.approve.key
          column:ApiKey.tenantId · read by module:src/durable/workflows/cli-login.ts (where) · written by step:cli.login.approve:cli.login.approve.key
          column:CliLogin.apiKeyId · read by module:src/durable/workflows/cli-login.ts (data)
          column:CliLogin.approvedAt · read by module:src/durable/workflows/cli-login.ts (data) · written by step:cli.login.approve:cli.login.approve.row
          column:CliLogin.approvedBy · read by module:src/durable/workflows/cli-login.ts (data) · written by step:cli.login.approve:cli.login.approve.row
          column:CliLogin.client · read by module:src/durable/workflows/cli-login.ts (data) · written by step:cli.login.start:cli.login.start.row (+19, --all)
providers none
refusals  refusal:plane:plane.key.scope · judged run at workflow:cli.login.approve, judged run at workflow:cli.login.start
          refusal:plane:plane.login.code_unknown · judged run at workflow:cli.login.approve, judged run at workflow:cli.login.deny
          refusal:plane:plane.login.expired · judged run at workflow:cli.login.approve, judged row at door:api:cli.login.token
          +5 judged at the doors above and at no reached step (the doors' whole catalogues, --all)
```

The radius is read off both halves of the graph: the bodies whose module or fold reaches the change, with the closure's bodies counted apart and never claimed; one hop over the engine's graph, the doors that admit them, the facts they emit with their listeners, the columns they write or read, the providers they call and the refusals they hand; then the rules whose holds name any of it with their guard files, the pages and the ADRs that name it, the tests one hop out, and on the last line what `durable-sdk test --changed` runs for it. `durable-sdk graph impact --changed` reads the working tree's change against `--base <ref>`, `origin/develop` unless said; `--files a.ts,b.ts` names the files instead; `--types` joins the type-only import edges; every list folds at sixteen unless `--all`. `durable-sdk graph diff --base <ref>` is the other reading of a change: what the graph gained, lost and changed against the ref's committed index, names only.

## What a run of `domain.add` does, step by step, and what can fail where

```bash
durable-sdk explain domain.add
```

```text
durable-sdk explain: workflow:domain.add · key [tenantId, appId, hostname, requestId] · version 1 @ src/durable/workflows/domain.ts:194
          "Adds a custom hostname to an app's project (Pro and up) and keeps its TXT challenge; emits domain.added."
admitted by none
started by unknown · 4 bodies not indexed
refuses   refusal:plane:plane.domain.invalid · "<hostname> is not a hostname" · judged run @ src/durable/workflows/domain.ts:212
          refusal:plane:plane.domain.taken · "<hostname> is already taken" · judged run @ src/durable/workflows/domain.ts:263
          refusal:plane:plane.domain.taken · "<hostname> is already taken" · judged run @ src/durable/workflows/domain.ts:366
step      domain.add.judge · ctx.step · read · cannot undo: a read · id judge @ src/durable/workflows/domain.ts:213
  refuses refusal:plane:plane.app.not_found · "no app <slug> under this organization" · judged step @ src/durable/workflows/domain.ts:219
          refusal:plane:plane.domain.platform · "<hostname> is the app's own hostname and is never removed" · judged step @ src/durable/workflows/domain.ts:233
          refusal:plane:plane.domain.taken · "<hostname> is already taken" · judged step @ src/durable/workflows/domain.ts:247
          refusal:plane:plane.tier.custom_domain · "custom domains are Pro and up" · judged step @ src/durable/workflows/domain.ts:223
step      domain.add.provider · defineExternalStep · external · undo · id provider · onFail return @ src/durable/workflows/domain.ts:135
  calls   provider:hosting.addDomain · via hostingFor @ src/durable/workflows/domain.ts:164
          provider:hosting.findDomain · via hostingFor @ src/durable/workflows/domain.ts:146
          provider:hosting.removeDomain · via hostingFor @ src/durable/workflows/domain.ts:179
step      domain.add.row · ctx.step · ledgered · undo · id row @ src/durable/workflows/domain.ts:275
  writes  column:Domain.status, .verificationTxt, .removedAt, .verifiedAt · key domain.add.row:domain · ledger domain · via rowWrite@src/durable/workflows/rows.ts:76 @ src/durable/workflows/rows.ts:80
  raw     table:Domain · deleteMany · data none @ src/durable/workflows/domain.ts:344
  calls   provider:hosting.findDomain · via hostingFor @ src/durable/workflows/domain.ts:278
step      domain.add.taken · ctx.step · external · cannot undo: the hostname was never the app's: it is taken off the project · id taken @ src/durable/workflows/domain.ts:351
  calls   provider:hosting.removeDomain · via hostingFor @ src/durable/workflows/domain.ts:355
through   module:src/durable/workflows/buckets.ts
          module:src/durable/workflows/facts.ts
          module:src/durable/workflows/rows.ts
          module:src/durable/workflows/shared.ts (+8, --all)
emits     fact:domain.added · parts tenantId, domainId, requestId · key domain.added:{tenantId}:{domainId}:{requestId} · "A custom domain was added to the app's project with its challenge pending (ADR-0105 D08)." @ src/durable/events/catalog.ts:514
  listeners none
waits     none
starts    none
calls     none
```

Four steps, four ways to fail. `domain.add.judge` is a read: it cannot be undone and need not be, and the four refusals it judges end the run as values. `domain.add.provider` is external with an undo and carries `onFail return`, so a refused call comes back to the body as a value and the run goes on, never to limbo. `domain.add.row` is ledgered with an undo: a failure after it runs the undo in reverse, and a failure inside it leaves the run in limbo for a person with its rows. `domain.add.taken` says why it has no undo. A step with `undo` and no `onFail` is the one that can stop a run; a step with `onFail return` ends as a value. The three refusals under the head are the run's own, judged between its steps.

## The closure from a node, and the chain between two

```bash
durable-sdk graph walk fact:deployment.ready --direction out --depth 2
```

```text
walk fact:deployment.ready · out · depth 2 · 1 edge · 2 nodes
depth 1
fact:deployment.ready listens listener:record-deployment-ready · record
depth 2
listener:record-deployment-ready starts none
```

The walk is the closure from a node, one depth at a time, each edge its kind and what it carries; under the edges the verb prints one sentence per primitive met, its drawback as the registry states it. `--direction in` walks the other way, who starts a workflow or who emits what it listens on; `--kinds` and `--node-kinds` keep the edge and node kinds named, refused by name otherwise; the depth is one to four.

```bash
durable-sdk graph path door:api:deployments.create provider:github.createCheckRun
```

```text
path door:api:deployments.create → provider:github.createCheckRun · 3 hops
door:api:deployments.create admits workflow:deploy.create @ src/app/api/v1/apps/[slug]/deployments/route.ts:38
workflow:deploy.create declares step:deploy.create:deploy.create.check_finish · defineExternalStep · external · no undo · id check-finish · onFail return @ src/durable/workflows/deploy.ts:527
step:deploy.create:deploy.create.check_finish calls provider:github.createCheckRun · via githubFor @ src/durable/workflows/deploy.ts:591
```

The first chain between two nodes: the door, the run it admits, the external step that opens the check run and the provider capability it calls, with the file and line of each hop. Two nodes that do not connect within six hops answer `none within 6 hops`.

## The same, drawn

> Diagram: The storefront sample of the landing page, drawn: the walk from its checkout door, three hops out. Press Walk to watch it fill one depth a beat; the pane under it prints the walk as the agent reads it.

[The graph, drawn](https://durablesdk.com/docs/guide/the-graph-drawn.md) has three figures a press can walk.

## The committed map

A card needs no CLI. The platform's own map is committed under `docs/map/` of its app directory, one card per door, workflow, listener, fact, table column and provider, rendered by the same renderer and held byte for byte, so `grep` alone is the card:

```bash
grep -rn '^workflow:cli.login.consume ' docs/map/
```

```text
docs/map/cards/cli.txt:33:workflow:cli.login.consume · key [loginId, requestId] · version 1 @ src/durable/workflows/cli-login.ts:497
```

A card opens on its id at column zero and ends at the next blank line; `grep -rn '<id>' docs/map/` is every line that names the id. The map's README names every file with its first and last id, the grammar, and the coverage line the walk wrote:

```text
gen-graph-index: 54 bodies (0 unresolved) · 142 steps · writes read on 53/54 ledgered steps · tables on 59/63 writes · columns on 58/63 · raw 65 · keys read on 49/50 workflows · doors 63/63 · refusals 137 · facts 32 · providers 75 capabilities · calls 148
```

The graph is generated, never guessed, so an answer says what the walk could not read instead of filling it in. `unknown · n bodies not indexed` under a word drawn from bodies, such as `started by`, `emitted by` or `called by`, means the list is empty while bodies the index never read stand. `none` means proved empty. `unread` is a value the walk could not read, `<expression>` a part spelled past what it reads, `a part unread` a table whose columns were not read whole; the README counts each under the coverage line:

```text
The map: 498 cards (doors 63, workflows 50, listeners 8, facts 51, columns 251, providers 75) in 22 files, 790654 bytes; the largest file `tables/app-5.txt` (65462 bytes), the largest card `door:api:deployments.create` (12453 bytes). Unread, printed `unread` or `<expression>` on its card and counted by the walk's own line above: keys on 1 of 50 workflows, tables on 4 of 63 writes, columns on 5 of 63 writes.
```

## A tenant's app gets the same

`durable-sdk init` writes `graph-index.json` and `workflow-index.json` beside `durable.config.ts`, and the config hands the index to the engine, so a deployment's `GET catalog/graph` carries the body edges too. The build runs `durable-sdk index` before the migration, so the deployed graph is current by construction; `durable-sdk test --changed` runs `durable-sdk index --check` first and goes red on a stale commit, the fix on the line. The verbs answer at the app's root from the first commit. This is the template's own run, as the verb prints it there:

```bash
durable-sdk explain hello.say
```

```text
durable-sdk explain: workflow:hello.say · key [name, requestId] · version 1 @ src/workflows/hello.ts:25
          "Greets a name once per request, undone when a later step fails."
admitted by none
started by unknown · 4 bodies not indexed
refuses   none
step      hello.say.greet · ctx.step · provider · undo @ src/workflows/hello.ts:33
through   none
emits     fact:hello.said · parts requestId · key hello.said:{requestId} · "Someone was greeted; one fact per request." @ src/events/catalog.ts:19
  listeners listener:note-greeting · record · starts none @ src/listeners.ts:10
waits     none
starts    none
calls     none
holds     (no graph-refs.json: pnpm gen:graph-refs)
pages     (no graph-refs.json: pnpm gen:graph-refs)
adr       by text (no graph-refs.json: pnpm gen:graph-refs)
tests     (no graph-refs.json: pnpm gen:graph-refs)
runtime   schedule none · cap, cancels, hooks, services: --api (catalog/graph) · observed steps and p95: --api (catalog/workflows?prefix=hello.say)
```

The four lines that read `(no graph-refs.json: pnpm gen:graph-refs)` are the checkout's half: the rules, the pages, the ADRs and the tests come with the refs file, which two generators of the engine's own tree write over an app directory today, the map with them; they are not verbs of the CLI yet, and the card says so rather than guessing. `durable-sdk graph impact` at a scaffold's root names the bodies, doors, facts, tables, providers and refusals a change reaches and says the same of the lines the refs file would fill.

## With a connection

`--json` on any verb prints the answer as data, the shape an agent parses. `--api <url>` on `explain`, `graph walk` and `graph path` reads the live graph of a deployment instead of the file, with `ADMIN_TOKEN` in the environment: the registries' edges the index cannot carry, a schedule, a cap, the reverters, and under `runtime` a workflow's observed steps. A self-hosted app has that bearer. A hosted app's is held sealed by the platform, so on the hosted platform the console proxy forwards the same read with a key: `GET /api/v1/apps/<slug>/console/catalog/graph?from=<node>&direction=out&depth=2&format=text` answers the walk's lines, `depth` one to three there, `drawbacks=table` the sentences once. The MCP is coming as `durable-sdk mcp`; its `graph_explain`, `graph_impact` and `graph_walk` tools are the same card, radius and walk off the checkout the server runs in, the deployment's half joined when it answers. [MCP and agents](https://durablesdk.com/docs/reference/mcp-and-agents.md) says what an agent uses until then.

## For an agent

Ask first, then open the `file:line` the line ends on; never answer "what happens" or "what is affected" by reading the tree top to bottom. Before an edit, `durable-sdk explain <subject>` for the door, the run or the column you will touch. After the edit and before the commit, `durable-sdk graph impact --changed`, and run what its last line names. The `AGENTS.md` a scaffolded app carries names `durable-sdk explain` as the first read and `durable-sdk graph walk` as the closure.

On an app with no index the verbs answer `no graph-index.json at <root>` and stop; `durable-sdk index` writes it.

---

Prompt for an agent:

```text
Read https://durablesdk.com/docs/guide/vibe-coding-with-the-graph.md, then ask the graph what the CLI's login door admits, what writes ApiKey.expiresAt, what a change to the login module reaches and what a run of domain.add does step by step, then open the file and line the answer ends on before changing it; run durable-sdk doctor --host before and after; a refused line is a refusal id: durable-sdk explain <id>
```
