{
  "schemaVersion": 1,
  "generatedAt": "2026-08-17T18:36:02.850Z",
  "generationKey": "53f8144616b572d64dabbd80669c564c2825512b70362df790aadcebc48c5c4f",
  "metadataPayloadSha256": "c7e71c15a76cfd0b53f985f537b0f44b81c922b23f08c4a585da34d601f2fd5d",
  "diagram": {
    "id": "ports-primary-runtime-flow-3a39f92a",
    "title": "Ports — primary runtime flow",
    "description": "One durable run. The web process owns admission, the queued row, and the stream tail; the worker owns the model loop; the approval decision and the suspended-to-queued transition commit together before the worker is notified.",
    "status": "current",
    "canonicalAppearanceKey": "tsx:src/app/(docs)/docs/modules/ports/page.tsx:primaryRuntimeFlowChart#1"
  },
  "aliases": [],
  "concepts": [
    "Primary runtime flow",
    "Modules",
    "Ports"
  ],
  "keywords": [
    "agent-run routes (API)",
    "GET {id}/stream (API)",
    "Durable executor + pg-boss queue (service)",
    "agent_runs + run_steps + run_approvals (store)",
    "commit queued agent_runs row, then enqueue job",
    "append run_steps, update budgets",
    "pending run_approvals row, status suspended",
    "Chat model (model)",
    "worker claims the run",
    "text or tool calls",
    "Your app (agents:run / runs:read)",
    "Admission control (service)",
    "Agent runner (service, worker)",
    "Tool registry under capability lock (service)",
    "createAgentRun — input, optional conversationId",
    "concurrency + monthly spend checks",
    "admitted (else 429 or 402)",
    "single-step generation with the locked toolset",
    "execute tool under scope + lock checks",
    "streamRun — replay persisted steps, then poll",
    "suspended frame, stream closes",
    "resolveRunApproval — allow or deny",
    "decision + suspended-to-queued commit together",
    "resume from the persisted cursor",
    "terminal status + output",
    "final frame with text and citations",
    "/api/v1",
    "/api/v1/runs"
  ],
  "mermaid": {
    "type": "sequence",
    "sourceSha256": "3a39f92a07b0bccbfc5c8661732c7474c7e0ad6586907e8289e4ee28b2806830"
  },
  "provenance": [
    {
      "appearanceKey": "tsx:src/app/(docs)/docs/modules/ports/page.tsx:primaryRuntimeFlowChart#1",
      "surface": "route",
      "sourcePath": "src/app/(docs)/docs/modules/ports/page.tsx",
      "line": 124,
      "route": "/docs/modules/ports",
      "symbol": "primaryRuntimeFlowChart",
      "caption": "One durable run. The web process owns admission, the queued row, and the stream tail; the worker owns the model loop; the approval decision and the suspended-to-queued transition commit together before the worker is notified."
    }
  ],
  "embeddedMetadata": [
    {
      "sourcePath": "src/app/(docs)/docs/modules/ports/page.tsx",
      "caption": "One durable run. The web process owns admission, the queued row, and the stream tail; the worker owns the model loop; the approval decision and the suspended-to-queued transition commit together before the worker is notified."
    }
  ],
  "generation": {
    "application": {
      "name": "eli-ai",
      "version": "0.1.0"
    },
    "environment": {
      "node": "v26.3.1",
      "yarn": "4.17.1",
      "platform": "linux",
      "architecture": "x64",
      "containerImage": "playwright:v1.62.1-noble@sha256:c091b21d9fae78c76e85cd4356431e9b018402f172a214fc7d7a5e9a7e29d8ac+node:26.3.1-bookworm-slim@sha256:209558c3e5e40e8adff68959d3c2ba7cd73723e716d89196878a0c362fa1e109"
    },
    "packages": {
      "mermaid": "11.16.0",
      "mermaidCli": "11.16.0",
      "playwright": "1.62.1",
      "playwrightCore": "1.62.1",
      "puppeteer": "25.6.0",
      "puppeteerCore": "25.6.0"
    },
    "renderer": {
      "mermaidConfigSha256": "68c10966fe84406ee626034d58bfabd555df9f65f691204b7c46db24038da101",
      "themeCssSha256": "c80287a78d80ad63d27bd5ca348b2ef9a7e2f44da289e436be6484ea28a1b033",
      "browser": {
        "name": "chromium",
        "revision": "1234",
        "version": "151.0.7922.34",
        "executableSha256": "0b20b130e7edd9dd51873be867761295fe0cfad490c2b9a64f95bd3cfc08fa71"
      },
      "font": {
        "family": "Eli Diagram Inter Variable",
        "fileSha256": "3100e775e8616cd2611beecfa23a4263d7037586789b43f035236a2e6fbd4c62",
        "licenseSha256": "3b0a5fca3d17942cde889069889dedbbbd075e9b599968c82a95f4d944e9b345"
      }
    },
    "adapterVersions": {
      "diagramGenerator": "2",
      "drawioFlowchart": "1",
      "drawioSequence": "1",
      "drawioState": "1",
      "drawioGantt": "1"
    }
  },
  "artifacts": {
    "mmd": "/diagrams/ports-primary-runtime-flow-3a39f92a/ports-primary-runtime-flow-3a39f92a.mmd",
    "svg": "/diagrams/ports-primary-runtime-flow-3a39f92a/ports-primary-runtime-flow-3a39f92a.svg",
    "png": "/diagrams/ports-primary-runtime-flow-3a39f92a/ports-primary-runtime-flow-3a39f92a.png",
    "drawio": "/diagrams/ports-primary-runtime-flow-3a39f92a/ports-primary-runtime-flow-3a39f92a.drawio",
    "json": "/diagrams/ports-primary-runtime-flow-3a39f92a/ports-primary-runtime-flow-3a39f92a.json"
  },
  "artifactSha256": {
    "mmd": "193779ecd2d845a7249fc85f6038deab35296fa6e10f440590d98abe663d95ce",
    "svg": "edc2205d399e2c1c1fe72fa468645d649d0e66061015cc099908a48f369d7bc9",
    "png": "f260f3a3444e7a65b59a41d2aae955533f6aa86dd5517951ee3983fada25a9d7",
    "drawio": "f3a2c2408c39ae9559d2899327ad26e714cad23bbceaf812abfe5ab5f4347983"
  }
}
