Files
tiny-worlds/HANDOFF.md
T

349 lines
20 KiB
Markdown

# Handoff — working state
A living document: trim items as they complete. Durable decisions live in
`README.md` (architecture, protocol, observables), `ROADMAP.md` (SOTA
review, steals, extension points), and the prompts (`system.md`,
`housekeeper.md`). Unanswered questions live in `QUESTIONS.md`, the
decision queue; the agent's own working notes live in `AGENTS.md`. This
file is the "where did we leave off" map.
## Where we are
- **DICTIONARY.md exists — the terms of art, one source of truth
(2026-11-14, GM-ruled).** A rename rules there first, then sweeps.
The full round is DONE: **paper → status, window → session, wrap →
housekeeping, context window → contwin** — swept on every surface
INCLUDING the machinery (element ids, routes, response fields, db
tables, journal ops), with one-time data-preserving migrations in
the clerk and **no dual-accepts** (the no-legacy convention is
recorded in the dictionary's Conventions). Two costs to remember:
the clerk's run summary is **`report`** now (`status` is the tier
verb, JSON), and Irene's pre-rename session log carries old-kind
notes that no longer render — cosmetic, data intact.
- **The SPA is refactored into modules (2026-11-14, GM-ruled).** The
1378-line app.mjs is gone; web/ is now flat ES modules like
server/: `app.mjs` (thin entry), `router.mjs` (path routing + the
view enter/leave lifecycle — each view owns its teardown, show()
never hand-resets panes), `client.mjs` (the fetch choke point —
named client, NOT api: a web file named api.mjs 404s, the static
guard matches the /api prefix), `state.mjs` (me/seq/runId only —
everything else is module-local to its view), `chrome.mjs`,
`log.mjs`, `widgets.mjs` (armedButton — the two-click confirm,
per-button arm state, fixing the shared-arm bug where arming one
user-revoke armed them all; paneEditor — the status/agenda twins as
one factory, two instances; modelsBox — the setup/play-aside
duplicate), `transcript.mjs`, and one `view-*.mjs` per view. The
mock smoke moved into the repo (`test/`). Verified: smoke 58/58,
reminder elision, restart check, and a full browser pass (claim,
home + admin, new run + name roll, setup editor + models box,
start, play: pane editors end to end, GM turn -> ask modal ->
answer, two-click housekeeping -> poll -> applied + log, the
auto-restarted session, spectator mode on Irene) — zero console
errors. Found en route, pre-existing, unfixed: **the dry-run
replay button is dead after a housekeeping pass** — housekeeping
auto-restarts the next session, so the latest session (the replay default) is the
fresh empty one and the call 409s ("no exchange to review"); the
closed session needs naming. Server-side semantics, GM's call.
- **The multiuser server, the agenda, and the per-turn reminder are
built, mock-proven, and committed (2026-11-14, through `89a2c16`).**
Token identity with single-use invites (no usernames, no passwords,
no external IDPs; the bootstrap invite auto-mints on the fresh
deployment to state/bootstrap-invite.txt and the console);
owner-gated runs with fork (atomic copy, owner replaced, no
lineage); system/user packages; per-run model selection (player +
housekeeper over the server.json defaults); spectator mode (read
everything, mutate nothing); the agenda — the player's second
status, `<add>`/`<drop>` deltas over a cap-5 recency queue, with
conflicts self-healing as their own message; and the reminder — the
GM-written turn-composition procedure riding every GM turn as its
own system chunk, one live copy. Design lives in ROADMAP ("The
multiuser server") and QUESTIONS #22-34, all resolved. **No users
exist yet:** the next server start mints the real bootstrap invite.
The server is stopped.
- **The GM surface rework is complete and live-proven (2026-11-14).**
Home lists runs by display name with live state; new run walks a
package picker into a naming form (package display name + a
dictionary-rolled, per-package-unique pc name, names-female.txt);
setup is a full-assembly editor (system.md/invariants.md read-only
first, then the editable craft in bundle order — handbook, backdrop,
character, seed, turn-0 — then read-only config; sigil/var
highlighting; $TOKENs declared by the prompts surface as inputs and
gate start; drafts two-click deletable); start opens the session and
sends turn-0 as the first GM turn. Play carries: the GM notepad
(gm.md — auto-saved, never model-facing), her status as a compact
comma block with a GM edit button (status-set, journaled),
housekeeping with a dry-run replay button, diagnostics on both
sides of the wire (server request log + a sessionStorage event log
behind the header's "log" button), busy indicators, and hardened
failure modes (no throw-to-home — only a real 404 leaves, loudly;
failed sends restore the line). Identity: @PC/@Package are identity
sigils (settings pc/name — a distinct class from $TOKENs, which the
prompts declare and setup collects); run ids are anonymous hex;
display is "La Caramba / Rell". Postulates: female PCs only;
boutique dormant AND defunct. Exposure rule: bundle parts are
inspectable read-only; agent prompts (housekeeper.md, repo-fed at
housekeeping, never copied) are never exposed.
- **Dates left the rings (GM, 2026-11-14).** No model-facing surface
renders a date — the old rendered date was the touch stamp
(referencing a memory rewrote its "when"), and records search
leaked real dates too. Manifest and seed carry no date keys; stamps
are internal and mechanical (LRU, overflow, "what's sinking" —
GM-facing only). Story time lives in prose. Live-proven: the real
housekeeper produced a clean dateless manifest first try.
- **The first real story is live: "La Caramba / Irene"** (run
4f261452, gitignored state). Window one open, 44+ exchanges at ~23K
prompt tokens — 9% of the contwin; the economy holds because
thinking never goes back, old status rides strip, and the bundle
floor is ~4.2K tokens. The GM ran the housekeeping dry-run on it: works
mechanically, output not yet as expected — housekeeper.md review
pending (the GM has not read the prompt yet).
- **The MVP substrate is complete (2026-11-14): all four phases built,
mock-proven, and live-proven.** Clerk (paper model, presets/runs),
server (REST spine, session machine, view renderer), housekeeping
job (async chain with autorestart), SPA (full v1 scope). The tool/
bridge is deleted. Two real housekeeping passes ran clean (both
manifests sound: correct ring-B classification, first-person voice,
precise touches); a full session was driven through the UI end to
end. **The server is stopped** (state as of this commit). Start it:
`node server/main.mjs [--mock]`, SPA at
http://127.0.0.1:7350/ (see AGENTS gotchas: check port 7350 first;
POST from PowerShell via Invoke-RestMethod).
- Live endpoint proven in-flow (glm-5.3 via llm.exan.tech, 13 models
carried on /models): right-format turns in her voice first try,
paper transport both directions, usage/context meter live.
- **Prompt split in force (GM's cut, 2026-11-14):** `system.md` =
opening + guards (glossary, purpose, input validation — repo-fed,
per-project); `invariants.md` = substrate (syntax markers, tools,
memory, records, the status + its 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,
editable to taste). One system message: system → invariants → the
run's handbook; then the bundle as GM messages (backdrop, character,
ring-b, ring-a, turn-0 on a fresh run). OOC is a single open paren,
closing optional; the SPA parses registers by that plus plain/italic.
`housekeeper.md` aligned (paper = acute states; relational shifts
recorded as the facts behind them; story dates taught).
- Prompt-side settled (2026-11-13): the content stance is the GM's
final form — erotica is not a special bucket (makes sense, isn't the
point, no pressure, never play anticipated leads to please the GM);
the adjudication philosophy is that the test is a review, not a
number (README). ROADMAP gained steal #11 (prompt re-injection) and
the projection principle (context is a projection, not a ledger).
- Red pen largely done (2026-11-13): new PC (shop girl, conviction by
association with a burnt decker), ten-state voice corpus (steal #1
done), gm notes recast (the ship-AI La Caramba, Missy, Pinky; pink
ice as licensed corpo firewall; mechanical feeders; the slop
quantified). Name call resolved: keep "Rell". Optional seed voice
touch-up may be revisited (QUESTIONS #19c, non-blocking). The seed
is authored but NOT applied — it rides the run copy at creation and
applies lazily at the first session-open.
- Build history in brief (details in ROADMAP phasing): phase 0 clerk
paper migration (2026-11-13), phase 1 preset/run split
(2026-11-13), phase 2 server (2026-11-14), phase 3 housekeeping job
(2026-11-14), phase 4 SPA (2026-11-14). The clerk's `--json` serves
the server; `tool/bridge.mjs` deleted at mock-parity.
- **Phase 0 (clerk side) DONE (2026-11-13):** the paper model is live in
`memory.mjs` — description-set schema (`paper` table), `paper` /
`paper-set` / `paper-apply` / `paper-ingest` verbs (exact-match
`<lost>`/`<gained>` deltas, non-blocking, `<conflict>` reporting,
prelude ingestion), amend/discard journal prior content (the saga
rule), seed rejects a status key loudly. Smoke-tested end to end
(delta misses, no-op re-adds, prelude ingest, dump/restore
round-trip, seed apply); both dbs reset clean. Loop-side items
(status tools gone from the tool list, per-turn `<status>` ride,
thinking-strip, usage tracking) land with the server.
- **Phase 1 (preset/run split) DONE (2026-11-13):** packages are
authored-only (backdrop, turn-0, character, seed, settings, gm — all
six state dirs removed); `create <package> <pc-name>` copies the
package wholesale into `runs/<id>/` (shared prompts included, run.json
lineage + optional model override) and inits state; `--run` addresses
runs; `packages`/`runs` list; `bridge.json` → `server.json`
(bind, endpoint, models, contwin, params; example committed,
key carried over, gitignored); `config.json` now names the default
package. Smoke-tested: create → seed → turn-0 ingest → delta apply →
status, re-seed refuses, smoke run deleted. `prelude.md` renamed
`turn-0.md` by the GM (comment dropped); clerk and docs follow.
- Boutique: dormant — a stub that never reached its design step
(concept brief in `packages/boutique/gm.md`).
- One run exists: Irene (4f261452, see above). Both packages render
clean as presets (`packages` lists them).
- **Substrate design round complete (2026-11-13)** — rulings recorded in
ROADMAP ("The harness"): the stated goal (a usable RP harness;
clone-and-run or invited instance, key on the backend, no secrets in
the repo), repo ships code + authored content only (state is
per-deployment), packages are presets copied wholesale into `runs/<id>/`
at creation (editable everything, discipline on the GM), lazy seed at
first session-open, per-run model selection with an upstream `/models`
listing, audit as per-pass dump snapshots inside the run
(commit-per-pass retired), zero-dep stack (QUESTIONS #4, #7 resolved).
## Immediate next steps, in order
1. **First start under multiuser (op, one-time).** Start the server,
claim the bootstrap invite (`state/bootstrap-invite.txt` and the
console both carry it), then hand-stamp Irene's `run.json` with
`"owner": "<your user id>"` — the SPA header tooltip shows the id.
No migration code exists, by ruling; this is the op's one manual
act.
2. **The first real housekeeping pass — the memory test begins.**
Close-and-housekeep the Irene session when the GM is ready; review
the manifest and the session log against the dump diff (the audit
surface). Everything from the story so far (the shipwreck, Molly,
the island) lives only in context and in her status until this
lands. Note: Irene's OPEN session still carries her old handbook
copy (craft edits land at session-open) — the housekeeping itself is
unaffected, but the clean reminder/agenda experiment starts at her
next session.
3. **Housekeeper prompt review (GM-led).** The GM's dry-run verdict:
works mechanically, output not as expected, and the prompt itself
is unseen so far. Iterate: read housekeeper.md, tweak, replay —
the dry-run button re-runs housekeeping over the session log with
nothing applied.
4. **Keep playing — and watch the experiments.** Observables #12 (the
status stays small and matches the transcripts) and #14 (turn
lengthening — the reminder is the countermeasure under test), plus
the fresh watchables: does thread-tracking move to the agenda;
drop off-by-ones; cross-channel drift; whether description-only
"empty turns" stay on her side of the purview line.
(Resolved en route: the status-discipline fight — the agenda gave the
drift its own channel, QUESTIONS #32/#33.)
## The multiuser build (2026-11-14) — DONE
Design round closed (ROADMAP "The multiuser server", QUESTIONS
#22-31); all four phases built and proven the same day:
1. **Storage + identity + auth spine** — `state/deployment.db`
(users, invites; gitignored `state/`), `server/users.mjs`,
bearer-token auth on every route except session/claim, bootstrap
invite on the fresh-deployment condition, owner stamping at create,
acting-user attribution in the request and LLM call logs.
2. **Ownership + fork + packages** — owner gating on every mutation
and every model call; per-run activity locks (turn, ask, turn0,
housekeeping job, fork); `POST /api/runs/:id/fork` (staged copy,
atomic swap, owner replaced, `forked` stamped, session state
mirrored); clerk learns the second packages root (`state/packages`)
and `save-package`; user packages published to all. Ownership is
resolved, never maintained (GM ruling): run.json keeps dead owner
ids, the API reads them as absent; revocation is a db delete plus
closing the revoked user's open sessions.
3. **SPA** — claim view, identity in the header, superuser admin on
home, spectator mode (read everything, mutate nothing, fork CTA),
save-as-package on setup, origin in the package picker, garnish
(owner, started/forked at second precision) on run names.
4. **Smoke + docs** — 34-step mock smoke plus a restart check, all
green; UI verified text-safely in the browser (claim, home, admin,
spectator on Irene, owner mode, fork click-through, picker,
setup; zero console errors). README deployment section +
layout updated; test state cleaned (Irene untouched).
Post-verdict cut (GM, same day): sign-out removed — signing in is
permanent and per-browser; the user lifecycle / auth story is a
ROADMAP extension point for a later revisit.
Gotcha learned while testing: the a11y snapshot races async renders —
wait for text that only exists POST-render (a card name, the
session-info line), never the static skeleton; and CSS text-transform
still uppercases wait targets.
Model selection wired (GM, same day): run.json now carries
`models: {player, housekeeper}` per-run overrides (replacing the old
singular `model` key — no run ever carried it), owner-settable via
POST /api/runs/:id/model and the SPA (setup box for drafts, play-aside
pane for started runs), falling back to the server.json defaults; the
housekeeper call resolves per wrap. Smoke 42/42, UI verified (setup
select + save, carried override visible on a fork's play view,
spectator pane hidden). #16's open call is now only the DEFAULT.
The agenda built (GM-designed, same day, QUESTIONS #32): the player's
second paper — intentions, not states. `<agenda>` rides every GM turn
(numbered from the top, as cited), `<add>`/`<drop>` deltas apply
received -> drop -> add, cap 5 with bottom-eviction, GM override + SPA
pane, housekeeping reads the deltas as evidence. Conflict delivery
re-ruled mid-build: a conflict goes back as its own message (clean of
prose), the model self-heals in the same exchange, capped at 3 heals a
turn — the `conflict` pending-state is gone entirely. Same-verb blocks
combine into one apply, never a sequence. The events journal CHECK was
widened (one-time lazy migration — ran clean on Irene's db, all rows
preserved). Invariants gained the substrate-tag syntax rule (any
`<tag>` line is OOC; unknown tags reported to GM) — the SPA register
parser follows it. Session-route fix rode along: /api/session returns
the public user shape only (it was leaking the token hash). Smoke
56/56, UI verified end to end.
The per-turn reminder built (GM-ruled, QUESTIONS #34, steal #11 DONE):
`reminder.md` (repo-shared) rides after every GM turn as its own
system chunk; one live copy — older elide from the view, the SPA shows
one collapsed card for the newest, housekeeping never sees it. The
GM's rewrite superseded the agent's extraction draft: it is a
*procedure* (understand -> decide -> compose -> adjust your papers),
not a rule list — new material throughout, including the per-class
turn budget (zero or one of thoughts/dialogue/actions) and the
dice-tiebreak. The handbook's "one thing per turn" was cut to "short
turns" in step (the budget lives in the reminder now). Smoke 58/58
plus an elision unit check (the log keeps every copy, the view carries
exactly one, at the freshest end). The next live window is the
experiment for observable #14.
## Working agreements with the GM
- **"I draft, you cut"** for all creative content.
- Character and world work is done together, unhurried ("we'll get
there together").
- The GM runs on organic memory and takes no notes — the system is the
prosthesis. The GM's lever is narrative, never mechanical.
- The GM answers point-by-point and expects pushback in both directions.
- `gm.md` files are GM-private: never pasted to any model.
- Rolls (`pick`) are legitimate at drafting time; rolled values are
proposals with the alternates listed for easy swaps.
- The play is uncensored; nothing lives in a special bucket — it makes
sense, it isn't the point, no pressure (no playing to please the GM).
Hard limits in `system.md` are absolute.
## Boutique creative brief
Now recorded in `packages/boutique/gm.md` (era, specialty, cast, and seeding
are open questions for the drafting session with the GM).
## Environment gotchas (learned the hard way)
- The portable shell scanner is picky: **plain ASCII only in shell
command strings.** Em-dashes in commit messages, here-strings, and
`< NUL` redirection have all been rejected. For multi-line stdin
tests, pipe an array of strings into node.
- `node:sqlite` prints an ExperimentalWarning on every invocation —
harmless; the clerk filters it in bridge context.
- `server.json` (gitignored) holds the real key; it mirrors opencode's
`dv` provider (config at `~/.config/opencode/opencode.jsonc`, auth at
`~/.local/share/opencode/auth.json`).
- Resetting a run: `Remove-Item runs/<id>/db/memory.db` then `init`.
`--force` flags are only for disposable pre-story states.
- Sessions log to `runs/<id>/sessions/<stamp>.jsonl` — housekeeping's
transcript, and the future watcher agent's food (see ROADMAP).
- The `--mock` mode has caught two real bugs already (dump column
rename, readline line-loss). Run it before any live first-use.
- The mock smoke lives in the repo (`test/` — the scripts moved in
from the temp dir at the GM's ask, 2026-11-14; no broader
test-infra ruling is attached): `smoke.mjs` (the 58-step
multiuser/agenda/reminder pass), `check-reminder.mjs` (the elision
unit check), `restart-check.mjs` (post-restart rebuild). They
expect a CLEAN state/ plus a running `--mock` server; smoke prints
its run ids and leaves a temp token file for the restart check.
Clean up state/ and the smoke runs afterwards — only the real runs
stay.
## Not yet exercised (expect first-use friction)
- **First start under multiuser** (step 1 above) — nothing live has
touched the auth spine, invites, fork, or spectator mode yet; all
are mock-proven only.
- ask_gm in live flow (pause/resume is mock-proven; the live model
simply made its own choices so far — by design), the self-heal
conflict path in live flow (mock-proven; capped at 3 heals a turn),
the agenda and the reminder against a live model, records tools
through the server (needs a records-enabled run).
- A live housekeeping rejection, and the recovery-apply path on a real
manifest, remain first-use items.
- The in-flow missed-update prediction (ROADMAP, system-1 entry) —
measurable from the second real session on.