RPG Mode — Design Document

Overview

Story-first platforms have one known complaint about games: "the dice aren't real, the AI just decides whether you succeed" (AI Dungeon reviews, docs-internal/product/competitive-research-latitude-aidungeon-voyage.md:76). Voyage sells the fix as its product: the engine decides, the narrator describes. Our Game Direction (docs-internal/vision/GAME_DIRECTION.md) names the same gap from the inside — the check / resolution mechanic is MISSING (GAME_DIRECTION.md:121-122).

RPG mode closes it with five mechanics:

All five are one thing underneath: something happened in this turn that isn't prose. They ride the chat events model, not four bespoke features (owner, 2026-10-28: "we should do this as a whole").

Where it lives — a Hybrid package, played in the RPG console

Game Direction's second principle (owner, 2026-09-20): chat and games are two surfaces over the same primitives. The owner's framing (2026-10-28) sets what each surface sells:

The package carries the contract; the reader plays it. An RPG game is a package with an RPG config. Its creator picks the dice system and the options and defines attributes, skills, items and the starting sheet. A reader starts the package and plays — rolling, using skills and items — but changes no rule. That answers Game Direction's fork #5 ("is a game a Package?") with yes, and fork #4 (rules ownership) with a split: dice systems are platform, the content they resolve is the package's.

It is always Hybrid. The AI game master is the beat leg, exactly as the Visual Novel's director is: a VN run is a Hybrid conversation with a scene graph bound to it (docs-internal/visual-novel/VISUAL_NOVEL_PROTOTYPE.md:23-29). An RPG story is a Hybrid conversation with an RPG config bound to it. Every design line below is judged by the VN's test: is this Hybrid with a value pinned, or new machinery? Package start lets readers pick the pipeline since the mode_locked pin was retired (hybrid-pipeline.md Package start, 2026-09-20); an RPG package is the one exception — fn_create_conversation_from_package starts it as Hybrid whatever the reader's preference, because the config can't run without the director. The exception keys on the package having an RPG config, not on the retired column.

It plays in its own console. A locked contract with visuals of its own needs a surface built around it, not controls bolted onto a freeform one — so RPG mode gets the RPG console, the games surface, exactly as the Visual Novel got visualNovelConsole:

Ready to elevate. The config is one validated document. At start the conversation copies the package's config (web_conversations.rpg_config, with the dice system's key and version), so a creator editing the package never changes a running story. Elevating to readers later is making selected fields of that copy reader-writable through the same validator — no new shape, no migration of the config.

Level Who sets what When
L1 the package creator sets everything; readers set nothing v1
L2 readers change chosen options on their copy (difficulty shown/hidden, re-roll policy) later
L3 creator-authored dice systems through the same validator later

Chat first — the primitives land in chat, the game stays in the console

The two surfaces are one set of building blocks under two contracts. In chat a block plugs into the freeform: it's optional, the reader configures it, and the text stays correctable around it. In the console the same block is locked into the package's tested contract and drawn as game UI. So every block that makes sense without a package's rules is built in chat first — real product, not a test harness — and the console takes the same code and locks it. That order also proves the riskiest machinery (staging, the composite guard, the seam resolution, delta ops) on real chats before the console exists.

Building block In chat (a plug-in to the freeform) In the RPG console (locked, tested, drawn)
Dice A dice control in chat.'s composer: free notation and quick dice, Roll now / Roll with my message, the cue and the line. Classic and Hybrid The dice tray, with the sheet's skills and items in it
Checks A bare check: a label, a tier and an optional modifier, read by the dice system the reader picks for the story (§1) Skill and item checks with modifiers from the sheet, declared effects
AI-called checks Hybrid only: "The AI may call for checks". The director picks an action and a tier from a code-built menu; the server rolls The same, with the package's skills and usable items in the menu, and the package's mode preset
Tracker kinds Resource, currency, conditions, XP, clock, inventory (a bag without Use) in the tracker form, with their renderers and delta ops. Readers can correct values, as with every chat tracker The package's contract set, plus attributes and skills, seeded from the sheet, read-only
Place The built-in Place tracker (LOCATION_TRACKER.md M1–M2) Locked under the map's mapped prefix (§7)
Inventory The uncatalogued bag kind: names and counts, correctable The package's catalog: item icons, equip slots, Use with effects
Map travel — The console only: the layered map, pins, routes, the party marker

Chat's settings for these live where every chat feature's do: Settings → Features (the user's default) and the story's own settings, off by default, so a reader who never turns them on sees chat exactly as today. They ship to every signed-in reader like any chat option — the staff-only gate is the console's, not the primitives'.

The pieces are built where both consumers reach them from the start: the dice control, the cue and the line in shared/src/chat/events/, the dice engine and the check resolution in Core. The console's tray is the chat control with the sheet added, not a second one.

The VN gains checks too. Luna wants exactly this ("Player asserts a theory, system adjudicates"). A VN transition may carry a check (door.force needs Strength vs Hard). It is the same check primitive the director calls in RPG mode, so it is built once.

Design Goals

  1. Code is god of what is. Every number — every die face, every total, every HP point — comes from server code. The story model never rolls, never sets a difficulty, never writes state. There is no "narrative dice" mode.
  2. The event is true before the cue plays. The Dream Shards cue rule, verbatim: a cue describes something that already happened; skip every cue and the story is identical (dreamShardsConsole/src/anim/cues.ts:1-25).
  3. One event model. Rolls, checks and item use are event kinds in the research's approach B, not columns of their own.
  4. The snapshot stays the tracker truth. Contract trackers live in tracker_json like every tracker; branch, the summary timeline and corrections keep working; only the eval write and its failure path learn to apply event ops.
  5. Pinned now, elevatable later. The creator's config is data in one validated shape, copied onto the story; a reader layer later writes the same shape. Nothing is hard-coded that a later level would have to dig out.
  6. A story that doesn't use these features is untouched. No events → byte-identical prompts, same number of eval calls. Classic gains only what a reader turns on — dice, bare checks, tracker kinds; never AI-called checks or the game.
  7. Chat first. A primitive that works without a package's rules ships in chat before the console, and the console reuses that code with the contract pinned.

Non-Goals

Deliberately out of scope:

The primitives

1. Dice systems and the package's RPG config

Two documents, split by owner (fork #4):

// dice system — platform
{
  "key": "d20_fantasy", "version": 1, "label": "d20 Fantasy",
  "check": {
    "dice": "1d20",
    "resolution": "dc",                      // dc | bands | roll_under | pool
    "advantage": true,                       // adv/dis allowed
    "crit": { "success": 20, "failure": 1 }  // natural faces, null = off
  },
  "difficulty": { "easy": 10, "medium": 15, "hard": 20, "very_hard": 25 },
  "modifier": "half_minus_5"                 // how an attribute value becomes a modifier
}
// RPG config — the package's (copied to web_conversations.rpg_config at start)
{
  "v": 1,
  "diceSystem": { "key": "d20_fantasy", "version": 1 },
  "mode": "both",                            // deterministic | game_master | both
  "options": { "advantage": true, "crits": true, "difficultyShown": true,
               "secretRolls": false, "checksPerTurn": 1, "reroll": "once" },   // reroll: none | once
  "attributes": [ { "key": "str", "label": "Strength" }, { "key": "dex", "label": "Dexterity" } ],
  "skills": [
    { "key": "lockpicking", "label": "Lockpicking", "attribute": "dex",
      "description": "Opening locks without the key.",
      "effects": { "critical_failure": [ { "tracker": "hp", "op": "damage", "amount": "1d4" } ] } }
  ],
  "items": [ /* inventory.md's item fields + "effects" */ ],
  "trackers": [                              // the contract tracker set, see §4
    { "key": "hp", "kind": "resource" },
    { "key": "attributes", "kind": "attributes" }, { "key": "skills", "kind": "skills" }
  ],
  "sheet": { "hp": { "current": 12, "max": 12 }, "str": 12, "dex": 15, "lockpicking": 1 }
}

trackers is the story's whole tracker set. Every tracker an effect, a cost or the sheet names is listed there with its kind (hp above: the Lockpicking effect and the sheet both name it). A config that names a tracker it doesn't list is refused on save, with every other problem: a running story holds only its copy of the config, so the copy has to say which trackers it plays by.

reroll is none or once. An earlier draft of this example spelled it once_per_turn; that spelling is still read, as once.

System dice systems shipped in v1 — these are the "various options" for deterministic dice, picked by the creator:

Key Check Outcome
d20_fantasy 1d20 + modifier vs a difficulty number success / failure; natural 20 and 1 are crits
story_2d6 2d6 + modifier, no difficulty bands: 6 or less miss · 7–9 partial · 10+ hit
percentile 1d100 roll-under the skill value success / failure; doubles under = critical
dice_pool N d6, N = attribute + skill count faces of 5+; 0 fail · 1 partial · 2+ success

Every resolution produces one value from a shared tier vocabulary: critical_failure · failure · partial · success · critical_success. Prose, lines, cues and effects key on the tier, so a dice-system swap never breaks a consumer.

The bare check — a check with no sheet. Chat has no attributes or skills, so each dice system also declares how a check reads from just a difficulty tier and the reader's modifier (a whole number, −10 to +10, default 0). The console's skill checks are the same resolution with the modifier computed from the sheet.

Key Bare check
d20_fantasy 1d20 + modifier vs the tier's number
story_2d6 2d6 + modifier + the tier's shift (easy +1 · medium 0 · hard −1 · very hard −2), read in bands
percentile 1d100 under the tier's target (easy 75 · medium 50 · hard 25 · very hard 10) plus 5 × modifier
dice_pool 3 + modifier + the tier's shift d6 (at least 1), counted as above

In a chat story the reader picks the dice system in the story's settings (default d20_fantasy); the record carries its key + version either way.

2. The dice engine

Core/Services/Rpg/Dice/ — pure, HTTP-free, no LLM.

{ "notation": "1d20+3", "faces": [14], "kept": [14], "modifier": 3,
  "modifierParts": [ { "label": "Dexterity", "value": 2 }, { "label": "Lockpicking", "value": 1 } ],
  "total": 17, "against": { "tier": "medium", "value": 15, "shown": true },
  "outcome": "success", "crit": false }

3. Checks — who calls, who sets the difficulty, who rolls

The request was an AI mode and a deterministic mode with options. They reconcile with goal 1 only as two independent axes — the server always rolls:

Axis Deterministic AI
Who calls for the check the reader (Roll control, Use skill, Use item) or a rule (Story Scripts, later) the AI game master — Hybrid's beat leg, picking from a menu of legal checks
Who sets the difficulty the dice system's table (difficulty), or the skill/item's declared value the game master picks a named tier (easy … very_hard), never a number
Who rolls the server the server
What the outcome does declared effects — the skill or item says what each tier changes, code applies it narrated — the prose tells the tier; the tracker eval observes what changed

In chat the reader sets the axes directly in the story's settings: the dice system, "The AI may call for checks" (Hybrid only, off by default), difficulty shown or hidden, the re-roll policy. Chat outcomes are always narrated — there's no config to declare effects in.

Modes are presets over the axes, chosen by the creator in the package's config:

Options (the creator's, in the config; L2 may hand some to readers): dice system; mode; advantage/disadvantage on/off; crits on/off; difficulty shown or hidden (hidden: the line names the tier, never the number); secret rolls (game-master checks show only the outcome; faces are kept on the record for export); checks per turn (1–2, default 1); free notation in the tray on/off; re-roll policy (none / once per staged roll; none / once in the config).

Re-roll exists only before sending. A staged Roll now may be re-rolled once (if the policy allows), and the line says so. Once a roll is sent it is the turn's: no Re-roll, no discard. A staged roll can't be cleared either — the next send consumes it. That keeps every version of a reply narrating one roll without a "re-roll after the reply exists" case to define.

The game master's contract (AI mode). The VN blocking precedent in spirit (VN_SCENE_ENGINE.md:193-228) — a code-consumed field, a menu, a guard — with the director's lookups as the parsing model:

Not tool calling. The story model has no tool calling in the chat pipeline (NativeToolCalling / TextToolProtocol serve only the Assistant harness), and a mid-prose tool call would put the roll inside the reply, breaking the before-reply phase. The director is the only "decide before writing" slot, which is why RPG mode is Hybrid. A conversation's pipeline is fixed at creation (ConversationPipelineType), hence the package-start clamp.

4. Fixed-contract trackers (tracker kinds)

Today a tracker's value_type (freeform / numeric / percentage / enum / list / datetime) is chosen per tracker and the renderer only knows the type, not the meaning — hp and affection are both "numeric". A tracker kind is a system-defined template that pins key shape, type, range, renderer, eval vocabulary and prompt wording. A tracker bound from a kind keeps the kind's contract for its lifetime.

Kind Value Renders as Eval says (delta ops) Code enforces
resource (HP, MP, stamina) current / max bar with numbers; flashes on change damage n · heal n · set_max n clamp to 0 … max
attributes key → whole number, −20 to 100 sheet block with modifiers — (set by the game, from the package's sheet) the dice system's modifier rule
skills skill → rank, a whole number, −20 to 100 sheet rows with total bonus — (set by the game, from the package's sheet; advancement later) skill keys exist in the config
currency integer coin badge gain n · spend n never below 0
conditions list of label + optional turns chips with a counter add · remove turns counts down per reply in code, at the reply's snapshot write
xp xp (the level is derived from the thresholds, never stored) progress to next level gain n level thresholds from the config
inventory inventory.md's item state the bag + equipped slots add · remove · qty · equip · unequip catalog rules, stack limits, capacity
clock in-world minutes since the start Day 4 · evening (the tracker's day parts) advance <duration> never goes backwards

In chat, inventory is a bag without a catalog: items are names (or the entries of a linked item lorebook, the T1 link below), with quantities and capacity, and no Use. The catalog, equip slots that matter and item_use are the package's (§6).

Where a kind lives. Today every tracker is user-owned (trackers.created_by_user_id is NOT NULL, the only insert is fn_upsert_tracker) and there is no template or system flag. A kind is therefore a column, not a row owner: trackers.contract_kind (NULL = a free tracker, as today), mirrored by hand across the SQL CHECK, a C# enum and the TS const like value_type is. A kind's own settings — a resource's starting max, XP's level thresholds, the clock's day parts, a bag's capacity — sit on the tracker row in one trackers.kind_config JSON column, validated per kind, so the kind works without a package. One column rather than one per setting, because every new column is a fn_upsert_tracker signature change mirrored in C#, TS and the Composer apply path (78:112-113, 68e_composer_apply_functions.sql:205). The row holds starting settings only; the live value — a resource's current / max after a set_max — is the snapshot's.

In chat a kind is one more choice in the tracker form (Forge and the workbench's tracker editor), offered next to the value types: resource, currency, conditions, XP, clock and inventory. Attributes and skills are not offered there — they mean nothing without a package's attribute and skill lists. Its values stay correctable by the reader like every chat tracker; delta ops, the cap and the renderer are the same code the console uses.

A reader can add one to their own story. Today trackers bind only to a character (owner_type 0) or a package (6), and nothing writes conversation bindings yet (TrackerSetUnion.cs:34-35, trackers.md T2) — so a reader playing someone else's character couldn't get an HP bar or a bag at all. M3 lands conversation bindings (owner_type 4, already allowed by the CHECK): the reader adds a tracker — kind or free — to the story from its settings, and TrackerSetUnion gains the conversation leg. A creator still binds kinds to their characters and packages as today.

In an RPG package the creator adds kinds in the package's RPG step; each becomes an ordinary creator-owned tracker with the kind set, bound to the package (owner_type = 6, written today by fn_save_package_full), so a story started from the package resolves them through TrackerSetUnion like any package tracker. The contract is enforced by the kind, wherever the row came from.

Storage stays the flat snapshot. A structured kind's value is a canonical JSON string, the way list already is (TrackerValueFormatter). Nothing new is added to web_messages for state; branch, the tracker_state lock and the summary timeline keep working unchanged. Two writers do change — the eval write and the eval-failure path — see Declared effects below.

The eval emits deltas for structured kinds, never a restated whole. A resource gets damage 3, not a fresh current: 11; an inventory gets add health_potion, not a re-listed bag. Code applies the op, clamps, validates and writes the snapshot. A restated whole is how state silently drops items — the same mismatch the living lorebook's relationships and the journal both had before their merge ops (commit 7329a48ab).

Declared effects are ops on the event, re-applied at every snapshot write of the reply. A value written once at storage doesn't survive: the eval builds the reply's state from the prior row and writes the whole map (WebTrackerEvalService.cs:209,294-308,364-366; fn_write_tracker_eval_snapshot never reads the target row's own tracker_json, 78_tracker_functions.sql:894-933), so it would clobber the effect. A storage-time value would also read a stale prior while the previous reply's detached eval is still in flight, and would move the eval's catch-up watermark (any non-empty earlier snapshot anchors it, WebTrackerEvalService.cs:562-566).

So an effect is stored as an op on the event record (hp damage 4, dice already rolled into the amount) and applied by C#:

There is no storage-time write, so the stored snapshot lands when the eval writes (or on the failure path), and the existing conversation_trackers push carries it. The sheet doesn't wait for it: the console projects the turn's event ops onto the last snapshot for display the moment the event arrives — the event is already true, the same cue rule — and swaps to the stored snapshot when the push lands. The dice land on "−4" and the HP bar drops with them.

An RPG story pins the per-conversation trackers feature on (FeatureId.Trackers — the reader has no switch for it) and its eval cadence to per_message. The platform-wide Features.EnableTrackers stays the operator's kill switch; with it off, RPG packages can't be started.

The starting sheet is the opening snapshot: fn_seed_opening_tracker_snapshot / OpeningTrackerSnapshot seed it from the conversation's rpg_config.sheet, so the first reply's prior is the package's sheet, not each tracker's generic initial value.

Readers don't edit the sheet. In an RPG story the scene editor is read-only for contract trackers — HP set by hand would make every check meaningless. Free trackers in the same package stay editable as today. (Hand-correcting a mis-applied effect is an L2 question.)

Attributes and skills are set by the game only. The two sheet kinds take no eval op, and a reader can't change them anywhere a chat tracker is corrected; the refusal names the tracker: "Attributes: the game sets this, so it can't be changed here." Their creator can rename the row, describe it and show or hide it, but not change its key, kind, type or start value: the package's config finds the row by its key, and the starting numbers are the config's sheet.

Hidden stays hidden. A contract tracker with "Visible to the user" off never appears in an event line, a target or a cue (the research's SCENE-GATE extension, §3.9).

5. Skills

A skill is defined in the package's config (key, label, governing attribute, description) and ranked on the sheet (the skills tracker). Using one is a check: modifier = attribute modifier + rank bonus, rolled with the dice system's dice.

How each dice system reads the sheet (as built for M5; the three rows after d20_fantasy are defaults, see Open Questions):

Key Skill check
d20_fantasy 1d20 + attribute modifier + rank against the tier's number; the attribute modifier is half the attribute, rounded down, minus 5 (10 gives 0, 15 gives +2)
story_2d6 2d6 + attribute modifier + rank + the tier's shift, read in bands; the attribute modifier is d20_fantasy's (half the attribute, rounded down, minus 5), never the raw value
percentile 1d100 at or under rank + (the tier's target − Medium's); the attribute isn't used
dice_pool attribute + rank + the tier's shift d6, at least 1 die and at most 100, counted as in §1

A skill may declare cost (paid before the roll, e.g. mp -3) and effects per tier (e.g. a Heal on success: hp heal 2d4). A skill with no roll — an ability — is a cost plus effects with an automatic success.

6. Inventory

Inventory System is the design; RPG mode makes two decisions it left open:

Catalog only in an RPG story. Items exist only in the package's catalog; an unknown item from the eval is dropped and logged. Chat's uncatalogued bag (§4) is the same kind with the catalog check off.

Reused, not rebuilt:

7. Map travel (layered)

Where the party is, is what is — code owns it. The model narrates the road; it never moves the party across the map.

The places are the Place tracker's places. Chat is getting a built-in Place tracker (docs-internal/architecture/chat-engine/LOCATION_TRACKER.md, planned): value type Place = 6, a path of names from widest to narrowest (["Ardent Coast","Saltmere","The Drowned Lantern"]), lorebook entries flagged This is a place with an Inside parent (lorebook_entries.is_place / parent_place_entry_id), Living Lorebook places beside them, and the current place plus its nearest ancestors pinned into knowledge. RPG mode uses that tracker, not a second one: the same value type, storage (a name path in tracker_json, never ids), resolver (PlacePathResolver), place index (IStoryPlaceIndex), breadcrumb, pins, timeline and history formatting. Its hierarchy is the map's hierarchy — an RPG package's places are lorebook place entries in its lorebook, and the map adds only what Place deliberately leaves out (its Non-Goals: maps, coordinates, travel time, distances). LOCATION_TRACKER.md §10 records what RPG mode needs from it.

What the map adds — a spatial layer over the place tree. A map layer belongs to one place entry (or the root) and shows that place's child places as pins on a picture, with routes between them. Ardent Coast (a place) has a layer whose pins are its children Saltmere, The Gull Steps, Wreckers' Cove; Saltmere has a layer with The Drowned Lantern, Harbour market, The Tide Chapel. Depth comes from the lorebook's Inside chain; the map never restates it.

// in the package's RPG config — places are referenced by lorebook entry (the config is authored and validated
// against the package's lorebooks; tracker snapshots still store names only, as Place requires)
"map": {
  "v": 1,
  "layers": [
    { "place": null,                                  // the root layer: top-level places
      "image": "gallery:8812",
      "pins": [ { "entry": 5101, "at": [0.42, 0.61] }, { "entry": 5102, "at": [0.70, 0.30] } ],
      "routes": [ { "from": 5101, "to": 5102, "time": "3d",
                    "cost": [ { "tracker": "rations", "op": "spend", "amount": 3 } ],
                    "encounter": { "chance": 0.25, "table": "coast_road" } } ] },
    { "place": 5101,                                  // Ardent Coast's layer: its child places
      "image": "gallery:8813", "entrances": [ 5120 ],
      "pins": [ { "entry": 5120, "at": [0.31, 0.44], "discovered": true } ],
      "routes": [ { "from": 5120, "to": 5121, "time": "4h", "when": { "flag": "bridge_repaired" } } ] }
  ],
  "start": 5140                                       // a place entry; the start path is its Inside chain
}

Mapped places are mechanical; below them the story wins. The Place tracker's rule — the story wins, an unknown place is recorded, never refused — still holds, but only below the deepest mapped place. In an RPG story:

The state — the Place tracker, the clock kind and one map-only kind, discovered:

Tracker Value Renders as Eval says Code enforces
Place (the built-in) a name path the breadcrumb Ardent Coast › Saltmere › The Drowned Lantern segments below the mapped prefix only travel events own the mapped prefix
discovered a set of place paths (names, like Place — no ids in a snapshot) fog on the map reveal <place> (mapped places only) unknown places dropped
clock (§4, shipped in chat first) in-world minutes since the start Day 4 · evening advance <duration>; travel advances it by the route's time never goes backwards

Moving. Two callers, as for checks (§3):

The travel event (before-reply, on the reader's row) records the path, the time and cost ops, the encounter roll and its result. Its line: — Travel · Saltmere → The Gull Steps · 4h · encounter: none —. Its cue: the party's marker walks the route on the map. Its prompt block (TravelOutcome, both legs for a reader move, prose only for a game-master move): "The party travels from Saltmere to The Gull Steps by the cliff road, about four hours. Nothing waylays them." Its ops land on the Place tracker, clock and the cost trackers by the same rule as every effect (§4).

The place's lore follows the party — through Place's own pins. LOCATION_TRACKER.md §6 already pins the current place's entry and its nearest ancestors (cap 3, budget-exempt, leg tracker). RPG mode adds nothing there; a travel event that lands a new path moves the pins on the next turn exactly as an eval-recorded move does. A place the party hasn't discovered is never listed in the eval's Known places, never pinned, and never named on a line or the map.

The map in the console. A full-screen layer (desktop: beside the transcript; phone: a sheet) drawn from the layer's gallery image, pins and SVG routes on top, in render layers: art → routes → fog → pins → the party marker. Undiscovered places are hidden or fogged by the creator's choice. Pinch / scroll zooms; tapping a place that has its own layer drops into it; the breadcrumb climbs back up. Keyboard: arrows move between pins, Enter opens, Escape climbs.

Depends on LOCATION_TRACKER.md M1–M2 (the Place value type, the place flag and Inside parent on entries, the place index, the pins) and its §10 RPG requirements. M10 builds on them; it doesn't build a second place system.

Not in v1: tile or hex grids on the travel map (the scene grid inside one place is in, owner decision 2026-11-12, see the map-layers plan), free movement between pins, procedurally generated maps, other actors moving on the map (NPC positions stay narrative), and a reader editing the map.

The ultimate form, later: a 2D moving mode (owner, 2026-10-28). The party walks a 2D scene instead of jumping between pins — the reader moves their character through a place, and walking up to a door, a person or a chest is how a turn starts. It is a presentation over the same truth: code still owns position (finer-grained than a place path), travel is still a travel event, and what happens on arrival is still narrated. Building the layered map on code-owned places, events and lorebook places now is what keeps that door open; nothing in v1 assumes position is only a pin. Its own spec when it comes.

Chat events: the answers this plan needs

The research's questions are now decided in docs-internal/architecture/chat-engine/CHAT_EVENTS.md §1 (2026-10-28); the table below matches it.

# Question Lean Why
O1 Shape B — turn_events on the row, staged_events on the conversation, one catalog, tracker changes derived Dice, skills and items are three stored kinds; A pays the seams three times
O2 Does a regenerate re-roll? No — not a reader roll and not a game-master check: both live on the reader's row and every version narrates them. Re-roll exists only on a staged roll, before sending, and the line says "re-rolled" Otherwise swipe is a free re-roll
O3 Who calls a check? Reader first (M2, chat), the AI (M4, chat Hybrid), rules with Story Scripts; in an RPG story the package's mode picks §3
O4 Do outcomes replay in later prompts? No — one-shot; the prose and the snapshot carry it Byte-identical prompts for event-free turns; no history bloat
O5 Public pages show events? Owner decides Product call
O6 Feature off: do recorded events render? Yes — they are a record; only injection and landing stop —
O7 Same change before and after: one line or two? One merged line for directions; for a check, the check line then the tracker change (they say different things: 17 vs 15 and HP 14 → 11) —
O8 chat-v2 parity Dice and checks are controls in chat., lines (read-only) in chat-v2; tracker kinds render in both chat. is the chat surface that grows; chat-v2 reads the same records
O9 Rules ownership in the record The record carries the dice system's key + version, never rules Ownership can move without a record migration

Event kinds these primitives add (all before-reply, all stored on the reader's row except where noted):

Kind Source Data Prompt block (legs)
dice_roll reader the dice record, a free-text label DiceRoll (both legs)
check reader a skill (RPG) or a label (a bare check), tier, dice record, outcome, effect ops (RPG only) CheckOutcome (both legs)
check game master (the AI, in chat or RPG) as above; the action text for a bare check CheckOutcome (prose leg only, appended with the director's note — §3)
item_use reader / game master item slug, effect ops, any dice CheckOutcome (as check, by source)
travel reader / game master path, time and cost ops, encounter roll and result TravelOutcome (as check, by source)

A game-master check belongs to the turn, not the version. If it lived on the reply row, a swipe would re-run the director and re-roll — the free re-roll O2 exists to forbid. So the first game-master check of a turn is written onto the reader's row (source game_master) — staged first on a send, see §3 — and every later version of the turn reads it:

The dice animation

The outcome is fixed before the model writes, and the animation plays anyway — goal 2 makes that the design, not a trick. The cue is told the recorded faces; it tumbles and lands on them.

When Delivery What the reader sees
Roll now (reader, before writing) the roll endpoint returns the record; it is staged dice tumble in the dice control (chat.) or tray (console), land; the reader writes knowing the outcome
Roll with send (reader) a new SSE events frame — on Hybrid emitted with the beat_running stage frame (ChatPipeline.cs:488), because start only comes after every pre-stage, director included (:681,689), too late; on Classic in the gate slot after the last pre-stage, before start (ChatPipeline.cs:603-610 — never between pre-stages, which would lose the turn's embedding accounting) dice tumble between the reader's turn and the reply while the director thinks (Classic: before the first token)
Game-master check the events frame at the beat → prose stage change dice tumble under the reader's turn; the reply streams in under them
Reload, history, export the stored record the line with the final faces; cues never replay

One refinement to the research's rule. The research says a cue never blocks the prose (§3.4). For a game-master check the first tokens can arrive mid-tumble and spoil the result. So the client holds the reveal, not the stream: tokens keep arriving and buffering, and the reply appears when the dice settle, capped at 1.6 s; a tap skips it. Reduced motion: no cue, no hold.

The line (the accessible text, the PDF line, the Discord line later): — Lockpicking · 14 + 3 = 17 vs Medium 15 · success —. With a hidden difficulty: — Lockpicking · 14 + 3 = 17 vs Medium · success — (the sum stays; only the number it is against goes). With secret rolls: — Lockpicking vs Medium · success —. (d20_fantasy's numbers: Easy 10, Medium 15, Hard 20, Very hard 25.)

The cue is 2D (SVG dice per die size, d4–d20 and d100), lives in shared/src/chat/events/cues/, and has a coverage test: every event kind declares a line and declares whether it has a cue.

Wire. The events frame is a new PipelineTokenType, a case in WebChatSseFrames.MapPipelineTokenToEvent and the VN mapper, null in the protected-reader mapper (WebChatSfwSseFrames.cs:51-78 — the SFW lane is Classic-only, so an RPG turn never reaches it; a protected reader's chat roll gets its line from the stored record on read, with no cue), and a new type with its fields on the ChatStreamFrame interface (shared/src/types/chatStream.ts:100). It stays out of done, whose key set is pinned by ChatSseDoneFramePromptTests; the stored record reaches a reload through the message read.

Surfaces

Chat — the primitives (chat. first)

Authoring — the package creator

Play — the RPG console

The play surface's structure follows the phone board docs-internal/mockups/RpgPhone.dc.html ("walk the scene, chat on arrival, the bar"), as the owner answered it (2026-11-06). The board's names, numbers and dice are sample content: they size and stress the UI and seed the prototype's fixtures, and they decide no rule.

Narration stays open; mechanics don't (owner, 2026-10-28). The reader fixes details of the text exactly as in chat: regenerate a reply (full or prose-only), edit a reply's text, edit their own message. None of that touches the mechanics — no edit or regenerate rolls, re-rolls, or re-applies an effect; every version narrates the turn's recorded rolls and checks, and the sheet moves only by event ops and the eval. The sheet itself is read-only to the reader.

Elsewhere

Cost

Implementation Plan (Sliced)

Milestone Scope Push unit
✅ built 2026-10-28 (19df61402) M0 — events projection CHAT_EVENTS.md M0: lift the derived tracker-change projection from chat.'s sceneModel.ts into shared/src/chat/events/; the stage direction, chat-v2 and the PDF read it. Behaviour-preserving own
✅ built 2026-10-29 (1b3c515a3, bd0f1f850) M1 — event storage + direction CHAT_EVENTS.md M1: turn_events, staged_events, every seam (branch copy, insert function, record, DTO, JSON export, PDF, SSE events frame); tracker transitions rebuilt on it one unit
✅ built 2026-10-29 (87e86280d, c8cb6fb53, 320972242, 926a67faf) M2 — dice + bare checks in chat Dice engine, the dice-system catalog + validator with the four system dice systems and their bare checks; dice_roll and reader check kinds; the roll endpoint (staged roll), Roll with my message at the send door, Re-roll by policy; DiceRoll / CheckOutcome blocks; the cue + the line in shared/src/chat/events/; chat.'s dice control and the story's dice settings (user default + story, off by default); chat-v2 lines. Classic and Hybrid own
🚧 in progress 2026-11-22 (the three owner decisions are made, with their defaults; conversation bindings shipped with trackers T2, 703cd43c0) M3 — tracker kinds in chat trackers.contract_kind + kind_config (the column already landed with Stage trackers, with one kind; M3 widens it); conversation bindings (owner_type 4, the TrackerSetUnion leg, add-a-tracker in the story's settings); resource, currency, conditions, XP, clock and the uncatalogued inventory bag; the eval's delta ops applied after the drift-merge; per-kind value caps that refuse at every writer; the kinds in the tracker form; kind renderers in chat.'s scene and chat-v2's tracker bar (shared components); kind-beats-free precedence in TrackerSetUnion; condition turns ticking on the snapshot write paths; the raised Tracker.DefaultMaxTrackers own
✅ built 2026-10-31, off by default M4 — AI-called checks in chat Hybrid: the checks beat field (bare checks), the code-built CheckMenu with the contract text, the composite IBeatGuard, attempt-2 accept-without-checks, resolution in the beat-direction seam, staging + the turn-pinned check (full and prose-only regenerates replay it, the guard refuses new checks), the reveal hold, the eval reading the outcome on check turns; the story setting own
🚧 built and landed 2026-11-23 (f51646f0d, f057a9f98, e6b3216f5, d5f960d67 pushed; 1d850767f, 94ff8fcf2 not pushed); the rpg. edge prefixes not landed; partly proven live locally M5 — the RPG console + package config + sheet Lift the VN console's shell into shared/; the RPG console (shelf, story view on the shared story renderer, sheet column, composer with chat.'s dice control + the sheet, read-only rules), its Railway service and worker route, staff-only; packages.rpg_config + its validator, the copy to web_conversations.rpg_config at start, the Hybrid start clamp and the Start route; the seeded package; the attributes and skills kinds; the opening snapshot from rpg_config.sheet (fn_seed_opening_tracker_snapshot / OpeningTrackerSnapshot); skill checks with sheet modifiers; declared effects as event ops through CHAT_EVENTS.md §6's landing; the console's projected display of ops until the snapshot lands; the read-only sheet; the trackers feature pinned on one unit
📋 M6 — inventory (RPG) The package's item catalog on the inventory kind, equip slots, the bag panel, item_use, item effects with dice own
📋 M7 — game master (RPG) The package's skills and usable items in M4's menu, the mode presets (deterministic / game master / both) from the config, the seeded RPG Game Master / RPG Prose style modes own
📋 M8 — creator authoring The workbench RPG step, the package page line, package save of contract trackers own
📋 M9 — VN checks A VN transition may require a check; the scene engine resolves it with the same primitive and M4's composite guard own
📋 M10 — map travel Needs LOCATION_TRACKER.md M1–M2 and lands its §10 (R1–R11). The map document + validator over the place tree; the Place tracker as the location, the discovered kind (clock is M3's); the console's layered map view; reader travel (travel event, path + cost + encounter rolls, the walk cue, TravelOutcome); the game master's move (after M7); the map step in the workbench (after M8) own

M0–M1 are CHAT_EVENTS.md's milestones (M1 carries tracker transitions). M2–M4 are chat and ship to readers on their own. Every one of M2–M4 needs M1 (staging and consume, the current-turn injector base, the events frame, fn_write_tracker_eval_snapshot_with_effects); M3's condition ticking also needs M1's no-eval write. M2 and M3 are independent of each other; M4 needs M2. The Place tracker (LOCATION_TRACKER.md M1–M2) runs in parallel on chat. M5 needs M2–M3; M6 needs M3 and M5; M7 needs M4 and M5; M8 needs M5; M9 needs M4; M10 needs M7 and M8. M8 can move ahead of M7 if creators should build RPG packages before the game master exists.

Open Questions

For the owner:

Decided here (engineering): dice systems are platform, content is the package's (fork #4); the config is copied onto the conversation at start; the Hybrid start clamp keys on the RPG config; the tier vocabulary; storage in the flat snapshot; trackers.contract_kind as a column; contract trackers bound to the package; Tracker.DefaultMaxTrackers raised (owner: bounded by model input); a contract tracker beats a free one on the same key; structured values refuse over their cap, never truncate; delta ops; effects as ops on the event, applied at the eval write and on eval failure (no storage-time write); faces on every record; game-master checks resolve in the beat-direction seam and are pinned to the turn on the reader's row; Re-roll only before sending; outcome-neutral beats on check turns; no tool calling; the reveal hold (1.6 s cap); 2D cues; the menu is director-only; the console lifts the VN console's shell into shared/; chat's primitives — reader dice and bare checks (Classic and Hybrid), AI-called bare checks (Hybrid), tracker kinds without attributes and skills — ship to every signed-in reader, off by default; each dice system declares a bare check; the check contract's text lives in the code-built menu, not in a mode; chat.'s dice control is the console's tray with the sheet added.

Acceptance Criteria

The feature is not done until every box below is verified ✅ against the running product. Each milestone gates on its own block plus every invariant.

User use cases — satisfiable + accessible (verify by driving the UI, not the code):

Chat (M2–M4):

The RPG console (M5–M10):

Both:

Behavior:

Invariants that must stay true (carve-outs):

Edges: