substrate: server, housekeeping job, spa - the mvp complete

- prompt split, GM's cut: system.md = opening + guards (glossary, purpose, input validation; repo-fed, per-project); invariants.md = substrate (syntax markers, tools, memory, records, the paper + its three-part gate; repo-fed, travels with the code); handbook.md = craft copy (shape of play, thoughts, purview, time skips, continuity, stance, hard limits; copied per run). One system message: system -> invariants -> the run's handbook. OOC is a single open paren, closing optional, match the GM's style; a lone paren is an empty OOC line, skipped by the parser. housekeeper.md aligned: the paper holds acute states, relational shifts are recorded as the facts behind them, and dates are story dates (follow the rings' calendar, never the wall clock - the seed is 2069 now, per canon)
- server/ (phase 2, zero-dep node:http): REST spine per the sketch, per-run session machine with ask_gm pause/resume (the whole tool-call batch waits, pairing stays sound), view renderer (thinking-strip, tool-result elision with ask answers exempt, old status/conflict blocks stripped), boot-rebuild from the typed jsonl, lazy seed + turn-0 ingestion at window-open with the unhousekept refuse-and-override guard, usage tracking + context meter, tool-pairing validation, scripted mock model. The clerk gained --json (packages/runs/status); tool/bridge.mjs deleted at mock-parity per the retirement decision
- housekeeping job (phase 3, server/housekeeping.mjs): trigger ends the window and runs the chain async - transcript with labeled thinking, run-state injection (records availability; the ring views stay pure memory), housekeeper on a fresh context, manifest saved (raw output too if unparseable), clerk apply (writes the window log, snapshots dumps/<window>.sql), state.json lastHousekeptSession, autorestart. Rejection holds the restart and surfaces why; the apply endpoint is the recovery path and the manual-relay close. Live-proven twice: both manifests sound (ring-B classification, first-person voice, precise touches, story-dated)
- spa (phase 4, web/ - no build, vanilla es modules, served at /): three-register transcript per the ruled markers incl. multi-line narration blocks, bundle as a collapsed card with turn-0 as the opening GM turn, paper tags as chips, status pane with conflict surfacing, context meter hot past 85 percent, gm line input, ask modal re-presented from pendingAsk, housekeeping button with two-click arm + poll + inline log. No js alert/confirm (they block the embedded pane) - in-page banner instead. Driven end to end through the ui on a disposable live run
- seed: date fixed to the 2069 story calendar (was a real-world date; real dates never surface to the player)
- docs: README goal states the mvp is complete, layout covers server/ and web/, protocol and substrate sections rewritten for the server; ROADMAP phases 0-4 done, harness decisions current; QUESTIONS #4 #7 #10 #12 #16-mechanism #19a #20 #21 resolved; HANDOFF is the handoff map; AGENTS carries the working lessons (tokens are free, no screenshots - not multimodal, no js dialogs, external state survives rewinds)
This commit is contained in:
2026-11-14 03:15:53 +00:00
parent 530170224f
commit ba72d2ed1f
22 changed files with 2418 additions and 838 deletions
+81 -44
View File
@@ -26,7 +26,9 @@ 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).
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
@@ -96,9 +98,9 @@ its drafting session.
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
the package is copied wholesale into `runs/<run-id>/` — the craft
prompts (`handbook.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.
@@ -109,8 +111,11 @@ its drafting session.
## The protocol
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
2. **Open a window:** 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. On a new game, `turn-0.md` is the opening beat, before
@@ -121,26 +126,28 @@ its drafting session.
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. 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
bridge mode, the model's OOC is the `ask_gm` tool; the GM's own OOC
stays `((...))` in their turns.
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 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 applies the deltas — exact match — and misses ride
back as a `<conflict>` block on the next GM turn). 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 window:** just stop. No in-band ritual; the player-model has no
end-of-session duties.
5. **Housekeep (fresh model, new context):** send `housekeeper.md`, then
the run's `backdrop.md` and `character.md`, then both ring views, then
the session transcript — pasted, or the latest
`packages/<story>/sessions/*.jsonl` when playing through the bridge. Save
`runs/<id>/sessions/*.jsonl` when playing through the server (the
phase-3 housekeeping job automates this). Save
its manifest to `packages/<story>/manifests/<window>.json`.
6. **Apply:** `node tool/memory.mjs apply packages/<story>/manifests/<window>.json`
— the tool validates, applies, handles overflow, writes the run's
@@ -317,20 +324,20 @@ 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 (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.
**Substrate:** `server/` — a zero-dependency `node:http` service
(`node server/main.mjs [--mock]`), loopback, single-human, synchronous
JSON. Boot-rebuilds open windows 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 paper 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
@@ -348,11 +355,16 @@ transcripts — same pattern as the housekeeper, smaller job.
## Layout
```
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
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 paper 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 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
@@ -364,15 +376,40 @@ tool/
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
(--run <id>; --gm for GM writes; --force for
migrations; --json for machine output on
packages/runs/status)
server/ the substrate: a zero-dependency node:http service
main.mjs entry + REST spine (node server/main.mjs [--mock]);
loopback, single-human, synchronous JSON; boot-rebuilds
open windows from the session logs on start
provider.mjs the endpoint client (chat completions, models listing)
bundle.mjs run context: prompt assembly (the trio system message,
the GM-message bundle, $NAME vars), the tool manifest
and its clerk dispatch
session.mjs window 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, paper ride and
delta apply, conflict carry; the scripted mock model
clerk.mjs the clerk boundary (every state op via memory.mjs)
housekeeping.mjs the window-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, served at /
index.html the layout: transcript, status pane, context meter,
GM input, ask modal
app.mjs the client: register parsing (speech / narration /
OOC), bundle cards, turns, housekeeping polling
style.css dark, quiet, fiction-first
server.example.json copy to server.json (gitignored) — bind, endpoint +
key env, models, contextWindow, params passthrough
db/
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,
the copied package, the craft prompts (handbook.md,
housekeeper.md), run.json (lineage,
model override), db/, canon/ (rendered views), dumps/,
log/, manifests/, sessions/
packages/ presets — authored content only, never state