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
+176
View File
@@ -0,0 +1,176 @@
/* rp-test SPA — dark, quiet, fiction-first. Three registers: speech is
plain, narration is italic (rendered dimmer), OOC is boxed. Machinery
(tools, notes, deltas) stays small and muted. */
:root {
--bg: #16161a;
--panel: #1e1e24;
--line: #2c2c34;
--text: #d6d3cb;
--dim: #8a877f;
--accent: #c9a26d;
--danger: #c96d6d;
--ok: #7da87d;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
height: 100%;
background: var(--bg);
color: var(--text);
font: 15px/1.55 ui-sans-serif, system-ui, sans-serif;
}
body {
display: grid;
grid-template:
"header header" auto
"main aside" 1fr
"footer footer" auto / 1fr 300px;
height: 100vh;
}
/* --- header --- */
header {
grid-area: header;
display: flex;
align-items: center;
gap: 12px;
padding: 8px 14px;
background: var(--panel);
border-bottom: 1px solid var(--line);
}
select, input, textarea, button {
background: var(--bg);
color: var(--text);
border: 1px solid var(--line);
border-radius: 4px;
padding: 5px 8px;
font: inherit;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
#new-run summary { cursor: pointer; color: var(--dim); }
#new-run form { display: flex; gap: 6px; margin-top: 6px; }
#window-info { color: var(--dim); font-size: 13px; margin-left: auto; white-space: nowrap; }
#context-meter { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
#context-bar { width: 90px; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#context-fill { height: 100%; width: 0; background: var(--ok); transition: width 0.4s; }
#context-fill.hot { background: var(--danger); }
/* --- transcript --- */
main { grid-area: main; overflow-y: auto; padding: 18px 22px; }
.turn { margin: 0 0 20px; max-width: 760px; }
.turn .who { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); margin-bottom: 3px; }
.turn.gm .who { color: var(--accent); }
.turn.player .who { color: var(--ok); }
.line { margin: 2px 0; white-space: pre-wrap; }
.narration { color: var(--dim); font-style: italic; }
.narration strong { color: var(--text); font-style: italic; }
.ooc { color: var(--dim); border-left: 2px solid var(--line); padding-left: 8px; font-size: 13px; }
.tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
font-size: 11px; padding: 1px 7px; border-radius: 9px;
border: 1px solid var(--line); color: var(--dim);
}
.chip.lost { text-decoration: line-through; }
.chip.gained { color: var(--ok); border-color: var(--ok); }
.chip.machinery { font-size: 11px; }
.machinery {
margin: 6px 0; font-size: 12px; color: var(--dim);
border-left: 2px solid var(--line); padding-left: 8px;
}
.machinery .head { color: var(--text); }
/* the bundle: a collapsed card, per part */
details.bundle {
margin: 14px 0; border: 1px solid var(--line); border-radius: 6px;
background: var(--panel); font-size: 13px; color: var(--dim);
}
details.bundle summary { cursor: pointer; padding: 6px 10px; letter-spacing: 0.06em; }
details.bundle pre { margin: 0; padding: 0 12px 10px; white-space: pre-wrap; font: inherit; }
.error-line { color: var(--danger); }
/* --- aside --- */
aside {
grid-area: aside;
border-left: 1px solid var(--line);
background: var(--panel);
padding: 14px;
overflow-y: auto;
font-size: 13px;
}
aside h2 {
margin: 4px 0 8px; font-size: 11px; letter-spacing: 0.14em;
text-transform: uppercase; color: var(--dim); font-weight: normal;
}
#paper { list-style: none; margin: 0; padding: 0; }
#paper li { padding: 3px 0; border-bottom: 1px dashed var(--line); }
#paper li::before { content: "— "; color: var(--dim); }
#paper li.empty { color: var(--dim); font-style: italic; }
#conflict {
margin-top: 10px; padding: 8px; border: 1px solid var(--danger);
border-radius: 4px; color: var(--danger); font-size: 12px;
}
#housekeeping { margin-top: 22px; }
#hk-state { color: var(--dim); margin-bottom: 8px; white-space: pre-wrap; }
#hk-state.rejected { color: var(--danger); }
#hk-state.applied { color: var(--ok); }
#hk-log pre { white-space: pre-wrap; font-size: 12px; max-height: 40vh; overflow-y: auto; }
#housekeeping button { width: 100%; margin-top: 6px; }
#hk-override-wrap { display: block; margin-top: 6px; color: var(--dim); font-size: 12px; }
/* --- footer --- */
footer {
grid-area: footer;
display: flex; gap: 8px; padding: 10px 14px;
background: var(--panel); border-top: 1px solid var(--line);
position: relative;
}
#gm-input { flex: 1; resize: none; }
#gm-send { padding: 5px 18px; }
/* in-page banner — replaces JS alert()/confirm() (they block the
embedded pane); errors and notices land here instead */
#banner {
position: absolute; left: 50%; top: -6px; transform: translate(-50%, -100%);
max-width: 70%; padding: 8px 14px; border-radius: 6px;
background: var(--panel); border: 1px solid var(--danger);
color: var(--danger); font-size: 13px; white-space: pre-wrap; z-index: 10;
}
#banner.info { border-color: var(--accent); color: var(--text); }
/* --- ask modal --- */
dialog {
background: var(--panel); color: var(--text);
border: 1px solid var(--accent); border-radius: 8px;
min-width: 380px; max-width: 560px; padding: 18px 20px;
}
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog h2 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
dialog p { margin: 0 0 12px; }
dialog textarea { width: 100%; }
dialog button { margin-top: 10px; }