# BUILD_SPEC — Production Loop Section for Workflow Guide

**Generated:** 2026-04-05
**Input:** `/Users/joeturnerlin/Dropbox/CLAUDE_PROJECTS/docs/superpowers/specs/2026-04-05-workflow-guide-loop-section.md`
**Detail level:** max
**Visual design:** Existing (all CSS patterns reused from target file)
**Phases:** 3
**Target file:** `recoil/docs/PRODUCTION_PIPELINE_GUIDE.html`

## Visual Design Reference

No DESIGN_SYSTEM.md needed. The target file already contains a complete design system:
- **Node colors:** `node-orange`, `node-amber`, `node-warm-red`, `node-emerald`, `node-purple`, `node-violet` (lines 363-377)
- **Connection types:** `normal`, `pass`, `fail`, `loop`, `warm`, `gold`, `bridge` (lines 246-270)
- **Status borders:** `status-built` = solid emerald (line 322)
- **Node structure:** `{ id, title, icon, color, status, desc, x, y, width, files[], phase?, subtitle?, ip? }` (lines 783-898)
- **Connection structure:** `{ from, to, type, icon? }` (lines 900-932)
- **File badge types:** `engine`, `project`, `state`, `output`, `gate`, `agent`, `tool`, `ip`, `model`, `spec`, `entry` (lines 420-430)

All new nodes MUST use these existing patterns. Do not invent new styles, colors, or badge types.

## Validation command
```bash
python3 -c "
import re
html = open('recoil/docs/PRODUCTION_PIPELINE_GUIDE.html').read()
# Check all 15 new node IDs exist
ids = ['v_batchmgr','v_loop','v_retry','v_prov','v_autonomy','v_learn',
       'i_loop','i_batchmgr','i_learn',
       'e_loop','e_batchmgr','e_retry','e_autonomy','e_prov','e_learn']
missing = [i for i in ids if f\"id: '{i}'\" not in html]
assert not missing, f'Missing node IDs: {missing}'
# Check phase labels
assert 'PHASE 8: PRODUCTION LOOP' in html, 'Missing investor phase label'
assert \"5: { title: 'ORCHESTRATION'\" in html or '5: { title: \"ORCHESTRATION\"' in html, 'Missing engine phase label'
print('All checks passed')
" && echo "BUILD_SPEC VALIDATION OK"
```

---

## Phase 1: Visual Mode — 6 Production Loop Nodes

### Goal
Add 6 orchestration loop nodes to `visualData` with circular layout, internal connections showing the retry loop, and sidebar commands.

### Files to modify
- `recoil/docs/PRODUCTION_PIPELINE_GUIDE.html` — Sections: `visualData.nodes`, `visualData.connections`, `visualData.commands`

### Layout (circular/loop arrangement)

```
                    Batch Manager
                     (598, 3050)
                         |
    Retry Dispatcher  Production Loop     Take Provenance
      (260, 3300)      (598, 3350)        (936, 3200)
         ↑               |
         └───────┐       |              Autonomy Controller
                 │       |                (936, 3500)
                 │  Learning Engine
                 │   (598, 3700)
                 │
                 └── loop connection creates visual loop
```

### Exact implementation

**In `visualData.nodes` array — insert after the v14 node (after `files: [] }` on the line ending the Final Cut node, BEFORE the `],` that closes the nodes array):**

Find this exact text:
```javascript
                  x: 597.9, y: 2710, width: 220,
                  files: [] }
            ],
            connections: [
```

Replace with:
```javascript
                  x: 597.9, y: 2710, width: 220,
                  files: [] },

                // ── PRODUCTION LOOP (Orchestration Engine) ──
                { id: 'v_batchmgr', title: "Batch Manager", icon: "fa-layer-group", color: "amber", status: "built",
                  desc: "Manages batch state (CREATED → RUNNING → COMPLETE/PAUSED/BUDGET_EXHAUSTED). Crash recovery via persistent JSON. Prioritizes retries > previs > keyframe > video.",
                  x: 598, y: 3050, width: 250,
                  files: [{ name: "batch_manager.py", type: "engine", desc: "Batch lifecycle and termination logic" }] },
                { id: 'v_loop', title: "Production Loop", icon: "fa-rotate", color: "orange", status: "built",
                  desc: "Synchronous orchestration loop. Fetches actionable shots, dispatches to StepRunner, handles results, manages retries. Single-threaded, crash-safe.",
                  x: 598, y: 3350, width: 270,
                  files: [{ name: "production_loop.py", type: "engine", desc: "Main orchestration loop" }] },
                { id: 'v_retry', title: "Retry Dispatcher", icon: "fa-arrows-rotate", color: "warm-red", status: "built",
                  desc: "Classifies failures into 8 categories. Exponential backoff (5s → 120s cap). Per-shot, per-category attempt tracking. Authoritative count from ExecutionStore for crash recovery.",
                  x: 260, y: 3300, width: 250,
                  files: [{ name: "retry_dispatcher.py", type: "engine", desc: "Failure classification and backoff" }] },
                { id: 'v_prov', title: "Take Provenance", icon: "fa-fingerprint", color: "purple", status: "built",
                  desc: "Every take carries: full prompt, all refs (with SHA-256 hashes), model/endpoint/params, gate verdicts, cost breakdown, lineage (parent take + change reason). Dual storage: inline + manifest JSON.",
                  x: 936, y: 3200, width: 240,
                  files: [{ name: "take_provenance.py", type: "engine", desc: "Reproduction recipe per take" }] },
                { id: 'v_autonomy', title: "Autonomy Controller", icon: "fa-robot", color: "emerald", status: "built",
                  desc: "7-check auto-approve gate: enabled? → budget cap? → deferred gate? → gate 3 required? → all gates pass? → complex shot type? → approve. Disabled in Phase 1 (all shots to human review).",
                  x: 936, y: 3500, width: 250,
                  files: [{ name: "autonomy_controller.py", type: "engine", desc: "Auto-approve decision gate" }] },
                { id: 'v_learn', title: "Learning Engine", icon: "fa-brain", color: "violet", status: "built",
                  desc: "Append-only JSONL logging for verdicts, human overrides, retry outcomes. Reports: pass-rate by model, gate calibration (false positive/negative rates). Auto-updates shared pipeline-learnings.",
                  x: 598, y: 3700, width: 250,
                  files: [{ name: "learning_engine.py", type: "engine", desc: "Pattern detection and insights" }] }
            ],
            connections: [
```

**In `visualData.connections` array — insert after the last existing connection (after `{ from: 'v13', to: 'v14', type: 'pass', icon: 'fa-check' }`), BEFORE the `],` that closes connections array:**

Find this exact text:
```javascript
                { from: 'v13', to: 'v14', type: 'pass', icon: 'fa-check' }
            ],
            commands: [
```

Replace with:
```javascript
                { from: 'v13', to: 'v14', type: 'pass', icon: 'fa-check' },
                // Production Loop connections
                { from: 'v_batchmgr', to: 'v_loop', type: 'normal' },
                { from: 'v_loop', to: 'v_retry', type: 'fail', icon: 'fa-rotate-left' },
                { from: 'v_loop', to: 'v_prov', type: 'warm', icon: 'fa-fingerprint' },
                { from: 'v_loop', to: 'v_autonomy', type: 'pass', icon: 'fa-check' },
                { from: 'v_loop', to: 'v_learn', type: 'normal' },
                { from: 'v_retry', to: 'v_loop', type: 'loop', icon: 'fa-rotate' },
                { from: 'v_autonomy', to: 'v_learn', type: 'normal' }
            ],
            commands: [
```

**In `visualData.commands` array — insert after the last existing command (after the "Dailies Review" command), BEFORE the `],` that closes commands array:**

Find this exact text:
```javascript
                { name: "Dailies Review", syntax: "Production Console → Dailies tab", desc: "<b>Asset Review.</b> Approve/reject/reroute/override per shot. Reroute sends to different video engine. Override for manual replacement." }
            ],
```

Replace with:
```javascript
                { name: "Dailies Review", syntax: "Production Console → Dailies tab", desc: "<b>Asset Review.</b> Approve/reject/reroute/override per shot. Reroute sends to different video engine. Override for manual replacement." },
                { name: "Production Loop", syntax: "orchestrator/production_loop.py", desc: "<b>Orchestration Engine.</b> Synchronous loop: fetch shots → dispatch to StepRunner → handle results → manage retries. Single-threaded, crash-safe." },
                { name: "Batch Manager", syntax: "orchestrator/batch_manager.py", desc: "<b>Lifecycle Control.</b> Manages batch state (CREATED → RUNNING → COMPLETE/PAUSED). Crash recovery via persistent JSON. Prioritizes retries > previs > keyframe > video." },
                { name: "Retry Dispatcher", syntax: "orchestrator/retry_dispatcher.py", desc: "<b>Failure Recovery.</b> 8 failure categories. Exponential backoff (5s → 120s cap). Per-shot, per-category attempt tracking." }
            ],
```

### Scope boundary
- ONLY modify the `visualData` object (nodes, connections, commands arrays)
- Do NOT modify any CSS, JavaScript functions, or other data objects
- Do NOT modify any existing nodes or connections
- Do NOT add phase labels (visual mode doesn't use them)

### Validation
```bash
cd /Users/joeturnerlin/Dropbox/CLAUDE_PROJECTS/recoil && \
grep -q "id: 'v_loop'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'v_batchmgr'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'v_retry'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'v_prov'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'v_autonomy'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'v_learn'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "from: 'v_retry', to: 'v_loop'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "from: 'v_loop', to: 'v_prov'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "Production Loop" docs/PRODUCTION_PIPELINE_GUIDE.html && \
echo "Phase 1 OK"
```

---

## Phase 2: Investor Mode — 3 Simplified Loop Nodes

### Goal
Add 3 Production Loop nodes to `investorData` as a new Phase 8, emphasizing cost control and autonomy. Add phase label and label override.

### What already exists (from Phase 1)
- Phase 1 added 6 loop nodes to `visualData`. This phase adds to `investorData` independently.
- The `investorData` object has 7 phases (1-7) with nodes up to y=4300.
- Phase labels defined in `phaseLabels` (line ~1723).
- Phase label position overrides in `phaseLabelOverrides` (line ~1648).

### Files to modify
- `recoil/docs/PRODUCTION_PIPELINE_GUIDE.html` — Sections: `phaseLabels`, `phaseLabelOverrides`, `investorData.nodes`, `investorData.connections`, `investorData.commands`

### Layout
```
              Production Loop
               (540, 4550)
              /            \
    Batch Manager      Learning Engine
     (270, 4700)        (810, 4700)
```

### Exact implementation

**In `phaseLabels` object — add Phase 8 entry after Phase 7:**

Find this exact text:
```javascript
            7: { title: "PHASE 7: DISTRIBUTION", color: "#1e293b", bg: "#e2e8f0", border: "#cbd5e1" }
        };
```

Replace with:
```javascript
            7: { title: "PHASE 7: DISTRIBUTION", color: "#1e293b", bg: "#e2e8f0", border: "#cbd5e1" },
            8: { title: "PHASE 8: PRODUCTION LOOP", color: "#ea580c", bg: "#fff7ed", border: "#fed7aa" }
        };
```

**In `phaseLabelOverrides` object — add Phase 8 override after Phase 7:**

Find this exact text:
```javascript
            7: { x: 540, y: 3670 }
        };
        const enginePhaseLabelOverrides = {
```

Replace with:
```javascript
            7: { x: 540, y: 3670 },
            8: { x: 540, y: 4470 }
        };
        const enginePhaseLabelOverrides = {
```

**In `investorData.nodes` array — insert after the i20 (Revenue) node, BEFORE the `],` that closes nodes array:**

Find this exact text:
```javascript
                { id: 'i20', title: "Revenue", icon: "fa-coins", color: "gold", status: "planned",
                  desc: "Monetization: ad revenue, premium content, licensing, franchise expansion.",
                  x: 540.49, y: 4300, width: 220, phase: 7,
                  files: [] }
            ],
            connections: [
                // Phase 1 internal
```

Replace with:
```javascript
                { id: 'i20', title: "Revenue", icon: "fa-coins", color: "gold", status: "planned",
                  desc: "Monetization: ad revenue, premium content, licensing, franchise expansion.",
                  x: 540.49, y: 4300, width: 220, phase: 7,
                  files: [] },

                // PHASE 8: PRODUCTION LOOP (Orchestration)
                { id: 'i_loop', title: "Production Loop", icon: "fa-rotate", color: "orange", status: "built",
                  desc: "Autonomous orchestration engine. Budget-aware generation loop with auto-pause at cap. Prioritizes retries over new work to maximize completion rate. Crash-safe with persistent state recovery.",
                  x: 540, y: 4550, width: 280, phase: 8,
                  files: [
                    { name: "production_loop.py", type: "engine", desc: "Synchronous orchestration loop" },
                    { name: "Autonomy Controller", type: "engine", desc: "7-check auto-approve gate — reduces human review overhead" }
                  ] },
                { id: 'i_batchmgr', title: "Batch Manager", icon: "fa-layer-group", color: "amber", status: "built",
                  desc: "Batch lifecycle management. Tracks state from CREATED through COMPLETE. Budget tracking with automatic pause at threshold. Crash recovery via persistent JSON — no lost work.",
                  x: 270, y: 4700, width: 260, phase: 8,
                  files: [{ name: "batch_manager.py", type: "engine", desc: "Lifecycle, budget, crash recovery" }] },
                { id: 'i_learn', title: "Learning Engine", icon: "fa-brain", color: "violet", status: "built",
                  desc: "Continuous improvement via append-only logging. Tracks model pass-rates, gate calibration (false positive/negative rates), retry outcomes. Data-driven optimization of generation quality and cost.",
                  x: 810, y: 4700, width: 260, phase: 8,
                  files: [{ name: "learning_engine.py", type: "engine", desc: "Quality analytics and optimization" }] }
            ],
            connections: [
                // Phase 1 internal
```

**In `investorData.connections` array — insert after the last existing connection (Phase 7 internal: i19 → i20), BEFORE the `],` that closes connections array:**

Find this exact text:
```javascript
                { from: 'i19', to: 'i20', type: 'gold', icon: 'fa-coins' }
            ],
            commands: [
                { name: "Full Pipeline",
```

Replace with:
```javascript
                { from: 'i19', to: 'i20', type: 'gold', icon: 'fa-coins' },
                // Phase 8: Production Loop
                { from: 'i_batchmgr', to: 'i_loop', type: 'normal' },
                { from: 'i_loop', to: 'i_learn', type: 'normal' }
            ],
            commands: [
                { name: "Full Pipeline",
```

**In `investorData.commands` array — insert after the last existing command ("Distribution"), BEFORE the `],` that closes commands array:**

Find this exact text:
```javascript
                { name: "Distribution", syntax: "Platform upload + analytics", desc: "<b>Phase 7.</b> Direct-to-audience delivery with retention analytics and revenue optimization." }
            ],
            assets: [],
            stack: [],
            tabs: ['commands', 'assets', 'stack']
        };
```

Replace with:
```javascript
                { name: "Distribution", syntax: "Platform upload + analytics", desc: "<b>Phase 7.</b> Direct-to-audience delivery with retention analytics and revenue optimization." },
                { name: "Production Loop", syntax: "Autonomous orchestration engine", desc: "<b>Phase 8.</b> Budget-aware generation loop. Auto-pauses at budget cap. Prioritizes retries over new work to maximize completion rate. Learning engine improves gate accuracy over time." }
            ],
            assets: [],
            stack: [],
            tabs: ['commands', 'assets', 'stack']
        };
```

### Scope boundary
- ONLY modify `phaseLabels`, `phaseLabelOverrides`, and `investorData` sections
- Do NOT modify any existing node positions (no y-shifting)
- Do NOT modify CSS or JavaScript functions
- Do NOT touch `narrativeData`, `visualData`, or `engineData`
- Do NOT modify existing connections — only add new ones

### Validation
```bash
cd /Users/joeturnerlin/Dropbox/CLAUDE_PROJECTS/recoil && \
grep -q "id: 'i_loop'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'i_batchmgr'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'i_learn'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "PHASE 8: PRODUCTION LOOP" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "8: { x: 540, y: 4470 }" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "from: 'i_batchmgr', to: 'i_loop'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
echo "Phase 2 OK"
```

---

## Phase 3: Engine Mode — 6 Technical Loop Nodes + New Phase

### Goal
Add 6 Production Loop nodes with full technical detail to `engineData` as a new Phase 5 "ORCHESTRATION". Show file paths, gate thresholds, retry policies. Update engine min-height.

### What already exists (from prior phases)
- Phase 1 added 6 nodes to `visualData`, Phase 2 added 3 nodes to `investorData` + phase label 8.
- The `engineData` object has 4 phases. Current engine phase labels defined in `enginePhaseLabels` (line ~1533).
- Engine phase label overrides in `enginePhaseLabelOverrides` (line ~1657).
- Engine mode min-height is set to `'2900px'` in the `renderNodes()` function.
- Last engine node: `e_enginecheck` at y=2750 (Phase 4).

### Files to modify
- `recoil/docs/PRODUCTION_PIPELINE_GUIDE.html` — Sections: `enginePhaseLabels`, `enginePhaseLabelOverrides`, `engineData.nodes`, `engineData.connections`, `engineData.commands`, `renderNodes()` min-height

### Layout
```
                 Batch Manager          Take Provenance
                  (600, 3150)            (900, 3250)
                      |                      |
             Production Loop           Learning Engine
              (260, 3250)               (900, 3550)
                   |    \
          Retry Disp.   Autonomy Ctrl
          (260, 3550)    (600, 3550)
```

### Exact implementation

**In `enginePhaseLabels` object — add Phase 5 after Phase 4:**

Find this exact text:
```javascript
            4: { title: "META & AGENTLESS", color: "#0d9488", bg: "#ccfbf1", border: "#99f6e4" }
        };
```

Replace with:
```javascript
            4: { title: "META & AGENTLESS", color: "#0d9488", bg: "#ccfbf1", border: "#99f6e4" },
            5: { title: "ORCHESTRATION", color: "#ea580c", bg: "#fff7ed", border: "#fed7aa" }
        };
```

**In `enginePhaseLabelOverrides` object — add Phase 5 override after Phase 4:**

Find this exact text:
```javascript
            4: { x: 530, y: 2790 }
        };
```

Replace with:
```javascript
            4: { x: 530, y: 2790 },
            5: { x: 600, y: 3080 }
        };
```

**In `engineData.nodes` array — insert after the e_enginecheck node, BEFORE the `],` that closes nodes array:**

Find this exact text:
```javascript
                { id: 'e_enginecheck', title: "/engine-check", icon: "fa-microscope", color: "navy", status: "existing",
                  subtitle: "engine_check_agent.md — 53 checks",
                  desc: "Comprehensive engine audit. 8 categories: structural, semantic, deep logic, GUI, visual pipeline, dead code, docs, security. Verifies all wiring shown in this diagram.",
                  x: 868, y: 2750, width: 260, phase: 4,
                  files: [
                    { name: "SKILL.md", type: "entry", desc: "Skill entry point" },
                    { name: "engine_check_agent.md", type: "agent", desc: "53-check audit" },
                    { name: "engine_check.py", type: "tool", desc: "Check runner CLI" },
                    { name: "engine_checks/", type: "engine", desc: "8 check modules" }
                  ] }
            ],
            connections: [
                // Constants radiates to gated skills
```

Replace with:
```javascript
                { id: 'e_enginecheck', title: "/engine-check", icon: "fa-microscope", color: "navy", status: "existing",
                  subtitle: "engine_check_agent.md — 53 checks",
                  desc: "Comprehensive engine audit. 8 categories: structural, semantic, deep logic, GUI, visual pipeline, dead code, docs, security. Verifies all wiring shown in this diagram.",
                  x: 868, y: 2750, width: 260, phase: 4,
                  files: [
                    { name: "SKILL.md", type: "entry", desc: "Skill entry point" },
                    { name: "engine_check_agent.md", type: "agent", desc: "53-check audit" },
                    { name: "engine_check.py", type: "tool", desc: "Check runner CLI" },
                    { name: "engine_checks/", type: "engine", desc: "8 check modules" }
                  ] },

                // ── ORCHESTRATION PHASE ──
                { id: 'e_loop', title: "production_loop.py", icon: "fa-rotate", color: "orange", status: "existing",
                  subtitle: "orchestrator/production_loop.py",
                  desc: "Synchronous orchestration loop. Check termination → get ready retries → execute retries → get actionable shots → for each: determine phase → StepRunner → gate → handle result → sleep(poll_interval) → repeat.",
                  x: 260, y: 3250, width: 280, phase: 5,
                  files: [
                    { name: "production_loop.py", type: "engine", desc: "Main loop — single-threaded, crash-safe" },
                    { name: "step_runner.py", type: "engine", desc: "Model API call + gate validation per shot" }
                  ] },
                { id: 'e_batchmgr', title: "batch_manager.py", icon: "fa-layer-group", color: "amber", status: "existing",
                  subtitle: "orchestrator/batch_manager.py",
                  desc: "Batch state machine: CREATED → RUNNING → COMPLETE | PAUSED | BUDGET_EXHAUSTED. Persistent JSON state for crash recovery. Shot priority queue: retries > previs > keyframe > video. Budget tracking with configurable cap.",
                  x: 600, y: 3150, width: 260, phase: 5,
                  files: [
                    { name: "batch_manager.py", type: "engine", desc: "Lifecycle, state machine, priority queue" },
                    { name: "production_types.py", type: "engine", desc: "BatchState, ShotPriority enums" }
                  ] },
                { id: 'e_retry', title: "retry_dispatcher.py", icon: "fa-arrows-rotate", color: "warm-red", status: "existing",
                  subtitle: "orchestrator/retry_dispatcher.py",
                  desc: "8 failure categories: transient, gate_identity, gate_wardrobe, content_filter, permanent, timeout, rate_limit, unknown. Exponential backoff: base=5s, cap=120s. Per-shot per-category attempt counts. Authoritative count from ExecutionStore for crash recovery.",
                  x: 260, y: 3550, width: 280, phase: 5,
                  files: [
                    { name: "retry_dispatcher.py", type: "engine", desc: "Classification, backoff, attempt tracking" },
                    { name: "production_types.py", type: "engine", desc: "FailureCategory enum" }
                  ] },
                { id: 'e_autonomy', title: "autonomy_controller.py", icon: "fa-robot", color: "emerald", status: "existing",
                  subtitle: "orchestrator/autonomy_controller.py",
                  desc: "7-check sequential gate: (1) autonomy enabled? (2) budget cap exceeded? (3) deferred gate present? (4) gate 3 identity check required? (5) all gates pass? (6) complex shot type? (7) approve. Phase 1 config: disabled (all shots → human review).",
                  x: 600, y: 3550, width: 280, phase: 5,
                  files: [
                    { name: "autonomy_controller.py", type: "engine", desc: "7-check auto-approve decision gate" },
                    { name: "pipeline_config.json", type: "spec", desc: "autonomy_enabled, gate3_required flags" }
                  ] },
                { id: 'e_prov', title: "take_provenance.py", icon: "fa-fingerprint", color: "purple", status: "existing",
                  subtitle: "orchestrator/take_provenance.py",
                  desc: "Per-take reproduction recipe: full compiled prompt, all reference images (SHA-256 hashes), model + endpoint + generation params, gate verdicts per gate, cost breakdown, lineage chain (parent_take_id + change_reason). Dual storage: inline in shot JSON + manifest JSONL.",
                  x: 900, y: 3250, width: 260, phase: 5,
                  files: [
                    { name: "take_provenance.py", type: "engine", desc: "Provenance recording + manifest writer" },
                    { name: "provenance_manifest.jsonl", type: "output", desc: "Append-only take manifest" }
                  ] },
                { id: 'e_learn', title: "learning_engine.py", icon: "fa-brain", color: "violet", status: "existing",
                  subtitle: "orchestrator/learning_engine.py",
                  desc: "Append-only JSONL event log: gate verdicts, human overrides, retry outcomes, cost events. Report generators: pass-rate by model, gate calibration (FP/FN rates), retry success rate by category. Auto-updates shared pipeline-learnings.json.",
                  x: 900, y: 3550, width: 260, phase: 5,
                  files: [
                    { name: "learning_engine.py", type: "engine", desc: "Event logging + report generation" },
                    { name: "pipeline-learnings.json", type: "output", desc: "Shared learning state" }
                  ] }
            ],
            connections: [
                // Constants radiates to gated skills
```

**In `engineData.connections` array — insert after the last existing connection (e_enginecheck → e_const loop), BEFORE the `],` that closes connections array:**

Find this exact text:
```javascript
                { from: 'e_enginecheck', to: 'e_const', type: 'loop', icon: 'fa-magnifying-glass' }
            ],
            commands: [
                { name: "/develop → develop_agent",
```

Replace with:
```javascript
                { from: 'e_enginecheck', to: 'e_const', type: 'loop', icon: 'fa-magnifying-glass' },
                // Orchestration phase
                { from: 'e_batchmgr', to: 'e_loop', type: 'normal' },
                { from: 'e_loop', to: 'e_retry', type: 'fail', icon: 'fa-rotate-left' },
                { from: 'e_loop', to: 'e_prov', type: 'warm', icon: 'fa-fingerprint' },
                { from: 'e_loop', to: 'e_autonomy', type: 'pass', icon: 'fa-check' },
                { from: 'e_loop', to: 'e_learn', type: 'normal' },
                { from: 'e_retry', to: 'e_loop', type: 'loop', icon: 'fa-rotate' },
                { from: 'e_autonomy', to: 'e_learn', type: 'normal' }
            ],
            commands: [
                { name: "/develop → develop_agent",
```

**In `engineData.commands` array — insert after the last existing command ("Agentless: /listen"), BEFORE the `],` that closes commands array:**

Find this exact text:
```javascript
                { name: "Agentless: /listen", syntax: "Direct → fountain_reader.py", desc: "TTS narration via ElevenLabs/Qwen3." }
            ],
            assets: [],
            stack: [],
            tabs: ['commands', 'assets', 'stack']
        };

        const enginePhaseLabels = {
```

Replace with:
```javascript
                { name: "Agentless: /listen", syntax: "Direct → fountain_reader.py", desc: "TTS narration via ElevenLabs/Qwen3." },
                { name: "production_loop.py", syntax: "orchestrator/production_loop.py", desc: "<b>Main Loop.</b> Synchronous. Fetches actionable shots, dispatches StepRunner, handles success/failure. Check: termination → retries → actionable → execute → sleep → repeat." },
                { name: "batch_manager.py", syntax: "orchestrator/batch_manager.py", desc: "<b>Batch Lifecycle.</b> States: CREATED → RUNNING → COMPLETE/PAUSED/BUDGET_EXHAUSTED. Persistent JSON for crash recovery. Shot priority: retries > previs > keyframe > video." },
                { name: "retry_dispatcher.py", syntax: "orchestrator/retry_dispatcher.py", desc: "<b>Retry Logic.</b> 8 categories: transient, gate_identity, gate_wardrobe, content_filter, permanent, timeout, rate_limit, unknown. Exponential backoff 5s → 120s cap." },
                { name: "autonomy_controller.py", syntax: "orchestrator/autonomy_controller.py", desc: "<b>Auto-Approve.</b> 7-check gate: enabled? → budget cap? → deferred gate? → gate 3 required? → all pass? → complex type? → approve. Phase 1: all to human review." },
                { name: "take_provenance.py", syntax: "orchestrator/take_provenance.py", desc: "<b>Provenance.</b> Per-take: full prompt, refs (SHA-256), model/endpoint/params, gate verdicts, cost, lineage. Dual storage: inline + manifest JSON." },
                { name: "learning_engine.py", syntax: "orchestrator/learning_engine.py", desc: "<b>Learning.</b> Append-only JSONL: verdicts, overrides, retries. Reports: pass-rate by model, gate calibration (FP/FN rates). Auto-updates pipeline-learnings." }
            ],
            assets: [],
            stack: [],
            tabs: ['commands', 'assets', 'stack']
        };

        const enginePhaseLabels = {
```

**In `renderNodes()` function — update engine mode min-height from 2900px to 3900px:**

Find this exact text:
```javascript
            flowchart.style.minHeight = (currentMode === 'engine') ? '2900px' : '6100px';
```

Replace with:
```javascript
            flowchart.style.minHeight = (currentMode === 'engine') ? '3900px' : '6100px';
```

### Scope boundary
- ONLY modify `enginePhaseLabels`, `enginePhaseLabelOverrides`, `engineData` sections, and the one min-height line
- Do NOT modify CSS
- Do NOT touch `narrativeData`, `visualData`, or `investorData`
- Do NOT modify any existing nodes, connections, or phase labels (only ADD)
- Do NOT modify the `drawConnections`, `setMode`, or `renderNodes` logic beyond the min-height change

### Validation
```bash
cd /Users/joeturnerlin/Dropbox/CLAUDE_PROJECTS/recoil && \
grep -q "id: 'e_loop'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'e_batchmgr'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'e_retry'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'e_autonomy'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'e_prov'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "id: 'e_learn'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "ORCHESTRATION" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "5: { x: 600, y: 3080 }" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "3900px" docs/PRODUCTION_PIPELINE_GUIDE.html && \
grep -q "from: 'e_retry', to: 'e_loop'" docs/PRODUCTION_PIPELINE_GUIDE.html && \
echo "Phase 3 OK"
```
