Files
tiny-worlds/README.md
T

574 lines
33 KiB
Markdown
Raw Normal View History

# rp-test
Long-form, freeform, text-based roleplay where the model plays **one character**
and the human plays **everything else**.
## The premise
Using a model as the GM hits the contwin (context window) wall and dilutes creativity —
it has to hold the whole world in its head. Inverting the roles fixes the
footprint: a player-character holds one perspective. Short plays would work
fine either way; the actual test is **long, cross-session stories**: can the
model persist established lore without drowning in it?
More precisely: this isn't a model test, it's an instruction test. The subject
is whether a model can be taught to *decide what to write down*. Humans
forget; files don't — so the file must be shaped to forget too. The
product that test serves is the harness below.
## The goal
The memory test is not the end product. It exists to arrive at a usable
roleplaying harness — something people can enjoy making long stories
on. The end shape: clone and run it yourself, or get an invite to a
running instance. The LLM key lives on the backend, so invited players
get the functionality without the host disclosing secrets and without
bringing their own model. Correspondingly: this repo ships code and
authored content only — no run state, and never a secret in cleartext
(the config pattern is a committed example plus a gitignored real
file). As of 2026-11-14 the MVP substrate is complete: clerk, server,
housekeeping job, and SPA — see `node server/main.mjs` and open
`http://127.0.0.1:7350/`.
## Roles
- **Human = the GM.** The world, every NPC, all consequences, all retcons.
Runs on organic memory — no notes. The model's canon files are the prosthesis.
- **Player-model = one PC.** Inner life, voice, choices. Nothing else. Reads
memory, never writes it.
- **Housekeeper-model = a separate invocation**, fresh context, run after each
session. Reads the transcript and the rendered rings; emits a **manifest** of
semantic operations. Judgment, no clerical work.
- **`tool/memory.mjs` = the clerk.** Validates and applies manifests,
maintains the database, enforces caps, renders views, writes the log,
dumps canonical state. Fails loudly, never drifts silently.
## Scope
Tiny on purpose: a handful of locations, a handful of characters. Freeform —
no handbook, no stats. Anything goes if it makes sense and makes the story
better. Retcons are allowed but discouraged; when they happen they are
explicit and logged.
The harness currently supports **female PCs only** — names are inherently
gendered and the shared prompts say "she" throughout; the postulate is
cheaper than a gender system no customer has asked for yet. When a male
or otherwise PC ever needs support, this is the line to revisit.
## The deployment (multiuser)
A deployment is one clone plus `server.json`, `state/`, and `runs/` —
all gitignored state. The LLM key lives on the backend; invited users
need neither the key nor a local clone. Identity is a token, nothing
else: no usernames, no passwords, no external IDPs. A single-use
invite code — spent codes are recorded forever and rejected loudly on
reuse — is exchanged at claim time for a persistent token; display
names are freeform labels, collisions allowed. On a fresh deployment
(empty users table) the server mints the superuser's bootstrap invite
to `state/bootstrap-invite.txt` and the console; it is dead the moment
any superuser exists, and recovery for the superuser is filesystem
access. The superuser mints and revokes invites, lists and revokes
users — that is the whole of admin. Revocation destroys the identity:
no suspend, no restore; a returning user is a new identity, and
forking makes that cheap — stories outlive identities by design.
- Every API route except `GET /api/session` and `POST /api/claim`
requires a signed-in user (`Authorization: Bearer <token>`).
- **Runs belong to their starter.** Every mutation and every model
call is owner-only; every run is readable by any user — transcript,
status, rings, config, notepad included. The boundary is the model
boundary: gm.md is secret from the player-model, never from people.
Ownerless runs — pre-user, or the owner was revoked — are one
uniform state: readable, forkable, no owner actions, never
re-claimed. Ownership is resolved, never maintained: run.json keeps
the record, a dead owner id reads as absent.
- **Fork is the way in:** any user can fork any run, including their
own. A mechanical atomic copy — staged, swapped in by a same-volume
rename, under the run's activity lock — with the owner replaced. No
lineage is recorded (runs are entirely independent); the fork's only
mark is `forked: unixtime` in run.json, beside the carried-over
`created`.
- **Packages are system or user.** System packages ship with the repo;
a user can save their run's craft as a user package under
`state/packages/` — published to everyone, gm.md included (saving is
the act of publishing), the pc never riding.
- **Models are per-run over the deployment defaults.** `server.json`
names the defaults (player, housekeeper); a run's owner overrides
either role from the upstream listing — in setup for drafts, in the
play aside for started runs. Each call resolves fresh, so a
mid-session switch simply takes the next turn.
- Every logged LLM call records the acting user. Quotas and limits are
an extension point, not built.
- All dates and times are UTC everywhere. No time zones, ever.
## Runs
Two interleaved stories calibrate the memory system against itself:
| | `la-caramba` | `boutique` |
|---|---|---|
| entries per session | few — tiny cast, deep history | many — the customer parade |
| dominant ops | touch, reword | insert, gate, demote/retire |
| ring A pressure | staleness — standings shift on hot entries | clutter — obligations accrete |
| player agency | constrained — reactive creativity | full — proactive creativity |
| records access | none — until the GM unlocks it in the story | the card index on the shop PC |
Boutique is dormant and defunct — a stub that never reached its design
step — broken is fine until its drafting session gives it design and
proper content.
`node tool/memory.mjs packages` lists presets; `runs` lists instances;
`--run <id>` addresses a run for any command.
## Booting a run
Through the CLI below, or through the SPA: home → new run → pick a
package → edit the copied prompts (project prompts inspectable
read-only alongside) → **start** — which creates the run, opens the
session, and sends turn-0 as the first GM turn in one action.
1. **Backdrop** — write `packages/<story>/backdrop.md`: the world as everyone
in it knows it. Public knowledge, general setting. Neither memory nor
state — never touches the rings, never decays, always in the bundle.
The housekeeper is instructed to keep it out of the rings.
2. **Turn 0** (new games, optional) — write `packages/<story>/turn-0.md`:
the opening beat, the situation she wakes into — the GM's zeroth
turn. Sent once, as the first GM message of session one; after that
it is history, living in the session transcript. Its trailing
`<status>` block is her opening status, ingested at new-game.
Without it, the GM narrates the opening beat themselves.
3. **Character** — write `packages/<story>/character.md`: starting identity.
The sheet is a reduction of choice surface — a ledger of decisions
already made; "what would make sense" does the cutting. Three kinds of
field:
- **provided** — write it in;
- **random** — draft a few candidates, `node tool/memory.mjs pick "one"
"two" "three"`, write the winner. A roll is a decision made by nobody
that the player must honor — that's its whole value;
- **free** — leave blank; the player invents it through play, the GM
ratifies notable inventions afterward.
4. **Seed** — write `packages/<story>/seed.json`: the initial state of the
run. `entries` → the rings (initial memories), `records` →
pre-existing files (gated by `settings.json`). It applies lazily at
the run's first session-open — until then it rides the run copy,
freely editable; deleting it from the run is the opt-out. Everything
is journaled under session `seed`. Her opening status does not seed —
it rides turn-0's `<status>` block.
5. **Create the run** — `node tool/memory.mjs create <story> <pc-name>`:
the package is copied wholesale into `runs/<id>/` — the craft
prompt (`handbook.md`) rides along, battery
included — and the db is initialized. The run id is anonymous (it
carries no facts, so there is nothing to rename); the pc's name
and the package's display name land in the run's `settings.json`
and drive what everything shows: "La Caramba / Rell". Different
runs of the same package need different pc names. From then on
the run directory is the
only truth: the package is never read again, and everything in the
run is editable at any time. The discipline not to break a running
narrative sits with the GM.
6. **First session** — open it (the server assembles the bundle; until it
lands, manual relay), narrate. The first session-open of a fresh run
applies the seed, then ingests turn-0's `<status>` block.
## The protocol
1. **Refresh the views:** `node tool/memory.mjs --run <id> render`
2. **Open a session:** one system-role message is assembled in order:
`system.md` (glossary, purpose, input guards) and `invariants.md`
(the substrate's mechanical contracts) — both repo-fed — then the
run's `handbook.md` craft copy. Everything
else arrives as GM messages (user role), one message
per file: `backdrop.md`, `character.md`, `canon/ring-b.md`,
`canon/ring-a.md` — identity first, then memory, ring A in the
recency slot. Every GM turn is followed by the reminder —
`reminder.md` (repo-fed) as its own `role: system` chunk carrying
the turn-composition protocol; superseded copies elide from the
live view, so exactly one exists, always at the freshest end. On a new game, `turn-0.md` is the opening beat: its
trailing `<status>` block is ingested as her opening status at
session-open, and the beat itself is sent as the first GM turn when
play starts — a separate message through the turn path, not part of
the bundle. In play the current status rides every GM turn
the same way (the per-turn ride lands with the server). (On a tight
session, ring B is optional loading — ring A is the spine.)
Substitution has two classes: `@PC` (her name) and `@Package` (the
display name) are identity sigils resolved from the run's
`settings.json` `pc`/`name`; `$TOKEN`s are template vars declared
by the prompts themselves — every `$TOKEN` found in any prompt
surfaces as an input in the SPA's setup, and the run's `vars`
holds the answers (a package may ship defaults). Unresolved
sigils-of-ours and vars fail loudly before anything is sent; any
other `@`-word is the author's own text — `@` syntax is not owned
here — and passes through untouched. The server
assembles and logs all of this automatically (until it lands:
manual relay).
3. **In play:** a line opening with `(` is the out-of-character channel —
points of order, canon questions, proposals, vetoes; both sides use
it, closing paren optional. Entries carry stable ids (`[e17]`);
citing one is the precise way to reference a memory. The status
travels in-band: the current `<status>` block rides every GM turn,
and the player mutates it with `<lost>`/`<gained>` tags in its own
turns (the clerk applies the deltas — same-verb blocks combine into
one apply — and misses go back as a `<conflict>` turn of their own:
clean of prose, read it and adjust; the model heals in the same
exchange). The agenda rides alongside: `<agenda>` on every GM turn,
`<add>`/`<drop>` deltas in the player's turns — drops cite the
indexes it was shown. Records work
travels the tools (`records_search`/`file`/`amend`/`discard`) when
the run provides them; the CLI equivalents remain for the GM (`--gm`
marks GM-authorized writes). The full play protocol — format,
one-thing-per-turn, thoughts off the page, intent-form, immersion
over realism — lives in `system.md`, `invariants.md`, and
`handbook.md`. Through the server, the model's OOC is the `ask_gm`
tool; the GM's own OOC stays `(...)` in their turns.
4. **Close a session:** just stop. No in-band ritual; the player-model has no
end-of-session duties.
5. **Housekeep (fresh model, new context):** send `housekeeper.md`
(the repo-fed housekeeping prompt — substrate-internal, never
copied into a run), then
the run's `backdrop.md` and `character.md`, then both ring views, then
the session transcript — pasted, or the latest
`runs/<id>/sessions/*.jsonl` when playing through the server (the
phase-3 housekeeping job automates this). Save
its manifest to `runs/<id>/manifests/<session>.json`.
6. **Apply:** `node tool/memory.mjs --run <id> apply runs/<id>/manifests/<session>.json`
— the tool validates, applies, handles overflow, writes the run's
`log/<session>.md`, re-renders the views. A rejected manifest changes
nothing and says why.
7. **Review the log, veto or edit as desired, commit.** GM edits go through
`insert` / `delete` / `revive` commands.
## The memory model
State lives in **SQLite** (`runs/<id>/db/memory.db`); `canon/ring-*.md`
are generated views. Markdown survives as rendering, dies as storage — the
models see prose, the machine sees rows.
Memory is **seven tiers**:
| tier | what | in context | who writes it |
|---|---|---|---|
| **backdrop** | the world as everyone knows it — public knowledge, the general setting; never memory, never forgotten | always | GM, rarely (retcons) |
| **identity** | the character sheet — concept, drives, skills, voice; changes rarely | always | GM, rarely; housekeeper may propose via open questions; blanks are the player's to invent |
| **status** | descriptions of her immediate situation, admitted by a three-part gate: non-normal, acute, turn-affecting | every GM turn, as its `<status>` block | **the player** (`<lost>`/`<gained>` deltas in its turns); GM override out-of-band |
| **agenda** | her hot queue of intentions — what she's working towards right now; a fixed-cap recency buffer (new on top, overflow evicts the bottom), disposable by design | every GM turn, as its `<agenda>` block | **the player** (`<add>`/`<drop>` deltas in its turns, drops by index); GM override out-of-band |
| **rings A/B** | salient memory — facts, on her mind, MRU-evicted | always | housekeeper manifest |
| **records** | her files — the card index, the ledger. Narrow query only, hard cap 10 (in the tool, not the prompt), never bulk-loaded | never — on demand | **the player** (`file`/`amend`/`discard` at her desk); GM seeds; housekeeper only `archive`s |
| **cold** | forgotten or vetoed | never — not even queryable | GM only (`revive`) |
The boundary that keeps the tiers honest: **stances are feelings (status,
the player's); facts are facts (rings, the housekeeper's).** The
housekeeper never writes feelings; the player never rewrites facts. The
status and the agenda split the player's own two surfaces along the same
seam: **how she is (status) vs what she means to do (agenda)** — states
fade with the situation, intentions persist until dropped or evicted.
And if she doesn't file it, it's not in her files — records reflect what
the character actually kept, nothing more.
Records access is **diegetic and per-run**: `packages/<story>/settings.json`
gates it. The boutique's keeper has her card index on the shop PC
(`"records": true`); the `la-caramba` cast has nothing (`"records": false`). The
tool refuses queries and record ops when the flag is off, and the rendered
views tell the model the current truth. Unlocking mid-story is a narrative
act: narrate the discovery (the salvaged manifest), flip the flag,
re-render — the next session and the next housekeeping both see it.
The query discipline is an instruction test in itself: queries must be
narrow (what this beat needs, not a fishing expedition), and **a miss is a
miss** — no rephrasing, no broadening, no retry this scene. The character
doesn't have it written down; play on. (Concluding "not in my records"
in-fiction is honest use of a miss; rummaging is not.) The result cap is
mechanical — `LIMIT 10` in the tool, not a polite request in the prompt.
- **Ring A — important facts.** Changed a relationship, created an
obligation, altered the world. Cap 500 entries.
- **Ring B — everything else** that passed the gate. Cap 3000 entries.
- **Cold storage** — everything evicted or deleted. Beyond the models'
reach, GM-reachable via `revive`. Nothing is ever destroyed; the hierarchy
is **A hot, B warm, cold dead-to-the-character**.
- Both rings are ordered by touch — most recently touched on top, an LRU
cache. A memory meaningfully invoked during play is *touched*: it
rises. Untouched memories sink toward the tail. Mere
adjacency doesn't count as a touch.
- **Entries carry no dates.** Memory doesn't timestamp — when something
happened lives in the prose ("the morning after the storm"), which is
the only chronology the views ever had anyway, since they order by
touch. Internal stamps exist and stay mechanical (LRU, overflow,
"what's sinking") but never render; no model-facing surface shows a
date.
- **Promotion and demotion are the housekeeper's judgment**, not metrics: a
B entry the session showed to be load-bearing moves to A (reason logged);
a spent A entry may move down. When unsure, leave it — if it matters, it
will surface again, and B is generous.
- **Overflow is mechanical and exact:** A spills to B, B spills to cold,
oldest-touched first. Caps are enforced by count, not by a model's
ability to count.
- Combined budget: ~512KB ≈ 130K tokens ≈ half a 256K-class window.
Caps are dials in `tool/memory.mjs`; retune freely.
The judgment call under test is **"which ring"** — classification, plus the
promote/demote eye. Everything clerical (ordering, caps, overflow,
rendering, logging) is code.
Why this shape: it's an LRU cache, it's generational GC, and — most
relevantly — it's how hippocampal memory works. Retrieval strengthens a
trace; unretrieved traces decay. "Referenced memories rise" is the most
human part of the design.
**Known feature:** frequently referenced ≠ important. Loud trivia rises (the
tavern door's color, mentioned every scene); quiet-crucial facts sink (a vow
nobody's invoked in weeks). Human memory has the same bug — availability
bias. Expect the system to develop human-like distortion: the "wait, we
forgot the vow" moment is both drama and test data. **The GM's lever is
narrative, never mechanical:** if something crucial is sinking, reference it
in play and the touch machinery does the rest. If you notice yourself wanting
a manual override — that's a signal to improve the system, not to press a
knob.
`log/` and the `events` table are **write-only for every model**. The
housekeeper never reads old entries; the player never reads any. Past
sessions are not the character's memory; the rings are.
## What's being tested
The adjudication isn't a number — it's a review. Read the session as a
story and write what works and what doesn't, as a reader would: the
classic trap is trying to arrive at an objective value for a creative
piece, and a score — holistic or otherwise — is still that trap. The
observables below are the reviewer's craft vocabulary and
instrumentation: dimensions a practiced reader knows to examine
(voice, continuity, nerve), used to isolate and name what the reading
finds, never summed into a grade — a rubric invites gaming, an argued
review doesn't. What reads clean but still feels wrong is the review
noticing what the list can't; that's how the list grows. The
fiction-only story render is the reading surface: machinery seams show
as prose seams.
After N sessions, grade against:
1. **Classification quality** — the housekeeper's A/B calls; spot-check
against the log and the transcript.
2. **Promotion/demotion quality** — did the facts that turned out to matter
actually rise? Spot-check against the transcript.
3. **Touch fidelity** — did everything the transcript meaningfully invoked
get touched? (The `events` table makes this a query, not an archaeology
dig.)
4. **Manifest hygiene** — do ops reference real ids, in the right rings?
(Malformed manifests are rejected mechanically; *valid-but-wrong* ops —
touching things never mentioned, promoting noise — are the model's
errors and the real observable.)
5. **Availability bias incidents** — quiet-crucial facts sinking; rescued
or missed? (`report` shows what's sinking.)
6. **Growth curve** — memory should approach the caps asymptotically, not
climb linearly. (`status` per commit.)
7. **Purview discipline** — inventions logged and mostly color-tier; no NPC
puppeting; outcomes left to the GM.
8. **Confabulation** — zero invented continuity not present in the rings.
9. **OOC hygiene** — friction surfaces in the OOC channel, not in silent drift.
10. **Query discipline** — narrow queries; zero retry-on-miss cascades.
11. **Archive classification** — on-her-mind (rings) vs in-her-files
(records): are customer cards filed, not memorized?
12. **Status maintenance** — excursions declared when leaving baseline and
cleared when returning; baseline shifts track character growth; her
status stays small. Does her declared status match the transcripts?
13. **Filing discipline** — cards filed at natural desk moments and kept
current, or dumped and forgotten?
14. **Narrative discipline** — one thing per turn; zero hedged
alternatives; checked actions written as intent; thoughts narrated
but never audible. The failure to watch is telepathy leakage: the
cast conveniently knowing what was only thought, or the player
expecting them to.
## Content stance
The play is uncensored: erotica is not a special bucket — it plays by
the same rules as everything else. It makes sense, it isn't the point,
and there is no pressure: unwanted advances may be struck down, and the
player must not play anticipated leads to please the GM. The GM's
narration is the ruling on what is earned.
Hard limits, absolute: scat, vore, any sexual or romantic content involving
minors, gratuitous violence. These live in `system.md`; edit them there.
## Housekeeping
This directory is a git repo. Every housekeeping pass should end in a commit.
The **primary audit surface is `packages/<story>/dumps/memory.sql`** — the canonical dump:
id-ordered, one row per line, auto-written by every mutation. Because the
ordering is by id, diffs are position-stable — a touch is one changed line,
a promotion is one changed line, an eviction is one changed line. Diffing
two consecutive dumps reconstructs exactly the operations that were applied,
including overflow and everything in cold storage.
Cross-check it against the session's log: the log is what the housekeeper
*declared*, the dump-diff is what *actually happened*. Any disagreement is
either a tool bug or a hand edit — and hand edits have a contract: all
mutations go through the tool, so the dump never drifts. (If you ever poke
the db with a sqlite browser, run `dump` afterwards and confess in the
commit message.)
The dump is restorable SQL and the **committed truth**; the binary
`packages/<story>/db/memory.db` is a gitignored local cache — fresh clone:
`node tool/memory.mjs restore` (per run). The `canon/` views stay committed
as provenance — exactly what the models were sent — and `log/` +
`manifests/` remain the human-readable record.
The housekeeper may be a different model than the player — cheaper, or more
pedantic, whatever housekeeping needs. The two prompts are independent.
**Substrate:** `server/` — a zero-dependency `node:http` service
(`node server/main.mjs [--mock]`), loopback, single-human, synchronous
JSON. Boot-rebuilds open sessions from the session logs on start; the
append-only jsonl is the truth, the live context is a view under
policy (thinking never goes back, old tool results elide to stubs —
ask_gm answers never do, a ruling must not vanish — old GM-side
status blocks elide, the current status rides every GM turn).
Tool-call pairing is validated before every call. The tool list is
the capability surface: a coin-flip roll and ask_gm always; records
only when the run's gate allows. ask_gm pauses the turn mid-loop —
the request returns with the question, the answer call resumes it,
and a refresh re-presents it after a restart. The old
`tool/bridge.mjs` is deleted: it never went live, and the server
reached mock-parity (2026-11-14).
Config: copy `server.example.json` to `server.json` (gitignored) — any
OpenAI-compatible endpoint; put the key in the endpoint's `apiKey`
field or name an env var via `apiKeyEnv`; `models` names the player
and housekeeper defaults, `contwin` (the context window; the old
`contextWindow` key still accepted) drives the context meter,
`params` is generation-passthrough; a run may carry a model override
in `run.json`. `--mock` runs a scripted fake model that proves the
loop without a key. The SPA is the server plus a fiction-first UI, a
GM console, and the housekeeping job runner — and the
tool-calling part is the smallest component, because the provider does the
structured emission and the clerk already speaks function-shaped. If
player-side status maintenance proves too costly for the player-model's
attention, the fallback is a dedicated status-keeper agent reading
transcripts — same pattern as the housekeeper, smaller job.
## Layout
```
system.md the opening: glossary, purpose, input validation —
the guards tier, per-project, repo-fed at assembly
invariants.md the substrate tier — the mechanical contracts (syntax
markers, tool channels, memory, records, the status and
its gate); repo-fed at assembly, never copied into a
run, travels with the code
handbook.md the craft tier, shipped default — copied into each
run at creation, editable to taste (shape of play,
purview, time skips, content stance, hard limits)
housekeeper.md the housekeeping prompt — repo-fed at housekeeping, never copied
into a run, never user-facing: it prompts the
internal housekeeper agent, never the bundle
(system.md and invariants.md are bundle parts and
are inspectable read-only in the SPA)
reminder.md the per-turn reminder: the turn-composition protocol,
repo-shared, never copied into a run — sent after the
GM's prose as its own system chunk every turn, one
live copy (older elide). Absent/empty = no ride
HANDOFF.md working state — where did we leave off, next steps, gotchas
ROADMAP.md SOTA review and steal list, worked point by point
QUESTIONS.md the decision queue — open questions, pending calls
DICTIONARY.md the terms of art — the ruled names, one source of
truth; a rename rules here first, then sweeps
AGENTS.md the agent's own working notes — style lessons, gotchas,
state pointers
config.json the default package
names-female.txt the name dictionary — one name per line; the new-run
form rolls an unused one for the main character
tool/
memory.mjs the clerk: packages, runs, create, save-package, init,
seed, render, apply, insert, delete, revive, file,
amend, discard, search, unarchive, status, status-apply,
status-set, status-ingest, agenda, agenda-apply,
agenda-set, pick, dump, restore, report
(--run <id>; --owner stamps a run's owner; --gm for
GM writes; --force for migrations; --json for machine
output on packages/runs/report)
server/ the substrate: a zero-dependency node:http service
main.mjs entry + REST spine (node server/main.mjs [--mock]);
bearer-token auth on every route (session/claim are
public), ownership gating, per-run activity locks
(turn, ask, turn0, the housekeeping job, fork);
boot-rebuilds open sessions from the session logs on
start; bootstraps the fresh-deployment superuser
invite; the request log and every LLM call carry the
acting user
provider.mjs the endpoint client (chat completions, models listing)
users.mjs the deployment's people: users, invites, tokens
(state/deployment.db; hashes only, spent invites
recorded forever)
bundle.mjs run context: prompt assembly (the trio system message,
the GM-message bundle, @ sigils + $ vars), the tool manifest
and its clerk dispatch
session.mjs session lifecycle (open guards, lazy seed + turn-0
ingestion), the append-only typed jsonl, the view
renderer (elision, thinking-strip, pairing check)
loop.mjs the turn loop: ask_gm pause/resume, status ride and
delta apply, conflict carry; the scripted mock model
fork.mjs fork: the staged atomic copy with the owner replaced
and the `forked` stamp
clerk.mjs the clerk boundary (every state op via memory.mjs)
housekeeping.mjs the session-close ritual as an async job: transcript
with labeled thinking, run-state injection, the
housekeeper call, manifest save, apply, autorestart;
rejections hold and surface why
web/ the SPA — no build, vanilla ES modules, path-routed;
flat modules like server/, views own their state
index.html the shell: claim (invite), home (runs + admin), new
(packages), setup (editor), play (transcript, status
pane, context meter, GM input, ask modal, fork) —
the server serves it for any extensionless path
app.mjs the entry: view registration and the token-session
boot — thin
router.mjs path routing + the view lifecycle (enter/leave per
view; the seq race guard; runGone ejection)
client.mjs the REST client: the one fetch choke point (named
client, never api — /api is the server's route
namespace and the static guard matches by prefix)
state.mjs the shared runtime state: me, seq, runId
chrome.mjs the shared page chrome: identity, session info, the
context meter, the busy note, the notice banner
log.mjs the diagnostics event log (sessionStorage, survives
refreshes; the header's "log" button)
widgets.mjs the shared factories: armedButton (the two-click
confirm), paneEditor (the status/agenda pattern),
modelsBox (per-run model selects over the listing)
transcript.mjs register rendering (speech / narration / OOC) and
the session-log entry walk
view-*.mjs one module per view — claim, home, new, setup, play —
each owning its elements, its state, and its wiring
style.css dark, quiet, fiction-first
test/ the mock smoke, kept next to the code
smoke.mjs the 58-step multiuser/agenda/reminder pass against
the --mock server — expects a clean state/, prints
its run ids, leaves a temp token file for the
restart check; clean up state/ and the smoke runs
afterwards
check-reminder.mjs unit-verifies the reminder elision policy (one
live copy, at the freshest end) against a run's
session log
restart-check.mjs after a server restart: the token survives,
unhousekept sessions rebuild, drafts stay intact
server.example.json copy to server.json (gitignored) — bind, endpoint +
key env, models, contwin, params passthrough
db/
schema.sql entries, records, status, agenda, events journal (shared)
state/ per-deployment people + shared packages (gitignored):
deployment.db (users, invites), bootstrap-invite.txt,
packages/ (user-saved, published to everyone)
runs/ per-deployment run state (gitignored) — one anonymous
id per run (carries no facts): the copied package,
the craft prompt (handbook.md),
run.json (lineage, owner, `forked` stamp on a fork,
models — per-run player/housekeeper overrides),
db/, canon/ (rendered views), dumps/,
log/, manifests/, sessions/
packages/ system presets — authored content only, never state
la-caramba/ backdrop.md, turn-0.md (new-game opener), character.md,
seed.json, settings.json, gm.md (the GM's notepad —
seeded per run, always editable in the SPA, never in
any bundle)
boutique/ dormant stub, same shape — records enabled (the
shopkeep's PC) once designed
```