From c51d31078edef2b98eda3a55d5bbd649e6974894 Mon Sep 17 00:00:00 2001 From: Mute Date: Sat, 14 Nov 2026 23:48:27 +0000 Subject: [PATCH] spa modules and terminology: app.mjs split into flat es modules (router lifecycle, shared widgets, views own their state), mock smoke in test/; DICTIONARY.md rules the terms, four renames swept clean through the machinery - paper->status (run summary command is report now), window->session, wrap->housekeeping, context window->contwin; no dual-accepts by ruling, old data migrates once in the clerk (restore self-heals old dumps) --- AGENTS.md | 97 ++- DICTIONARY.md | 252 +++++++ HANDOFF.md | 180 +++-- QUESTIONS.md | 10 + README.md | 132 ++-- ROADMAP.md | 68 +- db/schema.sql | 20 +- housekeeper.md | 10 +- invariants.md | 16 +- reminder.md | 2 +- server.example.json | 2 +- server/fork.mjs | 4 +- server/housekeeping.mjs | 38 +- server/loop.mjs | 22 +- server/main.mjs | 75 +-- server/session.mjs | 22 +- test/check-reminder.mjs | 34 + test/restart-check.mjs | 38 ++ test/smoke.mjs | 215 ++++++ tool/memory.mjs | 214 +++--- web/app.mjs | 1389 +-------------------------------------- web/chrome.mjs | 54 ++ web/client.mjs | 50 ++ web/dom.mjs | 11 + web/index.html | 52 +- web/log.mjs | 33 + web/router.mjs | 59 ++ web/state.mjs | 14 + web/style.css | 18 +- web/transcript.mjs | 216 ++++++ web/view-claim.mjs | 35 + web/view-home.mjs | 109 +++ web/view-new.mjs | 59 ++ web/view-play.mjs | 386 +++++++++++ web/view-setup.mjs | 319 +++++++++ web/widgets.mjs | 167 +++++ 36 files changed, 2643 insertions(+), 1779 deletions(-) create mode 100644 DICTIONARY.md create mode 100644 test/check-reminder.mjs create mode 100644 test/restart-check.mjs create mode 100644 test/smoke.mjs create mode 100644 web/chrome.mjs create mode 100644 web/client.mjs create mode 100644 web/dom.mjs create mode 100644 web/log.mjs create mode 100644 web/router.mjs create mode 100644 web/state.mjs create mode 100644 web/transcript.mjs create mode 100644 web/view-claim.mjs create mode 100644 web/view-home.mjs create mode 100644 web/view-new.mjs create mode 100644 web/view-play.mjs create mode 100644 web/view-setup.mjs create mode 100644 web/widgets.mjs diff --git a/AGENTS.md b/AGENTS.md index 3f97c6b..ad5bd5b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,7 +3,8 @@ Working notes for the agent working this repo. Not project documentation — the project's homes are README (architecture, protocol, observables), ROADMAP (decisions, steal list, substrate plan), -QUESTIONS (the decision queue), HANDOFF (working state). This file is +QUESTIONS (the decision queue), DICTIONARY (the terms of art), +HANDOFF (working state). This file is memory the agent owes itself across sessions. ## Working with the GM @@ -86,7 +87,7 @@ memory the agent owes itself across sessions. per-run `models: {player, housekeeper}` over server.json defaults (#16 narrowed to the default choice only). Signing in is permanent and per-browser — no sign-out (lifecycle is a ROADMAP extension - point). The agenda (QUESTIONS #32): second player paper, ``/ + point). The agenda (QUESTIONS #32): the player's second block, ``/ `` deltas, cap-5 recency queue; Irene's events journal migrated (CHECK widened) — her db is agenda-ready. The per-turn reminder (QUESTIONS #34, steal #11 done): reminder.md is repo-shared, @@ -127,44 +128,82 @@ memory the agent owes itself across sessions. expression, not an arrow function (an arrow returns the function uninvoked — its .value serializes to {} and silently corrupts whatever you build from it); wait's text matches RENDERED text, so - CSS text-transform breaks literal waits (wait for "HER PAPER", not - "her paper"); clickable divs are invisible to the a11y tree and the - keyboard — clickable things are buttons. Added 2026-11-14 (multiuser - round): the a11y snapshot races async renders — waiting for static - skeleton text ("RUNS") snapshots BEFORE the fetches land and looks - like a rendering bug; wait for text that only exists post-render (a - card name, the window-info line) or probe the DOM via evaluate. + CSS text-transform breaks literal waits (wait for "HER STATUS", not + "her status") and PLACEHOLDERS never match a wait at all (probe the + textarea via evaluate instead); clickable divs are invisible to the + a11y tree and the keyboard — clickable things are buttons. Added + 2026-11-14 (multiuser round): the a11y snapshot races async renders + — waiting for static skeleton text ("RUNS", the aside headings) + snapshots BEFORE the fetches land and looks like a rendering bug; + wait for text that only exists post-render (a card name, the + session-info line) or probe the DOM via evaluate. - Test-state discipline (2026-11-14): the deployment's state/ is real — never leave test users or invites in it. Smoke against --mock, then Remove-Item state/ and every test run (all but the GM's real ones) before calling it done. A stale bootstrap file is harmless (dead once a superuser exists), but test users make the deployment NOT fresh and block the real bootstrap. +- Naming gotcha (2026-11-14, SPA round): static files under web/ must + not have names starting with "api" — the server's route guard + matches the /api PREFIX, so web/api.mjs 404'd as a bogus API route + and the app died at module load with an empty
. The REST + client module is client.mjs. Any future web file name gets this + check. - Gotcha (2026-11-14, rewind aftermath): a session rewind erases my memory of tool calls but NOT their effects — the server, files, and databases keep them. After any rewind, external state is the truth: re-read it, and never assume authorship of found content (I once credited the GM with a GM-turn that pre-rewind me had written). -- Open tails (handoff, 2026-11-14): **housekeeper.md review is the - next creative step** — the GM's dry-run verdict was "works, but not - as expected; I never saw the prompt"; iterate with the replay - button (nothing applied). **Status discipline**: the paper has - taken up thread-tracking; the GM wants the admission-gate section - in invariants.md tightened. **Verbosity**: completions lengthened - 103 -> 668 chars across window one; the GM is thinking about it. - The first real wrap (Irene's window) is the memory test's start. -- Active work: NONE — the GM surface rework is complete and - live-proven; the first real story is being played. Working lessons - from the build: the newest GM turn must keep its / - blocks (that ride is the paper's only channel from window two on); - any new path that reads a run file for sending goes through - expandVars (turn0() initially didn't); the transcript must surface - failed window-open notes (ingest), not print success unconditionally; - after changing a default, re-run the primary path (the start button - broke for the GM because post-redesign tests never pressed it). +- Open tails (handoff, 2026-11-14, evening): **housekeeper.md review + is still the next creative step** — the GM's dry-run verdict was + "works, but not as expected; I never saw the prompt"; iterate with + the replay button (nothing applied). **Status discipline: RESOLVED** + by the agenda (QUESTIONS #32/#33). **Verbosity**: completions + lengthened 103 -> 668 chars across session one; the per-turn reminder + is the countermeasure now built — the next live session is the test. + The first real housekeeping pass (Irene's session) is the memory + test's start, and the op's one-time act (bootstrap claim + + hand-stamping Irene's owner) rides before it (HANDOFF step 1). **Replay-after-housekeeping is + dead** (found in the SPA round, unfixed, server-side): housekeeping + auto-restarts the next session, so the replay default (latest + session) points at the fresh empty session and 409s — the closed + session needs naming. GM's call where the default should point. +- Active work: NONE — the SPA module refactor + terminology round is + complete, verified, and committed (2026-11-14): web/ is flat ES + modules (app, router, client, state, chrome, log, widgets, + transcript, view-* per view), the three hand-copied patterns became + factories (armedButton, paneEditor, modelsBox), views own their + state and teardown via enter/leave, the mock smoke lives in test/, + and DICTIONARY.md rules the terms — four renames swept clean + through the machinery (paper->status, window->session, wrap-> + housekeeping, context window->contwin), one clerk normalizer + migrates old dbs/dumps, no dual-accepts (GM: no legacy hauling). + The multiuser + agenda + reminder round is committed through + 89a2c16 (the amended reminder commit — abf8ef3 is its dead + pre-amend twin); the first real story is being played. Working + lessons from the build: the newest GM + turn must keep its / blocks (that ride is the + status/agenda blocks' only channel from session two on); any new path that reads a + run file for sending goes through expandVars (turn0() initially + didn't); the transcript must surface failed session-open notes + (ingest), not print success unconditionally; after changing a + default, re-run the primary path (the start button broke for the GM + because post-redesign tests never pressed it); ownership is resolved + against the users table, never swept on disk; same-verb delta blocks + combine into one apply, never execute in sequence. Rename-mechanics + lesson (2026-11-14): scripted renames with split/join replace EVERY + occurrence — renaming the clerk's `paper` case to `status` and then + `status` to `report` ate both, leaving no `status` dispatch; the + smoke caught it on the next run. Order rename pairs so a new name + is never a later pair's old name, and grep dispatch tables after. + CLI note: the run summary is `report` now; `status` is the tier + verb. - Postulates (GM, 2026-11-14): female PCs only (names are gendered; QUESTIONS #2 closed by it). Boutique is dormant AND defunct — fine - broken until its design round; do not fix or design it unprompted. + broken until its design round; do not fix or design it unprompted, + and do not keep it aligned: term sweeps, renames, and audits skip + it entirely (2026-11-14, GM — its gm.md "paper" wording stays + as-is; don't flag it again). - Identity model (2026-11-14): @PC/@Package are identity sigils (settings pc/name); $TOKENs are prompt-declared template vars (setup inputs -> settings vars). Run ids are anonymous hex — @@ -186,13 +225,13 @@ memory the agent owes itself across sessions. below. - Watch: the "never open with world narration" rule was cut as superfluous by the GM — reinstate only if testing shows drift. -- Defaults taken without asking (2026-11-13): #21 window-open refuses +- Defaults taken without asking (2026-11-13): #21 session-open refuses over an unhousekept session with explicit override; #16 housekeeper defaults to the player's model; #10 tool-call pairing validation goes into the server loop. - Open decisions live in QUESTIONS.md — read it first. Remaining: #19c (seed voice, GM may revisit — non-blocking, seed editable until first - window-open) and #16 (which model the housekeeper defaults to). + session-open) and #16 (which model the housekeeper defaults to). Resolved lately: #19a keep "Rell"; #20 system.md split (substrate facts / per-project guards / per-run craft, hard limits in the craft copy); #21 unhousekept-session guard (refuse with override). diff --git a/DICTIONARY.md b/DICTIONARY.md new file mode 100644 index 0000000..de29efd --- /dev/null +++ b/DICTIONARY.md @@ -0,0 +1,252 @@ +# Dictionary — the terms of art + +The source of truth for what things are called. When prose, UI, or +code drifts from these names, the fix is to align to this file; when +a name here stops working, the fix is to re-rule it here first, then +sweep. Durable meanings live in `README.md`; this file rules the +WORDS. + +## The people and the models + +- **the GM** — the human running the world: every NPC, every + consequence, all retcons. Runs on organic memory; the model's canon + files are the prosthesis. Always a human, never a model. +- **the player** — the player-model: the LLM playing the one PC. + The two parties who play are the GM and the player (2026-11-14, + GM) — and the player is always the model: humans are never "the + player" (QUESTIONS #28); a human in the app is a GM (of their own + runs), a spectator, or the op. +- **the PC** — the one character the player-model plays. Female by + postulate (README Scope); the shared prompts say "she" throughout. +- **the housekeeper** — a fresh model invocation after each session, + reading the transcript and the rings; emits a manifest. Judgment, + never clerical work; never plays, never edits files. Its prompt + (housekeeper.md) is substrate-internal and never exposed. +- **the clerk** — `tool/memory.mjs`: validates, applies, renders, + dumps. Fails loudly, never drifts silently. Code, never a model. +- **the op** — the superuser of a deployment: mints and revokes + invites and users; recovery is filesystem access. The whole of + admin. + +## The story state + +- **the deployment** — one clone plus `server.json`, `state/`, and + `runs/` (all gitignored): the unit of sharing. Invited users need + neither the key nor a clone. +- **the package** — a preset: authored content only, no state. + System packages ship with the repo; user packages are saved runs, + published to the deployment (gm.md included — saving is the act of + publishing). Read exactly once per run, ever — at create. +- **the run** — one story: the package copied wholesale into + `runs//` at create; from then the run directory is the only + truth. The id is anonymous hex and carries no facts; the visible + name is "Package / PC". The run is the PROCESS that delivers; the + story is the DELIVERABLE it exists to produce. In anything + mechanical it is always "the run". +- **the story** — the emerging deliverable: the narrative a run + exists to deliver. Prose may speak of the story; mechanics + always say run. +- **draft** — a run with no sessions yet: created, never started. + Editable in setup, deletable from the SPA; a played run refuses + deletion server-side. +- **the session** — one play period between housekeeping passes: + opens with the bundle assembly, plays by turns, ends with + housekeeping (which applies memories and auto-opens the next). + Renamed from "window" — see Ruled renames. Its transcript log is + `sessions/.jsonl`; ordinals in prose: "session one", "her + next session". +- **the turn** — one exchange: a GM turn (user role), then the + player's turn (assistant role; tool calls may interleave between + beats). +- **the bundle** — the opening context of a session, assembled in + order: the system message trio (system.md → invariants.md → the + run's handbook), then the GM messages — backdrop, character, + ring-b, ring-a. Everything in it is inspectable read-only in the + SPA; agent prompts never enter it. +- **fresh** — a session over a never-started run: the seed applies + (lazily, once) and turn-0's `` block ingests at open. +- **the seed** — `seed.json`, the run's initial state (`entries` → + rings, `records` → files). Rides the run copy until the first + session-open applies it; freely editable until then; re-apply + refuses. +- **turn-0** — the opening beat file: the GM's zeroth turn, sent + once as the first GM message of the first session. The FILE is + turn-0; the MESSAGE, once sent, is "the opening beat". + +## Memory + +- **the rings** — her salient memory, two tiers ordered by touch + (an LRU cache): **ring A** — important facts, cap 500; **ring B** — + the rest that passed the gate, cap 3000. Storage is rows; the + views (`canon/ring-*.md`) are rendering. +- **touch** — a meaningful invocation during play (named, used, + clearly weighed); raises the entry. Mere adjacency doesn't count. +- **promotion / demotion** — the housekeeper's A↔B judgment, reason + logged. Judgment, not a metric. +- **overflow** — mechanical and exact: A spills to B, B spills to + cold, oldest-touched first. Enforced by count, never by a model's + arithmetic. +- **cold storage** — everything evicted or deleted. Beyond the + models' reach; GM-reachable via revive. Nothing is ever destroyed. +- **status** — descriptions of her immediate situation, admitted by + the three-part gate (non-normal, acute, turn-affecting). Rides + every GM turn as the `` block; mutated by + ``/`` deltas; entirely hers — the housekeeper never + writes it. Renamed from "paper" — see Ruled renames. +- **the agenda** — her second self-kept block: intentions — what she + means to do — in a cap-5 recency queue. Rides as the `` + block, mutated by ``/`` (drops by 0-based index); + disposable by design. The seam with the status: how she is vs what + she means to do. +- **records** — her files: the card index, the ledger, whatever she + keeps. Diegetic and per-run (the settings gate); narrow query, + hard cap 10 in the tool; a miss is a miss. Filed at her desk by + the player; the housekeeper only archives. +- **the backdrop** — the world as everyone in it knows it: public + knowledge. Never memory, never decays, always in the bundle. +- **identity** — `character.md`, the sheet: concept, drives, skills, + voice. The GM's to edit; the housekeeper proposes via open + questions; blanks are the player's to invent. +- **the manifest** — the housekeeper's whole output: JSON semantic + operations (insert, touch, promote, demote, reword, delete, + archive; plus summary, inventions, open questions). Validated and + applied by the clerk; a rejected manifest changes nothing and says + why. +- **housekeeping** — the session-close ritual: a fresh housekeeper + call over the transcript + rendered rings, the manifest, the + apply, the log, the autorestart of the next session. The only + word for it (2026-11-14, GM): the old shorthand "the wrap" is + retired. +- **the log** — `log/.md`, one per pass: what the + housekeeper declared, cross-checked against the dump diff. The + `events` table is the journal underneath; both are write-only for + every model. + +## Channels and syntax + +- **IC / OOC** — in-character vs out-of-character. OOC is a line + opening with `(`, closing paren optional; any opening `` line + is substrate traffic and always OOC. Unknown tags are reported to + the GM. +- **speech / narration** — plain text is spoken aloud; `*italics*` + carry actions, descriptions, thoughts, interiority. +- **sigils** — `@PC` (her name) and `@Package` (the display name): + identity substitution resolved from the run's settings. Any other + `@`-word is the author's own text — `@` syntax is not owned here. +- **$TOKENs / vars** — template variables the prompts declare + themselves; setup collects them; the run's `settings.vars` holds + the answers. +- **deltas** — the in-band mutations: ``/`` on the + status, ``/`` on the agenda. Same-verb blocks combine + into one apply; misses return as a conflict. +- **conflict** — the self-heal message: a `` block sent as + its own GM-side message, clean of prose; the model adjusts in the + same exchange. Capped at 3 heals per turn. +- **ask_gm** — the player's tool for points of order, canon + questions, proposals. Pauses the turn mid-loop; the answer is + authoritative and never elides from the context. +- **roll** — the dice tool: a uniform random pick among equal-weight + options; the model receives `picked: