System Architecture
Production-grade Storyworld Production Studio. FastAPI backend on Railway · Next.js frontend on Vercel · 25-agent CharacterOS orchestrated by AgentRuntime singleton.
Production Pipeline
Every storyworld moves through this 7-step pipeline. Steps are deterministic and ordered — shortcutting any step is explicitly prevented by the runtime contract.
Agent Network — 25 Agents, 5 Families
AgentRuntime is a singleton (get_agent_runtime_singleton()). Agents are lazy-instantiated on first use. Never construct agents per-request.
Scene Generation Orchestration
ContinuityAgent runs exactly 3 times — this is intentional. Pass 3 is warn-only and never triggers a revision. Do not collapse these calls.
Production Data Flow
All production backends are primary — no silent local fallbacks. IntegratedSecurityMiddleware handles CSRF, rate limiting, and XSS sanitization on every request.
Technology Stack
Frontend on Vercel, backend on Railway. PostgreSQL is the only database across all environments. Local development uses Docker for PostgreSQL + Redis.
Runtime Mode System
Mode controls how CharacterOS agents scope retrieval and frame responses. Legacy canon_locked=true maps to CANON, false maps to CANON+INFER.
Source material only — refuse out-of-scope queries
Filter by canon_scope.chapters + character_ids. Characters refuse spoilers.
Canon-bounded with safe inference, marks uncertainty
Broad retrieval, no chapter filter. Characters signal when inferring beyond known facts.
Creative expansion, personality-locked not plot-locked
Unrestricted retrieval. Characters stay true to personality but can explore alternate outcomes.
Scene generation mode for creative orchestration
Character interaction history retrieval. All agents active. Used by WriterAgent.