Write

"""
Build the Cubie Trust Compiler executive + technical PowerPoint presentation.
Run: python tools/build_presentation.py
Output: cubie_trust_compiler_presentation.pptx
"""

from pptx import Presentation
from pptx.util import Inches, Pt, Emu
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN
from pptx.oxml.ns import qn
from pptx.util import Inches, Pt
import copy
from lxml import etree

# ── Colour palette ─────────────────────────────────────────────────────────
BG      = RGBColor(0x08, 0x0D, 0x1A)   # deep navy
CARD    = RGBColor(0x0F, 0x17, 0x2A)   # card
CARD2   = RGBColor(0x15, 0x1F, 0x35)   # lighter card
CYAN    = RGBColor(0x00, 0xD4, 0xFF)   # primary accent
PURPLE  = RGBColor(0x7C, 0x3A, 0xED)  # secondary
AMBER   = RGBColor(0xF5, 0x9E, 0x0B)  # warning/highlight
GREEN   = RGBColor(0x10, 0xB9, 0x81)  # success
RED     = RGBColor(0xEF, 0x44, 0x44)  # danger
WHITE   = RGBColor(0xFF, 0xFF, 0xFF)
LGRAY   = RGBColor(0x9C, 0xA3, 0xAF)  # light gray text
DGRAY   = RGBColor(0x37, 0x41, 0x51)  # dark gray separator
DIVIDER = RGBColor(0x1E, 0x2A, 0x45)  # subtle divider

W = Inches(13.333)
H = Inches(7.5)

prs = Presentation()
prs.slide_width  = W
prs.slide_height = H

BLANK = prs.slide_layouts[6]   # completely blank

# ── Low-level helpers ───────────────────────────────────────────────────────

def add_rect(slide, x, y, w, h, fill=CARD, alpha=None):
    shape = slide.shapes.add_shape(1, Inches(x), Inches(y), Inches(w), Inches(h))
    shape.line.fill.background()
    sf = shape.fill
    sf.solid()
    sf.fore_color.rgb = fill
    return shape

def add_text(slide, text, x, y, w, h,
             size=18, bold=False, color=WHITE,
             align=PP_ALIGN.LEFT, italic=False, wrap=True):
    txb = slide.shapes.add_textbox(Inches(x), Inches(y), Inches(w), Inches(h))
    tf = txb.text_frame
    tf.word_wrap = wrap
    p = tf.paragraphs[0]
    p.alignment = align
    run = p.add_run()
    run.text = text
    run.font.size = Pt(size)
    run.font.bold = bold
    run.font.italic = italic
    run.font.color.rgb = color
    run.font.name = "Calibri"
    return txb

def add_para(tf, text, size=14, bold=False, color=WHITE,
             align=PP_ALIGN.LEFT, italic=False, space_before=0):
    p = tf.add_paragraph()
    p.alignment = align
    p.space_before = Pt(space_before)
    run = p.add_run()
    run.text = text
    run.font.size = Pt(size)
    run.font.bold = bold
    run.font.italic = italic
    run.font.color.rgb = color
    run.font.name = "Calibri"
    return p

def bg(slide, color=BG):
    shape = slide.shapes.add_shape(1, 0, 0, W, H)
    shape.fill.solid()
    shape.fill.fore_color.rgb = color
    shape.line.fill.background()
    sp = shape._element
    slide.shapes._spTree.remove(sp)
    slide.shapes._spTree.insert(2, sp)

def hline(slide, x, y, w, color=CYAN, thickness=3):
    line = slide.shapes.add_shape(1, Inches(x), Inches(y),
                                  Inches(w), Inches(0.03))
    line.fill.solid()
    line.fill.fore_color.rgb = color
    line.line.fill.background()

def tag(slide, text, x, y, fill=CYAN, text_color=BG):
    w = len(text) * 0.095 + 0.25
    box = add_rect(slide, x, y, w, 0.28, fill=fill)
    add_text(slide, text, x + 0.06, y + 0.02, w, 0.28,
             size=9, bold=True, color=text_color)
    return w

def bullet_box(slide, items, x, y, w, h,
               icon="▸", icon_color=CYAN, size=13, gap=0.32):
    for i, item in enumerate(items):
        add_text(slide, icon, x, y + i * gap, 0.3, 0.35,
                 size=size, bold=True, color=icon_color)
        add_text(slide, item, x + 0.3, y + i * gap, w - 0.3, 0.35,
                 size=size, color=WHITE)

def stat_card(slide, value, label, x, y, val_color=CYAN):
    add_rect(slide, x, y, 2.5, 1.3, fill=CARD2)
    hline(slide, x, y, 2.5, color=val_color, thickness=3)
    add_text(slide, value, x + 0.15, y + 0.1, 2.2, 0.65,
             size=32, bold=True, color=val_color, align=PP_ALIGN.CENTER)
    add_text(slide, label, x + 0.15, y + 0.75, 2.2, 0.45,
             size=10, color=LGRAY, align=PP_ALIGN.CENTER)

def section_divider(prs, title, subtitle="", color=CYAN):
    sl = prs.slides.add_slide(BLANK)
    bg(sl)
    add_rect(sl, 0, 0, 0.08, 7.5, fill=color)
    add_rect(sl, 2, 2.8, 9, 0.06, fill=color)
    add_text(sl, title,    2.3, 3.0,  9, 1.0, size=40, bold=True,  color=WHITE)
    add_text(sl, subtitle, 2.3, 4.1,  9, 0.6, size=18, color=LGRAY)
    return sl

def slide_header(slide, title, subtitle="", accent=CYAN):
    hline(slide, 0.5, 0.55, 12.3, color=accent)
    add_text(slide, title,    0.5, 0.1,  12, 0.5, size=22, bold=True, color=WHITE)
    if subtitle:
        add_text(slide, subtitle, 0.5, 0.55, 10, 0.38, size=12, color=LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE 1 — TITLE
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)

# Left accent bar
add_rect(sl, 0, 0, 0.12, 7.5, fill=CYAN)

# Background geometry — subtle grid rects
for i in range(6):
    add_rect(sl, 0.5 + i * 2.1, 5.8, 1.9, 2.0, fill=CARD2)

# Title block
add_rect(sl, 0.4, 1.4, 8.5, 0.07, fill=CYAN)
add_text(sl, "THE CUBIE TRUST COMPILER",
         0.5, 0.45, 11, 0.9, size=13, bold=True, color=CYAN)
add_text(sl, "Formally Verified AI Admission Gates\nfor Bare-Metal Silicon",
         0.5, 1.55, 10, 1.6, size=42, bold=True, color=WHITE)
add_text(sl,
         "733 theorems  ·  Coq + Lean 4 + Verus  ·  RISC-V / x86-64 / AArch64  ·  730 ns/call",
         0.5, 3.3, 11, 0.5, size=14, color=LGRAY)
add_rect(sl, 0.4, 3.85, 8.5, 0.07, fill=PURPLE)

# Right side — cube diagram (ASCII art style boxes)
cube_labels = [("WHO",   8.1, 1.2, CYAN),
               ("WHAT",  9.8, 1.2, CYAN),
               ("HOW",  11.5, 1.2, CYAN),
               ("WHERE", 8.1, 2.6, PURPLE),
               ("WHEN",  9.8, 2.6, PURPLE),
               ("WHY",  11.5, 2.6, PURPLE)]
for lbl, cx, cy, col in cube_labels:
    add_rect(sl, cx, cy, 1.5, 1.1, fill=CARD2)
    hline(sl, cx, cy, 1.5, color=col)
    add_text(sl, lbl, cx, cy + 0.25, 1.5, 0.6,
             size=15, bold=True, color=col, align=PP_ALIGN.CENTER)

add_text(sl, "GPU Corner",        8.4, 2.4,  3, 0.3, size=9, color=CYAN,   bold=True)
add_text(sl, "Deployment Corner", 8.4, 3.8,  3, 0.3, size=9, color=PURPLE, bold=True)

# Stats bar
stats = [("733", "Theorems"), ("35", "Coq Files"), ("34", "Lean Files"),
         ("17", "Verus Specs"), ("21/21", "Tests Pass")]
for i, (v, l) in enumerate(stats):
    x = 0.5 + i * 2.55
    add_text(sl, v, x, 4.9, 2.3, 0.65, size=28, bold=True, color=CYAN,  align=PP_ALIGN.CENTER)
    add_text(sl, l, x, 5.55, 2.3, 0.3, size=10, color=LGRAY, align=PP_ALIGN.CENTER)

add_rect(sl, 0.4, 4.75, 12.4, 0.03, fill=DIVIDER)
add_rect(sl, 0.4, 6.15, 12.4, 0.03, fill=DIVIDER)
add_text(sl, "CONFIDENTIAL  ·  Centillion AI  ·  2026",
         0.5, 6.3, 12, 0.4, size=9, color=LGRAY, align=PP_ALIGN.CENTER)

# ═══════════════════════════════════════════════════════════════════════════
# ACT 1 DIVIDER
# ═══════════════════════════════════════════════════════════════════════════
section_divider(prs, "ACT I", "The Problem", color=RED)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — THE GOVERNANCE LATENCY GAP
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "The Governance Latency Gap", "Why AI workloads fail before a decision is ever made", accent=RED)

add_text(sl,
    "\"If ts_gateway_decision − ts_prefill_start > 0,\n"
    " the request burned accelerator energy before governance completed.\"",
    0.5, 1.0, 12.3, 1.0, size=15, italic=True, color=AMBER)
hline(sl, 0.5, 2.05, 12.3, color=AMBER)

# Timeline diagram
boxes = [
    (0.5, 2.4, 2.2, "Request\nSubmitted",    CARD2, CYAN),
    (3.0, 2.4, 2.2, "GPU Prefill\nBEGINS",   RED,   WHITE),
    (5.5, 2.4, 2.2, "Tokens\nGenerated",     RED,   WHITE),
    (8.0, 2.4, 2.2, "Policy\nDecision",      CARD2, AMBER),
    (10.5,2.4, 2.2, "DENY\n(Too Late)",      RED,   WHITE),
]
for bx, by, bw, bl, fill, tc in boxes:
    add_rect(sl, bx, by, bw, 1.0, fill=fill)
    add_text(sl, bl, bx+0.1, by+0.2, bw-0.2, 0.65,
             size=11, bold=True, color=tc, align=PP_ALIGN.CENTER)

# Arrows between boxes
for i in range(len(boxes)-1):
    x = boxes[i][0] + boxes[i][2] + 0.05
    add_text(sl, "→", x, boxes[i][1] + 0.3, 0.35, 0.4,
             size=18, bold=True, color=LGRAY, align=PP_ALIGN.CENTER)

add_rect(sl, 2.9, 3.5, 5.0, 0.06, fill=RED)
add_text(sl, "Energy wasted — cannot be recovered", 3.2, 3.62, 4.5, 0.4,
         size=10, color=RED, bold=True)

# Three columns of problems
cols = [
    ("Surface-Clean\nSeam-Dirty",
     "A request can present correct\nservice names, API routes,\ntelemetry, and model labels\nwhile hidden seam evidence\nfails undetected.",
     RED, 0.5),
    ("Retry Storms &\nSingle-Token Aborts",
     "Agents re-issue the same\npayload repeatedly after\nparse, tool, or schema\nfailures — paying full\nprefill each time.",
     AMBER, 4.6),
    ("TP/NVLink\nWaiter States",
     "Tensor-parallel peers hold\nmemory with zero SM\nactivity — a monitoring\nblind spot that standard\nDCGM thresholding misses.",
     PURPLE, 8.7),
]
for title, body, col, x in cols:
    add_rect(sl, x, 4.1, 3.7, 2.9, fill=CARD2)
    hline(sl, x, 4.1, 3.7, color=col)
    add_text(sl, title, x+0.15, 4.2,  3.4, 0.7, size=13, bold=True, color=col)
    add_text(sl, body,  x+0.15, 4.95, 3.4, 1.9, size=10, color=LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — THE EVIDENCE
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "The Evidence Is Overwhelming", "44.9 million traces — Intel GPU fleet telemetry analysis", accent=RED)

stat_card(sl, "66.85%", "Fleet capacity destroyed\nby TP4 NVLink deadlock", 0.5, 1.1, val_color=RED)
stat_card(sl, "44.9M",  "GPU traces analyzed\nacross production runs", 3.2, 1.1, val_color=AMBER)
stat_card(sl, ">99%",   "Requests at depth 3+\nare contextual noise",   5.9, 1.1, val_color=PURPLE)
stat_card(sl, "<100μs", "Required gate latency\n(p50 verdict target)",   8.6, 1.1, val_color=GREEN)
stat_card(sl, "0",      "False-deny tolerance\n(target: <0.1%)",        11.3, 1.1, val_color=CYAN)

# Noise amplification table
add_rect(sl, 0.5, 2.65, 6.0, 3.7, fill=CARD2)
hline(sl, 0.5, 2.65, 6.0, color=RED)
add_text(sl, "Recursive Noise Amplification — Why Seams Must Be Evaluated",
         0.65, 2.72, 5.7, 0.45, size=12, bold=True, color=WHITE)

headers = ["Depth", "Total Sites", "Aligned Paths", "Noise"]
widths  = [1.0, 1.4, 1.6, 1.6]
xs = [0.65, 1.7, 3.15, 4.8]
for i, (h, x) in enumerate(zip(headers, xs)):
    add_text(sl, h, x, 3.25, widths[i], 0.3, size=10, bold=True, color=CYAN)
rows_data = [
    ("1", "54",      "5",   "90.7%"),
    ("2", "2,916",   "25",  "99.1%"),
    ("3", "157,464", "125", "99.92%"),
]
for ri, row in enumerate(rows_data):
    yy = 3.65 + ri * 0.5
    fill = CARD if ri % 2 == 0 else CARD2
    add_rect(sl, 0.55, yy, 5.85, 0.48, fill=fill)
    for ci, (val, x) in enumerate(zip(row, xs)):
        col = RED if ci == 3 else WHITE
        add_text(sl, val, x, yy+0.08, widths[ci], 0.35, size=11, color=col,
                 bold=(ci == 3))

add_text(sl,
    "At depth 3 (a 3-hop agentic chain),\n99.92% of all execution paths are\nnoise. Without formal gates at each\nseam, the signal is buried.",
    0.65, 5.25, 5.7, 1.0, size=10, color=LGRAY, italic=True)

# Waiter signature diagram
add_rect(sl, 6.9, 2.65, 5.9, 3.7, fill=CARD2)
hline(sl, 6.9, 2.65, 5.9, color=AMBER)
add_text(sl, "NVLink Waiter Signature — The Silent Killer",
         7.05, 2.72, 5.6, 0.45, size=12, bold=True, color=WHITE)

add_rect(sl, 7.1, 3.3,  2.5, 0.9, fill=CARD)
add_rect(sl, 10.0, 3.3, 2.5, 0.9, fill=RED)
add_text(sl, "TP Peer A\nSM Activity: 100%",  7.25, 3.4,  2.2, 0.7, size=10, color=GREEN)
add_text(sl, "TP Peer B\nSM Activity: 0%\nVRAM: 512 MiB HELD", 10.15, 3.35, 2.2, 0.85, size=10, color=WHITE, bold=True)
add_text(sl, "←  NVLink  →", 9.35, 3.6, 0.9, 0.4, size=9, color=AMBER, bold=True)

add_text(sl, "⚠", 10.8, 4.0, 0.5, 0.5, size=22, color=AMBER, bold=True)
add_text(sl,
    "Standard DCGM thresholding misses Peer B\nbecause SM activity is 0 — no compute,\nbut VRAM is pinned. The entire TP group\nstalls. Fleet capacity evaporates.",
    7.05, 4.4, 5.6, 1.3, size=10, color=LGRAY)

add_rect(sl, 7.05, 5.85, 5.6, 0.4, fill=RED)
add_text(sl, "SM_ACTIVITY = 0  ∧  VRAM_ALLOC > 0  →  WAITER DETECTED  →  DENY",
         7.1, 5.88, 5.5, 0.35, size=9, bold=True, color=WHITE, align=PP_ALIGN.CENTER)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — WHAT CURRENT SOLUTIONS MISS
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "What Current Solutions Miss", "Surface checks are not seam checks", accent=RED)

add_text(sl,
    "\"Clean surfaces can be spoofed. Aligned seams are authority.\"",
    0.5, 1.0, 12.3, 0.6, size=17, italic=True, color=AMBER, align=PP_ALIGN.CENTER)

cols = [
    ("API Gateways", ["Check service names and routes", "Miss identity-lineage seam mismatches", "Blind to model digest drift", "No GPU waste visibility", "Governance arrives after prefill"], RED),
    ("OPA / Policy Engines", ["Evaluate rules at request time", "Rules are not formally proven", "Cannot verify execution-layer seams", "No hardware attestation", "Cannot prevent TP waiter deadlocks"], AMBER),
    ("DCGM / Monitoring", ["Excellent for steady-state metrics", "Miss zero-SM + VRAM-held signature", "Cannot block — observe only", "No admission decision authority", "Reactive, not preventive"], AMBER),
    ("Cubie Trust Compiler ✓", ["Formally proven — 733 theorems", "Evaluates all 6 seam dimensions", "Hardware-backed HMAC + eFuse", "NVLink waiter detection in gate", "730 ns — ahead of GPU prefill"], GREEN),
]
for i, (title, items, col) in enumerate(cols):
    x = 0.4 + i * 3.22
    add_rect(sl, x, 1.75, 3.05, 5.3, fill=CARD2)
    hline(sl, x, 1.75, 3.05, color=col)
    add_text(sl, title, x+0.12, 1.85, 2.8, 0.55, size=13, bold=True, color=col)
    for j, item in enumerate(items):
        icon = "✗" if col != GREEN else "✓"
        ic   = RED if col != GREEN else GREEN
        if col == GREEN: ic = GREEN
        add_text(sl, icon, x+0.1,  2.55+j*0.55, 0.3, 0.45, size=12, bold=True, color=ic)
        add_text(sl, item, x+0.38, 2.55+j*0.55, 2.55, 0.45, size=10, color=WHITE if col==GREEN else LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# ACT 2 DIVIDER
# ═══════════════════════════════════════════════════════════════════════════
section_divider(prs, "ACT II", "What We Built", color=CYAN)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — THE CUBIE MODEL
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "The Cubie Model — A Recursive Trust Object", "Every AI workload becomes a 6-faced trust evaluation before action is allowed")

# Central cube diagram
faces = [
    ("WHO",   "Identity",   0.5, 1.1, CYAN,   "Who is calling? SVID, signature, binding"),
    ("WHAT",  "Context",    0.5, 2.4, CYAN,   "What capability is being invoked?"),
    ("HOW",   "Lineage",    0.5, 3.7, CYAN,   "How was this compiled / signed / versioned?"),
    ("WHERE", "Runtime",    7.2, 1.1, PURPLE, "Where does it run? Host, GPU, KV budget"),
    ("WHEN",  "Policy",     7.2, 2.4, PURPLE, "When is this lease valid? Epoch, freshness"),
    ("WHY",   "Outcome",    7.2, 3.7, PURPLE, "Why is this expected to produce goodput?"),
]
for face, domain, x, y, col, desc in faces:
    add_rect(sl, x, y, 5.8, 1.1, fill=CARD2)
    hline(sl, x, y, 5.8, color=col)
    add_text(sl, face,   x+0.15, y+0.08, 1.0, 0.45, size=18, bold=True, color=col)
    add_text(sl, domain, x+1.2,  y+0.08, 1.5, 0.45, size=11, bold=True, color=LGRAY)
    add_text(sl, desc,   x+0.15, y+0.6,  5.4, 0.4,  size=10, color=WHITE)

# Center — gate logic
add_rect(sl, 6.55, 1.1, 0.6, 3.7, fill=BG)
for i in range(3):
    add_text(sl, "→", 6.55, 1.38 + i * 1.3, 0.6, 0.4,
             size=18, bold=True, color=CYAN, align=PP_ALIGN.CENTER)
for i in range(3):
    add_text(sl, "←", 6.55, 1.38 + i * 1.3, 0.6, 0.4,
             size=18, bold=True, color=PURPLE, align=PP_ALIGN.CENTER)

# The gate
add_rect(sl, 5.85, 2.35, 1.6, 1.0, fill=GREEN)
add_text(sl, "GATE", 5.85, 2.45, 1.6, 0.4, size=16, bold=True, color=BG, align=PP_ALIGN.CENTER)
add_text(sl, "∧ all 6", 5.85, 2.85, 1.6, 0.35, size=10, color=BG, align=PP_ALIGN.CENTER)

# Math block
add_rect(sl, 0.5, 5.05, 12.3, 1.85, fill=CARD)
add_text(sl, "Formal Gate Condition (Cubie Bridge V1.40, proven in Coq + Lean 4):",
         0.65, 5.12, 12, 0.35, size=10, bold=True, color=CYAN)
add_text(sl,
    "WriteOK(c, policyOK) ⟺ GPUCorner(c) ∧ DeploymentCorner(c) ∧ Topology(c) ∧ policyOK",
    0.65, 5.5, 12, 0.4, size=13, bold=True, color=WHITE)
add_text(sl,
    "GPUCorner = who_pass ∧ what_pass ∧ how_pass        "
    "DeploymentCorner = where_pass ∧ when_pass ∧ why_pass ∧ has_valid_lease ∧ epoch_fresh",
    0.65, 5.95, 12, 0.4, size=10, color=LGRAY)
add_text(sl, "Proven axiom-free in Lean 4 Core — no Mathlib, no sorry, no Classical.choice",
         0.65, 6.42, 12, 0.35, size=9, italic=True, color=GREEN)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — 54-SITE GEOMETRY
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "The 54-Site Geometry — Where Trust Risk Lives",
             "88.9% of all sites are boundary sites — most runtime risk is interface risk")

add_text(sl,
    "\"Most runtime risk is interface risk. Trust fails where identity meets scope, scope meets runtime,\n"
    " runtime meets lineage, lineage meets outcome, and context meets policy.\"",
    0.5, 1.0, 12.3, 0.8, size=13, italic=True, color=AMBER)
hline(sl, 0.5, 1.85, 12.3, color=AMBER, thickness=1)

# Geometry grid — 6 faces × 3×3
colors_by_type = {
    "corner": AMBER,   # 4 per face × 6 = 24 (but 8 cube corners shared)
    "edge":   CYAN,    # boundary
    "center": LGRAY,   # 1 per face × 6 = 6
}
face_labels = ["IDENTITY", "CONTEXT", "LINEAGE", "RUNTIME", "POLICY", "OUTCOME"]
face_colors = [CYAN, CYAN, CYAN, PURPLE, PURPLE, PURPLE]

# Draw 6 mini 3×3 grids
cell = 0.32
for fi, (flbl, fcol) in enumerate(zip(face_labels, face_colors)):
    gx = 0.5  + (fi % 3) * 4.3
    gy = 2.1  + (fi // 3) * 2.4
    add_text(sl, flbl, gx, gy, 3.0, 0.3, size=9, bold=True, color=fcol)
    for row in range(3):
        for col in range(3):
            cx = gx + col * (cell + 0.04)
            cy = gy + 0.35 + row * (cell + 0.04)
            is_corner = (row in (0,2)) and (col in (0,2))
            is_center = (row == 1) and (col == 1)
            fill = AMBER if is_corner else (CARD2 if is_center else fcol)
            alpha_fill = CARD2 if is_center else fill
            add_rect(sl, cx, cy, cell, cell, fill=alpha_fill)
            if not is_center:
                site_num = fi * 9 + row * 3 + col + 1
                add_text(sl, str(site_num % 9 if site_num % 9 != 0 else 9),
                         cx+0.04, cy+0.05, cell-0.05, cell-0.08,
                         size=7, color=BG if fill != CARD2 else LGRAY,
                         align=PP_ALIGN.CENTER, bold=True)

# Legend
add_rect(sl, 0.5, 6.55, 12.3, 0.75, fill=CARD2)
legend = [
    (AMBER,  "Corner sites (×8 per face) — highest risk intersections — seam product must pass"),
    (CYAN,   "Edge/boundary sites (48 of 54 = 88.9%) — active seam evaluation zones"),
    (CARD2,  "Center sites (×1 per face, 6 total) — face-internal predicates only"),
]
for i, (col, lbl) in enumerate(legend):
    add_rect(sl, 0.65 + i * 4.1, 6.67, 0.28, 0.28, fill=col)
    add_text(sl, lbl, 1.05 + i * 4.1, 6.65, 3.7, 0.35, size=9, color=LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — THE PROOF STACK
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "The Proof Stack — 733 Theorems, Three Verification Layers",
             "Every gate condition backed by a machine-checked proof")

# Layer pyramid
layers = [
    (0.6, 1.1, 12.1, 1.4, CYAN,   "VERUS  (Rust formal verification)",
     "17 spec files · exec fn layer · machine-code-ready · 0 errors"),
    (0.6, 2.6, 12.1, 1.4, PURPLE, "LEAN 4  (dependent type theory)",
     "34 files · axiom-free in Lean Core · no Mathlib · no sorry · no Classical.choice"),
    (0.6, 4.1, 12.1, 1.4, AMBER,  "COQ  (calculus of constructions)",
     "35 files · coqchk kernel-verified · 733 rows in master theorem table"),
]
for lx, ly, lw, lh, col, title, sub in layers:
    add_rect(sl, lx, ly, lw, lh, fill=CARD2)
    hline(sl, lx, ly, lw, color=col)
    add_text(sl, title, lx+0.2, ly+0.12, lw-0.4, 0.55, size=16, bold=True, color=col)
    add_text(sl, sub,   lx+0.2, ly+0.72, lw-0.4, 0.55, size=11, color=LGRAY)
    # Count badge
    counts = {"VERUS": "17", "LEAN": "34", "COQ": "35"}
    for k, v in counts.items():
        if k in title:
            add_rect(sl, lx + lw - 1.3, ly + 0.15, 1.1, 0.8, fill=col)
            add_text(sl, v, lx + lw - 1.3, ly + 0.2, 1.1, 0.55,
                     size=28, bold=True, color=BG, align=PP_ALIGN.CENTER)
            add_text(sl, "files", lx + lw - 1.3, ly + 0.72, 1.1, 0.3,
                     size=8, color=BG, bold=True, align=PP_ALIGN.CENTER)

# Theorem coverage table
add_rect(sl, 0.5, 5.65, 12.3, 1.7, fill=CARD)
add_text(sl, "Coverage by Deliverable",
         0.65, 5.72, 12, 0.35, size=11, bold=True, color=WHITE)
entries = [
    ("V1.19.2 Ramen Corner", "53"),
    ("V2.0 Track C", "26"),
    ("V2.0-PP Per-Predicate", "54"),
    ("V1.50 Track B", "17"),
    ("Omega 4.0–6.0", "8"),
    ("V1.40 Cubie Bridge", "6"),
    ("V2.5 Gap (new)", "17"),
    ("Other", "552"),
]
for i, (name, count) in enumerate(entries):
    x = 0.65 + i * 1.57
    col = GREEN if "Gap" in name else CYAN
    add_text(sl, count, x, 6.08, 1.4, 0.45, size=22, bold=True, color=col, align=PP_ALIGN.CENTER)
    add_text(sl, name,  x, 6.55, 1.4, 0.55, size=7,  color=LGRAY, align=PP_ALIGN.CENTER)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — BARE-METAL SILICON GATE
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Bare-Metal Silicon Gate — No OS Required",
             "Pure Rust · no_std · zero dependencies · FIPS 198-1 HMAC + MMIO hardware checks")

# Architecture flow
nodes = [
    (0.4,  2.0, 2.0, 1.2, "Firmware /\nUEFI Caller",   CARD2, LGRAY),
    (2.75, 2.0, 2.3, 1.2, "CubieRequest\n#[repr(C)]",   CARD2, CYAN),
    (5.4,  2.0, 2.3, 1.2, "cubie_admit()\nC ABI gate",  CYAN,  BG),
    (8.05, 2.0, 2.3, 1.2, "admit_inner()\n6 + 3 checks",CARD2, WHITE),
    (10.7, 2.0, 2.1, 1.2, "ALLOW /\nDENY",              GREEN, BG),
]
for nx, ny, nw, nh, nl, nf, ntc in nodes:
    add_rect(sl, nx, ny, nw, nh, fill=nf)
    hline(sl, nx, ny, nw, color=CYAN if nf != CYAN else BG)
    add_text(sl, nl, nx+0.1, ny+0.2, nw-0.2, nh-0.3,
             size=11, bold=True, color=ntc, align=PP_ALIGN.CENTER)
for i in range(len(nodes)-1):
    x = nodes[i][0] + nodes[i][2] + 0.05
    add_text(sl, "→", x, nodes[i][1]+0.35, 0.3, 0.4,
             size=16, bold=True, color=CYAN, align=PP_ALIGN.CENTER)

# Hardware checks breakdown
hw = [
    (0.4,  3.6, 3.8, "HMAC-SHA256\n(FIPS 198-1 + 180-4)",
     "eFuse key read via MMIO →\nHMAC(key, request_hash) →\nconstant-time compare\n\n730 ns / 2,242 cycles", CYAN),
    (4.5,  3.6, 3.8, "NVLink Waiter\nDetection",
     "Read SM_ACTIVITY register\nRead VRAM_ALLOC register\nif SM=0 ∧ VRAM>0 → DENY\n\n< 1 ns / 1 cycle", PURPLE),
    (8.6,  3.6, 4.2, "PCIe Adapter\nSwap Gate",
     "16-entry static adapter cache\nCache hit → allow instantly\nCache miss → read BW register\nBW < 4 GB/s → DENY", AMBER),
]
for hx, hy, hw_, hlbl, hbody, hcol in hw:
    add_rect(sl, hx, hy, hw_, 3.5, fill=CARD2)
    hline(sl, hx, hy, hw_, color=hcol)
    add_text(sl, hlbl,  hx+0.15, hy+0.12, hw_-0.3, 0.65, size=13, bold=True, color=hcol)
    add_text(sl, hbody, hx+0.15, hy+0.85, hw_-0.3, 2.5,  size=10, color=WHITE)

# Cross-compile targets
add_rect(sl, 0.4, 7.05, 12.4, 0.35, fill=CARD)
targets = ["riscv32imc-unknown-none-elf", "x86_64-unknown-none  (UEFI)", "aarch64-unknown-none  (ARM)"]
for i, t in enumerate(targets):
    add_text(sl, "✓ " + t, 0.65 + i * 4.15, 7.07, 4.0, 0.3,
             size=9, color=GREEN, bold=True)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — PERFORMANCE
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Performance — Measured on Real Silicon",
             "Intel Core Ultra 9 285HX · RDTSC-calibrated · 1,000,000 iterations")

stat_card(sl, "730 ns",  "Full gate\nsteady state",    0.4,  1.1, CYAN)
stat_card(sl, "2,242",   "CPU cycles\nper admit call", 3.1,  1.1, CYAN)
stat_card(sl, "1.37M",   "Admits /\nsecond",           5.8,  1.1, GREEN)
stat_card(sl, "3.07 GHz","Measured CPU\nclock (RDTSC)",8.5,  1.1, AMBER)
stat_card(sl, "<1 ns",   "NVLink + PCIe\nchecks",      11.2, 1.1, PURPLE)

# Bar chart
add_rect(sl, 0.4, 2.65, 12.3, 4.2, fill=CARD2)
add_text(sl, "Time Breakdown Per Admit Call (ns)", 0.6, 2.72, 8, 0.38, size=12, bold=True, color=WHITE)

bars = [
    ("HMAC-SHA256\n(pure crypto)", 785, CYAN,   "97% of gate time — pure math, identical in production"),
    ("Full gate\n(cache miss)",    730, GREEN,  "Gate overhead above HMAC: only 25 ns"),
    ("Full gate\n(cache hit)",     730, GREEN,  "Same — PCIe/NVLink are sub-nanosecond"),
    ("NVLink check",                 1, PURPLE, "Two atomic loads"),
    ("PCIe cache hit",               1, AMBER,  "Linear scan, 16 entries"),
]
max_ns = 900
bar_x = 3.5
bar_w_max = 8.8
for i, (lbl, ns, col, note) in enumerate(bars):
    y = 3.2 + i * 0.68
    frac = ns / max_ns
    add_text(sl, lbl, 0.5, y, 2.9, 0.6, size=9, color=WHITE)
    add_rect(sl, bar_x, y + 0.08, bar_w_max * frac, 0.42, fill=col)
    add_text(sl, f"{ns} ns", bar_x + bar_w_max * frac + 0.1, y + 0.1, 1.5, 0.35,
             size=10, bold=True, color=col)

# Projection table
add_rect(sl, 0.4, 7.0, 12.3, 0.38, fill=CARD)
proj = [("Intel Core Ultra 9 285HX", "3.07 GHz", "730 ns", "1.37M/s"),
        ("RISC-V @ 1 GHz",           "1 GHz",    "~2.4 µs","~416K/s"),
        ("ARM Cortex-A @ 1.8 GHz",   "1.8 GHz",  "~1.3 µs","~750K/s")]
for i, (cpu, clk, lat, tput) in enumerate(proj):
    x = 0.55 + i * 4.1
    add_text(sl, f"{cpu}  {clk}  {lat}  {tput}",
             x, 7.04, 4.0, 0.32, size=8, color=LGRAY if i > 0 else GREEN)

# ═══════════════════════════════════════════════════════════════════════════
# ACT 3 DIVIDER
# ═══════════════════════════════════════════════════════════════════════════
section_divider(prs, "ACT III", "Zero Gaps — Our Process", color=GREEN)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — THE PIPELINE
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "From Whitepaper to Silicon — The Full Pipeline",
             "Every claim traced through formal proof to machine-verified binary")

steps = [
    ("01", "Whitepaper\nv2.5",         "Source of truth for\nall predicates and\ntheorems",      AMBER,  0.35),
    ("02", "Gap\nAnalysis",            "52 items reviewed\nagainst master table\n15 NO gaps found", RED,  3.0),
    ("03", "Coq +\nLean 4",            "5 new proof files\nper tool · coqchk\nkernel verified",    CYAN,  5.65),
    ("04", "Verus +\nexec fn",         "Machine-code-ready\nformal specs · Rust\nexec layer added", PURPLE,8.3),
    ("05", "Bare-Metal\nRust",         "no_std crate · 0\ndeps · FIPS HMAC\nMMIO hardware",        GREEN, 10.95),
]
for step, title, body, col, x in steps:
    add_rect(sl, x, 1.2, 2.3, 5.5, fill=CARD2)
    hline(sl, x, 1.2, 2.3, color=col)
    add_rect(sl, x + 0.75, 1.35, 0.8, 0.8, fill=col)
    add_text(sl, step, x + 0.75, 1.4, 0.8, 0.7, size=18, bold=True, color=BG, align=PP_ALIGN.CENTER)
    add_text(sl, title, x + 0.1, 2.35, 2.1, 0.75, size=13, bold=True, color=col, align=PP_ALIGN.CENTER)
    add_text(sl, body,  x + 0.1, 3.2,  2.1, 2.5,  size=10, color=WHITE, align=PP_ALIGN.CENTER)
    if x < 10.95:
        add_text(sl, "→", x + 2.35, 3.3, 0.3, 0.5, size=20, bold=True, color=LGRAY, align=PP_ALIGN.CENTER)

add_rect(sl, 0.35, 6.85, 12.6, 0.55, fill=CARD)
add_text(sl,
    "Result:  733 theorems  ·  0 gaps remaining  ·  21/21 tests pass  ·  "
    "730 ns/call on silicon  ·  GitHub + Google Drive backup  ·  v1.1-bare-metal tagged",
    0.5, 6.9, 12.3, 0.42, size=10, color=GREEN, bold=True, align=PP_ALIGN.CENTER)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — GAP ANALYSIS
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Gap Analysis — Nothing Falls Through the Seams",
             "Whitepaper v2.5 cross-referenced against master theorem table — 52 items reviewed")

stat_card(sl, "52",  "Total items\nreviewed",       0.4,  1.1, CYAN)
stat_card(sl, "14",  "Already\ncovered (YES)",      3.1,  1.1, GREEN)
stat_card(sl, "22",  "Partially\ncovered (PARTIAL)",5.8,  1.1, AMBER)
stat_card(sl, "15",  "Gaps identified\n(NO)",        8.5,  1.1, RED)
stat_card(sl, "17",  "New theorems\nadded (DONE)",  11.2, 1.1, GREEN)

# 5 new theorem clusters
add_text(sl, "Five New Theorem Clusters Added (CUB-0717 – CUB-0733)",
         0.4, 2.65, 12.3, 0.4, size=13, bold=True, color=WHITE)

clusters = [
    ("Cluster 16", "V2.1 Execution Physics",   "ConsumedHashLedger · OneTimeExecutionLease\nreplay_rejection — executed hash invalidates lease",    CYAN),
    ("Cluster 17", "Delegation & Recursion",   "PermBudget · permission_attenuation\n4-constraint containment — subagents cannot exceed parent",  PURPLE),
    ("Cluster 18", "Attention Geometry v2.5",  "AttentionManifest · WasteOKFactors\nhead_shape_mismatch_implies_waste_zero",                       AMBER),
    ("Cluster 19", "Engineering Physics",      "kv_cache_byte_estimator · roofline_admission_time\nfailure_probability_bound — monotone layers lemma",CYAN),
    ("Cluster 20", "Cubie Site Topology",      "9-tuple CubieSiteTuple · boundary_site_fraction\n8×6=48 boundary + 1×6=6 center = 54 sites proven",   GREEN),
]
for i, (cluster, name, body, col) in enumerate(clusters):
    x = 0.4 + (i % 3) * 4.3
    y = 3.1 + (i // 3) * 2.2
    add_rect(sl, x, y, 4.0, 2.0, fill=CARD2)
    hline(sl, x, y, 4.0, color=col)
    add_text(sl, cluster, x+0.15, y+0.07, 1.5, 0.35, size=9,  bold=True, color=LGRAY)
    add_text(sl, name,    x+0.15, y+0.35, 3.7, 0.45, size=12, bold=True, color=col)
    add_text(sl, body,    x+0.15, y+0.85, 3.7, 1.0,  size=9,  color=WHITE)

# Each cluster proof coverage bar
add_rect(sl, 0.4, 7.12, 12.3, 0.28, fill=CARD)
add_text(sl,
    "Each cluster: Coq .v  +  Lean 4 .lean  +  Verus .rs with exec fn  →  "
    "VERIFIED_EXACT · status updated in master_theorem_table.csv",
    0.55, 7.15, 12.0, 0.24, size=9, color=GREEN)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — TEST RESULTS
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Test Results — 21 of 21 Pass", "Mock MMIO · atomic register cells · host-side CI · all gate conditions exercised")

add_rect(sl, 0.4, 1.1, 5.8, 6.3, fill=CARD2)
hline(sl, 0.4, 1.1, 5.8, color=GREEN)
add_text(sl, "Integration Test Matrix", 0.55, 1.18, 5.5, 0.4, size=13, bold=True, color=WHITE)

tests = [
    ("allow_all_conditions_pass",         "PASS", GREEN),
    ("deny_null_pointer",                 "PASS", GREEN),
    ("deny_who_false",                    "PASS", GREEN),
    ("deny_what_false",                   "PASS", GREEN),
    ("deny_how_false",                    "PASS", GREEN),
    ("deny_where_false",                  "PASS", GREEN),
    ("deny_when_false",                   "PASS", GREEN),
    ("deny_why_false",                    "PASS", GREEN),
    ("deny_lease_invalid",                "PASS", GREEN),
    ("deny_epoch_stale",                  "PASS", GREEN),
    ("deny_hmac_mismatch",                "PASS", GREEN),
    ("deny_hmac_wrong_key_slot",          "PASS", GREEN),
    ("deny_hmac_wrong_request_hash",      "PASS", GREEN),
    ("allow_hmac_exact_match",            "PASS", GREEN),
    ("deny_nvlink_waiter_detected",       "PASS", GREEN),
    ("allow_nvlink_sm_active",            "PASS", GREEN),
    ("allow_nvlink_sm_zero_no_vram",      "PASS", GREEN),
    ("deny_pcie_congested_cache_miss",    "PASS", GREEN),
    ("allow_pcie_good_bandwidth",         "PASS", GREEN),
    ("allow_pcie_cache_hit_bypasses_bw",  "PASS", GREEN),
    ("deny_zero_adapter_id_sentinel",     "PASS", GREEN),
]
for i, (name, result, col) in enumerate(tests):
    y = 1.68 + i * 0.27
    add_rect(sl, 0.45, y, 5.65, 0.26, fill=CARD if i % 2 == 0 else CARD2)
    add_text(sl, name,   0.6,  y+0.03, 4.7, 0.22, size=8,  color=WHITE)
    add_text(sl, result, 5.3,  y+0.03, 0.7, 0.22, size=8,  bold=True, color=col, align=PP_ALIGN.CENTER)

# Right side — test infrastructure
add_rect(sl, 6.5, 1.1, 6.3, 3.0, fill=CARD2)
hline(sl, 6.5, 1.1, 6.3, color=CYAN)
add_text(sl, "Test Infrastructure", 6.65, 1.18, 6.0, 0.4, size=13, bold=True, color=WHITE)
infra = [
    "mock feature  →  AtomicU32 replaces MMIO",
    "mock_set_efuse_key(slot, &[u8;32])",
    "mock_set_nvlink_sm(peer, value: u32)",
    "mock_set_nvlink_vram(peer, value: u32)",
    "mock_set_pcie_bw(mbs: u32)",
    "pcie::clear_adapter_cache()  between tests",
    "compute_hmac(hash)  inside test to self-verify",
    "cargo test  runs on host (std + mock features)",
]
for i, item in enumerate(infra):
    add_text(sl, "•  " + item, 6.65, 1.7 + i * 0.31, 6.0, 0.3, size=9, color=WHITE)

add_rect(sl, 6.5, 4.3, 6.3, 3.1, fill=CARD2)
hline(sl, 6.5, 4.3, 6.3, color=AMBER)
add_text(sl, "Why This Matters", 6.65, 4.38, 6.0, 0.4, size=13, bold=True, color=WHITE)
add_text(sl,
    "The mock MMIO cells are AtomicU32 — the HMAC-SHA256\n"
    "computation is 100% identical between test and production.\n\n"
    "What changes in production:\n"
    "  · MMIO read replaces atomic load (+100–300 ns eFuse latency)\n"
    "  · NVLink SM/VRAM reads from real GPU telemetry registers\n"
    "  · PCIe BW read from hardware bandwidth counter\n\n"
    "The formal properties proven by Verus hold in both environments\n"
    "because the exec fn layer is verified against the same spec.",
    6.65, 4.85, 6.0, 2.4, size=10, color=LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# ACT 4 DIVIDER
# ═══════════════════════════════════════════════════════════════════════════
section_divider(prs, "ACT IV", "The Opportunity", color=PURPLE)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — PATENT PORTFOLIO
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Patent Portfolio — Formally Verified, Hardware-Bound IP",
             "Three patents · granted + pending · every theorem maps to a claim")

patents = [
    ("US11956363B2", "GRANTED",
     "Cubie Trust Compiler",
     "Core admission gate · 6-face recursive\ntrust object · seam-product evaluation\nbefore GPU prefill",
     GREEN),
    ("US12073439B2", "GRANTED",
     "Cubie Geometry +\nCorner Model",
     "54-site oriented surface · 88.9%\nboundary theorem · corner consensus\nscore K_v = min(J_e1, J_e2, J_e3)",
     GREEN),
    ("US20240195628A1", "PENDING",
     "V2.0-PP Per-Predicate\nCorollaries",
     "54 per-predicate corollaries · constructive\nproofs for each site · fully axiom-free\nin Lean 4 Core",
     AMBER),
]
for i, (num, status, title, body, col) in enumerate(patents):
    x = 0.4 + i * 4.3
    add_rect(sl, x, 1.1, 4.0, 5.0, fill=CARD2)
    hline(sl, x, 1.1, 4.0, color=col)
    add_rect(sl, x + 0.15, 1.25, 3.7, 0.42, fill=col)
    add_text(sl, status, x + 0.15, 1.28, 3.7, 0.35, size=12, bold=True, color=BG, align=PP_ALIGN.CENTER)
    add_text(sl, num,   x + 0.15, 1.78, 3.7, 0.35, size=11, bold=True, color=col)
    add_text(sl, title, x + 0.15, 2.2,  3.7, 0.75, size=14, bold=True, color=WHITE)
    add_text(sl, body,  x + 0.15, 3.05, 3.7, 2.5,  size=10, color=LGRAY)

# Defensibility
add_rect(sl, 0.4, 6.25, 12.3, 1.15, fill=CARD)
add_text(sl, "Proof-of-Defensibility", 0.6, 6.32, 4, 0.38, size=11, bold=True, color=CYAN)
points = [
    "All 733 theorems independently machine-verified (coqchk kernel, Lean 4 Core)",
    "Zero Admitted / zero sorry / zero Classical axioms in delivered proof corpus",
    "Constructive proofs only — every claim has an executable witness",
    "SHA-256 file hashes committed to GitHub — tamper-evident audit trail",
    "Hardware bound — exec fn layer proves Rust binary satisfies formal spec",
]
for i, p in enumerate(points):
    x = 0.6 + (i % 3) * 4.1
    y = 6.72 + (i // 3) * 0.35
    add_text(sl, "✓  " + p, x, y, 3.9, 0.32, size=9, color=GREEN if i < 2 else WHITE)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — DEPLOYMENT TARGETS
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Four Deployment Targets — One Verified Core",
             "Same formally-proven gate · different integration surfaces")

targets = [
    ("☁  Cloud / SaaS",
     "Cloudflare Workers · API gateway\nplugin · service mesh policy\npoint · Kubernetes admission\nwebhook",
     "First deny at the edge — before\nrequest reaches GPU cluster.",
     CYAN, 0.4),
    ("🏥  Medical / On-Prem",
     "HIPAA-compliant · air-gapped\ndeploy · hardware eFuse key\nbinding · no external calls\nrequired",
     "PHI access gated by formally\nproven identity + lineage seam.",
     GREEN, 3.6),
    ("🏢  Data Center / Enterprise",
     "Intel Xeon rack-edge · Slurm\nscheduler plugin · GPU prefill\nfirewall · NVLink waiter\nprotection",
     "Prevent the 66.85% fleet\ncapacity loss event.",
     PURPLE, 6.8),
    ("📱  Consumer (McAfee-for-AI)",
     "Core Ultra edge verifier ·\nembedded RISC-V gate · agent\nruntime guard · tool and\nsubagent invocation check",
     "Every AI action on-device\npasses the formal gate first.",
     AMBER, 10.0),
]
for title, body, tagline, col, x in targets:
    add_rect(sl, x, 1.1, 2.95, 5.8, fill=CARD2)
    hline(sl, x, 1.1, 2.95, color=col)
    add_text(sl, title,    x+0.12, 1.18, 2.7, 0.55, size=12, bold=True, color=col)
    add_text(sl, body,     x+0.12, 1.82, 2.7, 2.8,  size=10, color=WHITE)
    add_rect(sl, x+0.12,   4.75, 2.7, 1.0, fill=CARD)
    add_text(sl, tagline,  x+0.2,  4.85, 2.55, 0.82, size=9, italic=True, color=LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — OPPORTUNITY
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "The Market Opportunity",
             "AI Safety is Infrastructure — every GPU cluster, every agentic runtime needs this gate")

add_text(sl,
    "\"Agentic AI does not fail because models lack intelligence or clusters lack compute.\n"
    " It fails because every agent, subagent, tool call, data hop, and model invocation\n"
    " multiplies context noise. Cubie addresses that failure.\"",
    0.5, 1.05, 12.3, 1.1, size=14, italic=True, color=AMBER)
hline(sl, 0.5, 2.2, 12.3, color=AMBER, thickness=1)

opps = [
    ("GPU Fleet\nEfficiency",
     "Every hyperscaler, cloud provider, and\nenterprise GPU cluster is hemorrhaging\ncapacity to NVLink deadlocks and\ncontext bombs. Cubie is the firewall.",
     "TAM: Every GPU-as-a-service deployment",
     CYAN, 0.4, 2.45),
    ("Agentic AI\nRuntime Security",
     "Every MCP server, AutoGPT, LangChain,\nand enterprise AI agent framework needs\na formal gate before tool execution\nand model invocation.",
     "TAM: Every agentic AI deployment",
     PURPLE, 4.6, 2.45),
    ("Regulatory\nCompliance",
     "NIST SP 800-207 (Zero Trust), NIST AI\nRMF 1.0, NIST CAISI AI Agent Security\nRFI (2026). Cubie provides machine-\nverified compliance evidence.",
     "TAM: Any regulated AI deployment",
     GREEN, 8.8, 2.45),
    ("Hardware IP\nLicensing",
     "The bare-metal gate is a 730-ns,\nzero-dependency staticlib. OEM licensing\nto Intel, AMD, NVIDIA for embedding\nin silicon management firmware.",
     "TAM: Every AI accelerator shipped",
     AMBER, 0.4, 5.1),
    ("Formal Proof\nSaaS",
     "The 733-theorem corpus + master table\n+ Excel tooling becomes a SaaS product:\n'verify your AI deployment policy\nagainst our formal proof stack'",
     "TAM: Every enterprise AI governance team",
     CYAN, 4.6, 5.1),
    ("Government &\nDefense",
     "FIPS-compliant HMAC, formally proven\nadmission logic, air-gapped no_std\ndeploy, eFuse hardware binding —\nchecks every DoD AI requirement.",
     "TAM: All government AI programs",
     RED, 8.8, 5.1),
]
for title, body, tam, col, x, y in opps:
    add_rect(sl, x, y, 3.9, 2.4, fill=CARD2)
    hline(sl, x, y, 3.9, color=col)
    add_text(sl, title, x+0.15, y+0.1,  3.6, 0.6, size=12, bold=True, color=col)
    add_text(sl, body,  x+0.15, y+0.75, 3.6, 1.2, size=9,  color=WHITE)
    add_text(sl, tam,   x+0.15, y+2.0,  3.6, 0.35,size=8,  color=LGRAY, italic=True)

# ═══════════════════════════════════════════════════════════════════════════
# SLIDE — NEXT STEPS
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Next Steps", "From formal proof to production deployment")

steps_next = [
    ("1", "Hardware Integration",
     "Connect bare-metal gate to real eFuse MMIO on\ntarget silicon (SiFive HiFive, Intel Core Ultra,\nARM Cortex-A). Platform linker script + device tree.",
     CYAN),
    ("2", "Verus Crypto Library",
     "Replace uninterpreted HMAC predicate with a\nfull Verus-verified SHA-256 + HMAC proof.\nEliminate the last FUTURE_OBLIGATION in the stack.",
     PURPLE),
    ("3", "130 DERIVED_CANDIDATE Theorems",
     "Formalize the 130 derived-candidate rows in\nmaster_theorem_table.csv. Parent theorems already\nexist — formalization work only.",
     AMBER),
    ("4", "Silicon Benchmark Run",
     "Run speedtest.ps1 on RISC-V hardware (SiFive\nor QEMU). Confirm 2.4 µs/call projection.\nAdd mcycle CSR timing to CI.",
     GREEN),
    ("5", "Enterprise Pilot",
     "Deploy Cubie gate as Kubernetes admission webhook\nor Slurm scheduler plugin at one enterprise GPU\ncluster. Measure capacity recovery.",
     RED),
    ("6", "US20240195628A1 Grant",
     "54 per-predicate corollaries — constructive proofs\nsubmitted. Monitor patent prosecution. Coordinate\nwith counsel on claim mapping to V2.5 gap theorems.",
     LGRAY),
]
for i, (num, title, body, col) in enumerate(steps_next):
    x = 0.4 + (i % 3) * 4.3
    y = 1.1 + (i // 3) * 2.9
    add_rect(sl, x, y, 4.0, 2.7, fill=CARD2)
    hline(sl, x, y, 4.0, color=col)
    add_rect(sl, x+0.15, y+0.12, 0.55, 0.55, fill=col)
    add_text(sl, num, x+0.15, y+0.13, 0.55, 0.5, size=16, bold=True, color=BG, align=PP_ALIGN.CENTER)
    add_text(sl, title, x+0.85, y+0.15, 3.0, 0.5, size=12, bold=True, color=col)
    add_text(sl, body,  x+0.15, y+0.85, 3.7, 1.7, size=9, color=WHITE)

# ═══════════════════════════════════════════════════════════════════════════
# TECHNICAL ADDENDUM DIVIDER
# ═══════════════════════════════════════════════════════════════════════════
section_divider(prs, "TECHNICAL ADDENDUM", "Architecture · Proofs · Benchmarks · File Inventory", color=LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# ADDENDUM — FULL SYSTEM ARCHITECTURE
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Full System Architecture", "Whitepaper → Proof → Spec → Silicon", accent=LGRAY)

# Three-column architecture
cols_arch = [
    ("FORMAL PROOF LAYER", CYAN, [
        "coq/  (35 files)",
        "  RamenCornerConsensusV1192.v",
        "  CubieTrustCompilerV2_0.v",
        "  CubieTrustCompilerV2_0_PP.v",
        "  TheoremOmega{4,5,6,7,8}.v",
        "  CubieAttentionGeometry_v7.v",
        "  CubieSiteTopology_v4.v",
        "  + 29 more",
        "",
        "lean/  (34 files)",
        "  mirrors coq/ module-for-module",
        "",
        "coqchk kernel verification",
        "Lean 4 Core (no Mathlib)",
        "733 theorems · 0 sorry · 0 admitted",
    ]),
    ("VERUS SPEC LAYER", PURPLE, [
        "verus/  (17 files)",
        "  cubie_runtime_spec.rs",
        "  cubie_per_predicate_spec.rs",
        "  cubie_geometry_spec.rs",
        "  cubie_lease_spec.rs",
        "  cubie_capacity_spec.rs",
        "  cubie_delegation_spec.rs",
        "  cubie_execution_lease_spec.rs",
        "  cubie_attention_geometry_spec.rs",
        "  cubie_engineering_physics_spec.rs",
        "  cubie_site_topology_spec.rs",
        "  + 7 more",
        "",
        "spec fn  →  ghost (erased at compile)",
        "exec fn  →  compiled to machine code",
        "ensures result == spec_fn(args)",
    ]),
    ("BARE-METAL RUST LAYER", GREEN, [
        "bare-metal/src/",
        "  sha256.rs   FIPS 180-4 compress()",
        "  hmac.rs     FIPS 198-1 hmac_sha256()",
        "  mmio.rs     volatile MMIO + mock cells",
        "  nvlink.rs   SM_ACTIVITY + VRAM_ALLOC",
        "  pcie.rs     16-entry cache + BW check",
        "  hmac_stub.rs eFuse key + verify()",
        "  admit.rs    cubie_admit() C ABI",
        "  types.rs    CubieRequest #[repr(C)]",
        "  cycle_counter.rs  rdtsc/mcycle/cntvct",
        "",
        "Targets:",
        "  riscv32imc-unknown-none-elf",
        "  x86_64-unknown-none",
        "  aarch64-unknown-none",
    ]),
]
for ci, (title, col, items) in enumerate(cols_arch):
    x = 0.4 + ci * 4.3
    add_rect(sl, x, 1.1, 4.0, 6.3, fill=CARD2)
    hline(sl, x, 1.1, 4.0, color=col)
    add_text(sl, title, x+0.15, 1.18, 3.7, 0.38, size=11, bold=True, color=col)
    for i, item in enumerate(items):
        is_header = item.endswith("/") or item.endswith(")")
        c = LGRAY if item.startswith("  ") else WHITE
        add_text(sl, item, x+0.15, 1.65 + i * 0.29, 3.7, 0.28,
                 size=8 if item.startswith("  ") else 9,
                 color=col if (is_header and not item.startswith("  ")) else c,
                 bold=is_header and not item.startswith("  "))

# ═══════════════════════════════════════════════════════════════════════════
# ADDENDUM — HMAC-SHA256 ARCHITECTURE
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "HMAC-SHA256 Implementation — FIPS 198-1", "Pure Rust · no_std · no heap · constant-time comparison", accent=LGRAY)

# Flow diagram
flow = [
    (0.4, 1.6, 2.8, "cubie_admit()\nreq.request_hash\nreq.capability_hmac\nreq.key_slot", CARD2, LGRAY),
    (0.4, 3.3, 2.8, "read_efuse_key\n(key_slot)\nMMIO → 8 × u32\n= 32-byte key",          RED,   WHITE),
    (3.6, 2.2, 2.8, "HMAC-SHA256\n(FIPS 198-1)\nhmac.rs",                                  CYAN,  BG),
    (3.6, 1.1, 2.8, "Inner: SHA256\n(key⊕ipad ∥ msg)\n72 bytes",                           CARD2, LGRAY),
    (3.6, 3.4, 2.8, "Outer: SHA256\n(key⊕opad ∥ inner)\n96 bytes",                         CARD2, LGRAY),
    (7.0, 2.2, 2.8, "Truncate to\n8 bytes\n(first 64 bits)",                               CARD2, WHITE),
    (7.0, 1.1, 2.8, "SHA256 compress()\nFIPS 180-4\n64 K-rounds",                          CARD2, LGRAY),
    (10.2,2.2, 2.9, "ct_eq_32()\nconstant-time\ncompare → bool",                           PURPLE,WHITE),
]
for fx, fy, fw, fl, ff, ftc in flow:
    add_rect(sl, fx, fy, fw, 1.0, fill=ff)
    if ff != BG:
        hline(sl, fx, fy, fw, color=CYAN if ff==CYAN else (RED if ff==RED else (PURPLE if ff==PURPLE else LGRAY)))
    add_text(sl, fl, fx+0.1, fy+0.12, fw-0.2, 0.75, size=9, color=ftc, align=PP_ALIGN.CENTER)

# Arrow annotations
arrows = [(3.2, 2.25, "→"), (6.6, 2.25, "→"), (9.8, 2.25, "→")]
for ax, ay, ar in arrows:
    add_text(sl, ar, ax, ay, 0.4, 0.4, size=18, bold=True, color=CYAN, align=PP_ALIGN.CENTER)

add_text(sl, "↓", 1.7, 2.65, 0.4, 0.5, size=16, color=RED, bold=True, align=PP_ALIGN.CENTER)
add_text(sl, "↑  ↓", 5.0, 2.2, 0.6, 0.3, size=10, color=LGRAY, align=PP_ALIGN.CENTER)
add_text(sl, "↑", 8.5, 2.2, 0.4, 0.3, size=14, color=LGRAY, align=PP_ALIGN.CENTER)

# Key properties
add_rect(sl, 0.4, 4.6, 12.3, 2.8, fill=CARD)
add_text(sl, "Key Implementation Properties", 0.6, 4.68, 8, 0.38, size=12, bold=True, color=WHITE)
props = [
    ("No heap allocation",        "All buffers on stack — 128-byte inner_input, 96-byte outer — zero dynamic memory",       CYAN),
    ("FIPS 198-1 compliant",      "Key padded to 64-byte block size; XOR with 0x36 (ipad) / 0x5C (opad); SHA-256 inner+outer", GREEN),
    ("Constant-time comparison",  "ct_eq_32() accumulates XOR diff into single byte — no early exit — timing-oracle safe",  PURPLE),
    ("Truncated MAC",             "First 8 bytes of 32-byte HMAC used as capability_hmac u64 — reduces attack surface",     AMBER),
    ("Hardware key binding",      "32-byte key read from eFuse MMIO slot — key never touches RAM — bound to physical device",RED),
    ("Mock/prod identical crypto","AtomicU32 mock only replaces the MMIO read; hmac_sha256() is bit-identical in both paths", GREEN),
]
for i, (label, desc, col) in enumerate(props):
    x = 0.6 + (i % 2) * 6.2
    y = 5.1 + (i // 2) * 0.55
    add_text(sl, label + ":", x, y, 2.5, 0.45, size=10, bold=True, color=col)
    add_text(sl, desc, x + 2.5, y, 3.5, 0.45, size=9, color=LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# ADDENDUM — VERUS EXEC FN PATTERN
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Verus exec fn — Bridging Proof to Binary", "spec fn is ghost · exec fn compiles · ensures links them at compile time", accent=LGRAY)

add_rect(sl, 0.4, 1.1, 5.8, 6.2, fill=CARD2)
hline(sl, 0.4, 1.1, 5.8, color=PURPLE)
add_text(sl, "Pattern: exec fn wrapping spec fn", 0.55, 1.18, 5.5, 0.38, size=12, bold=True, color=WHITE)

code = """// GHOST — erased at compile time
spec fn admit_spec(r: CubieRequest) -> bool {
    r.who_pass && r.what_pass && r.how_pass
    && r.where_pass && r.when_pass && r.why_pass
    && r.has_valid_lease && r.epoch_fresh
    && capability_hmac_valid(r.request_hash,
                             r.capability_hmac,
                             r.key_slot as int)
    && nvlink_waiter_safe(r.peer_id as int)
    && adapter_swap_ok(r.adapter_id as int)
}

// COMPILED — in the binary
pub fn exec_admit(r: &CubieRequest,
                  hmac_ok: bool,
                  nvlink_ok: bool,
                  pcie_ok: bool) -> (result: bool)
    requires
        capability_hmac_valid(...) == hmac_ok,
        nvlink_waiter_safe(...)    == nvlink_ok,
        adapter_swap_ok(...)       == pcie_ok,
    ensures
        result == admit_spec(*r),
{
    r.who_pass && r.what_pass && r.how_pass
    && r.where_pass && r.when_pass && r.why_pass
    && r.has_valid_lease && r.epoch_fresh
    && hmac_ok && nvlink_ok && pcie_ok
}"""

add_text(sl, code, 0.55, 1.65, 5.5, 5.5, size=8, color=GREEN)

add_rect(sl, 6.5, 1.1, 6.3, 6.2, fill=CARD)
add_text(sl, "Why This Matters for Silicon Deployment", 6.65, 1.18, 6.0, 0.38, size=12, bold=True, color=WHITE)

points = [
    ("spec fn is ghost code", PURPLE,
     "Verus erases it at compile time — zero binary\nsize, zero runtime cost. Proofs live in the\ntoolchain, not in flash memory."),
    ("exec fn is real code", CYAN,
     "The exec fn compiles to machine instructions.\nThis is what runs on RISC-V, x86-64, ARM —\nthe actual admission gate."),
    ("ensures links them", AMBER,
     "'ensures result == admit_spec(r)' is verified\nby Verus at build time. If the exec body does\nnot satisfy the spec, the build fails."),
    ("uninterp for hardware", GREEN,
     "MMIO predicates (capability_hmac_valid,\nnvlink_waiter_safe) are uninterpreted —\nhardware computes the bool; exec accepts it\nas a parameter with requires == param."),
    ("no runtime overhead", GREEN,
     "The formal proof adds zero cycles to the\nadmit path. 730 ns is pure computation —\nno verification logic at runtime."),
]
for i, (label, col, body) in enumerate(points):
    y = 1.75 + i * 1.08
    add_rect(sl, 6.65, y, 5.9, 0.95, fill=CARD2)
    hline(sl, 6.65, y, 5.9, color=col)
    add_text(sl, label, 6.8,  y+0.07, 5.6, 0.35, size=11, bold=True, color=col)
    add_text(sl, body,  6.8,  y+0.45, 5.6, 0.45, size=9,  color=LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# ADDENDUM — AXIOM AUDIT SUMMARY
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Axiom Audit — Constructive Proof Discipline", "Zero forbidden axioms in delivered corpus", accent=LGRAY)

stat_card(sl, "0",    "Admitted /\nsorry",          0.4,  1.1, GREEN)
stat_card(sl, "0",    "Classical.choice /\npropext", 3.1,  1.1, GREEN)
stat_card(sl, "733",  "Theorems\nmachine-checked",   5.8,  1.1, CYAN)
stat_card(sl, "35+",  "Opaque carrier\ntypes",        8.5,  1.1, AMBER)
stat_card(sl, "~20",  "Postulated\naxioms (total)",  11.2, 1.1, LGRAY)

# Axiom breakdown
add_rect(sl, 0.4, 2.65, 5.8, 4.7, fill=CARD2)
hline(sl, 0.4, 2.65, 5.8, color=AMBER)
add_text(sl, "Axioms by Module (v1.13 corpus)", 0.55, 2.72, 5.5, 0.38, size=12, bold=True, color=WHITE)

axioms = [
    ("v1.10 Non-Quantum",    2,  "projection_not_state, pattern_depth_fail_fast"),
    ("Theorem Omega 6.0",   10, "macro_graph_attestation + 6 adversarial implications"),
    ("CubieQ Apex",          3,  "capacity alignment + holonomy required"),
    ("Canon v1.4",           6,  "Cayley distance, consume_sets, vrf_functional"),
    ("Holographic Manifold", 6,  "hierarchical_self_similarity + 5 CS axioms"),
    ("CubieQuantumConsent",  5,  "measure_plus, non_commutativity, Holevo bound"),
    ("OmegaEight",           3,  "strict_ambiguity, B < R_states, entropy_margin"),
]
for i, (mod, count, desc) in enumerate(axioms):
    y = 3.2 + i * 0.56
    add_rect(sl, 0.45, y, 5.65, 0.5, fill=CARD if i % 2 == 0 else BG)
    add_text(sl, mod,   0.6,  y+0.08, 2.5, 0.35, size=9, bold=True, color=WHITE)
    add_text(sl, str(count), 3.1, y+0.08, 0.4, 0.35, size=11, bold=True, color=AMBER, align=PP_ALIGN.CENTER)
    add_text(sl, desc, 3.55, y+0.08, 2.4, 0.35, size=7, color=LGRAY)

# What axioms are NOT
add_rect(sl, 6.5, 2.65, 6.3, 4.7, fill=CARD)
add_text(sl, "What the Proofs DO and DO NOT Establish", 6.65, 2.72, 6.0, 0.38, size=12, bold=True, color=WHITE)
dos = [
    ("✓", GREEN, "Machine-verified correctness of admission logic"),
    ("✓", GREEN, "Seam product evaluation is formally sound"),
    ("✓", GREEN, "No bypass path exists through any corner"),
    ("✓", GREEN, "Subagent permission attenuation holds"),
    ("✓", GREEN, "Replay attack rejection: executed hash → invalid"),
    ("✓", GREEN, "Boundary theorem: 48 of 54 sites are boundary"),
]
donts = [
    ("✗", RED, "Side-channel or timing attack resistance"),
    ("✗", RED, "Thermodynamic claims about energy efficiency"),
    ("✗", RED, "Security against threats outside abstract predicates"),
    ("✗", RED, "Runtime implementation correctness (that's Verus)"),
]
for i, (icon, col, text) in enumerate(dos + donts):
    y = 3.25 + i * 0.42
    add_text(sl, icon,  6.65, y, 0.35, 0.38, size=12, bold=True, color=col)
    add_text(sl, text,  7.05, y, 5.5,  0.38, size=9, color=WHITE if col==GREEN else LGRAY)

# ═══════════════════════════════════════════════════════════════════════════
# ADDENDUM — FILE INVENTORY
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
slide_header(sl, "Complete File Inventory", "172 files · 5.1 MB · GitHub + Google Drive", accent=LGRAY)

groups = [
    ("Coq proofs", "35 .v files", CYAN,   [
        "RamenCornerConsensusV1191/2.v",
        "CubieTrustCompilerV2_0.v",
        "CubieTrustCompilerV2_0_PerPredicate.v",
        "TheoremOmega{4,5,6,7,8}.v",
        "CubieAttentionGeometry_v7.v",
        "CubieSiteTopology_v4.v",
        "+ 29 more",
    ]),
    ("Lean 4 proofs", "34 .lean files", PURPLE, [
        "Mirrors coq/ module-for-module",
        "RamenCornerConsensusV1192.lean",
        "CubieTrustCompilerV2_0.lean",
        "TheoremOmega{4,6,7,8}.lean",
        "CubieAttentionGeometry_v7.lean",
        "+ 29 more",
    ]),
    ("Verus specs", "17 .rs files", AMBER, [
        "cubie_runtime_spec.rs",
        "cubie_per_predicate_spec.rs",
        "cubie_geometry_spec.rs",
        "cubie_execution_lease_spec.rs",
        "cubie_attention_geometry_spec.rs",
        "+ 12 more",
    ]),
    ("Bare-metal Rust", "9 .rs + config", GREEN, [
        "sha256.rs  (FIPS 180-4)",
        "hmac.rs    (FIPS 198-1)",
        "mmio.rs    (MMIO + mock)",
        "nvlink.rs  (waiter detect)",
        "pcie.rs    (cache + BW)",
        "admit.rs   (C ABI gate)",
        "types.rs   cycle_counter.rs",
    ]),
    ("Tests & benches", "3 files", CYAN, [
        "tests/admit.rs  (21 tests)",
        "benches/admit_bench.rs",
        "src/speedtest.rs",
        "(Criterion + RDTSC)",
    ]),
    ("Roadmap & data", "6 files", LGRAY, [
        "master_theorem_table.csv (733r)",
        "cubie_full_proof_stack.jsonl",
        "comprehensive_proof_inventory.csv",
        "crosswalk_203.csv",
        "cubie_theorem_roadmap_full.csv",
        "predicate_scaffold_128.txt",
    ]),
    ("Tools (Python)", "14 .py", AMBER, [
        "load_jsonl_to_excel.py",
        "gap_analysis_to_excel.py",
        "append_whitepaper_gaps.py",
        "build_comprehensive_table.py",
        "scan_for_unsound_tokens.py",
        "+ 9 more",
    ]),
    ("Scripts & docs", "4 .ps1 + docs", GREEN, [
        "speedtest.ps1",
        "run_verus{,_debug,_full}.ps1",
        "README.md  Makefile",
        "docs/ AXIOM_AUDIT.md",
        "reports/ coqchk logs",
        "manifest.json (SHA-256)",
    ]),
]
for i, (group, count, col, items) in enumerate(groups):
    x = 0.4 + (i % 4) * 3.25
    y = 1.1  + (i // 4) * 3.2
    add_rect(sl, x, y, 3.0, 3.0, fill=CARD2)
    hline(sl, x, y, 3.0, color=col)
    add_text(sl, group, x+0.12, y+0.08, 2.75, 0.38, size=11, bold=True, color=col)
    add_text(sl, count, x+0.12, y+0.48, 2.75, 0.3,  size=9,  color=LGRAY)
    for j, item in enumerate(items):
        add_text(sl, "· " + item, x+0.12, y+0.82 + j * 0.31, 2.75, 0.29, size=8, color=WHITE)

# ═══════════════════════════════════════════════════════════════════════════
# CLOSING SLIDE
# ═══════════════════════════════════════════════════════════════════════════
sl = prs.slides.add_slide(BLANK)
bg(sl)
add_rect(sl, 0, 0, 0.12, 7.5, fill=CYAN)
add_rect(sl, 0.4, 3.2, 12.5, 0.06, fill=CYAN)

add_text(sl, "THE CUBIE TRUST COMPILER",   0.5, 1.4,  12, 0.6, size=13,  bold=True,  color=CYAN, align=PP_ALIGN.CENTER)
add_text(sl, "Formally Verified.\nHardware Backed.\nProduction Ready.",
         0.5, 2.1, 12, 1.8, size=38, bold=True, color=WHITE, align=PP_ALIGN.CENTER)
add_text(sl, "733 theorems · Coq + Lean 4 + Verus · 730 ns on silicon · 1.37M admits/second",
         0.5, 4.1, 12, 0.5, size=13, color=LGRAY, align=PP_ALIGN.CENTER)
add_text(sl, "github.com/iamdatanick/cubie-math  ·  v1.1-bare-metal",
         0.5, 4.75, 12, 0.4, size=11, color=CYAN, align=PP_ALIGN.CENTER)

add_rect(sl, 0.4, 5.5, 12.5, 0.03, fill=DIVIDER)
add_text(sl, "CONFIDENTIAL  ·  Centillion AI  ·  2026",
         0.5, 5.7, 12, 0.4, size=9, color=LGRAY, align=PP_ALIGN.CENTER)

# ═══════════════════════════════════════════════════════════════════════════
# SAVE
# ═══════════════════════════════════════════════════════════════════════════
import os
out = os.path.join(os.path.dirname(os.path.dirname(__file__)),
                   "cubie_trust_compiler_presentation.pptx")
prs.save(out)
print(f"Saved → {out}")
print(f"Slides: {len(prs.slides)}")