the sheet round: the GM's ledger of arbitrated run state -- the second state channel, split from status and agenda by truth model (GM, 2026-11-17). The rulings first: status and agenda are narrative self-report (their truth is "she said so", the scan caches her latest words); the sheet is actual run state (its truth is "the GM set so", the record IS the truth event -- nothing cached from anyone's words). The override channel promoted to a standing section, and that precedent decided the presentation: the sheet renders as its OWN authoritative system chunk at the freshest end, never a canon-point stamp, which would read as her words -- the same reason the override composes as hers and the sheet never does. Schemaless JSON in the tag (the mind-verb philosophy: the substrate teaches the channel, the package teaches the vocabulary -- the invariants rule the GM wrote is one universal paragraph with deliberately non-box examples, clothes and grades, and the propose-additions line as her schema-evolution channel); details learnt in-place; NO package gating -- the channel is universal and "optional, if given" makes the invariant forward-compatible in every bundle that never sets one. The build: a sheet record rides the GM turn like the override (readSheet: object-ness is the route's only law, 400 loud on arrays and scalars, nothing appended; OOC turns refuse it exactly like block edits); scanState derives newest-wins whole-set -- an absent key drops, never keeps, and {} is a live empty ledger (a truthy check, never falsy); the boundary state note carries it across stops and the dormant read path serves it; renderView appends the chunk once per assembly so one live copy holds by construction; the guard is the <model> sibling (an emitted <sheet> conflicts with "the GM's ledger -- propose changes in prose", healed in-turn, cap 3, and her emission never applies -- the scan holds the GM's record); every strip surface learned the tag (the view's STRIP_HERS, the story's verbs, the table's chip regex -- the standing grep-every-strip-list lesson, applied); and the web gains sheetEditor, the paneEditor's JSON sibling in widgets.mjs (same stage/pending/discard pattern, bad JSON refuses at the stage), the third pane in the aside, the send attaching body.sheet, and [sheet] machinery lines on both table and raw walks. The mock's sheet-guard branch is CUE-KEYED, not position-keyed: the carried tail shifts the script's counts (session 4's log starts the script over -- the battery's first attempt landed on the ask position and crashed renderView on the unpaired call; the battery now answers the script ask and moves on), while a marked GM turn is immune to every shift -- mockModel reads the view, the marked turn earns the emission, the conflict it earns earns the plain-prose heal. check-reminder is sheet-aware (the chunk is a legitimate third system surface; the count and freshest-end assertions tolerate exactly one, and the freshest-end check now allows her latest reply and/or the chunk to follow the reminder). Verified: smoke ALL PASS with +15 sheet assertions (newest-wins, whole-set semantics, the chunk one-live-copy -- ANCHORED with startsWith because the invariants bundle itself mentions the tag and a bare regex matches it twice, an honest test bug caught by an honest test), the guard's conflict and heal with her emission kept verbatim in the raw log and never applied, the view and story strips, the empty ledger rendering its chunk, the boundary note carrying the sheet, the dormant read deriving it, and session 5 deriving it from the carried note end to end), restart + reminder checks green, typecheck green on both programs, check-repo clean (it caught the round's own prose twice: "window" is a retired term in README, the contwin vocabulary wins), and a browser pass over the pane end to end with zero console errors -- staging, the pending marker, the ride, the scan re-render, and both machinery lines on the table. Docs: README's protocol passage carries the sheet with the numbers-live-on-the-sheet line (prose numbers die with the contwin; sheet numbers ride the scan forever) -- NOT in the memory tiers table, where the first draft wrongly put it (the GM's ruling: the sheet belongs in neither memories nor records); the identity tier lost its loose "character sheet" name now that the term is technical; DICTIONARY gains the sheet entry with the history line (dice retired into variant literature, sheets arrived as the state machinery -- the tabletop metaphor completing while its realism stays advisory, players hold their own pencils in the real thing and we don't, for drift); ROADMAP parks the bookkeeper extension (the housekeeper's arithmetic sibling: reads the setting's rules prose and the latest turns, computes the ledger delta from a purchase in her prose, lands it as a STAGED edit -- applied on the GM's next turn or discarded; sheet-only authority, curator fallback, per-package opt-in because an agent cannot bookkeep what is not arithmetic). The GM's prompt-side edits ride the same commit: invariants' "Character's sheet" section (the universal rule, the trailing-clause flag taken in review), the reminder's inventory line gaining "the sheet (optional)", and la caramba's gm.md lore updates. The box package (the first consumer) and detention stay untracked WIP, untouched. The 2026-11-17 roadmap audit rides the same commit (GM: "done items can retire"): retired outright -- the SPA-vs-bridge and voice-examples decisions (long resolved) and steal items #1, #3, #4, #8, #11 (done, or in #8's case never work -- the housekeeper model is per-run selection, built); retired with tombstones -- the multiuser section (built 2026-11-14, the rulings live in DECISIONS #22-31 and README, the lifecycle tail kept visible) and the SPA v1 section (all four phases done, the API sketch superseded by README's living API docs, the substrate doctrine in README), with the one unbuilt design it held -- the turn-surgery saga rule -- surviving as its own bullet cross-referenced at steal #2; amended in place, dated -- seed.json (dead, successors named: the authored carryover and memory.json), turn-0.md (dead: her authored opening turn), the upstream model listing (never queried in play since discovery), the delta-tag transport (the full-block protocol, the sheet named), the service step (multiuser built, hosting remains), the carryover editor (the raw file-editor surface exists, the purpose-built UI stays deferred); kept -- the operator's queue, the landscape and receipts, the live constraints, the open steals with numbering preserved so cross-references resolve, the deferred tasks, the distant points, the rejections, the notes. 582 lines to 338; the first deletion pass duplicated the steal-list header and the verification re-read caught it
This commit is contained in:
@@ -148,6 +148,12 @@
|
||||
</div>
|
||||
<div id="agenda"></div>
|
||||
</section>
|
||||
<section id="sheet-pane">
|
||||
<div class="pane-head">
|
||||
<h2>the sheet</h2>
|
||||
</div>
|
||||
<div id="sheet"></div>
|
||||
</section>
|
||||
<section id="notes-pane">
|
||||
<div class="pane-head">
|
||||
<h2>gm notes</h2>
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ export {};
|
||||
* her two blocks, the fill, the context meter's numbers.
|
||||
* paramDefaults is the knobs' deployment layer (server.json params)
|
||||
* -- the only default an unset knob honestly resolves to. */
|
||||
/** @typedef {{ run: { id: string, package: ?string, created: ?string, forked: ?number, owner: ?string, ownerName: ?string, models: { player?: ?string, housekeeper?: ?string }, params: { player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams }, modelDefaults: { player?: ?string, housekeeper?: ?string }, paramDefaults: { player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams } }, display: string, open: boolean, phase: ?string, session: ?number, sessions: number, draft: boolean, ready: ?boolean, status: string[], agenda: string[], records: number, fill: Record<string, number>, events: number, pendingAsk: ?string, usage: ?{ promptTokens: number, completionTokens: number }, context: ?{ used: number, contwin: ?boolean, pct: ?number } }} RunDetail */
|
||||
/** @typedef {{ run: { id: string, package: ?string, created: ?string, forked: ?number, owner: ?string, ownerName: ?string, models: { player?: ?string, housekeeper?: ?string }, params: { player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams }, modelDefaults: { player?: ?string, housekeeper?: ?string }, paramDefaults: { player?: ?import('../server/shapes.mjs').RoleParams, housekeeper?: ?import('../server/shapes.mjs').RoleParams } }, display: string, open: boolean, phase: ?string, session: ?number, sessions: number, draft: boolean, ready: ?boolean, status: string[], agenda: string[], sheet: ?Record<string, unknown>, records: number, fill: Record<string, number>, events: number, pendingAsk: ?string, usage: ?{ promptTokens: number, completionTokens: number }, context: ?{ used: number, contwin: ?boolean, pct: ?number } }} RunDetail */
|
||||
|
||||
/** GET /api/models -- the deployment's model registry and the
|
||||
* discovery job state riding along. phase 'none' is the fresh
|
||||
|
||||
+13
-4
@@ -58,12 +58,13 @@ function renderContent(target, text, { extract }) {
|
||||
if (am) { agenda = am[1]; body = body.replace(am[0], ''); }
|
||||
}
|
||||
const tags = [];
|
||||
for (const m of body.matchAll(/<(lost|gained|add|drop|mind|status|agenda)>([\s\S]*?)<\/\1>/g)) {
|
||||
for (const m of body.matchAll(/<(lost|gained|add|drop|mind|status|agenda|sheet)>([\s\S]*?)<\/\1>/g)) {
|
||||
// the mind block is JSON -- it rides whole (no comma-splitting);
|
||||
// the note line carries the human-readable form. Status and
|
||||
// agenda blocks are the full-block protocol: their items chip
|
||||
// like the deltas did (list markers stripped for display)
|
||||
const items = m[1] === 'mind'
|
||||
// like the deltas did (list markers stripped for display). The
|
||||
// sheet is JSON too -- it chips whole like the mind
|
||||
const items = m[1] === 'mind' || m[1] === 'sheet'
|
||||
? [m[2].trim()]
|
||||
: m[2].split('\n').flatMap((l) => l.replace(/^\s*[-*]\s+\d*[.:)]?\s*/, '').split(',')).map((x) => x.trim()).filter(Boolean);
|
||||
tags.push({ kind: m[1], items });
|
||||
@@ -160,7 +161,8 @@ export function viaLine(via, fail = null) {
|
||||
|
||||
// the GM's block edit, as the machinery line both walks show: the
|
||||
// override rides its turn as the record; the composition overwrites
|
||||
// her newest blocks with it
|
||||
// her newest blocks with it. The sheet record rides the same way --
|
||||
// the GM's ledger, a whole set
|
||||
/** @param {{ status?: string[], agenda?: string[] }} o @returns {string} */
|
||||
function overrideText(o) {
|
||||
const parts = [];
|
||||
@@ -168,6 +170,10 @@ function overrideText(o) {
|
||||
if (o.agenda) parts.push(`agenda ${JSON.stringify(o.agenda)}`);
|
||||
return `[block edit] ${parts.join(' | ')} -- composes over her newest blocks`;
|
||||
}
|
||||
/** @param {Record<string, unknown>} sheet @returns {string} */
|
||||
function sheetText(sheet) {
|
||||
return `[sheet] ${JSON.stringify(sheet)} -- the GM's ledger`;
|
||||
}
|
||||
|
||||
// the note line, shared by both walks
|
||||
/** @param {NoteEvent} e @returns {?string} */
|
||||
@@ -190,6 +196,7 @@ function noteText(e) {
|
||||
const parts = [];
|
||||
if (e.status) parts.push(`status ${JSON.stringify(e.status)}`);
|
||||
if (e.agenda) parts.push(`agenda ${JSON.stringify(e.agenda)}`);
|
||||
if (e.sheet) parts.push(`sheet ${JSON.stringify(e.sheet)}`);
|
||||
return `boundary state carried across the stop: ${parts.join(' | ')}`;
|
||||
}
|
||||
return null;
|
||||
@@ -266,6 +273,7 @@ export function renderRaw(entries) {
|
||||
const d = block(e.conflictOnly ? 'gm -- conflict only' : 'gm');
|
||||
d.appendChild(el('pre', null, String(e.m.content ?? '')));
|
||||
if (e.override) d.appendChild(el('div', 'machinery', overrideText(e.override)));
|
||||
if (e.sheet) d.appendChild(el('div', 'machinery', sheetText(e.sheet)));
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'msg' && e.m.role === 'assistant') {
|
||||
@@ -366,6 +374,7 @@ export function renderTranscript(entries, { onConflict, onRaw } = {}) {
|
||||
const { conflict } = renderContent(body, e.m.content, { extract: true });
|
||||
if (conflict) onConflict?.(conflict);
|
||||
if (e.override) d.appendChild(el('div', 'machinery', overrideText(e.override)));
|
||||
if (e.sheet) d.appendChild(el('div', 'machinery', sheetText(e.sheet)));
|
||||
if (onRaw) addRawControl(head, d, idx);
|
||||
t.appendChild(d);
|
||||
}
|
||||
|
||||
+16
-4
@@ -16,7 +16,7 @@ import { state } from './state.mjs';
|
||||
import { banner, hideBanner, renderMeter, setBusy, setSessionInfo } from './chrome.mjs';
|
||||
import { navigate, render, runGone } from './router.mjs';
|
||||
import { logEvent } from './log.mjs';
|
||||
import { armedButton, modelList, modelsBox, paneEditor } from './widgets.mjs';
|
||||
import { armedButton, modelList, modelsBox, paneEditor, sheetEditor } from './widgets.mjs';
|
||||
import { renderRaw, renderTranscript, stickBottom, viaLine } from './transcript.mjs';
|
||||
|
||||
// the table's two faces: the curated projection (the table) and the
|
||||
@@ -58,6 +58,11 @@ const agendaPane = paneEditor({
|
||||
.map((x) => x.trim()).filter(Boolean),
|
||||
});
|
||||
|
||||
// the sheet: the GM's ledger, the same stage-and-ride pattern -- an
|
||||
// edit rides the next GM turn as the record; the panes re-render from
|
||||
// the scan
|
||||
const theSheet = sheetEditor('sheet-pane', 'sheet');
|
||||
|
||||
const models = modelsBox('models-pane', { title: 'models' });
|
||||
|
||||
export function leave() {
|
||||
@@ -72,6 +77,7 @@ export async function enter(id, seq) {
|
||||
if (rawRun !== id) { rawRun = id; rawOpen = false; } // a new run starts at the table
|
||||
statusPane.reset();
|
||||
agendaPane.reset();
|
||||
theSheet.reset();
|
||||
$('conflict').hidden = true;
|
||||
await saveNotes(); // flush the pad for the previous run before switching
|
||||
state.runId = id;
|
||||
@@ -101,6 +107,7 @@ async function refreshPlay(id, seq) {
|
||||
renderMeter(detail);
|
||||
statusPane.set(detail.status);
|
||||
agendaPane.set(detail.agenda);
|
||||
theSheet.set(detail.sheet);
|
||||
$('conflict').hidden = true;
|
||||
|
||||
// the owner's table, live only for the panes: a block edit rides a
|
||||
@@ -109,6 +116,7 @@ async function refreshPlay(id, seq) {
|
||||
// was redirected to the story above.
|
||||
statusPane.setEditable(detail.phase === 'live');
|
||||
agendaPane.setEditable(detail.phase === 'live');
|
||||
theSheet.setEditable(detail.phase === 'live');
|
||||
/** @type {HTMLTextAreaElement} */ ($('gm-notes')).readOnly = false;
|
||||
|
||||
$('table-tabs').hidden = true; // the tabs are the live session's
|
||||
@@ -460,11 +468,14 @@ async function sendTurn() {
|
||||
const line = /** @type {HTMLInputElement} */ ($('gm-input')).value.trim();
|
||||
if (!line || !state.runId) return;
|
||||
// staged block edits ride the turn (the override): only the kinds
|
||||
// staged attach, whole-list
|
||||
/** @type {{ line: string, status?: string[], agenda?: string[] }} */ const body = { line };
|
||||
// staged attach, whole-list. The staged sheet rides the same way --
|
||||
// the GM's ledger record ({} is a live empty ledger, so the null
|
||||
// check, not truthiness)
|
||||
/** @type {{ line: string, status?: string[], agenda?: string[], sheet?: Record<string, unknown> }} */ const body = { line };
|
||||
if (statusPane.staged) body.status = statusPane.staged;
|
||||
if (agendaPane.staged) body.agenda = agendaPane.staged;
|
||||
if ((body.status || body.agenda) && line.startsWith('(')) {
|
||||
if (theSheet.staged !== null) body.sheet = theSheet.staged;
|
||||
if ((body.status || body.agenda || body.sheet !== undefined) && line.startsWith('(')) {
|
||||
banner('a block edit cannot ride an OOC turn -- send it as a normal GM turn, or discard the edit');
|
||||
return; // the line stays in the box, the staging stays staged
|
||||
}
|
||||
@@ -478,6 +489,7 @@ async function sendTurn() {
|
||||
await api(`/runs/${state.runId}/turn`, { method: 'POST', body });
|
||||
statusPane.clearStaged(); // sent -- the panes re-render from the scan
|
||||
agendaPane.clearStaged();
|
||||
theSheet.clearStaged();
|
||||
} catch (e) {
|
||||
failed = e.message;
|
||||
/** @type {HTMLInputElement} */ ($('gm-input')).value = line; // a failed send must not eat the line
|
||||
|
||||
@@ -110,6 +110,93 @@ export function paneEditor({ section, body, empty, placeholder, rows, format, to
|
||||
};
|
||||
}
|
||||
|
||||
// the sheet pane: the same stage-and-ride pattern as the block panes,
|
||||
// JSON-typed -- the GM's ledger of arbitrated run state (GM,
|
||||
// 2026-11-17: the model reads it, never writes it; her proposals
|
||||
// arrive in prose). A record is a whole set: staging replaces the
|
||||
// entire object, an empty object is a deliberate empty ledger. Bad
|
||||
// JSON refuses at the stage -- the server would refuse it at the turn.
|
||||
/** @typedef {{ set: (next?: ?Record<string, unknown>) => void, setEditable: (ok: boolean) => void, reset: () => void, staged: ?Record<string, unknown>, clearStaged: () => void }} SheetPane */
|
||||
/** @param {string} section @param {string} body @returns {SheetPane} */
|
||||
export function sheetEditor(section, body) {
|
||||
const sec = $(section);
|
||||
const bodyEl = $(body);
|
||||
const editBtn = el('button', null, 'edit');
|
||||
(/** @type {HTMLElement} */ (sec.querySelector('.pane-head'))).appendChild(editBtn);
|
||||
const editor = el('div', 'pane-editor');
|
||||
editor.hidden = true;
|
||||
const area = /** @type {HTMLTextAreaElement} */ (el('textarea'));
|
||||
area.rows = 6;
|
||||
area.placeholder = 'the sheet is JSON -- the GM\'s ledger of the run\'s objective state';
|
||||
const actions = el('div', 'pane-editor-actions');
|
||||
const saveBtn = el('button', null, 'stage');
|
||||
const cancelBtn = el('button', null, 'cancel');
|
||||
actions.appendChild(saveBtn);
|
||||
actions.appendChild(cancelBtn);
|
||||
editor.appendChild(area);
|
||||
editor.appendChild(actions);
|
||||
bodyEl.after(editor);
|
||||
const pending = el('div', 'pane-pending');
|
||||
pending.hidden = true;
|
||||
pending.appendChild(el('span', null, 'edited -- rides your next turn'));
|
||||
const dropBtn = el('button', null, 'discard edit');
|
||||
pending.appendChild(dropBtn);
|
||||
editor.after(pending);
|
||||
|
||||
/** @type {?Record<string, unknown>} */ let sheet = null; // the current truth (never a falsy check -- {} is a live empty ledger)
|
||||
/** @type {?Record<string, unknown>} */ let staged = null;
|
||||
let mayEdit = false;
|
||||
let open = false;
|
||||
|
||||
const sync = () => {
|
||||
bodyEl.hidden = open;
|
||||
editBtn.hidden = open || !mayEdit;
|
||||
editor.hidden = !open;
|
||||
pending.hidden = staged === null;
|
||||
};
|
||||
const renderBody = () => {
|
||||
const show = staged ?? sheet;
|
||||
bodyEl.textContent = show == null ? 'nothing tracked' : JSON.stringify(show, null, 2);
|
||||
bodyEl.classList.toggle('empty', show == null);
|
||||
};
|
||||
const openEditor = () => {
|
||||
area.value = JSON.stringify(staged ?? sheet ?? {}, null, 2);
|
||||
open = true;
|
||||
sync();
|
||||
area.focus();
|
||||
};
|
||||
const cancel = () => { open = false; sync(); };
|
||||
const doSave = () => {
|
||||
try {
|
||||
const parsed = JSON.parse(area.value);
|
||||
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
||||
banner('the sheet wants a JSON object');
|
||||
return;
|
||||
}
|
||||
staged = /** @type {Record<string, unknown>} */ (parsed);
|
||||
} catch (e) {
|
||||
banner(`the sheet is JSON -- ${String(e.message ?? e).split('\n')[0]}`);
|
||||
return;
|
||||
}
|
||||
cancel();
|
||||
renderBody();
|
||||
};
|
||||
const dropStaged = () => { staged = null; sync(); renderBody(); };
|
||||
|
||||
editBtn.addEventListener('click', openEditor);
|
||||
cancelBtn.addEventListener('click', cancel);
|
||||
saveBtn.addEventListener('click', doSave);
|
||||
dropBtn.addEventListener('click', dropStaged);
|
||||
|
||||
return {
|
||||
set(next) { sheet = next ?? null; renderBody(); },
|
||||
setEditable(ok) { mayEdit = ok; cancel(); if (!ok) dropStaged(); },
|
||||
reset() { cancel(); dropStaged(); },
|
||||
get staged() { return staged; },
|
||||
clearStaged: dropStaged,
|
||||
};
|
||||
}
|
||||
|
||||
// the model registry, fetched once per session -- the selectors read
|
||||
// the saved registry, never the live provider (discovery is the op's
|
||||
// manual act; a listing fetch every render would hammer the endpoint
|
||||
|
||||
Reference in New Issue
Block a user