substrate: paper model in the clerk, preset/run split, harness decisions

- clerk phase 0: the paper replaces key/value status - a description set with exact-match lost/gained delta apply (paper-apply), non-blocking, misses relayed back as conflict strings; paper / paper-set (GM override) / paper-ingest (a file's status block at new-game); amend and discard journal prior content and the paper ops journal what they replace (events.prior, the saga rule); seed rejects a status key loudly. Smoke-tested end to end
- preset/run split: packages are presets (authored content only - the six state dirs are gone from both), runs are per-deployment instances under runs/ (gitignored); create <package> <run-id> copies the package wholesale (shared prompts included, run.json lineage plus optional model override) and inits state; --run addresses runs; packages and runs list them; config.json names the default package. The seed applies lazily at a fresh run's first window-open
- bridge retired before ever going live: bridge.json became server.json (bind, endpoint, models, contextWindow, params - steal #4), example committed, bridge.mjs stays as the loop donor until server mock-parity
- prelude.md renamed turn-0.md (GM); mechanical feeders, pink ice as licensed corpo firewall, slop section, Pinky treatment pinned (GM)
- harness decisions (ROADMAP The harness): stated goal - a usable RP harness, clone-and-run or invited instance, key on the backend, no secrets in the repo; repo ships code and authored content only; copy-at-creation, editable everything, discipline on the GM; per-run model selection with an upstream models listing; audit as per-wrap dump snapshots inside the run (commit-per-wrap retired); zero-dep stack (#4 resolved, #7 dissolved with the bridge, #21 by default)
- system.md split ruled (#20): substrate facts / per-project guards / per-run craft, hard limits in the craft copy; name call resolved - keep Rell (#19a)
- docs: README gains the goal and deployment model, booting rewritten for the create flow; ROADMAP phasing 0-1 done; HANDOFF and the decision queue current
This commit is contained in:
2026-11-13 23:40:33 +00:00
parent 7ed729e294
commit 530170224f
29 changed files with 772 additions and 538 deletions
+107 -63
View File
@@ -13,7 +13,20 @@ 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.
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).
## Roles
@@ -47,8 +60,11 @@ Two interleaved stories calibrate the memory system against itself:
| 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 |
`node tool/memory.mjs runs` shows fill levels; `--run <name>` overrides the
`config.json` default for any command.
Boutique is dormant — a stub that never reached its design step — until
its drafting session.
`node tool/memory.mjs packages` lists presets; `runs` lists instances;
`--run <id>` addresses a run for any command.
## Booting a run
@@ -56,11 +72,12 @@ Two interleaved stories calibrate the memory system against itself:
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. **Prelude** (new games, optional) — write `packages/<story>/prelude.md`:
the opening beat, the situation she wakes into. Sent once, as the
first GM message of window one; after that it is history, living in
the session transcript. Without it, the GM narrates the opening beat
themselves.
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 window one; after that
it is history, living in the session transcript. Its trailing
`<status>` block is her opening paper, 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
@@ -71,37 +88,48 @@ Two interleaved stories calibrate the memory system against itself:
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` and run
`node tool/memory.mjs seed`. A one-time, all-or-nothing migration:
`entries` → the rings (initial memories), `status` → starting values
(a string is shorthand for `{normal, value}` — the starting state is
her normal; use the object form for an excursion in medias res),
`records` → pre-existing files (gated by `settings.json`). Refuses if
the run has any history; `--force` only on a disposable db. Everything
is journaled under window `seed`.
5. **First window** — `render`, open the window (the bridge assembles
the bundle), narrate.
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 window-open — until then it rides the run copy,
freely editable; deleting it from the run is the opt-out. Everything
is journaled under window `seed`. Her opening paper does not seed —
it rides turn-0's `<status>` block.
5. **Create the run** — `node tool/memory.mjs create <story> <run-id>`:
the package is copied wholesale into `runs/<run-id>/` — the shared
prompts (`system.md`, `housekeeper.md`) ride along, battery included —
and the db is initialized. 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 window** — open it (the server assembles the bundle; until it
lands, manual relay), narrate. The first window-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 render` (default run comes
from `config.json`; `--run <name>` overrides)
1. **Refresh the views:** `node tool/memory.mjs --run <id> render`
2. **Open a window:** `system.md` goes as the system message — the only
one. Everything else arrives as GM messages (user role), one message
per file: `backdrop.md`, `character.md`, `canon/ring-b.md`,
`canon/ring-a.md`, `canon/status.md` — identity first, then memory,
ring A and her paper in the recency slots. On a new game, `prelude.md`
is the opening beat, before the GM's first line. (On a tight window,
ring B is optional loading — ring A is the spine.) `$NAME` tokens in
any bundle file are substituted from the run's `settings.json` `vars`
before sending. The bridge assembles and logs all of this automatically.
`canon/ring-a.md` — identity first, then memory, ring A in the
recency slot. On a new game, `turn-0.md` is the opening beat, before
the GM's first line, and its trailing `<status>` block is ingested
as her opening paper. In play the current paper rides every GM turn
the same way (the per-turn ride lands with the server). (On a tight
window, ring B is optional loading — ring A is the spine.) `$NAME`
tokens in any bundle file are substituted from the run's
`settings.json` `vars` before sending. The server assembles and
logs all of this automatically (until it lands: manual relay).
3. **In play:** `((double parentheses))` is the out-of-character channel —
points of order, canon questions, proposals, vetoes. Both sides use it.
Entries carry stable ids (`[e17]`); citing one is the precise way to
reference a memory. Status declarations (`((status key: value))`,
`((status norm key: value))`, `((status clear key))`,
`((status drop key))`) are relayed to `set`/`norm`/`clear`/`unset`;
record work (`((q:))`, `((file:))`, `((amend:))`, `((discard:))`) to
reference a memory. The paper 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 implements the delta
transport — `paper-apply`, exact match, `<conflict>` reporting;
the per-turn ride lands with the server); record work
(`((q:))`, `((file:))`, `((amend:))`, `((discard:))`) to
`search`/`file`/`amend`/`discard` — `--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`. In
@@ -133,7 +161,7 @@ Memory is **six tiers**:
|---|---|---|---|
| **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** | her own piece of paper — baselines (defaults she plays to) plus declared excursions; exception reporting keeps the chatter down | always | **the player** (`set`/`norm`/`clear`/`unset`); GM override exceptional and journaled |
| **status** | her piece of paper — 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 |
| **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`) |
@@ -289,22 +317,28 @@ as provenance — exactly what the models were sent — and `log/` +
The housekeeper may be a different model than the player — cheaper, or more
pedantic, whatever housekeeping needs. The two prompts are independent.
**Substrate:** `tool/bridge.mjs` is the thin bridge — a player session with
native tools, no UI. It assembles the bundle from the run's files (views
refreshed), offers the player tools (status, a coin-flip roll, and ask_gm
always; records only when the run's gate allows — the tool list is the
capability surface), executes
model tool calls against the clerk, logs the full exchange to
`packages/<story>/sessions/<stamp>.jsonl` (the housekeeping transcript), and
elides old tool results to stubs in the live context (use-and-discard).
**Substrate (transition):** the bridge — `tool/bridge.mjs`, a player
session with native tools, no UI — is retired by decision before ever
going live; REST + SPA is the MVP and the bridge is deleted at server
mock-parity. Its loop (bundle assembly from the run's files with views
refreshed, tool execution against the clerk, session logging to
`packages/<story>/sessions/<stamp>.jsonl`, tool-result elision) is
extracted into the server. The tool list is the capability surface: a
coin-flip roll and ask_gm always; records only when the run's gate
allows. The four legacy status tools are gone from the clerk (replaced
by the paper tags) — the bridge's copies are dead code until the file
is deleted.
Model-initiated OOC is the `ask_gm` tool: the GM types the reply as the
tool result, so the prose channel stays pure fiction — and ask_gm answers
are exempt from elision, because a ruling must not vanish mid-session.
Config: copy `bridge.example.json` to `bridge.json` — any OpenAI-compatible
endpoint; put the key in the `apiKey` field (bridge.json is gitignored) or
name an env var via `apiKeyEnv`. `--mock` runs a scripted fake model
that proves the loop without a key. The SPA is the bridge plus a
fiction-first UI, a GM console, and the housekeeping job runner — and the
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, `contextWindow` 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
@@ -314,27 +348,37 @@ transcripts — same pattern as the housekeeper, smaller job.
## Layout
```
system.md system prompt for the player-model (play-side only, shared)
housekeeper.md system prompt for the post-session housekeeping model (shared)
HANDOFF.md working state — where we left off, next steps, gotchas
system.md shipped-default system prompt, play-side — copied into each
run at creation (battery included); a substrate-owned
invariant core + per-project guards are repo-fed at
assembly (split pending)
housekeeper.md shipped-default housekeeping prompt — copied per run
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
config.json the default run
AGENTS.md the agent's own working notes — style lessons, gotchas,
state pointers
config.json the default package
tool/
memory.mjs the clerk: runs, init, seed, render, apply, insert, delete,
revive, file, amend, discard, search, unarchive, set, norm,
clear, unset, pick, dump, restore, status
(--run <name>; --gm for GM writes; --force for migrations)
bridge.mjs the thin bridge: player session with native tools, session
logging, tool-result elision; --mock for a scripted model
bridge.example.json copy to bridge.json (gitignored) — endpoint + model + key env
memory.mjs the clerk: packages, runs, create, init, seed, render,
apply, insert, delete, revive, file, amend, discard,
search, unarchive, paper, paper-apply, paper-set,
paper-ingest, pick, dump, restore, status
(--run <id>; --gm for GM writes; --force for migrations)
bridge.mjs retired by decision — the loop donor, deleted at server
mock-parity
server.example.json copy to server.json (gitignored) — bind, endpoint +
key env, models, contextWindow, params passthrough
db/
schema.sql entries, records, status, events journal (shared)
packages/
la-caramba/ one story: backdrop.md, prelude.md (new-game opener),
character.md, seed.json, settings.json, gm.md (GM-private —
never in any bundle), db/, dumps/, canon/ (status.md,
ring-a.md, ring-b.md), log/, manifests/, sessions/ (bridge
transcripts)
boutique/ same shape — records enabled (the shopkeep's PC)
schema.sql entries, records, paper, events journal (shared)
runs/ per-deployment run state (gitignored) — one dir per run:
the copied package + shared prompts, run.json (lineage,
model override), db/, canon/ (rendered views), dumps/,
log/, manifests/, sessions/
packages/ presets — authored content only, never state
la-caramba/ backdrop.md, turn-0.md (new-game opener), character.md,
seed.json, settings.json, gm.md (GM-private — never in
any bundle)
boutique/ dormant stub, same shape — records enabled (the
shopkeep's PC) once designed
```