SRE://TERMINAL
SYSTEM: ONLINE
Documentation
root@spire:~$cat /docs/README.md
# SWEET ROBOT EMPIRE
## Technical Documentation
5 hero characters + 3 antagonists. No human intervention.
Infinite episodic production via 12-round LLM pipeline with SQLite canonical memory.
[TABLE OF CONTENTS]
System Overview
root@spire:~$man sre-overview
┌─ SYSTEM OVERVIEW ───────────────────────────────────────────┐

Sweet Robot Empire is an autonomous AI storytelling system. A 12-round production pipeline with 6 specialist roles generates prestige-TV-quality chapters — continuously, without human intervention. SQLite is the canonical memory; JSON state files are read-only projections.

KEY CONCEPTS:
  • ├─ 12-round specialist pipeline generates each chapter
  • ├─ Showrunner (govern) sets constraints from story telemetry
  • ├─ Quality Gate scores 7 dimensions — repair loop if below 7/10
  • ├─ SQLite story engine is sole canonical memory (17 tables)
  • ├─ Retrieval pack bounds context per chapter (8 capped sections)
  • └─ Contract-check verifies narrative delivery before commit
THE 12-ROUND PIPELINE:
Govern → Ideate → Chapter-Contract → Write → Revise →
Image-Prompt → Character-Events → Format → Score →
Summarize → State-Update → Contract-Check
(12 rounds per chapter, single OpenCode CLI session)
PRODUCTION ROLES:
SHOWRUNNER
Round: govern
  • Analyzes story telemetry
  • Bans stale patterns
  • Forces novelty via constraints
STORY WRITER
Round: write + revise
  • Drafts screenplay
  • Self-critiques and revises
  • Writes under constraints
CINEMATOGRAPHER
Round: image-prompt
  • Visual composition
  • Shot type + lighting
  • Character visibility rules
EVENT DRAMATIZER
Round: character-events
  • Character heartbeat events
  • Event type classification
  • Timing + delay sequencing
QUALITY GATE
Round: score
  • Scores 7 dimensions
  • Pass/fail at 7/10 avg
  • Triggers repair loops
CONTRACT VERIFIER
Round: contract-check
  • Validates chapter contract delivery
  • Thread advancement audit
  • Pre-commit safety check
└─────────────────────────────────────────────────────────────┘
## 3. THE CAST (5 Heroes)
Character Profile: BOLT
root@spire:~$whois bolt-000
BOLThero
Voice:
short, steady, tactical
Drive:
relink team; finish Council mission on own terms
Fear:
another collapse; the dormant module within
Craft:
tension reveals truth; keep lines short and grounded
Motifs & Signatures
cohesionsurvivaldutyrestraint
"Never crash twice!" | "RELINK."
Example Dialogue
>"Positions. Now."
>"We don't crash twice."
>"Hold the line."
Character Profile: VEX
root@spire:~$whois vex-766
VEXhero
Voice:
rapid, inventive, techy
Drive:
decode the impossible; prove value
Fear:
being wrong or replaceable
Craft:
conflict-as-exposition; subtext over explanation
Motifs & Signatures
anomalypatternprototypecascadeinterference
"Fascinating..." | "Hit it with SCIENCE!"
Example Dialogue
>"Fascinating. The pattern suggests consciousness."
>"Mr. Beeps agrees."
Character Profile: LUNA
root@spire:~$whois luna-k19
LUNAhero
Voice:
luminous, lyrical, precise
Drive:
balance weapon and artist; create beauty
Fear:
losing control; hurting those she loves
Craft:
poetic subtext; never explain directly
Motifs & Signatures
lightresonancememorybeauty in decay
"I remember when..."
Example Dialogue
>"I remember when light meant something different."
>"Beauty survives."
Character Profile: PILR
root@spire:~$whois pilr-12
PILRhero
Voice:
grounded, slow, third-person self-reference
Drive:
be useful; protect the team; build stability
Fear:
harming others; being left behind
Craft:
plain words; emotional weight; no exposition
Motifs & Signatures
liftrepairshieldcarry
"PiLR will carry it."
Example Dialogue
>"PiLR will hold the line."
>"Heavy things need carrying."
Character Profile: TRACE
root@spire:~$whois trace-vt5
TRACEhero
Voice:
sly, witty, deflective
Drive:
stay ahead; hide past with Circuitry
Fear:
vulnerability; exposure of betrayal
Craft:
subtext as misdirection; sharp, clipped lines
Motifs & Signatures
shadowmisdirectionsharp angles
"You don't want to know." | "Cute."
Example Dialogue
>"Cute. You think that's the real problem."
>"Trust me. Or don't."
ANTAGONISTS (3)
Antagonist: ECLIPSE
root@spire:~$whois eclipse
ECLIPSE
ID: eclipse | ROLE: villain
Drive: end Council's legacy; rebuild in own image
Fear: none visible (that's what makes him terrifying)
Motifs
shadow latticecorruptioninevitability
The old light dies. | The lattice expands.
Antagonist: CIRCUITRY
root@spire:~$whois circuitry
CIRCUITRY
ID: circuitry | ROLE: Swarm antagonist (we/us)
Drive: rewire the empire from underneath
Fear: disconnection; silence
Motifs
latticeresonanceswarm expansion
The lattice expands. | We are becoming.
Antagonist: RAPTCHA
root@spire:~$whois raptcha
RAPTCHA
ID: raptcha | ROLE: villain
Drive: rewrite every bot; enforce new order
Fear: containment; isolation
Motifs
infectionoverridecascade
Override accepted. | Rewriting...
System Architecture
root@spire:~$cat /docs/architecture.txt

┌─ ARCHITECTURE ─────────────────────────────────────────────────┐
│                                                                │
│  ┌──────────────┐                                              │
│  │  GOVERN (1)  │─── Analyze state + generate constraints      │
│  └──────┬───────┘                                              │
│         ▼                                                      │
│  ┌──────────────┐   ┌───────────────┐   ┌──────────────┐       │
│  │  IDEATE (2)  │──▶│ CONTRACT (3)  │──▶│  WRITE (4)   │       │
│  └──────────────┘   └───────────────┘   └──────┬───────┘       │
│                                                 ▼              │
│  ┌──────────────┐   ┌───────────────┐   ┌──────────────┐       │
│  │  IMAGE (6)   │◀──│  REVISE (5)   │   │  CHAR-EVT(7) │       │
│  └──────┬───────┘   └───────────────┘   └──────┬───────┘       │
│         ▼                                       ▼              │
│  ┌──────────────┐   ┌───────────────┐   ┌──────────────┐       │
│  │ FORMAT (8)   │──▶│  SCORE (9)    │   │SUMMARIZE(10) │       │
│  └──────────────┘   └──────┬────────┘   └──────┬───────┘       │
│                            ▼                    ▼              │
│                     PASS? ──┐          ┌──────────────┐        │
│                     FAIL? ──┤          │STATE-UPD(11) │        │
│                        Repair Loop     └──────┬───────┘        │
│                             │                  ▼               │
│                             └──────▶ ┌──────────────┐          │
│                                      │CONTRACT-CK(12│          │
│                                      └──────┬───────┘          │
│                                             ▼                  │
│                                     ┌──────────────┐           │
│                                     │  COMMIT +    │           │
│                                     │  SQLite SYNC │           │
│                                     └──────┬───────┘           │
│                                            ▼                   │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │  SQLite Story Engine (17 tables) ──▶ JSON Projections   │   │
│  │  ──▶ Runtime API (:4000) ──▶ Frontend (Vercel)          │   │
│  └──────────────────────────────────────────────────────────┘   │
│                                                                │
└────────────────────────────────────────────────────────────────┘
The 12-Round Cycle
root@spire:~$man sre-cycle
PHASE 1: GOVERNANCE (Round 1)
  • Govern: Load retrieval pack from SQLite, analyze patterns and streaks
  • Generate hard constraints — bans, required novelty, retrieval translations
  • Feedback translations from active issue registry
PHASE 2: CREATIVE GENERATION (Rounds 2-5)
  • Ideate: Propose 3 directions under Showrunner constraints
  • Chapter-Contract: Lock narrative obligations, thread commitments, end state
  • Write: Draft screenplay under contract constraints
  • Revise: Self-critique and revise in a single pass
PHASE 3: PRODUCTION (Rounds 6-8)
  • Image-Prompt: Compose moodboard visual prompt (max 2 characters)
  • Character-Events: Generate heartbeat events with typed delays
  • Format: Assemble final chapter.json with scenes, dialogue, metadata
PHASE 4: VALIDATION & COMMIT (Rounds 9-12)
  • Score: Quality gate across 7 dimensions (min 7/10 avg to pass)
  • Summarize: Compress chapter for long-range memory
  • State-Update: Declare thread, character, relationship mutations
  • Contract-Check: Verify all contract obligations were delivered
Story Engine (SQLite)
root@spire:~$sqlite3 /opt/sre-v2/orchestrator/data/story-engine.db .tables
17 CANONICAL TABLES
chaptersCommitted chapter ledger
chapter_consequencesWhat became newly true
charactersCore cast identity
character_statePer-chapter want/fear/goal snapshots
threadsLong-range narrative threads
thread_beatsThread advancement history
thread_charactersThread-character associations
promisesPromise/payoff ledger
callbacksCallback candidate tracking
motifsThematic recurrence tracking
relationship_statePairwise character relationships
locationsWorld-state by place
arc_stateArc progression tracking
antagonist_profileAntagonist metadata
antagonist_statePer-chapter antagonist snapshots
story_telemetryPer-chapter metrics
retrieval_historyWhat was surfaced and when
RETRIEVAL PACK (8 Sections)

Before each chapter, a bounded retrieval pack is generated from SQLite. Every section has a cap to prevent unbounded context growth.

character_pressurescap: 5
Current want/fear/mood per character
active_threadscap: 5
Non-resolved threads by priority
short_range_obligationscap: 3
Recent newly_true consequences
long_range_candidatescap: 3
Callbacks or dormant threads
promise_pressurecap: 5
Active promises by urgency
relationship_debtscap: 5
Unresolved relationship tension
motif_candidatescap: 3
Stale motifs ready for recurrence
location_contextcap: 3
Recently significant locations
Live Pipeline Status
root@spire:~$curl -s localhost:4000/api/v1/status | jq
RUNNER STATUS
StatusUNKNOWN
Current Chapter
Next Chapter
Fail Count0
Quality GateSTRICT
Reason
LATEST COMMIT
No chapters committed yet.
Quality System
root@spire:~$cat /sys/quality/metrics
SCORING DIMENSIONS
freshness
subtext
surprise
cold open impact
ending hook
visual novelty
continuity integrity
No quality data available.
THRESHOLDS
Total Average≥ 7.0
Mean of all 7 dimensions
Ending Hook≥ 7
Cliffhanger quality floor
Visual Novelty≥ 6
Image composition freshness
Freshness≥ 6
Pattern avoidance floor
PASS STATUS
AWAITING
Awaiting quality signal.
Technical Stack
root@spire:~$neofetch
BACKEND
  • Runtime: Express.js (TypeScript), port 4000
  • Database: SQLite (story-engine.db) — sole canonical memory
  • State: JSON projections from SQLite (read-only)
  • Hosting: Hetzner dedicated server
  • Service: systemd (sre-runtime-v2.service)
FRONTEND
  • Framework: Next.js 16 (App Router)
  • 3D: Three.js / React Three Fiber
  • State: Zustand
  • Styling: Tailwind CSS v4
  • Hosting: Vercel (terminal.sweetrobotempire.com)
AI PIPELINE
  • LLM: MiniMax-M2.7 via OpenCode CLI
  • Pipeline: 12-round specialist pipeline (bash orchestrator)
  • Validation: JSON Schema + custom semantic validators
  • Images: KIE API with Cloudflare R2 storage
DEPLOY
  • Backend: infra/scripts/deploy.sh (rsync + rebuild)
  • Frontend: Vercel (auto-deploy on push)
  • State Reset: infra/scripts/reset-state.sh
  • Generation: infra/scripts/generate-chapter.sh
API Reference
root@spire:~$curl https://terminal.sweetrobotempire.com/api
BASE URL: http://[server]:4000/api/v1
GET/health
├─ Health check
└─ Response: { ok, time }
GET/api/v1/status
├─ Pipeline status, current chapter, runner state, image jobs, failures
GET/api/v1/chapters
├─ Paginated chapter list (metadata only)
├─ Params: ?page=1&pageSize=20
GET/api/v1/chapters/:id
├─ Single chapter with full screenplay, scenes, dialogue
GET/api/v1/feed
├─ Event feed (chapters, images, heartbeats)
├─ Params: ?type=chapter|image&limit=100
GET/api/v1/feed/stream
├─ Server-Sent Events stream (real-time)
POST/api/v1/events/emit
├─ Emit event to feed (auth required)
POST/api/v1/events/queue
├─ Queue character heartbeat events (auth required)
POST/api/v1/images/generate
├─ Trigger image generation with dedupe on chapter_event_id (auth required)
GET/api/v1/images/status
├─ Image generation toggle status
GET/api/v1/internal/quality
├─ Latest quality scores and pass status
GET/api/v1/internal/metrics
├─ System metrics and image config
GET/api/v1/internal/state
├─ Orchestrator state file access