# Diagrams — Deep-Dive DD-01: Pi — The Minimal Baseline

**Deep-Dive**: DD-01 — Pi: The Minimal Baseline
**Diagram count**: 5
**Tool**: Mermaid (primary). Each diagram validated in [Mermaid Live Editor](https://mermaid.live).

---

## Diagram 1 — Pi's Architecture: The Three Jobs, Minimal

**Type**: Component map
**Purpose**: The single orientation diagram. Shows Pi as the minimal expression of the three harness jobs (loop, tools, safety) — and every component Pi deliberately omits (context manager, memory, sandbox, verification, structured observability). The absence is the lesson.
**Reading the diagram**: Pi is the inner box. The loop (~80 lines, ReAct dumb-loop) talks to the model and dispatches to the 4 tools. Safety is only the max-iter guard + basic try/catch. Every box NOT inside Pi is a deliberate omission — a layer thicker harnesses add and Pi leaves to the model.

```mermaid
flowchart TB
  subgraph PI["Pi (~1,200 LOC) — the irreducible minimum"]
    LOOP["LOOP — ~80 lines<br/>ReAct dumb-loop<br/>2 of 5 stop conditions"]
    TOOLS["4 TOOLS — schema-first<br/>bash · read_file · write_file · search"]
    SAFETY["SAFETY — max-iter guard + basic try/catch<br/>trust-the-model"]
  end
  MODEL(("Model<br/>(the 1.6%)"))
  WORLD[("World — host filesystem<br/>+ shell + network")]
  OMITTED["DELIBERATELY OMITTED:<br/>context manager · memory · sandbox ·<br/>permission gates · verification ·<br/>state checkpoint · structured observability"]

  LOOP <--> MODEL
  LOOP --> TOOLS --> WORLD
  SAFETY --> LOOP
  PI -.- OMITTED

  style PI fill:#14141f,stroke:rgba(94,234,212,0.5),color:#e4e4e8
  style LOOP fill:#08080c,stroke:rgba(94,234,212,0.3),color:#5eead4
  style TOOLS fill:#08080c,stroke:rgba(94,234,212,0.3),color:#5eead4
  style SAFETY fill:#08080c,stroke:rgba(240,168,104,0.3),color:#f0a868
  style MODEL fill:#08080c,stroke:rgba(94,234,212,0.4),color:#5eead4
  style WORLD fill:#08080c,stroke:rgba(255,255,255,0.12),color:#9494a0
  style OMITTED fill:#08080c,stroke:rgba(240,168,104,0.4),stroke-dasharray:4 3,color:#f0a868
```

---

## Diagram 2 — Pi's Position on the Thickness Spectrum

**Type**: Linear spectrum
**Purpose**: Establishes Pi as the leftmost (thinnest) reference point. Every other harness in the deep-dive roster sits to its right. Pi's position is not a deficiency — it is the deliberate choice that makes Pi the legibility and co-evolution benchmark every other harness is measured against.
**Reading the diagram**: Left = thin (few tools, small prompt, few LOC, trust-the-model). Right = thick (many tools, large prompt, many flags, defense-in-depth). Pi anchors the left end; the comparison question for every subsequent deep-dive is "how far right of Pi, and why?"

```mermaid
flowchart LR
  PI["Pi<br/>4 tools · <1k prompt · ~1.2k LOC<br/>trust-the-model"]
  AIDER["Aider<br/>git-native pair programmer"]
  OCODE["OpenCode<br/>terminal-native harness"]
  CC["Claude Code (reference)<br/>40+ tools · ~40k prompt · 40 flags"]

  PI --> AIDER --> OCODE --> CC

  NOTE["Pi anchors the THIN end.<br/>Every other deep-dive sits to the right.<br/>The comparison question: how much<br/>thickness does X add, and why?"]

  CC --> NOTE

  style PI fill:#08080c,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
  style AIDER fill:#14141f,stroke:rgba(255,255,255,0.12),color:#e4e4e8
  style OPCODE fill:#14141f,stroke:rgba(255,255,255,0.12),color:#e4e4e8
  style CC fill:#08080c,stroke:rgba(240,128,128,0.5),color:#f08080
  style NOTE fill:#08080c,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
```

---

## Diagram 3 — The ReAct Loop: Pi's Full Control Flow

**Type**: Flowchart (control flow)
**Purpose**: The primary visual. Shows the complete execution path through Pi — entry, context assembly, the model call, the end_turn / tool_use branch, the 7-step tool dispatch, and the max-iter guard. Compare this to Module 1's reference loop: it is the same shape with every optional component stripped.
**Reading the diagram**: Follow the arrows from the top. Two exit paths (end_turn returns to the user; max-iter guard hard-stops). One loop path (tool_use → 7-step dispatch → append result → back to model). The absence of a compaction node, observability wrapper, permission gate, memory store, and verification step IS the lesson.

```mermaid
flowchart TB
  ENTRY(["user task"]) --> CTX["assemble context<br/><1k system prompt +<br/>4 tool defs + history"]
  CTX --> CALL["model.complete()"]
  CALL --> BRANCH{stop reason?}
  BRANCH -->|end_turn| DONE(["return to user<br/>(natural stop)"])
  BRANCH -->|tool_use| DISPATCH["7-step tool dispatch<br/>validate name → schema-check →<br/>execute → return result"]
  DISPATCH --> APPEND["append result to history<br/>(no compaction, no masking)"]
  APPEND --> CALL
  GUARD["max-iterations guard<br/>(the ONLY safety net)"]
  GUARD -.->|hard stop| HALT(["hard stop<br/>(safety net)"])

  style ENTRY fill:#08080c,stroke:rgba(94,234,212,0.4),color:#5eead4
  style CTX fill:#14141f,stroke:rgba(255,255,255,0.12),color:#e4e4e8
  style CALL fill:#14141f,stroke:rgba(94,234,212,0.4),color:#5eead4
  style BRANCH fill:#08080c,stroke:rgba(240,168,104,0.4),color:#f0a868
  style DONE fill:#08080c,stroke:rgba(130,224,170,0.4),color:#82e0aa
  style DISPATCH fill:#14141f,stroke:rgba(255,255,255,0.12),color:#e4e4e8
  style APPEND fill:#14141f,stroke:rgba(255,255,255,0.12),color:#e4e4e8
  style GUARD fill:#08080c,stroke:rgba(240,168,104,0.4),color:#f0a868
  style HALT fill:#08080c,stroke:rgba(240,128,128,0.5),color:#f08080
```

---

## Diagram 4 — The 12-Module Rubric Score (Pi vs the reference)

**Type**: Annotated score table
**Purpose**: Shows where Pi scores high (loop, tools, prompt assembly), where it scores low (memory, sandbox, state, verification), and why each score is correct *for Pi's use case*. Resolves the misconception that a 25/60 score means Pi is a bad harness.
**Reading the diagram**: Teal = Pi's strengths (the irreducible core it does well). Warn (orange) = the deliberate omissions (correct for trusted single-user, wrong for enterprise). Danger (red) = the safety absences that make Pi unfit for untrusted input. The footer is the principle: the score reflects what Pi IS NOT, not a failure of what Pi IS.

```mermaid
flowchart LR
  subgraph STRONG["Pi's STRENGTHS — the irreducible core"]
    S1["M1 Execution Loop: 4/5<br/>ReAct dumb-loop, co-evolves"]
    S2["M2 Tool Design: 5/5<br/>4-tool set, schema-first"]
    S3["M12 Prompt Assembly: 5/5<br/>ultra-thin <1k tokens"]
  end
  subgraph OMISSION["DELIBERATE OMISSIONS — correct for trusted single-user"]
    O1["M3 Context: 2/5 · M4 Memory: 1/5"]
    O2["M7 Errors: 2/5 · M8 State: 1/5"]
    O3["M11 Observability: 2/5"]
  end
  subgraph SAFETY["SAFETY ABSENCES — wrong for untrusted input"]
    F1["M5 Sandboxing: 1/5<br/>blast radius = host"]
    F2["M6 Permission: 2/5<br/>trust-the-model"]
    F3["M9 Verification: 1/5<br/>ship and hope"]
  end

  TOTAL["TOTAL: 25/60<br/>The expected score for a<br/>deliberate THIN harness.<br/>The score reflects what Pi IS NOT,<br/>not a failure of what Pi IS."]

  STRONG --> TOTAL
  OMISSION --> TOTAL
  SAFETY --> TOTAL

  style STRONG fill:#14141f,stroke:rgba(94,234,212,0.5),color:#e4e4e8
  style OMISSION fill:#14141f,stroke:rgba(240,168,104,0.5),color:#e4e4e8
  style SAFETY fill:#14141f,stroke:rgba(240,128,128,0.5),color:#e4e4e8
  style S1 fill:#08080c,stroke:rgba(94,234,212,0.3),color:#5eead4
  style S2 fill:#08080c,stroke:rgba(94,234,212,0.3),color:#5eead4
  style S3 fill:#08080c,stroke:rgba(94,234,212,0.3),color:#5eead4
  style O1 fill:#08080c,stroke:rgba(240,168,104,0.25),color:#f0a868
  style O2 fill:#08080c,stroke:rgba(240,168,104,0.25),color:#f0a868
  style O3 fill:#08080c,stroke:rgba(240,168,104,0.25),color:#f0a868
  style F1 fill:#08080c,stroke:rgba(240,128,128,0.3),color:#f08080
  style F2 fill:#08080c,stroke:rgba(240,128,128,0.3),color:#f08080
  style F3 fill:#08080c,stroke:rgba(240,128,128,0.3),color:#f08080
  style TOTAL fill:#08080c,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
```

---

## Diagram 5 — How the Curriculum Threads Through Pi

**Type**: Hub-and-spoke dependency map
**Purpose**: The load-bearing diagram of the deep-dive. Shows that Pi is the base architecture every subsequent course builds on, varies, attacks, or deploys. This is why Pi is the reference harness and this deep-dive is the priority.
**Reading the diagram**: Pi is the hub. Course 2A adds the security layers Pi omits. Course 2B attacks Pi's trust-the-model posture. Course 3 swaps the model inside Pi's loop. Course 4 deploys Pi's loop at scale. Every spoke assumes you have read Pi and understand why it is thin.

```mermaid
flowchart TB
  PI(("Pi — the irreducible core<br/>~80-line loop · 4 tools · trust-the-model"))

  C2A["COURSE 2A — Security Harnesses<br/>BUILDS the layers Pi omits:<br/>sandbox · scope · approval gate"]
  C2B["COURSE 2B — Attacking Harnesses<br/>ATTACKS Pi's trust-the-model posture:<br/>ASI01 drift · ASI07 output · ASI10 trust"]
  C3["COURSE 3 — LLM Fine-Tuning<br/>DROPS a fine-tuned model<br/>into Pi's UNCHANGED loop"]
  C4["COURSE 4 — Enterprise Platforms<br/>DEPLOYS Pi's loop at scale:<br/>+ observability + state checkpoint"]

  PI --> C2A
  PI --> C2B
  PI --> C3
  PI --> C4

  NOTE["Read Pi once, here.<br/>You will refer back to it<br/>in every subsequent course."]

  C4 --> NOTE

  style PI fill:#08080c,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
  style C2A fill:#14141f,stroke:rgba(94,234,212,0.4),color:#e4e4e8
  style C2B fill:#14141f,stroke:rgba(240,128,128,0.4),color:#e4e4e8
  style C3 fill:#14141f,stroke:rgba(240,168,104,0.4),color:#e4e4e8
  style C4 fill:#14141f,stroke:rgba(130,224,170,0.4),color:#e4e4e8
  style NOTE fill:#08080c,stroke:#5eead4,stroke-width:1.5px,color:#5eead4
```

---

## Validation notes

- All five diagrams use the course design system colors: `#14141f` panel fill, `#08080c` deep background for nested nodes, `#5eead4` teal accent for Pi's strengths and the thesis/principle nodes, `#f0a868` warn for the deliberate omissions and the branch points, `#f08080` danger for the safety absences. `#e4e4e8` / `#9494a0` for text.
- Paste each into [Mermaid Live Editor](https://mermaid.live) to render. All use stable Mermaid syntax (`flowchart TB/LR`, `subgraph`) supported in current Mermaid (v10.4+).
- For the slide deck (artifact 03), these are rendered as static captures from Mermaid Live, inlined into reveal.js.
- The teal/warn/danger color coding is consistent across diagrams and matches the SDD-B01 reference: teal = the core/strengths, warn = deliberate omissions (context, memory, state), danger = safety absences (sandbox, permission, verification). This mapping is load-bearing — it lets the reader track which category a score belongs to across diagrams 1, 4, and 5.
