import{_ as i,o as a,c as n,ag as e}from"./chunks/framework.CmQHR1bQ.js";const E=JSON.parse('{"title":"Venture Service Catalog (v1)","description":"","frontmatter":{},"headers":[],"relativePath":"reference/SERVICE_CATALOG.md","filePath":"reference/SERVICE_CATALOG.md"}'),t={name:"reference/SERVICE_CATALOG.md"};function l(p,s,h,k,r,o){return a(),n("div",null,[...s[0]||(s[0]=[e(`<h1 id="venture-service-catalog-v1" tabindex="-1">Venture Service Catalog (v1) <a class="header-anchor" href="#venture-service-catalog-v1" aria-label="Permalink to &quot;Venture Service Catalog (v1)&quot;">​</a></h1><h2 id="overview" tabindex="-1">Overview <a class="header-anchor" href="#overview" aria-label="Permalink to &quot;Overview&quot;">​</a></h2><p>This document catalogs every service in the Venture system: name, port, language, dependencies, health check, scaling notes, and environment contracts. Use this as the canonical reference for service deployment, inter-service communication, and orchestration.</p><hr><h2 id="service-registry" tabindex="-1">Service Registry <a class="header-anchor" href="#service-registry" aria-label="Permalink to &quot;Service Registry&quot;">​</a></h2><h3 id="_1-control-plane-api-port-8000" tabindex="-1">1. control-plane-api (Port 8000) <a class="header-anchor" href="#_1-control-plane-api-port-8000" aria-label="Permalink to &quot;1. control-plane-api (Port 8000)&quot;">​</a></h3><p><strong>Language</strong>: Python 3.14 (FastAPI)</p><p><strong>Responsibility</strong>: Founder-facing REST + WebSocket API; task submission, policy publishing, system controls (freeze, kill-switch, rollback).</p><p><strong>Dependencies</strong>:</p><ul><li>policy-engine (:8001) — validate task intents</li><li>venture-orchestrator (:8005) — dispatch tasks</li><li>ledger-db (:5432, PostgreSQL) — query workflows, audit trail</li><li>redis-cache (:6379) — session store, rate limiting</li></ul><p><strong>Scaling</strong>: 1 replica (founder ops bottleneck; could scale to 2 with sticky sessions).</p><p><strong>Health Check</strong>:</p><ul><li>Endpoint: <code>GET /health</code></li><li>Response: <code>{ &quot;status&quot;: &quot;ok&quot;, &quot;timestamp&quot;: &quot;...&quot;, &quot;dependencies&quot;: { &quot;policy-engine&quot;: &quot;ok&quot;, ... } }</code></li><li>Timeout: 5s</li><li>Interval: 10s</li></ul><p><strong>Startup Order</strong>: After policy-engine, venture-orchestrator, ledger-db, redis-cache.</p><p><strong>Environment Variables</strong>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CONTROL_PLANE_HOST</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">0.0.0.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CONTROL_PLANE_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">8000</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CONTROL_PLANE_LOG_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">INFO</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CONTROL_PLANE_REQUEST_TIMEOUT_SECONDS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">30</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CONTROL_PLANE_CORS_ORIGINS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">*</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # restrict in production</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POLICY_ENGINE_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">http://policy-engine:8001</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">VENTURE_ORCHESTRATOR_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">http://venture-orchestrator:8005</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">LEDGER_DB_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://user:pass@ledger-db:5432/venture</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">FOUNDER_AUTH_MODE</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">mTLS</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # or bearer-token</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  control-plane-api</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">python -m uvicorn control_plane.api:app --host 0.0.0.0 --port 8000 --log-level info</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      CONTROL_PLANE_PORT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">8000</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      POLICY_ENGINE_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">http://policy-engine:8001</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">      # ... (other env vars)</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    depends_on</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">policy-engine</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">venture-orchestrator</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ledger-db</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis-cache</span></span></code></pre></div><p><strong>Endpoints</strong> (representative):</p><ul><li><code>POST /workflows</code> — submit task intent</li><li><code>GET /workflows</code> — list active workflows</li><li><code>GET /workflows/{id}</code> — workflow detail + progress</li><li><code>POST /workflows/{id}/cancel</code> — cancel workstream</li><li><code>POST /control/freeze</code> — global pause</li><li><code>POST /control/unfreeze</code> — resume</li><li><code>POST /policies/publish</code> — publish new policy bundle</li><li><code>GET /audit/{workflow_id}</code> — retrieve audit trail</li><li><code>GET /health</code> — system health + incidents</li><li><code>WebSocket /ws/workflows/{id}</code> — real-time task completion events</li></ul><hr><h3 id="_2-policy-engine-port-8001" tabindex="-1">2. policy-engine (Port 8001) <a class="header-anchor" href="#_2-policy-engine-port-8001" aria-label="Permalink to &quot;2. policy-engine (Port 8001)&quot;">​</a></h3><p><strong>Language</strong>: Python 3.14 (FastAPI)</p><p><strong>Responsibility</strong>: Tool allowlist enforcement, task intent validation, schema registry, workload identity verification, prompt injection defense.</p><p><strong>Dependencies</strong>:</p><ul><li>redis-cache (:6379) — tool allowlist cache, policy cache</li><li>ledger-db (:5432) — schema registry, policy bundle history</li></ul><p><strong>Scaling</strong>: Horizontal (multiple replicas behind HTTP load balancer). Cache layer (Redis) absorbs most read load; direct DB fallback on cache miss.</p><p><strong>Health Check</strong>:</p><ul><li>Endpoint: <code>GET /health</code></li><li>Response: <code>{ &quot;status&quot;: &quot;ok&quot;, &quot;cache_hit_rate&quot;: 0.95, &quot;db_latency_ms&quot;: 15 }</code></li><li>Timeout: 5s</li><li>Interval: 10s</li></ul><p><strong>Startup Order</strong>: After redis-cache, ledger-db.</p><p><strong>Environment Variables</strong>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POLICY_ENGINE_HOST</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">0.0.0.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POLICY_ENGINE_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">8001</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POLICY_ENGINE_LOG_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">INFO</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POLICY_ENGINE_CACHE_TTL_SECONDS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">300</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POLICY_ENGINE_DB_FALLBACK_TIMEOUT_MS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">1000</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">LEDGER_DB_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://user:pass@ledger-db:5432/venture</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POLICY_BUNDLE_REFRESH_INTERVAL_SECONDS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">60</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">TOOL_ALLOWLIST_CACHE_KEY_PREFIX</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">policy:allowlist:</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  policy-engine</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">python -m uvicorn policy_engine.api:app --host 0.0.0.0 --port 8001 --workers 4</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      POLICY_ENGINE_PORT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">8001</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      POLICY_ENGINE_CACHE_TTL_SECONDS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">300</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      LEDGER_DB_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      REDIS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    depends_on</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis-cache</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ledger-db</span></span></code></pre></div><p><strong>Endpoints</strong> (representative):</p><ul><li><code>POST /evaluate-intent</code> — validate task intent against schema + tool allowlist</li><li><code>POST /check-tool-allowed</code> — check if tool_name permitted for agent_role</li><li><code>GET /schemas/{task_type}</code> — retrieve schema for task type</li><li><code>GET /policy-bundle/{version}</code> — fetch policy bundle by version</li><li><code>POST /schemas/register</code> — register new task type schema</li><li><code>GET /health</code> — health status + metrics</li></ul><p><strong>Inter-Service Communication</strong>:</p><ul><li>Called by: control-plane-api (validate intents), agent-runtime (check tool permissions), treasury-api (authorization checks)</li><li>Protocol: HTTP REST (sync request/response)</li></ul><hr><h3 id="_3-artifact-compiler-port-8002" tabindex="-1">3. artifact-compiler (Port 8002) <a class="header-anchor" href="#_3-artifact-compiler-port-8002" aria-label="Permalink to &quot;3. artifact-compiler (Port 8002)&quot;">​</a></h3><p><strong>Language</strong>: Python 3.14 (FastMCP)</p><p><strong>Responsibility</strong>: Artifact IR spec validation, deterministic build pipeline (validate → render → export), provenance attachment, non-deterministic provider handling.</p><p><strong>Dependencies</strong>:</p><ul><li>ledger-db (:5432) — artifact_ir, artifact_builds, artifact_provenance tables</li><li>event-bus (NATS, :4222) — emit artifact events</li><li>redis-cache (:6379) — build result cache, idempotency tracking</li><li>External APIs: Claude API, Veo/Banana (for rendering)</li></ul><p><strong>Scaling</strong>: Horizontal (queue-based dispatch via NATS work queue). Queue depth monitored; scale up if depth &gt; 50.</p><p><strong>Health Check</strong>:</p><ul><li>Endpoint: <code>GET /health</code></li><li>Response: <code>{ &quot;status&quot;: &quot;ok&quot;, &quot;build_queue_depth&quot;: 3, &quot;cache_hit_rate&quot;: 0.75 }</code></li><li>Timeout: 5s</li><li>Interval: 10s</li></ul><p><strong>Startup Order</strong>: After ledger-db, event-bus, redis-cache.</p><p><strong>Environment Variables</strong>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ARTIFACT_COMPILER_HOST</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">0.0.0.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ARTIFACT_COMPILER_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">8002</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ARTIFACT_COMPILER_LOG_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">INFO</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ARTIFACT_COMPILER_BUILD_TIMEOUT_SECONDS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">300</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ARTIFACT_COMPILER_CACHE_TTL_DAYS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">7</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">LEDGER_DB_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://user:pass@ledger-db:5432/venture</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">CLAUDE_API_KEY</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sk-...</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">VEO_API_KEY</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">...</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">BANANA_API_KEY</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">...</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ARTIFACT_COMPILER_POLICY_TIER_DEFAULT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">balanced</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  artifact-compiler</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">python -m artifact_compiler.api:app --host 0.0.0.0 --port 8002</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      ARTIFACT_COMPILER_PORT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">8002</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      ARTIFACT_COMPILER_BUILD_TIMEOUT_SECONDS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">300</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      LEDGER_DB_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      NATS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      REDIS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      CLAUDE_API_KEY</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">\${CLAUDE_API_KEY}</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    depends_on</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ledger-db</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">event-bus</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis-cache</span></span></code></pre></div><p><strong>Endpoints</strong> (representative):</p><ul><li><code>POST /artifacts/register-ir</code> — register artifact IR spec</li><li><code>POST /artifacts/{ir_id}/build</code> — start artifact build pipeline</li><li><code>GET /artifacts/{build_id}/status</code> — poll build status</li><li><code>POST /artifacts/{build_id}/replay</code> — re-render artifact (cache bypass)</li><li><code>GET /health</code> — health status + queue metrics</li></ul><p><strong>Inter-Service Communication</strong>:</p><ul><li>Subscribes to: task completion events (async)</li><li>Publishes to: event-bus (artifact.ir.registered, artifact.build.started, artifact.build.completed, artifact.provenance.attested)</li></ul><hr><h3 id="_4-treasury-api-port-8003" tabindex="-1">4. treasury-api (Port 8003) <a class="header-anchor" href="#_4-treasury-api-port-8003" aria-label="Permalink to &quot;4. treasury-api (Port 8003)&quot;">​</a></h3><p><strong>Language</strong>: Python 3.14 (FastAPI)</p><p><strong>Responsibility</strong>: Authorization decisions, double-entry ledger, velocity controls, merchant/category enforcement, reconciliation.</p><p><strong>Dependencies</strong>:</p><ul><li>ledger-db (:5432) — money_intents, authorization_decisions, ledger_entries tables</li><li>event-bus (NATS, :4222) — emit money events, subscribe to task events</li><li>redis-cache (:6379) — velocity control tracking, lock store</li><li>policy-engine (:8001) — policy bundle validation</li></ul><p><strong>Scaling</strong>: 1-2 replicas (state: ledger + authorization queue). Serialize via distributed lock (Redis) or DB-level serialization.</p><p><strong>Health Check</strong>:</p><ul><li>Endpoint: <code>GET /health</code></li><li>Response: <code>{ &quot;status&quot;: &quot;ok&quot;, &quot;ledger_latency_ms&quot;: 20, &quot;last_reconciliation&quot;: &quot;...&quot; }</code></li><li>Timeout: 5s</li><li>Interval: 10s</li></ul><p><strong>Startup Order</strong>: After ledger-db, event-bus, redis-cache, policy-engine.</p><p><strong>Environment Variables</strong>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">TREASURY_API_HOST</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">0.0.0.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">TREASURY_API_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">8003</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">TREASURY_API_LOG_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">INFO</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">TREASURY_API_AUTH_TIMEOUT_MS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">500</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">LEDGER_DB_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://user:pass@ledger-db:5432/venture</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POLICY_ENGINE_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">http://policy-engine:8001</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">TREASURY_RECONCILIATION_CRON</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">0</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # daily at midnight</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">TREASURY_GLOBAL_DAILY_CAP_CENTS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">1000000</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">TREASURY_VELOCITY_WINDOW_SECONDS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">3600</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  treasury-api</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">python -m uvicorn treasury.api:app --host 0.0.0.0 --port 8003</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      TREASURY_API_PORT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">8003</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      TREASURY_API_AUTH_TIMEOUT_MS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">500</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      LEDGER_DB_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      NATS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      REDIS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    depends_on</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ledger-db</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">event-bus</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis-cache</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">policy-engine</span></span></code></pre></div><p><strong>Endpoints</strong> (representative):</p><ul><li><code>POST /money/intents</code> — create money intent</li><li><code>POST /money/authorize</code> — authorize money intent</li><li><code>GET /money/intents/{id}</code> — fetch intent status</li><li><code>GET /ledger/{workflow_id}</code> — retrieve ledger entries for workflow</li><li><code>POST /reconciliation/run</code> — trigger reconciliation (admin)</li><li><code>GET /health</code> — health status</li></ul><p><strong>Inter-Service Communication</strong>:</p><ul><li>Calls: policy-engine (policy bundle fetch)</li><li>Publishes to: event-bus (money.intent.created, money.authorization.decided, ledger.entry.created)</li><li>Subscribes to: task completion events (settle ledger)</li></ul><hr><h3 id="_5-compliance-engine-port-8004" tabindex="-1">5. compliance-engine (Port 8004) <a class="header-anchor" href="#_5-compliance-engine-port-8004" aria-label="Permalink to &quot;5. compliance-engine (Port 8004)&quot;">​</a></h3><p><strong>Language</strong>: Python 3.14 (FastAPI)</p><p><strong>Responsibility</strong>: Policy rule evaluation, audit trail generation, violation detection + escalation, DSAR/deletion processing, incident classification.</p><p><strong>Dependencies</strong>:</p><ul><li>ledger-db (:5432) — compliance_cases, privacy_requests, audit_trail tables</li><li>event-bus (NATS, :4222) — subscribe to all events, emit compliance events</li><li>redis-cache (:6379) — rule cache, incident state</li></ul><p><strong>Scaling</strong>: 2+ replicas (read-heavy). NATS consumer groups handle fair distribution of events.</p><p><strong>Health Check</strong>:</p><ul><li>Endpoint: <code>GET /health</code></li><li>Response: <code>{ &quot;status&quot;: &quot;ok&quot;, &quot;event_lag_ms&quot;: 100, &quot;rule_cache_hit_rate&quot;: 0.88 }</code></li><li>Timeout: 5s</li><li>Interval: 10s</li></ul><p><strong>Startup Order</strong>: After ledger-db, event-bus, redis-cache.</p><p><strong>Environment Variables</strong>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMPLIANCE_ENGINE_HOST</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">0.0.0.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMPLIANCE_ENGINE_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">8004</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMPLIANCE_ENGINE_LOG_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">INFO</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMPLIANCE_ENGINE_RULE_CACHE_TTL_SECONDS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">300</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">LEDGER_DB_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://user:pass@ledger-db:5432/venture</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMPLIANCE_ENGINE_VIOLATION_ESCALATION_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">http://control-plane-api:8000/incidents</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COMPLIANCE_ENGINE_AUTO_FREEZE_ON_CRITICAL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">true</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  compliance-engine</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">python -m compliance.engine:app --host 0.0.0.0 --port 8004</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      COMPLIANCE_ENGINE_PORT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">8004</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      COMPLIANCE_ENGINE_RULE_CACHE_TTL_SECONDS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">300</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      LEDGER_DB_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      NATS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      REDIS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    depends_on</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ledger-db</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">event-bus</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis-cache</span></span></code></pre></div><p><strong>Endpoints</strong> (representative):</p><ul><li><code>POST /evaluate</code> — evaluate policy rule against action</li><li><code>GET /cases/{workflow_id}</code> — retrieve compliance cases for workflow</li><li><code>GET /audit/{workflow_id}</code> — retrieve audit trail</li><li><code>POST /privacy/requests</code> — submit DSAR/deletion request</li><li><code>GET /health</code> — health status</li></ul><p><strong>Inter-Service Communication</strong>:</p><ul><li>Subscribes to: all event topics (policy.<em>, workflow.</em>, task.<em>, money.</em>, etc.)</li><li>Publishes to: event-bus (compliance.evaluated, compliance.violation.detected, incident.classified)</li><li>Calls: control-plane-api (escalate incidents)</li></ul><hr><h3 id="_6-venture-orchestrator-port-8005" tabindex="-1">6. venture-orchestrator (Port 8005) <a class="header-anchor" href="#_6-venture-orchestrator-port-8005" aria-label="Permalink to &quot;6. venture-orchestrator (Port 8005)&quot;">​</a></h3><p><strong>Language</strong>: Python 3.14 (FastAPI)</p><p><strong>Responsibility</strong>: Portfolio management, workstream DAG execution, L1/L2/L3 task dispatch, task queue management, monitoring/alerting.</p><p><strong>Dependencies</strong>:</p><ul><li>ledger-db (:5432) — workflows, tasks, agent_actions tables</li><li>event-bus (NATS, :4222) — publish task events, subscribe to task completion</li><li>agent-runtime (Python, direct call for L1/L2)</li><li>redis-cache (:6379) — task queue, agent slot tracking</li></ul><p><strong>Scaling</strong>: 2+ replicas. Distributed task dispatch via Redis-backed queue (fair distribution).</p><p><strong>Health Check</strong>:</p><ul><li>Endpoint: <code>GET /health</code></li><li>Response: <code>{ &quot;status&quot;: &quot;ok&quot;, &quot;queue_depth&quot;: 5, &quot;agent_pool_utilization&quot;: 0.65 }</code></li><li>Timeout: 5s</li><li>Interval: 10s</li></ul><p><strong>Startup Order</strong>: After ledger-db, event-bus, agent-runtime, redis-cache.</p><p><strong>Environment Variables</strong>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">VENTURE_ORCHESTRATOR_HOST</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">0.0.0.0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">VENTURE_ORCHESTRATOR_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">8005</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">VENTURE_ORCHESTRATOR_LOG_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">INFO</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">VENTURE_ORCHESTRATOR_TASK_QUEUE_MAX_DEPTH</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">100</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">VENTURE_ORCHESTRATOR_L3_POOL_MAX_CONCURRENCY</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">10</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">VENTURE_ORCHESTRATOR_L3_TASK_TIMEOUT_SECONDS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">1800</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">LEDGER_DB_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://user:pass@ledger-db:5432/venture</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">AGENT_RUNTIME_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">http://agent-runtime:5000</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # for L1/L2 calls</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  venture-orchestrator</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">python -m uvicorn venture.orchestrator:app --host 0.0.0.0 --port 8005 --workers 2</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      VENTURE_ORCHESTRATOR_PORT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">8005</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      VENTURE_ORCHESTRATOR_L3_POOL_MAX_CONCURRENCY</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      LEDGER_DB_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      NATS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      REDIS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    depends_on</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ledger-db</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">event-bus</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">agent-runtime</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis-cache</span></span></code></pre></div><p><strong>Endpoints</strong> (representative):</p><ul><li><code>POST /dispatch/l1</code> — dispatch L1 orchestrator task</li><li><code>POST /dispatch/l2/{agent_type}</code> — dispatch L2 specialist task</li><li><code>POST /dispatch/l3</code> — dispatch L3 copilot CLI task</li><li><code>GET /queue/depth</code> — task queue depth</li><li><code>GET /agents/slots</code> — agent pool slot availability</li><li><code>POST /workflows/{id}/cancel</code> — cancel workstream</li><li><code>GET /metrics</code> — Prometheus metrics</li><li><code>GET /health</code> — health status</li></ul><p><strong>Inter-Service Communication</strong>:</p><ul><li>Calls: agent-runtime (L1/L2 task execution)</li><li>Publishes to: event-bus (task.dispatch.initiated, task.completed)</li><li>Subscribes to: task completion events (DAG progression)</li></ul><hr><h3 id="_7-agent-runtime-port-—-internal-no-exposed-http" tabindex="-1">7. agent-runtime (Port — internal, no exposed HTTP) <a class="header-anchor" href="#_7-agent-runtime-port-—-internal-no-exposed-http" aria-label="Permalink to &quot;7. agent-runtime (Port — internal, no exposed HTTP)&quot;">​</a></h3><p><strong>Language</strong>: Python 3.14</p><p><strong>Responsibility</strong>: L1 orchestrator, L2 specialist agents (Writer, Coder, Researcher, Analyst), L3 copilot CLI worker pool management, tool call auditing, result capture.</p><p><strong>Dependencies</strong>:</p><ul><li>policy-engine (:8001) — tool allowlist checks</li><li>event-bus (NATS, :4222) — emit tool.call.executed, task.completed events</li><li>ledger-db (:5432) — store results, agent_actions</li><li>redis-cache (:6379) — agent state, slot tracking</li></ul><p><strong>Scaling</strong>: Horizontal. Each replica manages subset of L2 agents + L3 worker pool. Consistent hashing for L2 dispatch.</p><p><strong>Health Check</strong>:</p><ul><li>Internal status: agent_runtime maintains /metrics (Prometheus) exposed via subsidiary HTTP service.</li><li>Check: <code>GET http://agent-runtime:5000/metrics</code> (if health sidecar enabled).</li><li>Metrics: active_agents, task_queue_depth, tool_calls_per_sec.</li></ul><p><strong>Startup Order</strong>: Before venture-orchestrator (orchestrator needs agent-runtime available).</p><p><strong>Environment Variables</strong>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">AGENT_RUNTIME_LOG_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">INFO</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">AGENT_RUNTIME_L2_AGENT_COUNT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">4</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # Writer, Coder, Researcher, Analyst (1 each or more)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">AGENT_RUNTIME_L3_MAX_CONCURRENCY</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">10</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">AGENT_RUNTIME_L3_TASK_TIMEOUT_SECONDS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">1800</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">AGENT_RUNTIME_L3_WORKSPACE_DIR</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">/tmp/venture-l3-workspace</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POLICY_ENGINE_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">http://policy-engine:8001</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">LEDGER_DB_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://user:pass@ledger-db:5432/venture</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">COPILOT_PATH</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">/usr/local/bin/copilot</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  agent-runtime</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">python -m agent_runtime.main</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      AGENT_RUNTIME_LOG_LEVEL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">INFO</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      AGENT_RUNTIME_L3_MAX_CONCURRENCY</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">10</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      AGENT_RUNTIME_L3_TASK_TIMEOUT_SECONDS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1800</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      POLICY_ENGINE_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">http://policy-engine:8001</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      NATS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">nats://event-bus:4222</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      LEDGER_DB_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgresql://...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      REDIS_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis://redis-cache:6379/0</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      COPILOT_PATH</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">/usr/local/bin/copilot</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    depends_on</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">policy-engine</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">event-bus</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ledger-db</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis-cache</span></span></code></pre></div><p><strong>Inter-Service Communication</strong>:</p><ul><li>Calls: policy-engine (tool allowlist checks)</li><li>Publishes to: event-bus (tool.call.executed, task.completed)</li><li>Queries: ledger-db (store results)</li></ul><hr><h3 id="_8-event-bus-nats-jetstream-port-4222" tabindex="-1">8. event-bus (NATS JetStream, Port 4222) <a class="header-anchor" href="#_8-event-bus-nats-jetstream-port-4222" aria-label="Permalink to &quot;8. event-bus (NATS JetStream, Port 4222)&quot;">​</a></h3><p><strong>Language</strong>: Go/Rust (NATS binary)</p><p><strong>Responsibility</strong>: Immutable event streams, topic fan-out, consumer group management, event replay, event persistence.</p><p><strong>Dependencies</strong>:</p><ul><li>PostgreSQL (optional backing store for persistence, :5432)</li></ul><p><strong>Scaling</strong>: 1 node (single-node mode) or 3+ node cluster (multi-node HA). Peer replication within cluster.</p><p><strong>Health Check</strong>:</p><ul><li>Endpoint (NATS monitoring): <code>GET http://event-bus:8222/healthz</code></li><li>Response: <code>{ &quot;status&quot;: &quot;ok&quot;, &quot;connections&quot;: 10, &quot;streams&quot;: 20 }</code></li><li>Timeout: 5s</li><li>Interval: 10s</li></ul><p><strong>Startup Order</strong>: Before any service that publishes/subscribes.</p><p><strong>Environment Variables</strong> (process-compose):</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># NATS Server Config</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">4222</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_HTTP_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">8222</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_JETSTREAM</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">true</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_STORE_DIR</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">/data/nats</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # file-based persistence</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">NATS_LOG_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">info</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  event-bus</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">/usr/local/bin/nats-server -c /config/nats.conf</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      NATS_PORT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">4222</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      NATS_HTTP_PORT</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">8222</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      NATS_JETSTREAM</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;true&quot;</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      NATS_STORE_DIR</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">/data/nats</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    ports</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;4222:4222&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;8222:8222&quot;</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    volumes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">./nats.conf:/config/nats.conf:ro</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">./data/nats:/data/nats</span></span></code></pre></div><p><strong>NATS Streams</strong> (topics):</p><ul><li><code>policy.&gt;</code> — policy published, policy evaluated</li><li><code>workflow.&gt;</code> — workflow created, started, completed, cancelled</li><li><code>task.&gt;</code> — task dispatched, running, completed, failed</li><li><code>artifact.&gt;</code> — artifact IR registered, build started/completed, provenance attested</li><li><code>money.&gt;</code> — intent created, authorization decided, settled</li><li><code>ledger.&gt;</code> — entry created, materialized, reconciliation completed</li><li><code>compliance.&gt;</code> — evaluated, violation detected, case opened</li><li><code>privacy.&gt;</code> — request received, DSAR compiled, deletion completed</li><li><code>audit.&gt;</code> — checksum computed, integrity verified</li></ul><p><strong>Consumer Groups</strong>: Each consumer group (e.g., &quot;ledger-db&quot;, &quot;compliance-engine&quot;) consumes events independently; NATS tracks offset per group.</p><p><strong>Inter-Service Communication</strong>:</p><ul><li>All services publish to event-bus; all services subscribe to relevant topics.</li><li>Request/Reply pattern: some RPCs use NATS request/reply (e.g., policy evaluation).</li></ul><hr><h3 id="_9-ledger-db-postgresql-port-5432" tabindex="-1">9. ledger-db (PostgreSQL, Port 5432) <a class="header-anchor" href="#_9-ledger-db-postgresql-port-5432" aria-label="Permalink to &quot;9. ledger-db (PostgreSQL, Port 5432)&quot;">​</a></h3><p><strong>Language</strong>: SQL (PostgreSQL 15+)</p><p><strong>Responsibility</strong>: Event store (append-only), read projections, state snapshots, schema registry, policy bundles, audit logs, checksum integrity.</p><p><strong>Dependencies</strong>: None (foundational).</p><p><strong>Scaling</strong>: 1 primary + 1-2 replicas (async streaming replication). Failover via pg_failover_slot or Patroni.</p><p><strong>Health Check</strong>:</p><ul><li>Endpoint: <code>psql -h ledger-db -U venture -d venture -c &quot;SELECT 1;&quot;</code></li><li>Response: <code>(1 row)</code></li><li>Timeout: 5s</li><li>Interval: 10s</li></ul><p><strong>Startup Order</strong>: First (foundational service).</p><p><strong>Environment Variables</strong>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_HOST</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ledger-db</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">5432</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_DB</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">venture</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_USER</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">venture</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_PASSWORD</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">...</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # from secret</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_LOG_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">warn</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_MAX_CONNECTIONS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">200</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_SHARED_BUFFERS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">256MB</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_WAL_LEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">replica</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # for replication</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_WAL_ARCHIVE_MODE</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">on</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">POSTGRES_WAL_ARCHIVE_COMMAND</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&#39;...&#39;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # S3 archive</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  ledger-db</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">postgres:15-alpine</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      POSTGRES_DB</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">venture</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      POSTGRES_USER</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">venture</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      POSTGRES_PASSWORD</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">\${POSTGRES_PASSWORD}</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      POSTGRES_INITDB_ARGS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;-c max_connections=200 -c shared_buffers=256MB&quot;</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    volumes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">./data/postgres:/var/lib/postgresql/data</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">./init-db.sql:/docker-entrypoint-initdb.d/init.sql:ro</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    ports</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;5432:5432&quot;</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    healthcheck</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      test</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;CMD&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;pg_isready&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;-U&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;venture&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      interval</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">10s</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      timeout</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">5s</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      retries</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">5</span></span></code></pre></div><p><strong>Core Tables</strong>:</p><ul><li><code>events</code> (append-only) — event_id, event_type, payload, checksum_prev, checksum_current, signature, created_at</li><li><code>policy_bundles</code> — id, version, content_hash, status, created_at</li><li><code>workflows</code> — id, objective, policy_bundle_id, status, budget_cents, created_at</li><li><code>tasks</code> — id, workflow_id, type, status, retries, created_at</li><li><code>agent_actions</code> — id, task_id, agent_role, tool, input_hash, output_hash, created_at</li><li><code>money_intents</code> — id, workflow_id, amount_cents, merchant_scope, status, created_at</li><li><code>authorization_decisions</code> — id, money_intent_id, decision, reason_code, created_at</li><li><code>ledger_entries</code> — id, workflow_id, entry_type, amount_cents, account_from, account_to, created_at</li><li><code>compliance_cases</code> — id, workflow_id, rule_id, severity, status, created_at</li><li><code>privacy_requests</code> — id, subject_ref, request_type, status, created_at</li><li><code>schema_registry</code> — id, task_type, schema_json, version, created_at</li><li><code>audit_checkpoints</code> — batch_id, event_id_start, event_id_end, checksum, created_at</li></ul><p><strong>Inter-Service Communication</strong>: All services query/insert into ledger-db. No special protocol; standard PostgreSQL client libraries.</p><hr><h3 id="_10-redis-cache-redis-port-6379" tabindex="-1">10. redis-cache (Redis, Port 6379) <a class="header-anchor" href="#_10-redis-cache-redis-port-6379" aria-label="Permalink to &quot;10. redis-cache (Redis, Port 6379)&quot;">​</a></h3><p><strong>Language</strong>: C (Redis binary)</p><p><strong>Responsibility</strong>: Agent state cache, tool call rate limits, idempotency keys, session store, policy cache, hot data.</p><p><strong>Dependencies</strong>: None (foundational).</p><p><strong>Scaling</strong>: 1 node (with optional Sentinel for failover). Persistent RDB snapshots.</p><p><strong>Health Check</strong>:</p><ul><li>Endpoint: <code>redis-cli ping</code></li><li>Response: <code>PONG</code></li><li>Timeout: 2s</li><li>Interval: 10s</li></ul><p><strong>Startup Order</strong>: First (foundational service).</p><p><strong>Environment Variables</strong>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_HOST</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis-cache</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_PORT</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">6379</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_LOGLEVEL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">notice</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_PERSISTENCE_RDB_INTERVAL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">60</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # snapshot every 60s</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">REDIS_PERSISTENCE_RDB_SAVE_PATH</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">/data/redis/dump.rdb</span></span></code></pre></div><p><strong>Process-compose Config</strong>:</p><div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">  redis-cache</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis:7-alpine</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">redis-server --loglevel notice --dir /data --save 60 1000</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    volumes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">./data/redis:/data</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    ports</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;6379:6379&quot;</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">    healthcheck</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      test</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: [</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;CMD&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;redis-cli&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;ping&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      interval</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">10s</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      timeout</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">2s</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D;">      retries</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">5</span></span></code></pre></div><p><strong>Key Namespaces</strong> (examples):</p><ul><li><code>policy:allowlist:{agent_role}</code> — tool allowlist (cached JSON)</li><li><code>velocity-control:{workflow_id}:{merchant}:{category}</code> — spend tracking (counter)</li><li><code>global-spend:{YYYY-MM-DD}</code> — daily spend total (counter)</li><li><code>agent-slots:{agent_role}</code> — available agent slots (counter)</li><li><code>pool-utilization</code> — L3 worker pool utilization (%)</li><li><code>artifact-cache:{idempotency_key}</code> — cached artifact output</li><li><code>session:{session_id}</code> — founder session state (expiring, TTL 24h)</li></ul><p><strong>Inter-Service Communication</strong>: Standard Redis client libraries (redis-py, node-redis, etc.). No special protocol.</p><hr><h2 id="inter-service-communication-map" tabindex="-1">Inter-Service Communication Map <a class="header-anchor" href="#inter-service-communication-map" aria-label="Permalink to &quot;Inter-Service Communication Map&quot;">​</a></h2><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>control-plane-api (8000)</span></span>
<span class="line"><span>  ├─ calls ──→ policy-engine (8001)          [validate intents]</span></span>
<span class="line"><span>  ├─ calls ──→ venture-orchestrator (8005)   [dispatch tasks]</span></span>
<span class="line"><span>  ├─ queries ──→ ledger-db (5432)            [workflows, audit]</span></span>
<span class="line"><span>  └─ reads ──→ redis-cache (6379)            [sessions, rate limits]</span></span>
<span class="line"><span></span></span>
<span class="line"><span>policy-engine (8001)</span></span>
<span class="line"><span>  ├─ reads ──→ redis-cache (6379)            [policy cache, allowlists]</span></span>
<span class="line"><span>  ├─ queries ──→ ledger-db (5432)            [schema registry, policies]</span></span>
<span class="line"><span>  └─ (called by all services for tool checks)</span></span>
<span class="line"><span></span></span>
<span class="line"><span>artifact-compiler (8002)</span></span>
<span class="line"><span>  ├─ inserts ──→ ledger-db (5432)            [artifact_ir, builds, provenance]</span></span>
<span class="line"><span>  ├─ publishes ──→ event-bus (4222)          [artifact.* events]</span></span>
<span class="line"><span>  ├─ reads/writes ──→ redis-cache (6379)     [build cache]</span></span>
<span class="line"><span>  └─ calls ──→ external APIs                 [Claude, Veo, Banana]</span></span>
<span class="line"><span></span></span>
<span class="line"><span>treasury-api (8003)</span></span>
<span class="line"><span>  ├─ queries ──→ ledger-db (5432)            [money_intents, authorization_decisions, ledger_entries]</span></span>
<span class="line"><span>  ├─ publishes ──→ event-bus (4222)          [money.*, ledger.* events]</span></span>
<span class="line"><span>  ├─ reads/writes ──→ redis-cache (6379)     [velocity control, locks]</span></span>
<span class="line"><span>  └─ calls ──→ policy-engine (8001)          [policy bundle validation]</span></span>
<span class="line"><span></span></span>
<span class="line"><span>compliance-engine (8004)</span></span>
<span class="line"><span>  ├─ inserts ──→ ledger-db (5432)            [compliance_cases, audit_trail]</span></span>
<span class="line"><span>  ├─ subscribes ──→ event-bus (4222)         [all event topics]</span></span>
<span class="line"><span>  ├─ publishes ──→ event-bus (4222)          [compliance.* events]</span></span>
<span class="line"><span>  ├─ reads ──→ redis-cache (6379)            [rule cache]</span></span>
<span class="line"><span>  └─ calls ──→ control-plane-api (8000)      [escalate incidents]</span></span>
<span class="line"><span></span></span>
<span class="line"><span>venture-orchestrator (8005)</span></span>
<span class="line"><span>  ├─ queries/inserts ──→ ledger-db (5432)    [workflows, tasks]</span></span>
<span class="line"><span>  ├─ publishes/subscribes ──→ event-bus (4222) [task.* events]</span></span>
<span class="line"><span>  ├─ calls ──→ agent-runtime                 [L1/L2 dispatch]</span></span>
<span class="line"><span>  └─ reads/writes ──→ redis-cache (6379)     [task queue, agent slots]</span></span>
<span class="line"><span></span></span>
<span class="line"><span>agent-runtime</span></span>
<span class="line"><span>  ├─ calls ──→ policy-engine (8001)          [tool allowlist checks, workload identity]</span></span>
<span class="line"><span>  ├─ publishes ──→ event-bus (4222)          [tool.call.executed, task.completed]</span></span>
<span class="line"><span>  ├─ inserts ──→ ledger-db (5432)            [agent_actions, results]</span></span>
<span class="line"><span>  └─ reads/writes ──→ redis-cache (6379)     [agent state, slot tracking]</span></span>
<span class="line"><span></span></span>
<span class="line"><span>event-bus (NATS, 4222)</span></span>
<span class="line"><span>  └─ backed by ──→ ledger-db (5432)          [event persistence (optional)]</span></span>
<span class="line"><span></span></span>
<span class="line"><span>ledger-db (PostgreSQL, 5432)</span></span>
<span class="line"><span>  └─ queried by all services                 [append-only event store + projections]</span></span>
<span class="line"><span></span></span>
<span class="line"><span>redis-cache (Redis, 6379)</span></span>
<span class="line"><span>  └─ accessed by all services                [caching, rate limiting, state]</span></span></code></pre></div><hr><h2 id="startup-order-process-compose" tabindex="-1">Startup Order (process-compose) <a class="header-anchor" href="#startup-order-process-compose" aria-label="Permalink to &quot;Startup Order (process-compose)&quot;">​</a></h2><ol><li><strong>redis-cache</strong> (foundational)</li><li><strong>ledger-db</strong> (foundational)</li><li><strong>event-bus</strong> (NATS)</li><li><strong>policy-engine</strong> (depends on redis, ledger)</li><li><strong>agent-runtime</strong> (depends on policy, event-bus, ledger, redis)</li><li><strong>artifact-compiler</strong> (depends on ledger, event-bus, redis)</li><li><strong>treasury-api</strong> (depends on ledger, event-bus, redis, policy)</li><li><strong>compliance-engine</strong> (depends on ledger, event-bus, redis)</li><li><strong>venture-orchestrator</strong> (depends on ledger, event-bus, agent-runtime, redis)</li><li><strong>control-plane-api</strong> (depends on policy, orchestrator, ledger, redis)</li></ol><h2 id="shutdown-order-reverse" tabindex="-1">Shutdown Order (reverse) <a class="header-anchor" href="#shutdown-order-reverse" aria-label="Permalink to &quot;Shutdown Order (reverse)&quot;">​</a></h2><ol><li>control-plane-api (stop accepting new requests)</li><li>venture-orchestrator (wait for in-flight tasks, cancel pending)</li><li>compliance-engine (stop event consumption)</li><li>treasury-api (settle pending intents)</li><li>artifact-compiler (cancel pending builds)</li><li>agent-runtime (kill in-flight L3 workers, wait for L2 completion)</li><li>policy-engine (stop serving)</li><li>event-bus (NATS flush and close)</li><li>ledger-db (checkpoint, close)</li><li>redis-cache (persist RDB, close)</li></ol><hr><h2 id="health-check-strategy" tabindex="-1">Health Check Strategy <a class="header-anchor" href="#health-check-strategy" aria-label="Permalink to &quot;Health Check Strategy&quot;">​</a></h2><p>Each service exposes <code>GET /health</code> returning <code>{ &quot;status&quot;: &quot;ok&quot;|&quot;degraded&quot;|&quot;down&quot;, ... }</code>.</p><p><strong>Composite health</strong> (control-plane-api):</p><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> check_system_health</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">():</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    services </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">        (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;policy-engine&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, call_health(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;http://policy-engine:8001/health&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">        (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;artifact-compiler&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, call_health(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;http://artifact-compiler:8002/health&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">        (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;treasury-api&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, call_health(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;http://treasury-api:8003/health&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">        (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;compliance-engine&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, call_health(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;http://compliance-engine:8004/health&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">        (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;venture-orchestrator&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, call_health(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;http://venture-orchestrator:8005/health&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">        (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;event-bus&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, call_health(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;http://event-bus:8222/healthz&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">        (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;ledger-db&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, check_postgres()),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">        (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;redis-cache&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, check_redis()),</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    ]</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    all_ok </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> all</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(s[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;ok&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> s </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> services)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">    system_status </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;ok&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> all_ok </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;degraded&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> any</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(s[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;down&quot;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> s </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> services) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">else</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;down&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">    return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> { </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;status&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: system_status, </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;services&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">dict</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(services) }</span></span></code></pre></div><p>Founder queries via <code>GET /health</code> endpoint; triggers system freeze if status=&quot;down&quot;.</p><hr><h2 id="monitoring-metrics" tabindex="-1">Monitoring &amp; Metrics <a class="header-anchor" href="#monitoring-metrics" aria-label="Permalink to &quot;Monitoring &amp; Metrics&quot;">​</a></h2><p><strong>Prometheus scrape targets</strong>:</p><ul><li>control-plane-api:8000/metrics</li><li>policy-engine:8001/metrics</li><li>artifact-compiler:8002/metrics</li><li>treasury-api:8003/metrics</li><li>compliance-engine:8004/metrics</li><li>venture-orchestrator:8005/metrics</li><li>redis_exporter:9121 (for Redis)</li><li>postgres_exporter:9187 (for PostgreSQL)</li><li>nats_exporter:7777 (for NATS)</li></ul><p><strong>Key metrics</strong> per service: see TECHNICAL_SPEC.md &quot;Monitoring &amp; Observability&quot; section.</p><hr><h2 id="revision-history" tabindex="-1">Revision History <a class="header-anchor" href="#revision-history" aria-label="Permalink to &quot;Revision History&quot;">​</a></h2><table tabindex="0"><thead><tr><th>Date</th><th>Version</th><th>Author</th><th>Changes</th></tr></thead><tbody><tr><td>2026-02-21</td><td>1.0</td><td>AI Agent</td><td>Complete service catalog: 10 services, health checks, environment contracts, inter-service communication map, startup/shutdown order.</td></tr></tbody></table>`,199)])])}const c=i(t,[["render",l]]);export{E as __pageData,c as default};
