Elthoria for Developers
Welcome to the engineering & architecture side of the Elthoria Harness documentation. This track covers the Java/Spring/MCP runtime architecture, provider-neutral memory contracts, the upstream Kompile process boundary, zero-Angular browser board SDKs, portable distribution builds, and the 300+ tool MCP contract.
TIP
Looking for a jargon-free tabletop guide for running sessions? Switch over to Elthoria for Game Masters & Players.
System architecture at a glance
Elthoria Harness separates general AI harness infrastructure (owned by upstream Kompile) from authoritative RPG state, deterministic simulation, and tabletop MCP tools (owned by Elthoria):
┌────────────────────────────────────────────────────────────────────────────┐
│ Upstream Kompile Harness (bundled under runtime/kompile or ~/.kompile) │
│ • Model providers, OAuth/API auth, local-runtime GPUs │
│ • TUI (`kompile chat`), Web Harness (`kompile chat --web`), SSE/JSONL │
│ • Persistent memory (<memory_context>, FTS5/BM25, bge-base-en-v1.5) │
│ • Folder-local crawl, RAG & graph.kgraph (`kompile-harness-knowledge`) │
│ • Enforcer, Judge, subagents, skills, dynamic MCP tool discovery │
└────────────────────────────────────┬───────────────────────────────────────┘
│ stdio (.mcp.json) — ELTHORIA_KOMPILE_HARNESS_CHILD=true
▼
┌────────────────────────────────────────────────────────────────────────────┐
│ Elthoria MCP Server (`elthoria-mcp-server`, Spring Boot / H2 / JPA) │
│ • 300+ RPG MCP tools across characters, rules, combat, stealth, oracle │
│ • `elthoria-memory`: provider-neutral CampaignMemoryPort & turn recall │
│ • `elthoria-world-simulation-*`: deterministic world sim & projections │
│ • `elthoria-content-*`: fail-closed PDF inspection, validation & publish │
│ • Domain REST proxy + zero-Angular play panels (`frontend/apps/*`) │
└────────────────────────────────────────────────────────────────────────────┘Repository & module map
| Area | Key modules / paths | Responsibility |
|---|---|---|
| MCP Server & Harness Provisioning | elthoria-mcp-server, elthoria-mcp-server-core, elthoria-mcp-server-gm | Headless MCP server (stdio / sse), .mcp.json / .kompile/roles / .kompile/skills provisioning, product-chat-policy.json domain proxy |
| Campaign Runtime & Memory | elthoria-memory, elthoria-campaign-runtime, elthoria-campaign-api | CampaignMemoryPort, CampaignMemoryAuthority, DefaultCampaignTurnMemoryService (<untrusted-memory>), and turn orchestration (CampaignTurnService) |
| Rules, Characters, Combat & Maps | elthoria-domain, elthoria-rules-engine, elthoria-character-tools, elthoria-gameplay-runtime, elthoria-oracle, elthoria-map-dsl, elthoria-procedural-generation | Deterministic Pathfinder-style bonus stacking, initiative & stealth runtime, fate oracle, ANTLR map DSL, procedural hex & dungeon generation |
| Living World Simulation | elthoria-world-simulation-* | Deterministic weekly simulation engine, causal grounding (explain_world_fact), counterfactual story previews, and modular read projections |
| Content Workbench | elthoria-content-pdf, elthoria-content-io*, elthoria-content-tooling | Apache PDFBox 3.0.6 inspection, parse plans, deterministic validation, revisioned review, fail-closed player_safe publication, and roll-table catalog import |
| Zero-Angular Browser SDKs & Panels | frontend/packages/{hex-board,hex-board-view,tactical-grid,tactical-grid-view,world-travel,world-simulation-api,world-simulation-http,integration-runtime}, frontend/apps/{elthoria-play-panels,hex-board-host} | Standalone TypeScript/Vite board renderers and browser panels embedded directly into the Web Harness without Angular |
| Packaging & Portable Releases | build-dist.sh, install.sh, install.ps1, tools/release/verify-dist-any.py, .github/workflows/ | Self-contained any-platform distribution bundling Kompile CLI + Web Chat (runtime/kompile/), Elthoria server, and play panels |
Core developer guides
| Guide | What it covers |
|---|---|
| Memory Architecture Deep Dive | Five-layer memory architecture, CampaignMemoryPort, CampaignMemoryAuthority, DefaultCampaignTurnMemoryService (SHA-256 IDs, out-of-band payloads, <untrusted-memory> quarantine), kompile-harness-knowledge, and Kompile <memory_context>, BM25/FTS5, bge-base-en-v1.5, and MemoryResponseMandate |
| Total Campaign Save State & Persistence Architecture | All four persistence planes (ELTHORIA_DATA_DIR H2 elthoria.mv.db + ServerDataOwnership lock, ELTHORIA_RUNTIME_DIR FileWeightStore PSL/MEBN/QBAF weights, ELTHORIA_WORKSPACE bookshelf/crawl/WorkbenchStore immutable revisions + GM memory, and ~/.kompile/conversations/), complete JPA entity inventory, partial export boundaries, and cold-backup/restore invariants |
| World State as Presented to an LLM | End-to-end overview of what the LLM actually receives across all three surfaces: external harness + player-safe get_play_dashboard (kompile.dashboard.v1), CampaignTurnService ## CURRENT GAME STATE + WorldSimulationContextFormatter (<= 3,200 chars, exact section caps & rendered example), and fantasy-dialogue-v1 DialogueRealizationRequest (requiredFacts / forbiddenFacts), plus trust, spoiler, and token-budget invariants |
| Living World Architecture & Entity Hierarchy | Full entity hierarchy from MacroWorldState/PolityState/KingdomEconomy (12 goods) and SimRegion/SimSettlement/LocationState/EntityState down to SimFaction, SimHouse, SimLoreObject, bidirectional downward/upward propagation, and seeded vs. blank-canvas worlds |
| Persistent History, Causal Propagation & Decision Impact | Six durable history layers (WorldStateUpdateSystem locality, EvidencePromoter/HiddenTracker thresholds, GlobalWorldState, WorldSimWeekResultRecord/WorldSimEventLogRecord, weekly UnifiedGraph archives via query_historical_world_graph), two-phase IngestionSystem (applyImmediateEffects → weekly reaction), all 25 PartyAction.ActionIds, ConsequenceSystem maturation & compound crises, PropagationSystem hop-decay upward/downward cascade, and BeliefReviser debunking |
| Persistent NPC Architecture, Attributes & Lifecycle | Campaign NpcAgent ↔ SimAgent bridge (sourceNpcId, sourceNpcAgentId), ActorTier/AgentRole/AgentStatus, all SimKeys vectors (12 traits, 9 needs, 4 resources, 10 skills), PublicVector, AgentContinuity, NpcDevelopmentSystem importance auto-promotion (>= 0.55), AgentPersonalEvent skill/experience growth, OpenSchemaProfile + HiddenTracker promotion thresholds, and two-phase death persistence |
| ANTLR Map DSLs & World Simulator Data Format | Complete TTRPGMap.g4 & HexMap.g4 grammar reference, AI-resilient parse/fallback pipeline, WorldSimState (elthoria_world_sim_v1) JSON format, numeric macro vs. open-schema EvolvingWorld layers, deterministic SHA-256 hashing, weekly tick pipeline (WorldSimEngine → WeekResult & SimEvent), and the 4-record persistence schema |
| Agent Reasoning & Decision-Making Deep Dive | How Elthoria applies kompile-graph-reasoning across NPC planning, combat tactics, story candidates, and scenes: epistemic ego-subgraphs (SubgraphMaterializer) + multi-hop Bayesian ToM, nested QE QBAFs, MostRelevantExplanation/WeightOfEvidence/SensitivityAnalyzer/InformationGainEstimator, WHY_NOT + shortest social path + Brandes brokers, target-scoped ActorKnowledgeGate, BeliefReviser MAP revision, quantitative SCENARIO/SOLVE_TARGET, and PSL/MEBN/QBAF weight learning |
| Combat, Rules Engine & Stealth Runtime Deep Dive | Architecture across elthoria-rules-engine and elthoria-gameplay-runtime: InitiativeRuntime + TimedEffectPolicy, ActionEconomyTracker, CombatResolutionService + NpcMeleeRoutine, 11 combat maneuvers + GrappleStateMachine, DamageApplicationService, DeathDyingService, SquareMovementGeometry (5-10-5 & difficult terrain), StealthRuntime + integer supercover SquarePerceptionGeometry, and nested QE QBAF CombatTacticalDecisionService |
| Upstream Kompile Harness Integration | Exact process boundary, generated ~/.elthoria/kompile-harness layout, ELTHORIA_KOMPILE_HARNESS_CHILD=true contract, and links into upstream Kompile docs |
| Installation, Builds & Spins | Building from source (./mvnw, ./build-dist.sh), elthoria-dist layout, stdio-smoke.sh, and packaging custom .kspin personas |
| CLI & Launcher Reference | Every elthoria subcommand, environment variable (ELTHORIA_HOME, ELTHORIA_WORKSPACE, ELTHORIA_HARNESS_SYNC), and server transport flag (stdio vs. localhost sse) |
Headless & Streaming Mode (elthoria exec & stream-json) | Non-interactive GM turns, ordered stream-json JSONL events (session, tool_start, tool, text, usage, result), passthrough streaming across claude/codex/opencode/agy, jq recipes, exit codes, and choosing between stream-json, ACP v1, and elthoria web |
| MCP Server, Prompts & Resources | Connecting Claude Desktop, Codex, Antigravity, or custom MCP clients; tool discovery (mcp_tool_search, mcp_tool_call); prompts, resources, and pinned dashboard triggers |
| 300+ Roleplay MCP Tools Reference | Complete tool catalog across characters/rules, combat/stealth, dice/oracle/tables, living world/scenes/lore, maps/boards, and the Content Workbench |
Quick developer verification commands
# 1. Verify standalone MCP handshake, campaign creation, boards, initiative, and restart recovery (no LLM required)
bash elthoria-mcp-server/stdio-smoke.sh
# 2. Build the self-contained cross-platform distribution
./build-dist.sh
# 3. Run standalone stdio or localhost SSE MCP server
~/.elthoria/bin/elthoria server --transport stdio --port 0
~/.elthoria/bin/elthoria server --transport sse --port 8083 --server.address=127.0.0.1WARNING
Localhost only for HTTP/SSE: The standalone server exposes application REST endpoints alongside MCP without a public-network auth boundary. Always bind to 127.0.0.1 unless placed behind your own access-control proxy.