RUNTIME_GENERATIVE_LAYER.md

systems/RUNTIME_GENERATIVE_LAYER.md

Runtime Generative Layer — Local-LLM Life Inside Deterministic Scaffolding

0. Thesis (the continuo lesson, ported to runtime)

Josh's frame: a local LLM is dumb and current-tech-limited. The studio already proved the fix at build time — the /dev/continuo lesson (ROADMAP §8, docs/START_HERE.md wiring doctrine): a dumb 14B model hit 0.965 truth-recall not by being smart but by being wrapped in deterministic code that encoded every failure/reward pattern and gave it perfect-precision recall over a bounded, structured truth store. Continuo did this for untrusted audio extraction; we do it for canon.

The build-time version already exists in this repo: harness/canon_graph.json (3,118 nodes, 11,974 edges) + the planned harness/recall.py give Opus perfect-precision recall so it never re-derives canon (docs/CANON_INTEGRITY_ARCHITECTURE.md §B, §D). This spec ports that exact architecture to RUNTIME. The local model that voices a boss, an animal, or an NPC at 60fps is the dumb 14B. The canon graph is the bounded truth store. A runtime context-pack is perfect-precision recall. A post-generation validator is the deterministic gate. Authored fallback is the reward-pattern floor. The model never touches lore it could get wrong; it only ever performs surface texture over facts the deterministic layer already proved.

The one governing move, stated once and specialized everywhere below. Josh's hard constraint restated as the architecture's first law:

The world is a deterministic simulation. The local LLM is a strategy oracle the sim consults on a slow tick — never a mechanic, never per-frame, never on the render thread, never with a write path into sim state. The LLM never emits actions; it emits a small, schema-constrained, canon-validated STRATEGY TOKEN — a bundle of {goal, disposition, plan-selector, a few knobs, a bounded line} — and a deterministic controller (state machine / GOAP / utility AI / behavior tree) executes that token at 60 Hz. The token is a latent variable that conditions deterministic policy; it is validated against the canon graph before it can bind; on validation failure or a latency miss, an authored fallback token binds instead. The game is always running a valid token. The LLM only ever changes *which* valid token, on a slow tick.

This is the strongest idea in the 2025–26 hierarchical-control literature (an LLM emits a compact latent/symbolic plan; a fast deterministic executor runs it — SayCan / Voyager-style skill libraries, LLM-strategist-over-symbolic-executor) hardened for a shipping console frame budget. The entire taxonomy in §1 is that one idea specialized per entity class: *what is the strategy token for this entity, how often is it refreshed, what deterministic system consumes it, and how does the player manipulate it.*

Design rule inherited verbatim from build_canon_graph.py: never trust the model with a fact it could hallucinate; never drop a constraint silently; on any violation, fall back, log, and stay shippable. The runtime layer fails the way the harness fails — loudly to the log, invisibly to the player.

The cardinal rule from CLAUDE.md still binds at runtime: the local LLM does not invent canon. It has no authority over any fact in §1's deterministic column. It reallocates and re-postures *existing* canon entities within *existing* rules; anything it "wants" to create routes to [DECISION NEEDED - JOSH], never self-canonizes.

---

1. The generative/deterministic split (the load-bearing table)

The single most important decision. Anything the model could get *wrong in a way a player notices* is deterministic. The model only gets what is safe to vary and cheap to be wrong about — and even those pass the §4 validator.

1.0 — The distinction stated once

DETERMINISTIC (code owns, 60 Hz, sim-authoritative)STRATEGIC (LLM, slow tick, advisory-only)
Question it answers*What happens this frame?**What is this entity trying to do, and why?*
Ownsphysics, hitboxes, i-frames, damage, pathfinding, GOAP/utility/BT execution, RNG (Sigma-bounded), state machines, spawn/cooldown/timer clocks, all worldstate writesgoals, dispositions, plans, faction intent, dialogue surface, tactical *read* of the player, adaptation of *emphasis*
Failure if wrongbroken gamea slightly-off intent, caught by validation → authored fallback; player sees nothing
Cadenceevery frame0.2 Hz – 0.003 Hz depending on class (see per-class ticks)
Write path to simyes, it *is* the simnone — the token is a read-only input leaf; enforced at the API boundary (F10)

The rule that assigns any capability to a column: **if getting it wrong changes what is *true* in the world or breaks a rule, it is deterministic; if getting it wrong only changes *how* a true thing is pursued or said, it is strategic — and the validator still checks it.**

1.1 — DETERMINISTIC (code owns it; the model never emits it)

DomainOwned byWhy it can never be generative
Damage numbers, hit/crit resolution, hitboxes, i-framesCombat simA hallucinated number is a broken game
Boss phase transitions, phase HP gates, enrage timers, add-spawnsT0_Boss_Encounter_Registry (75 staged rows) → encounter state machinePhase logic is the fight; §17 hard-line-bound (Ch 38/52/57 boss protocol)
Attack selection / AI target priority / aggroBehavior tree + weighted RNGDeterminism-where-needed: fights must be learnable + speedrun-stable
Loot / dropsT0_RNG_Drop_Table (seeded PRNG)Economy integrity; dupe/exploit surface
Ability effects, cooldowns, vril costsT0_Ability_Tree_Registry (185)Balance canon
Fauna spawn rates, bonding windows, tameability, familiar slotsT0_Creature_Roster (spawn_rate, chapter_bonding_window, trade_8_tameable)Progression + familiar-slot canon (22 slots)
Companion combat AI, cooldowns, relationship state machineUtility AI + T0_Ability_Tree_RegistryPer-frame mechanics — the hard line
Faction spawning, patrols, encounters (the three declared systems only)Encounter system (Aggro Magnet / Rift Instability / Antagonist Hunter Triggers)CVD Pillar §167-169: a random encounter outside the three declared systems is a pillar violation
The environmental-boss protocol (Perception → Vril-management → Restraint → Purgation) + vril_density difficulty dialT1_Combat_System_Spec §1.3/§6.2, DIFFICULTY_SYSTEM.mdL1-playable win-condition mechanic; multi-channel readability is a non-negotiable L1 requirement
Quest state, flags, worldstate, integrity band, path lock-inT0_Worldstate_Variables (25), T0_Quest_Definition_RegistrySave integrity; the 5→3 integrity-band collapse at Ch 65; path lock forbids late flip
Any hard-line-bound *content*T0_Hard_Lines (120)Culturally protected combat, §17.1 depiction, Grand-Sage no-leak (§17.5)
Cultural ritual/language/mythology depictionAuthored, primary-sourced (HL_0002)HL_0002: every cultural claim traces to primary source — the model cannot source anything
Character canonical facts (name, relations, era, arc); operative sector/awareness tierT0_Character_Index (118), T0_Antagonist_Network_Registry (62)Continuity; the do-not-invent rule
Voice identity / TTS routingT0_Voice_Registry (persona substrate + ElevenLabs refs)§17.12 gender-lock; §17.5 no pre-reveal voice leak
Whether a strategy token executes, and its tick-by-tick effectsThe tick/encounter engine (§3, §7-societies)This is per-frame-adjacent mechanics — Josh's hard line

1.2 — GENERATIVE (local LLM STRATEGIC layer, always §4-validated, always fallback-guarded)

OutputEntity classWhat variesFixed input (from the recall pack)
Boss taunts / combat barksBossPhrasing, timing, escalation tonePersona voice card; current phase; player's last action class; hard-line filter
Adaptive tactical hints (diegetic — a taunt that *reveals* the counter)BossWhich weakness to needle, how obliquelyThe deterministic AI's *own* next-move intent + known player-death cause; never invents a mechanic
Fauna behavior flavor (the *read* on deterministic behavior)CreatureIdle/alert/threat/bond vocalizations + descriptive beatsfolklore_behavior_substrate + folklore_attribution_source; the behavior-tree state the sim already chose
NPC ambient dialogue (barks, crowd chatter, vendor lines)Ambient NPCLine content within topic + moodPersona card; region; worldstate facts flagged safe-to-reference; integrity band
NPC reactions + disposition delta (to deeds, integrity, world events)Named NPCAcknowledgement phrasing; ±-clamped stance shiftWorldstate delta the code hands it; faction standing; awareness tier
Persona-consistent free responses (where a talk system lets the player probe)Named NPCAnswer surfacePersona card + a whitelist of facts this NPC is allowed to know; else → deflect
Companion combat-disposition bias + banter + relationship deltaPartner/familiarA bounded utility-weight bias (protective/aggressive/cautious); banter phrasingPersona; relationship state; legal combat-disposition set
Faction intent + plan-selector + negotiation/propaganda stanceSociety/factionWhich legal campaign posture; ordering over an authored action librarySector identity + awareness tier + legal-goal menu + resources + territory slice + player_strategy_vector
Atmosphere bias + environmental-boss readEnvironmentScene mood bias (clamped); diegetic read of the deterministic protocol stateRegion substrate; arena legal atmosphere range; env-boss protocol fields

The rule that separates the columns: the model performs; it never adjudicates. If getting it wrong changes what is *true* in the world or breaks a rule, it is in 1.1. If getting it wrong only changes *how a true thing is said or pursued* — and the sim still validates and deterministically executes that choice — it is in 1.2, and §4 still checks it.

---

A. Entity taxonomy — the six classes and their strategy tokens

Six entity classes. For each: the strategic tick (how often the LLM is consulted), the token the LLM emits, the deterministic executor that consumes it, and the manipulation mechanic (how the player changes/exploits the entity). Efficiency for every class is gated by §B; canon-safety by §D. The cadence ladder is the efficiency spine — *the more populous or hot-path an entity, the slower and more pooled/cached its LLM contact.*

A.1 — Class 1: Ambient NPCs (crowds, vendors, villagers, background townsfolk)

High-population, low-stakes. Efficiency is the whole game: a market square has 40 of them and the model must not be consulted 40× a frame — or even 40× a second.

A.2 — Class 2: Named characters (T0_Character_Index 118, T0_Antagonist_Network_Registry 62)

Canon fidelity is highest-stakes here — these are people Josh wrote. The LLM voices them; it owns zero of their facts.

[DECISION NEEDED - JOSH] Which named characters ship with runtime-generated probe responses ON vs authored-only. Recommendation (§6): main antagonists + companions ON; culturally-high-care community figures (Aboriginal Elders, Sámi noaidi, Vodou priests, indigenous shamans — the §17.1 / CVD L265 inviolable set) authored-only at launch — the model assists *authoring* their lines, not runtime speech, given HL_0002 (every cultural claim traces to a primary source, which the model cannot do).

A.3 — Class 3: Fauna / creatures (33 legendary species; open-ended regional fauna)

Canon: 33 legendary species = 21 mortal (7 Ground/7 Flight/7 Water) + 12 elven; 22 familiar slots; T0_Creature_Roster carries folklore_behavior_substrate + folklore_attribution_source. The LLM performs the *read* over deterministic behavior; it never picks behavior.

A.4 — Class 4: Partners / teammates / familiars (bonded party companions)

The class the player spends the most continuous time beside — so the "feels alive" vs "never on the hot path" tension is sharpest. Solved by splitting the companion into a deterministic combat/traversal agent and a slow strategic personality tick.

A.5 — Class 5: Societies / factions (the Velheim antagonist network + protected communities)

The strategic heart — where the LLM earns its place (faction-level intent is the "slow, high-level, why-not-what" decision the model is good at and the sim is bad at hand-authoring across 30M words) and where canon binds hardest. Full simulation layer in §7.

A.6 — Class 6: Environments / world-state (weather, vril density, arena cycles, the environmental-boss protocol)

The world itself as an entity — almost entirely deterministic, plus a thin strategic layer of *atmospheric intent* and the *diegetic read* of the environmental-boss protocol (canon's non-damage-win layer).

A.7 — The taxonomy at a glance

ClassStrategic tick (LLM cadence)LLM emits (token)Deterministic executorPlayer manipulation
1 Ambient NPC~0.05–0.1 Hz pooled/zone; per-NPC event + speculative-cachedzone mood, rumor-key, bounded lineschedule FSM, path, vendor economy, bark-select (Sigma)edit the *world* (integrity/deeds) → crowd mirrors it
2 Named characterevent-driven, ~700 ms probedisposition-delta, ≤80-tok whitelisted responsecanonical facts, arc beats, voice ID, dialogue-tree structureearn disposition + probe within whitelist (can't jailbreak canon)
3 Faunaon BT state-transition, ~0.1–0.5 Hzbehavior-flavor read, temperament readspawn/aggro/flee, bonding window, binding stone, familiar slots, combattame/bond/provoke/exploit territory (all deterministic)
4 Partner/familiarcombat: 0 LLM; personality ~0.03 Hzcombat-disposition *bias*, banter, relationship-deltafull 60 Hz combat AI, cooldowns/vril, relationship SMcultivate relationship → shifts fighting *style* (bounded bias)
5 Faction (Velheim / communities)~0.005–0.02 Hz director tickfaction-intent, operative-assignment bias, rationaleencounter-spawn (3 declared systems, Sigma), authored boss arc, protected-community wallheat/aggro + integrity + defend-communities; can't break antagonist canon
6 Environment/world-state~0.01 Hz / scene-entryatmosphere bias, env-boss readvril_density dial, all clocks, env-boss protocol, worldstate flagsread/time the world; run the 4-step protocol; the difficulty dial

Cadence ladder (the efficiency spine): ambient crowds share a zone tick; combat companions get zero LLM in-fight; factions think in minutes. At no tick does the LLM run per-frame or on the render thread. One shared 3–8B quantized model, prefix-cached persona preambles, priority-batched (combat-relevant reads > player-facing > ambient), speculative pre-warm during idle. The frame budget belongs to the sim; the LLM lives in the gaps.

---

2. Guardrail architecture — the truth-guardrail loop

Every generation is a four-stage deterministic sandwich around one model call. The model is the meat; it never touches the outside world directly. Generalized from "generate a line" to "generate a strategy token":

  [1] CONTEXT PACK      deterministic: recall.py builds a per-entity, canon-true pack
        |                (persona/disposition prior + hard-line rule vector + fact/goal
        v                whitelist + care band + action vocabulary for strategic entities)
  [2] CONSTRAINED GEN   local LLM: grammar/JSON-schema-constrained decode of a STRATEGY
        |                TOKEN (goal ∈ enum, plan ∈ legal set, knobs ∈ ranges, line ≤ N tok)
        v                — malformed impossible, out-of-vocabulary name unsampleable
  [3] POST-GEN VALIDATE deterministic: check token vs the canon graph + rule vector +
        |                legal-transition set. PASS -> bind;  FAIL -> [4]
        v
  [4] AUTHORED FALLBACK deterministic: bind the authored default token for (entity,
                         state_bucket); log the miss; the sim never stalls, never sees
                         an invalid token

The strategy token is the ONLY thing that crosses from LLM to sim. It is small (a few enums + floats + short strings), schema-constrained so it cannot be malformed, and validated so it cannot be canon-false, before any deterministic system reads it. §D is the full spine; §2.1–2.4 are the summary each class in §A inherits.

2.1 — Stage 1: the context pack (perfect-precision recall, runtime edition)

recall.py (docs/CANON_INTEGRITY_ARCHITECTURE.md §D) run at runtime instead of cascade time. The build-time recall node CH_34 "all-canon-for-a-node" query becomes a precomputed context pack baked per entity at load, not per frame. A pack is a small frozen struct assembled offline by walking the canon graph outward from the entity node:

Because the pack is precomputed and frozen at entity load, per-frame cost is zero graph work — just prompt assembly from a cached struct whose KV-prefix is cached once. This is the continuo move: do the expensive, must-be-perfect recall once, deterministically, and hand the dumb model a bounded, pre-verified truth slice.

2.2 — Stage 2: constrained generation

2.3 — Stage 3: post-generation validation (the deterministic gate — where continuo lives)

lint_canon_graph.py's spirit at runtime: a battery of cheap deterministic checks, ordered fast-and-common first, one fail → fallback. Full V1–V5 + strategy checks in §D.4; the dialogue summary:

1. Denylist / cultural filter — regex + phrase set over the §17.1 forbidden-framing corpus (HL_0005: Vodou-as-zombie, shaman-as-mystical-other, temple-as-trap; joik/songline misuse; slurs). Hard fail, runs first.

2. Hard-line rule-vector check — the machine-readable form of this entity's hard lines (a protected-community line must carry no combat-provocation intent; a pre-Ch-76 entity must not reference Grand-Sage tokens). Hard fail.

3. Canon-graph fact check — every proper noun/named entity must resolve to a node in the entity's whitelist, including the retired-alias reverse index so a hallucinated "Agartha" is caught even though canon says Maatherion. Hard fail.

4. Persona/register check — output language matches language_primary; register keywords present/absent; length in band. Soft fail.

5. Repetition / anti-slop check — reject within edit-distance ε of the last K lines or matching the global slop-phrase set. Soft fail.

For strategic entities, add the §D.4 plan checks (legality, resource-feasibility, lock-state, awareness-consistency). Checks 1–3 (+ legality/lock/awareness) are correctness gates (hard fail → fallback); 4–5 (+ resource/framing) are quality gates (one cheap retry → fallback). Every fail writes {entity, state, prompt_hash, output, failed_check} to the rotating reward corpus (§5).

2.4 — Stage 4: authored fallback (the reward floor)

Every generative slot has a deterministic authored fallback keyed by (entity_id, state_bucket) — for dialogue, a hand-written line bank (3–6 lines, RNG-picked); for strategic entities, the authored default behavior tree/policy for that state bucket. Fallback triggers on any hard-fail, retry-budget exhaustion, or a latency-budget miss. The player never sees a hole, a hang, or a slop line. This is the shippable floor: the local LLM is upside, never a dependency. The sim is already coherent on the authored defaults alone; the LLM is pure upside layered on top.

---

B. On-device inference architecture — sizing, quantization, scheduling, budgets

This section answers the orthogonal engineering question: how the model physically runs — sized, quantized, scheduled, budgeted — alongside a AAA renderer on a player's own PC / Xbox Series / PS5, fully offline. The governing principle is inherited: the local LLM is upside, never a dependency, so every budget below is allowed to *fail its own latency targets* without the player ever seeing a stall — that freedom is what makes an aggressive on-device design shippable.

The continuo §4.2 lesson — *write-time-structured, read-time-cheap* — is also the inference strategy: the largest per-call cost is re-processing a long context prompt every time, so the persona card / hard-line preamble / fact whitelist are frozen per entity at load and their KV-cache prefix computed once, leaving the runtime call to decode only a 12–80 token variable tail. Every technique below specializes that one move: *do the expensive thing once, off the critical path; make the per-frame thing small, bounded, and interruptible.*

B.1 — Model sizing (the tier ladder)

Bigger is a frame-time and VRAM tax the renderer refuses to pay. *Humanity*'s outputs are short, persona-conditioned, and heavily scaffolded by the context pack — a regime where sub-4B models are near-indistinguishable from 8B once the pack carries the persona and the §D validator catches the misses (the ≤4B class closed the quality gap in 2025–26: Qwen3-3B / Phi-4-mini lead the under-4B benchmarks).

TierModel classQuantWeights on diskVRAM residentRole
Draft / ambient0.5–1B (Qwen3-0.8B-class, Llama-3.2-1B)Q4_K_M~0.4–0.7 GB~0.6–0.9 GBThe speculative draft model (§B.6); low-end ambient-bark generator
Baseline target3–4B (Qwen3-3B / Phi-4-mini-class)Q4_K_M~1.9–2.3 GB~2.6–3.2 GB w/ KVThe recommended runtime model. Voices bosses, named NPCs, fauna; runs faction/env strategy. One shared instance.
Prestige (PC high-end)7–8B (Qwen3-8B-class)Q4_K_M / Q5_K_M~4.4–5.5 GB~5.5–6.5 GB w/ KVOpt-in "enhanced NPC" graphics tier on ≥12 GB-VRAM PCs; identical prompts & validator, higher literary register

Recommendation: ship the 3–4B Q4_K_M as the single canonical target. Author every context pack, fallback, and eval fixture against it. The 0.5–1B is co-loaded as the speculative draft (earns its VRAM twice). The 8B is a PC-only graphics option, never a content dependency — a Series S or base PS5 plays the whole game on the 3–4B tier and loses nothing but prose polish, because the *facts* are all deterministic. Sub-1B fails the anti-slop gate too often to be the baseline; it is the right size for the *draft* role and the low-end ambient floor.

B.2 — Quantization (int4 weights)

Weights: 4-bit, K-quant mixed precision (Q4_K_M) as the shipping default — ~75% memory reduction vs FP16, ~18× CPU throughput, minimal quality loss on short generations; Q5_K_M is the fallback if a specific persona's eval pass-rate regresses at Q4. Use AWQ (activation-aware) for the int4 export — it protects the salient weight channels that carry persona/register, exactly what short style-sensitive outputs are sensitive to.

Format by platform (the console reality forces two packaging paths from one trained model):

B.3 — The compute reality (memory is the whole game)

An LLM co-resident with a AAA renderer is memory-bandwidth-bound, not FLOP-bound — inference speed is gated by how fast weights stream from VRAM, and the renderer is saturating the same bus. This drives every other decision (small model, int4 weights, prefix cache, off-thread scheduling, batching). Consoles are unified-memory: Series X 16 GB GDDR6 (10 GB @ 560 GB/s + 6 GB @ 336 GB/s); PS5 16 GB @ 448 GB/s — shared across CPU/GPU/LLM, no separate pool to hide in.

Proposed inference-layer memory budget (16 GB shared console class):

ConsumerBudgetNote
Game (render targets, meshes, textures, audio, sim)~12.5–13 GBUntouched — the renderer's budget is sacred
LLM weights (3B Q4/int4, shared single instance)~2.0 GBOne copy, ever
KV cache pool (all in-flight entities, paged)~0.4–0.8 GBPaged, capped, evictable
Frozen persona prefix-cache store (per active entity)~0.2–0.4 GBThe precompute win
Draft model + grammar FSM tables + scratch~0.4 GB§B.6/§B.7
Inference total~3.0–3.6 GBFits the carve-out AAA teams can spare on a 16 GB console

Compute placement: NPU (Copilot+ PCs, Ryzen AI, future consoles) is ideal — runs the LLM without touching the GPU's bandwidth; treat as a bonus, never a requirement. Xbox ML units via Windows ML (the int4 TOPS are real). Otherwise the LLM shares the GPU with the renderer and the mitigation is entirely in scheduling (§4-sched): a low-priority async compute queue in the gaps, never holding the queue during the render-critical window.

B.4 — The strategic tick (scheduling off the render critical path)

The LLM lives on its own async worker, decoupled from the render/sim tick, on a slow clock. This is what physically enforces Josh's hard line.

 RENDER/SIM THREAD (16.6 ms @ 60fps)  ── owns all mechanics, deterministic
        │  posts request  │ polls result mailbox (non-blocking)
        ▼                 ▲
 STRATEGIC TICK (async worker, ~2–10 Hz, low-prio async-compute queue)
        │  builds prompt from frozen pack → constrained decode → validate
        ▼
   result mailbox (double-buffered; render thread reads last completed only)

The render thread never blocks on the LLM — it posts and polls; if the answer isn't ready, it uses last frame's token or the authored fallback. Generated output is a pure output leaf with no write path into the sim, so a late or dropped generation *cannot* stall a mechanic, by construction. On GPU-shared platforms, submit inference on a low-priority async compute queue so the graphics queue preempts it; a strategic tick spilling across several frames is fine (the mailbox tolerates it).

Latency budgets by output class (soft P99 → hard cap → action on miss):

ClassSoft P99Hard capOn miss
Combat bark / reaction120 ms250 msAuthored fallback, drop silently
NPC ambient line300 msPre-generated during idle; never on demand
Player-facing probe (talk UI)700 ms~1 sShow "thinking" beat, then fallback
Faction/disposition/env plansecondsRuns fully in background; no player waits

B.5 — Latency & throughput budget (the arithmetic)

The budget must survive a worst-case moment — a boss + several adds + an ambient crowd all wanting lines in the same second — via two levers: short outputs and batching. Per-call (3B Q4, GPU-shared, illustrative): prefill ~0 (persona preamble prefix-cached) + the small variable head; decode of a 12–20-token bark at a conservative 40 tok/s shared-GPU is ~300–500 ms single-stream — *over* the 120 ms soft target, which is why single-stream is never the runtime path. Batching (§B.7) + speculative decode (§B.6) pull the *effective* per-line latency under budget; anything that still misses hits the authored floor, invisibly.

Throughput target: sustain the aggregate line rate of a busy scene, not minimize any single call. Design target: ~8–15 completed generations/second across all entities on the baseline console tier, via micro-batching concurrent requests into one forward pass + pre-warming ambient during idle. The architecture wins by (a) making most calls free (cache hits), (b) batching the rest so the fixed weight-streaming cost amortizes across many entities, (c) having a floor. Remove any one and the budget breaks.

B.6 — Speculative / draft-model decoding

The single highest-leverage latency technique for this workload — short, grammar-constrained outputs are exactly the regime where a tiny draft model's guesses are accepted at a high rate (2025 production spec-decode: 2–3× decode speedup, quality unchanged). Draft = the 0.5–1B tier model; target = the 3B. On our short grammar-shaped outputs, acceptance is high → the 3B often emits a full bark in ~2–3 verification passes instead of 15–20 sequential decodes. Prefix-injected drafting (DFlash-style) composes with our precomputed prefix cache; grammar-aware speculation prunes the draft's proposals to structurally-valid tokens before verification, raising acceptance further. On the tightest PS5 tier where the draft's extra ~0.4 GB is too costly, drop speculation and rely on the 1–3B model's raw speed + heavier caching — speculation is an accelerator, not a dependency.

B.7 — Batching + KV/prefix caching (the continuo core, in silicon)

One shared model instance serves every entity; persona differences come entirely from the context pack — that single decision is what makes batching possible: a boss, its adds, and the ambient crowd are the same model with different prompts, so their requests batch into one forward pass and the bandwidth-bound weight-streaming cost is paid once for the whole batch. Priority micro-batch queue (combat bark > player probe > ambient > background disposition); continuous batching (entities finishing early release their slot mid-batch); selective operation batching to handle the ragged-tensor caveat from speculative decode.

Three cache layers, most-to-least precomputed: (1) frozen persona prefix cache — each entity's persona card + hard-line preamble + few-shots is a fixed prefix whose KV cache is computed once at entity load and frozen, dropping prefill to near-zero (the biggest single lever); (2) response cache per (entity, state_bucket) — ambient/idle lines pre-generated during low load, so a crowd draws pre-warmed lines from cache, capped + LRU-evicted; (3) live KV pool — paged (PagedAttention-style), capped at the §B.3 budget, evicted the instant a generation completes. Seed the sampler from (worldseed, entity_id, event_counter) so a replay/speedrun reproduces the exact lines and the response cache is content-addressed by that seed — a cache hit *is* deterministic reproduction.

B.8 — LoRA / adapters (personas from the pack, not per-character fine-tunes)

Do NOT ship a LoRA per persona at launch — persona differences come entirely from the context pack; per-character adapters would be an unmanageable authoring/QA surface, and the pack + few-shots already carry persona at this output length (continuo §4.5 M5: data over code). Where a small LoRA *is* justified: a single always-on game-voice LoRA trained on the 30M-word prose corpus so the base model's default register *is* the game's literary voice (strengthening the anti-slop gate at the model level); optionally 3–5 broad register adapters (archaic/formal, folk/vernacular, antagonist-menace) selected by the pack's speech_register. If per-persona adapters are ever wanted ([DECISION NEEDED - JOSH]), 2025 multi-LoRA serving (S-LoRA / Punica SGMV) hot-swaps adapters in ms during active batching, so it would not break the single-instance/batching architecture — but it is explicitly not the launch design.

B.9 — Graceful degradation (the authored floor as a hardware tier)

The architecture is safe to run aggressively *because* it degrades to authored content, never to a stall. A declared, tiered ladder auto-detected at launch by a VRAM/NPU probe:

Hardware tierConfig
PC ≥12 GB VRAM / strong NPU8B prestige, speculation on, full generative on all entity classes
Baseline — Series X, PS5, mid PC (8–12 GB)3–4B Q4/int4, speculation on, batching, full generative
Series S / entry PC (≤8 GB) / thermally throttled1–3B, speculation off, ambient = cache-only, generative on bosses + key NPCs only
Low-end / NPU-only budget / battery-saverGenerative on bosses only; all ambient + fauna + crowd = authored fallback
Floor / accessibility "deterministic text" mode / any hard failureAuthored-only, model never loads. The game is 100% complete and correct — the shippable floor

Key property: because the model owns zero facts, *every* tier plays the identical, canon-correct game. Degradation removes only prose variety, never content, correctness, or a single point of progression. A Series S player and an RTX-4090 player fight the same boss with the same tells and the same win condition; one just hears more varied taunts. This is the design's core safety guarantee restated as a hardware policy.

B.10 — Recommended baseline configuration (the one-line pin)

Ship a single 3–4B model (Qwen3-3B / Phi-4-mini class), Q4_K_M on the GGUF/PC path and block-int4 ONNX via Windows ML on Xbox, int8 compute-shader on PS5 (PS5 defaulting down to 1–3B pending devkit profiling). One shared instance, personas as context-pack data (plus one always-on game-voice register LoRA), no per-character adapters. A 0.5–1B draft model for speculative decode. XGrammar/GBNF constrained decoding for guaranteed-valid short JSON. Frozen per-entity persona prefix-cache + (entity, state_bucket) response cache filled speculatively at idle. Priority micro-batching on a 2–10 Hz strategic-tick async worker on a low-priority compute queue, off the render critical path, double-buffered mailbox to the render thread. Budget ~3.0–3.6 GB of the shared 16 GB console pool. Every output class has an authored fallback; a latency miss, hard-fail, or low-end hardware degrades to authored content, never to a stall. Seedable sampler for replay/speedrun determinism; fully offline, no network, no telemetry required.

---

3. AAA runtime constraints (the budget the design lives inside)

The layer must be invisible, offline, deterministic-where-needed, and never the reason a frame drops. (Superseded in engineering detail by §B; retained here as the top-level contract.)

---

4. How this makes them feel ALIVE and novel (without slop)

The novelty is not "an LLM is in the game." It is generative texture rendered over a deterministic truth spine the player can trust — the model reacts to the *actual* fight/world state so it feels aware, and it can never lie, so the world stays coherent.

The difference from typical "AI NPC" demos: those let the model own facts and hope it's right, so they hallucinate and break canon. Here the model owns *zero* facts and the deterministic layer owns *all* of them. The life is real; the lies are impossible.

---

5. Failure/reward-pattern encoding (the continuo core, made concrete)

Continuo's real lesson: enumerate the specific ways the dumb model fails, encode each as a deterministic check, and turn every caught failure into a reward signal that hardens the system. Mapped failure → deterministic catcher → reward:

#Dumb-LLM failure modeDeterministic catcher (§2/§D stage)Reward-pattern encoding
F1Hallucinates a person/place/item not in canonStage 3 check 3: named entity must resolve in the graph whitelistLogged miss → negative few-shot; if the name is *wanted*, [DECISION NEEDED - JOSH], never auto-canonized
F2Uses a retired alias (Agartha, Hyperborea, Lemuria…)Stage 3 check 3 + retired-alias reverse index (recall aliases, id_normalization.json)Same reverse index the build-time G1 straggler gate uses — one shared truth source
F3Violates a cultural §17.1 hard lineStage 3 check 1 (denylist) + check 2 (HL_0005 rule vector)Denylist corpus grows from every catch; high-care chapters bias to fallback
F4Leaks a future/protected fact (Grand-Sage pre-Ch-76, §17.5)Fact-whitelist absence + §17.5 token denylistThe fact was never in the pack — structural prevention; a leak = pack-assembly bug, gated at build
F5Provokes combat against a protected community (HL_0003)Stage 3 check 2: intent classifier on the line/plan vs the protected flagCh29/42/57 entities carry the flag from the pack; Ch 57 director disabled; catch → fallback + log
F6Breaks persona / wrong register / wrong languageStage 3 check 4Soft-fail retry; persistent misses re-tune the exemplar set
F7Slop / repetition / generic-LLM ticStage 3 check 5 (edit-distance + global slop set)Global slop set shared across all entities and grows from logs
F8Malformed structure (bad JSON, out-of-enum tag, over-length)Stage 2 grammar-constrained decode (prevented, not caught)Impossible by construction — the highest-value encoding removes the failure class
F9Latency miss under loadStage 4 trigger on budget timeoutMiss rate monitored; sustained misses trigger pre-warm/cache tuning, not player-visible degradation
F10Tries to affect game stateNo write path exists (§3)Structural: generated output is a pure output leaf, enforced at the API boundary

The reward loop closes exactly like continuo's: every caught failure is written to a local corpus (runtime_generation_log) that (a) grows the authored-fallback bank, (b) grows the denylist/slop sets, and (c) becomes eval fixtures. A nightly/CI offline job replays the logged prompts against candidate model+prompt versions and scores them with the *same deterministic §2.3 checks* — a truth-recall-style metric (fraction passing all gates first-try) directly analogous to continuo's 0.965. You ship a version only when its first-try pass rate clears the bar; the authored fallback guarantees the floor never drops. The system is correct on day one because the deterministic scaffolding — not the model — guarantees canon.

---

C. The living-world simulation layer — deterministic society/environment evolution, LLM-directed strategy

The runtime layer above puts a guardrailed model behind an entity's *speech*; this section extends the same split up one level, to the world's *behavior*. Josh's line — "even societies and environments can change and manipulate" — is a request for a world that *acts*, not just reacts. The continuo answer holds verbatim: the simulation is deterministic; the LLM only ever proposes strategy over a bounded, pre-verified state slice, and every proposal is validated against the canon graph before it can touch a single world-state variable. The novelty is not "an LLM runs the world" — it is *a fully deterministic world-state machine whose long-horizon strategy is authored at runtime by a model structurally incapable of breaking canon.*

C.1 — State variables (the world's deterministic substrate)

Everything the sim evolves already has canon anchors; this layer adds no world canon. It reads/writes the 25 canonical T0_Worldstate_Variables:

Faction taxonomy (from canon, not invented): the seven Inner Council sectors (SECTOR_1_BANKING, _2_EXTRACTION, _3_MILITARY_INDUSTRIAL, _4_PHARMACEUTICAL, _5_MEDIA_INFORMATION, _6_POLITICAL_ACCESS, _7_OCCULT_KNOWLEDGE — registry-verbatim these carry the INNER_COUNCIL_ prefix) + VRIL_STANDALONE + ARCHITECT_ROLE, each operative carrying sector_assignment + awareness_tier (UNAWARE → FAMILY_BRIEFED → FULLY_AWARE → INNER_COUNCIL). Non-antagonist factions (communities, guilds, institutions) are the counter-weight side of WS_021. The sim never adds a sector or community; it evolves the state of the ones canon lists.

[EXTENSION] sim-internal variables (labeled, sim-scoped, NOT world canon, flagged for Josh — CK-style bookkeeping no canon doc specifies; each a [DECISION NEEDED - JOSH]): faction_resource_pool[sector], territory_control_graph, inter_faction_relation[a][b], player_strategy_vector (a rolling histogram of *how* the player dismantles operations — combat vs exposure/journalism vs economic vs environmental-protocol vs diplomacy), faction_goal_current/plan_active[sector]. All are fixed-size current-value stores (continuo discipline: no unbounded append-only logs; the only growing log is the rotating reward corpus).

C.2 — The tick model (three clocks, three altitudes)

The load-bearing performance decision and the answer to Josh's hard line: the sim ticks deterministically; the LLM is invoked only at coarse, off-critical-path cadence and never inside a tick — continuo's "write-time-structured, read-time-cheap" reshaped to *decide-time-rare, execute-time-cheap.*

  FRAME  (per render frame)      — NO sim, NO model. Present the current world-state field
                                   (vril VFX, NPC posture, community recovery visuals). Read-only.

  SIM TICK (coarse: per in-world  — DETERMINISTIC ONLY. Advance economy/territory ledgers, apply
   day / per chapter-beat)          active faction plans one step, resolve consequences, recompute
                                     WS_019/020, update WS_021, couple integrity→WS_024. Fixed-cost,
                                     seedable, no model call.

  STRATEGY TICK (rare: per         — LLM STRATEGIC layer, off-thread, budgeted, §D-validated. For each
   region-arrival / era-shift /      faction whose situation changed materially: propose goal + disposition
   material-pressure event)          + plan sketch + negotiation/propaganda stance + alliance/betrayal
                                     intent. Validate. Commit or fall back to the deterministic default.

The strategy tick fires on events, not a wall clock (region entry, era boundary, an operation exposed past threshold, a material shift in player_strategy_vector). Between ticks — tens of minutes of play apart — the world runs on the last committed plans, fully deterministically. On consumer hardware the shared 3–8B instance is idle during play and wakes only at a region transition or loading beat, where a ≤700 ms budget is invisible; a strategy tick is a handful of short constrained decodes (1–4 factions, not all nine), prefix-cached per sector. Seed from (worldseed, sector_id, strategy_tick_counter) so a save reproduces the world's trajectory; a "deterministic world" mode forces default-policy-only.

C.3 — Canon-safety at world altitude

The strategy-tick loop is the §2/§D sandwich at world scale (SITUATION PACK → STRATEGY GEN → PLAN VALIDATE → DEFAULT POLICY). Stage 2 uses schema-and-enum-constrained decoding: the model emits a goal chosen from an enumerated legal menu and a plan as an ordered list of pre-existing action IDs — it literally cannot name a faction that doesn't exist or an action the sim doesn't implement. The plan validator (§D.4, world edition) adds: legality check, hard-line rule-vector check (Ch 57: no antagonist-family presence → any plan projecting a sector operation into Ch 57 is rejected outright; protected communities: a plan may target the community's *oppressors* per Ruling 5 but never re-frame the protected people as a combat/erasure target), canon-graph entity check (+ alias reverse index), lock-state check (post-Ch-65: no goal migration that re-opens path), awareness-consistency check (an UNAWARE operative cannot plan on knowing the Grand-Sage reveal — the world-scale fact-whitelist), resource-feasibility, framing/tone check (Cassius is *sophisticated, not monstrous*; the Corrupted-path world is *hollowed, not cartoonish*).

The write-path guarantee (structural, not policy): the LLM's output has no direct write access to any world-state variable. It emits a proposal struct; only the validator, on PASS, calls the sim's commit_plan() API; only the deterministic sim tick mutates WS_0xx. A faction cannot set integrity_score, flip a path lock, or expose an operation by *saying* so; it can only propose a plan whose *validated deterministic execution* moves the ledgers.

C.4 — How the player manipulates factions and environments

Five real levers, each grounded in a canon coupling:

Across the arc the accumulation is the payoff: the Ch 59–65 continental revisits let the player *see* the society/environment they shaped — communities recovered or traceably damaged by their own ancient-world choices — earned state, not an authored slideshow.

C.5 — Emergent-but-bounded

CK-grade emergence inside a canon cage, achieved by four structural properties, none relying on the model behaving: (1) the action space is a closed authored library (sequencing/emphasis is open — the emergence; vocabulary is closed — the cage); (2) every proposal is validated before it acts, so the worst reachable outcome is a faction running its deterministic default behavior tree (the sim is already shippable on defaults alone); (3) convergence discipline caps branching (goal-migration is free Ch 2–64, frozen against path-moving change at the Ch 65 lock); (4) emergence is texture, never truth — faction scheming modulates *how intact/exposed/recovering* a region reads and *what a faction tries next*, never a canonical beat or hard-line state (the Architect still contacts at Ch 17; Cassius still resolves at Ch 76). The sim colors the space between the canon anchors; it never moves an anchor.

---

D. The canon-graph guardrail spine (context-pack → constrained-decode → validate → fallback)

This is the safety spine that makes a dumb local model reliable, specified in build-ready detail. It is the same four stages as §2, drawn as the shared machinery every entity class and the world sim run through.

D.1 — Context pack (perfect-precision recall, baked per entity)

Built by recall node <id> at bake time, frozen at load: persona/disposition prior + hard-line rule vector + fact/goal whitelist + retired-alias index + care band, plus action_vocabulary for strategic entities. One shared model, N personas in the packs; per-frame graph work is zero; the pack's KV-prefix is cached once (§B.7). (See §2.1 for the field-by-field composition.)

D.2 — Constrained decoding (three layers, tightest-first) + the novel improvement

Three layers, from strongest guarantee to loosest: (a) JSON-schema/grammar structure (XGrammar/GBNF) — malformed output impossible; (b) enum/ID constraints — goals ∈ the legal menu, plan actions ∈ the existing action library, emotion ∈ enum; (c) length caps per output class. The novel improvement over SOTA (§E claim 1): a per-entity dynamic canon-vocabulary logit mask driven by the graph — the decoder's legal-name universe is the entity's fact whitelist, so two adjacent NPCs decode against *different* name universes and a hallucinated or retired name is unsampleable at the token level, not merely rejected after the fact. This welds the "boss reads you" adaptivity to deterministic truth at the decoder: the model cannot name a tell the sim didn't hand it, or an operative canon doesn't list.

D.3 — Validate (V-checks mapped to build-time gates)

The runtime cousins of lint_canon_graph.py gates, so build-time and runtime enforce the *same* canon from the *same* sources: V1 denylist/cultural ≈ the §17.1 corpus; V2 hard-line rule-vector ≈ G4 (hard-line resolution); V3 canon-graph entity resolution ≈ G1 (retired-name straggler) + G2 (entity resolution); V4 persona/register; V5 anti-slop. For strategic entities add the plan checks: legality (goal ∈ legal menu, action_id exists), lock-state (Ch 65+ freeze), awareness-consistency (the fact-whitelist wall), resource-feasibility, framing/tone. Correctness gates hard-fail → fallback; quality gates get one retry → fallback.

D.4 — Fallback (the shippable floor)

Authored line bank per (entity, state_bucket) for dialogue; authored default behavior tree/policy per (sector/entity, state_bucket) for strategic output. Triggers on any hard-fail, retry exhaustion, or latency miss; logs the miss to the reward corpus (§5). The floor is AAA-quality authored content — the model is pure upside.

D.5 — The write-path guarantee

Structural, not policy: the model emits a typed strategic token / bounded line over an authored vocabulary; a deterministic executor disposes it; the model has no per-frame or state-mutating API verb (F10 prevented by construction). Strategy is still wrapped in the same four-stage sandwich as dialogue. Making illegal states unrepresentable (continuo M7) is the strongest encoding in the whole design.

---

E. Novelty — state of the art, and where *Humanity* is distinct

E.1 — The prior art and what each does NOT solve

E.2 — The novelty claims *Humanity* can stand behind

1. The world-canon truth-guardrail. The first entity-generation system whose LLM is checked, per output, against a formal canon graph + fact-whitelist + retired-alias index, making a lore/plot contradiction structurally impossible rather than merely unlikely — and, via §D.2's dynamic canon-vocabulary logit mask, hallucinated/retired names are *unsampleable*, not just caught. *(Flagship claim.)*

2. Inverted trust boundary — "the model performs, it never adjudicates." The field gives the LLM authority over facts and hopes; *Humanity* gives it authority over zero facts and lets deterministic code own all of them. This is what makes an LLM safe for a plot-load-bearing entity, not just side chatter.

3. Plot-critical, not side-character. Because facts are guarded, generative life extends to story-critical NPCs and named bosses — the exact class every shipping LLM-NPC system deliberately avoids. A villager who *can't* know the ending is more real than one who might recite it.

4. Pervasive across every entity class on one shared model. Bosses, fauna, crowds, vendors, plot NPCs, factions, and the environment run the same pack→gen→validate→fallback loop — versus Nemesis (rivals only) and ACE (ambient only).

5. AAA-believable at deterministic-sim cost, fully offline on consumer/console hardware. One 3–8B quantized model, ≤120 ms P99 barks off the render thread, prefix-cached personas, seedable for speedruns — no cloud, no per-query bill, no platform lock-in.

6. Anti-slop as a first-class deterministic gate, not a hope. An edit-distance + slop-phrase rejector plus authored few-shots that pull the model toward the game's 30M-word literary register.

7. A self-hardening, day-one-correct loop (continuo, ported to runtime). Every caught failure grows the fallback bank + denylists and becomes an eval fixture; nightly replay scores model versions on a truth-recall-style first-try-pass metric. The system is correct on day one because deterministic scaffolding guarantees canon, and it improves over time without the model ever being the safety dependency.

The one-sentence synthesis: *Humanity* is the first game to make every entity — boss, animal, crowd, plot NPC, faction, and the world itself — generatively alive on a small on-device model that runs fully offline on consumer and console hardware, while a deterministic canon-graph guardrail makes it structurally incapable of contradicting a 30M-word authored world — life that is real because the sim owns it, and truthful because the model owns nothing.

---

F. Staged build plan (plugging into the canon-integrity system + the 5-chapter milestone pipeline)

This layer is not a separate program; it is a tenth engine that rides the 5-chapter milestone pipeline (docs/MILESTONE_BUILD_PIPELINE.md) and consumes the canon-integrity system (docs/CANON_INTEGRITY_ARCHITECTURE.md). It follows the milestone doctrine: *build and prove the engine on a 5-chapter slice, then roll the same proven loop forward.* Nothing here is greenfield — every stage extends an artifact that already exists or is already planned, and where it needs a canon fact not yet authored it consumes it through recall.py or flags [DECISION NEEDED - JOSH], exactly as the cascade does.

F.0 — Dependency preconditions (must land first, in the canon-integrity system)

F.1 — Stage 0: the exporter + validator skeleton (build-time, no model yet)

Extend the harness: recall packs <entity_id> emits a frozen per-entity context-pack file (persona + hard-line rule vector + fact whitelist + care band); recall factions <sector> emits per-sector strategy packs (legal-goal menu + rule vector + territory slice). Stand up the §D.3 validator as a pure function over (token, pack) reusing lint_canon_graph.py gate logic (V2≈G4, V3≈G1+G2). Gate to advance: the validator passes/fails a hand-written fixture set (valid tokens PASS, injected hallucinations/retired-aliases/hard-line violations FAIL) with zero false-negatives on the correctness gates. No model, no runtime cost — this is the guardrail proven in isolation, the continuo "code first" discipline.

F.2 — Stage 1: prove the loop on the milestone slice (Classes 1–3, dialogue only)

On the first 5-chapter milestone slice, wire the four-stage sandwich (§2) for the three read-only-surface classes — ambient NPCs, named characters, fauna — with the recommended 3–4B baseline (§B.10), grammar-constrained decode (§D.2), and authored fallback banks for every (entity, state_bucket) in the slice. Build the runtime_generation_log + the nightly offline replay harness (§5) so the slice yields a first-try-pass-rate number. Gate to advance: on the slice, first-try pass rate clears a set bar; P99 latency budgets (§B.4) hold on the baseline console tier under a scripted worst-case busy scene; zero canon-fidelity escapes in a critic pass. This is the milestone-pipeline's "prove the engine on a slice" applied to the runtime layer.

F.3 — Stage 2: strategic entities (Classes 4–6) on the same slice

Add the strategy-token path for companions (combat-disposition bias), the environment (atmosphere bias + env-boss read), and — the highest-stakes — the faction director (§C). This requires the ratified action vocabulary (F.0) and the world-sim tick engine (§C.2) running deterministically first. Validate the world-scale plan checks (§C.3): Ch 57 director-disabled, protected-community wall, lock-state freeze, awareness-consistency. Gate to advance: the sim is coherent and shippable on the default policies alone (model off) across the slice; with the model on, every plan either validates or falls back with zero hard-line escapes; the Ch 57 / protected-community walls are proven un-crossable by an adversarial red-team fixture set.

F.4 — Stage 3: on-device hardening + the degradation ladder

Port the reference GGUF runtime to the console export paths (§B.2: block-int4 ONNX/Windows ML on Xbox; int8 compute-shader on PS5) and prove the §B.9 degradation ladder end-to-end (each tier plays the identical canon-correct slice; the floor tier runs authored-only with the model never loaded). Stand up speculative decode (§B.6), prefix + response caching (§B.7), and the seedable-sampler determinism path for replay/speedrun. Gate to advance: the slice runs within the ~3.0–3.6 GB inference carve-out on a 16 GB devkit without regressing the renderer's frame budget; a PS5 devkit profile confirms the tier choice (the flagged assumption resolved); a seeded replay reproduces identical output.

F.5 — Stage 4: roll forward 5 chapters at a time

With the engine proven on the slice, each subsequent milestone re-runs the same loop scoped to its nodes: recall packs regenerates packs for the new entities, authored-fallback banks are written alongside VO authoring, gates run scoped to the slice, cost staggers by milestone (only this slice's packs, fixtures, and eval fixtures). The nightly replay harness accumulates a corpus-wide first-try-pass-rate trend; a model+prompt version ships only when it clears the bar, the authored floor guaranteeing shippability regardless. The layer's build cost is thereby amortized across milestones exactly as the pipeline intends, never front-loaded as one bill.

F.6 — Placement in the repo

Sits in the T99-operational tier under T1_Combat_System_Spec + T1_Integrity_Paths_Worldstates_Master (which own the combat and integrity-faction *frameworks*), beside docs/COMBAT_ENCOUNTER_SYSTEM.md, docs/RUNTIME_GUARDRAIL_ARCHITECTURE.md, docs/MILESTONE_BUILD_PIPELINE.md, and docs/CANON_INTEGRITY_ARCHITECTURE.md. It invents no world canon and does not enroll in the authored-canon lint gate; it *consumes* that gate's graph and reuses its gate logic at runtime.

---

6. Buildability + open items (the do-not-invent rule binds)

Open items for Josh (flagged, not decided)

Assumptions flagged (hardware — validate on devkit)

1. PS5 int4/int8 ML throughput not publicly specified; design assumes bandwidth-bound-before-compute-bound on a 3B model → smaller PS5 tier + heavier caching.

2. The ~3.0–3.6 GB inference carve-out on a 16 GB shared console is proposed, not measured; the real number is negotiated against the renderer's VRAM footprint per title (tolerated by dropping to the 1–3B tier).

3. Per-call decode coefficients (40 tok/s shared-GPU) are illustrative; profile under real render-queue contention. Correctness is floor-guaranteed; the ~8–15 gen/s aggregate target should be validated against a worst-case busy scene.

4. Console Windows ML maturity for LLM-shaped ONNX graphs is evolving — the Xbox export path needs a spike before commit.

---

Companion / source docs (all absolute):

---

Returned above is the full enhanced document body for docs/RUNTIME_GENERATIVE_LAYER.md. It is the v1 draft (thesis / split / guardrail loop / AAA constraints / F1–F10 / buildability, all preserved) enhanced with six new lettered sections synthesized from the five input streams: A (entity taxonomy + the deterministic/LLM-strategic split for all six classes, with per-class strategy token, tick, executor, and manipulation mechanic + the at-a-glance table), B (on-device inference architecture — sizing ladder, int4/AWQ quant + per-platform packaging, the memory-bound compute reality with a concrete ~3.0–3.6 GB budget, off-critical-path scheduling, latency/throughput arithmetic, speculative decode, batching + prefix/response caching, LoRA posture, the graceful-degradation ladder, and the one-line baseline pin), C (the living-world societies/environments simulation layer — deterministic substrate, three-clock tick model, world-scale canon-safety, five player-manipulation levers, emergent-but-bounded), D (the canon-graph guardrail spine with the novel per-entity dynamic canon-vocabulary logit mask), E (state-of-the-art survey vs Nemesis/F.E.A.R./Sims-DF/Generative-Agents/ACE/newest-research + seven defensible novelty claims), and F (a staged build plan F.0–F.6 that plugs into the canon-integrity system and rides the 5-chapter milestone pipeline as a tenth engine). It is deterministic-first, LLM-strategic-only, consumer-hardware/offline, novel, and canon-safe; it invents no world canon and flags every enum, roster, extension variable, and coefficient as a [DECISION NEEDED - JOSH] proposal shape. Verified on disk: harness/canon_graph.json = 3,118 nodes / 11,974 edges; docs/MILESTONE_BUILD_PIPELINE.md (5-chapter model, 9 engines) and the referenced companion docs all exist.

---

DIRECTIVES FOLDED IN (Josh rulings 2026-07-04, post-dating the design workflow)

These ratify/extend the design above. Where they touch a number the workflow left open, they close it.

Hardware — RULED: on-device only, 2030 next-gen

on 2030 hardware); dev/test on the local 14B now. The strategy-token architecture is model-size-

agnostic — a larger model emits richer tokens through the identical guardrail sandwich, so scaling the

model up is a quality dial, not an architecture change. Tier DOWN to min-spec via smaller distilled models

Nemesis-class system — our architecture + patent differentiation (FLAGGED FOR IP COUNSEL)

The WB Nemesis PATENT claims a specific three-part chain: (1) a procedurally-generated enemy HIERARCHY with

promotions, (2) procedural MEMORY of specific player encounters, (3) dynamic RELATIONSHIPS between the

enemies. Bypass games each sacrifice ONE link (XCOM 2 Chosen = handcrafted, not procedural; Warframe Liches

= fixed to player choice, not a dynamic background hierarchy; AC Odyssey mercenaries = infinite hierarchy but

no battle-memory / inter-enemy relationships). **Humanity does not break a link — it replaces the engine

with a different MECHANISM:**

reputation, resources, territory) — not a procedurally-templated combat-orc ladder.

entity, faction, AND place carries real state + history, semantically (fortresses remember your entrances;

people remember the theft) — not scripted per-orc flags.

graph — not template-slotted rules.

buffs at higher difficulty.

Posture: same-or-superior experience via a genuinely different technical method (LLM-strategy-token over

a canon/world-state graph vs procedural templates), applied to a far broader system — the strongest IP

footing. **CAVEAT: this documents the differentiation; final patent-infringement clearance is Josh's IP

counsel, not this design.**

Persistent memory + difficulty-as-intelligence — RULED

settlement/faction aggregate. It persists per playthrough and carries a distilled reputation echo into

NG+ / The Forgotten One (the prestige world remembers the one it forgot).

longer faction memory, better use of the player's tells) — "smarter, not bigger numbers," scaling with the

vril-density tier (Wellspring naive -> The Forgotten One cunning). NEVER stat-buffs.

Living ecology + the immune set — RULED (never soft-lock)

REGROWS over time (tunable per-resource). The world reacts and feels alive.

progression_critical on the canon graph = IMMUNE (never depletes/migrates/vanishes): legendary-weapon

materials, quest-gate resources, unique NPCs. Everything else is simulatable. The sim can never produce

a state where the story is not progressable.

Replayability — RULED first-class

Replayability BECAUSE reactive: persistent memory + ecology + faction sim + LLM-strategy variance make every

playthrough diverge. The 30M-word authored spine is the invariant; the reactive layer varies the texture

around it. This is a design DRIVER, not a bolt-on.

Dev/test path

Validate the strategy-token loop + the 4-stage guardrail NOW on the local 14B (proves the mechanism before

2030 hardware). SHARED-RESOURCE CAUTION: that same 14B runs Continuo's harness simulations — check for a

concurrent Continuo session before launching a local-LLM test run; do not contend for the GPU.

---

STRENGTHENING DIRECTIVES — Opus review, folded 2026-07-04

The architecture STANDS (deterministic-first, model-owns-zero-facts, the F10 structural write-path

guarantee, the dynamic canon-vocab logit mask, the authored floor). These are NOT blockers — each converts

a review finding into a work-item or an evidence gate riding the existing F.0-F.6 milestone structure + the

authored floor. Through-line: the design already guarantees the model can't LIE; these make it measurably

ALIVE, reliable where it matters most, and honest about proven-vs-projected numbers.

RULED — 14B is the reference; model size is a quality dial

Collapse the 3-4B and the 28-32B targets onto one anchor:

Q4_K_M ~8-9 GB weights: co-resides with a AAA renderer on a high-VRAM PC today + on 2030 next-gen

unified-memory consoles. Does NOT fit a 2024 16 GB base console beside a ~12.5 GB renderer -> min-spec tier.

14B = reference (high-VRAM PC today, next-gen console 2030); 28-32B = optional prestige if 2030 HW

allows, NEVER a content dependency.

case** as canonical; relabel the 3-4B numbers as min-spec. Update §B.1/§B.3/§B.9/§B.10 + the hardware

directive. Numbers stay illustrative-shape pending the Phase-5M balance audit.

LOAD-BEARING, not optional — the live-decode path cannot hit the 120 ms combat budget at 14B.

clears its quality bar at the reference tier; the 3-4B min-spec tier leans harder on the authored floor.

ENHANCE §5 — measure ALIVENESS, not just safety (the deepest gap)

§5 scores model versions on first-try pass rate against §2.3 gates — all correctness/safety checks. A model

can pass all of them and be FLAT; optimizing pass-rate alone Goodharts toward safe-and-boring.

only when it clears BOTH the correctness bar AND the quality bar.

(docs/proposals/exemplars/ Ch 3/42/43) + the authored 30M-word prose as positive class; supplement with

periodic SAMPLED human A/B on slice fixtures (not per-run).

ENHANCE §2.3 + §B.8 — promote the register LoRA; learn the slop gate

§2.3 check 5 (edit-distance + slop-phrase set) catches repetition/known tics but not distributional

"generic-assistant voice." The real lever is the game-voice register LoRA (§B.8), currently deferred.

(seed from the exemplar-graded subset); prove on the slice. Whether 14B + register-LoRA holds literary

voice at 12-80-token outputs is a GO/NO-GO for the whole alive layer — learn it early on the slice.

alongside the phrase-list. One instrument, two uses (vividness score + slop gate).

ENHANCE §A.1 / §B.4 / §B.7 — pre-warm the flagship off the live path (REQUIRED at 14B)

A boss bark that "reads you" is a hot, single, low-latency call fired mid-combat (GPU most contended) — the

marquee moment most likely to fall back to authored exactly when most wanted. At 14B this is guaranteed on

the live path.

~1-2 s ahead. During the wind-up, pre-generate the intent-conditioned bark(s) keyed on (phase,

likely-next-intent, known player tell) into the (entity, state_bucket) response cache -> CACHE HIT when

the intent fires, not a live decode. Extends the §A.1 ambient speculative-pre-warm primitive to the

hottest class. Add the rule to §A.1's cousin + §B.7 cache layer 2; budget in §B.4/§B.5.

scene." Moves the flagship off best-effort onto reliable.

ENHANCE §C + F.3 — make the faction director EARN its complexity with evidence

§C is the densest engineering + carries the most validation, yet F.3's gate says the world sim is coherent

highest-canon-risk / lowest-perceived-ROI.

vs (b) utility-AI-weights-only; measure whether playtesters perceive a difference. Keep §C sequenced last.

shippable) + thin/defer the LLM-director, reallocating engineering to the dialogue classes where

aliveness is most felt. The deterministic sim is the floor; the LLM-director is upside that must prove it.

RULED — smaller closes

("deterministic text mode"), NOT bitwise-identical regenerated text (continuous batching + batched-matmul

FP non-associativity make same-seed-same-logits unachievable across batch/HW/driver). Soften the §B.10

claim; deterministic-text-mode is the canonical speedrun/verification mode.

tier (no NPU, bandwidth-bound); the 14B reference targets high-VRAM PC + 2030 next-gen. Platform-parity-

of-experience is a conscious devkit-gated decision; the floor guarantees correctness on every tier, only

prose variety differs.

telemetry) — deliberate (privacy, no per-query cost, no lock-in), stays default. Compensate by making the

QA corpus deliberately adversarial + broad (red-team fixtures feeding §5). An optional future opt-in

telemetry tier could enrich the loop without breaking the offline default — FLAGGED, not adopted.

Net

2 pure additions (vividness metric, combat pre-warm), 2 evidence gates (register-LoRA go/no-go, faction A/B),

1 number closed (14B ladder), 3 honest re-labels (replay, platform, offline). All ride F.0-F.6 + the

authored floor; none is a blocker — the design ships on defaults regardless.

Generated by harness/site/structure_site.py — the URL path is the repo path. review root