the state-scan round: the log is the one truth for status and agenda, the db tiers retired -- scanState (server/session.mjs) derives each kind newest-wins across her emissions (the picked variant's text), the GM's override records, and the boundary state notes; the panes, the run detail, and the stamp all read it, GET /status and detail.status are derived reads, no clerk call, no db copy; the agenda cap is a derivation rule (GM, 2026-11-16: we log all seven items on reception, but the only way to see all seven is the raw event -- at no point an over-cap list can be derived), the reception note still shows the GM what sank; the stamp renders the canonical grammar -- status comma-separated, agenda markdown bullets, matching the line the GM added to invariants; the GM's block edits are overrides (GM, 2026-11-16: mutate during the contwin composition, the logs record the overrides arriving with the GM's turn as they should, the model sees the blocks overwritten with GM's edits attached to her turn, append if empty): the pane editors STAGE (paneEditor reworked -- no save callback, staged state, pending marker, discard), the send attaches them to POST /turn, node logs the override field on the GM turn, the composition renders it as hers -- the log never mutates, her words stay verbatim, the raw surfaces show the record; OOC turns refuse edits client and server both, the out-of-band POST /status and /agenda routes retired; stop writes the boundary state note at the carry head always (the crash-reconcile filters it before comparing), the start gate's n=1 seeding is dead (her authored opening turn IS the seed, the lint keeps requiring it), continuation carryovers are writable in the file editor during dormancy -- the review window's one editing surface, blocks included, no new pane; the clerk lost the tiers wholesale (schema tables, four verbs, canon status/agenda views, dump sections, report fields; the events CHECK keeps the historical op names; old dbs keep dead tables, never read, never dropped -- Irene is hands-off, and by the same day's ruling she is broken and never runs again: logs and db kept as they are, no replay, no continuation, no compatibility designed for her); Chloe hand-migrated to the new protocol -- her most recent turn carries the whole-list blocks applied from her db's exact values, her next context stamps them, her older lost/gained tags stay as history; the mock's agenda blocks went bullet, a new script position for the override turn's reply restates the mind so the boundary assert holds; smoke reworked to the scan battery (+ the 10f override block: the record rides its turn, the composition stamps at her canon point, the log keeps her emission verbatim, the OOC refusal, the boundary note at the carry head, the retired routes 404) -- ALL PASS; restart + reminder + repo checks green; the browser pass caught and fixed two real bugs (the pending marker's display:flex beat the hidden attribute -- any display rule needs a [hidden] override; setEditable(true) never ran the widget sync so the edit button stayed hidden) and proved the whole UX end to end with zero console errors -- staging, send-with-turn, the machinery lines on the table and raw, the OOC gate banner, discard, dormant read-only panes, the boundary note in the dormant preview; typecheck green on both programs; README/DICTIONARY carry the single-truth design, HANDOFF the round record and the Irene rewording, AGENTS the state pointer and the browser lessons

This commit is contained in:
2026-11-16 22:49:50 +00:00
parent 894737fcf3
commit 5ffecee935
17 changed files with 581 additions and 465 deletions
+55 -17
View File
@@ -10,7 +10,10 @@
// inherited by a fork), the full-block protocol (whole-list status
// and agenda sets, absent = unchanged, the silent over-cap eviction,
// the view stamping at the canon point, the <model> display blocks,
// the emitted-<model> guard, GM prose pure), the session lifecycle
// the emitted-<model> guard, GM prose pure), the state scan (the log
// is the one truth -- no db tier; the GM's block edit rides its turn
// as the override and composes over her newest blocks, the boundary
// state note rides the carry head), the session lifecycle
// (create dormant -> start -> live ->
// stop -> dormant -> re-run -> start -> the auto-send rule -> the
// start lint), the draft's memory.json (authored while draft, the
@@ -174,7 +177,7 @@ ok('live', r.data.phase === 'live' && r.data.open === true);
ok('the draft edit is what she starts with', r.data.fill.a === 5 && r.data.fill.b === 1, JSON.stringify(r.data.fill));
const filesLive = await call(`/runs/${runId}/files`, { token: op });
ok('memory.json is provenance once live', filesLive.data.files['memory.json']?.mode === 'ro', filesLive.data.files['memory.json']?.mode ?? 'missing');
ok('her authored blocks seed the clerk', JSON.stringify(r.data.status) === '["cuffed","belted","naked","barefoot","worried"]', JSON.stringify(r.data.status));
ok('her authored blocks are the seed (the scan derives them)', JSON.stringify(r.data.status) === '["cuffed","belted","naked","barefoot","worried"]', JSON.stringify(r.data.status));
r = await call(`/runs/${runId}/table`, { token: op });
ok('the opening renders on the table', r.data.entries.some((e) => e.t === 'msg' && e.m.role === 'assistant' && /Modesty, decency or respect/.test(e.m.content ?? '')));
ok('the opening event is retired (her authored blocks are the seed)', r.data.entries.every((e) => e.t !== 'opening'), 'an opening event rode the log');
@@ -226,6 +229,8 @@ r = await call(`/runs/${runId}/session`, { token: op });
const evictNote = r.data.entries.find((e) => e.t === 'note' && e.kind === 'agenda' && e.evicted?.length);
ok('the eviction is visible to the GM (the note)',
!!evictNote && JSON.stringify(evictNote.evicted) === '["item six","item seven"]', JSON.stringify(evictNote ?? null));
ok('the log keeps all seven items (raw is the only place they live)',
r.data.entries.some((e) => e.t === 'msg' && e.m.role === 'assistant' && /- item six\n- item seven/.test(e.m.content ?? '')), 'her emission was capped in the log');
r = await call(`/runs/${runId}/turn`, { method: 'POST', token: op, body: { line: '*Dawn breaks.*' } });
ok('next gm turn is clean', r.status === 200 && !r.data.conflicts, r.data.error ?? JSON.stringify(r.data.conflicts ?? null));
@@ -252,8 +257,10 @@ ok('the mind verb: her next turn rides at the stated mind',
const lastGm = [...r.data.entries].reverse().find((e) => e.t === 'msg' && e.m.role === 'user' && !e.conflictOnly);
ok('no conflict attached to the GM turn', !/<conflict>/.test(lastGm.m.content), lastGm.m.content.slice(-100));
ok('GM prose goes pure', !/<\/?(status|agenda)>/.test(lastGm.m.content), lastGm.m.content.slice(-120));
r = await call(`/runs/${runId}/agenda`, { method: 'POST', token: op, body: { items: ['climb the ridge', 'rest'] } });
ok('agenda-set (GM override)', r.status === 200 && JSON.stringify(r.data.agenda) === '["climb the ridge","rest"]', JSON.stringify(r.data.agenda));
r = await call(`/runs/${runId}/status`, { method: 'POST', token: op, body: { items: [] } });
ok('the out-of-band status route is retired', r.status === 404, `${r.status}`);
r = await call(`/runs/${runId}/agenda`, { method: 'POST', token: op, body: { items: [] } });
ok('the out-of-band agenda route is retired', r.status === 404, `${r.status}`);
// 10d. an OOC GM turn: the paren channel carries no cache blocks -- an
// OOC exchange does not move her state, the next IC turn re-carries them
@@ -284,11 +291,11 @@ const her1 = view1.filter((m) => m.role === 'assistant');
const lastHer = [...her1].reverse().find((m) => typeof m.content === 'string' && /breathes until the numbers behave/.test(m.content));
ok('the view stamps the newest status and agenda at her latest turn',
!!lastHer && /<status>cuffed, belted, naked, barefoot, settled, curious about the clicking<\/status>/.test(lastHer.content)
&& /<agenda>item one\nitem two\nitem three\nitem four\nitem five\nitem six\nitem seven<\/agenda>/.test(lastHer.content),
(lastHer?.content ?? 'none').slice(-220));
ok('the stamped agenda is her own emission (the eviction stays silent to her)',
!!lastHer && (lastHer.content.match(/<agenda>/g) ?? []).length === 1 && /item seven<\/agenda>/.test(lastHer.content),
'the stamp leaked the clerk truth');
&& /<agenda>\n- item one\n- item two\n- item three\n- item four\n- item five\n<\/agenda>/.test(lastHer.content),
(lastHer?.content ?? 'none').slice(-260));
ok('the capped agenda is what derives (the eviction stays silent to her)',
!!lastHer && (lastHer.content.match(/<agenda>/g) ?? []).length === 1 && !/item (six|seven)/.test(lastHer.content),
'the stamp leaked the over-cap items');
ok('superseded copies strip from the view',
her1.filter((m) => m !== lastHer).every((m) => !/<\/?(status|agenda)>/.test(String(m.content ?? ''))), '');
ok('her mind tags are write-only (stripped from the view)',
@@ -305,8 +312,6 @@ r = await call(`/runs/${runId}/session`, { token: op });
const reminders = r.data.entries.filter((e) => e.reminder);
ok('reminder rode every GM turn', reminders.length === 6 && reminders.every((x) => x.m.role === 'system'), `${reminders.length} in the log`);
ok('reminder carries the turn protocol', /How to compose your turn/i.test(reminders[0]?.m.content ?? ''), (reminders[0]?.m.content ?? '').slice(0, 60));
r = await call(`/runs/${runId}/agenda`, { method: 'POST', token: ash, body: { items: [] } });
ok('agenda override owner-only', r.status === 403);
r = await call(`/runs/${runId}/status`, { token: op });
ok('status endpoint carries both', Array.isArray(r.data.status) && Array.isArray(r.data.agenda), JSON.stringify(r.data).slice(0, 120));
@@ -355,6 +360,32 @@ r = await call(`/runs/${forkId}/session`, { token: ash });
const forkReply = [...r.data.entries].reverse().find((e) => e.t === 'msg' && e.m.role === 'assistant');
ok('the fork inherits her unconsumed mind', forkReply?.via?.params?.temperature === 1.2, JSON.stringify(forkReply?.via ?? null));
// 10f. the GM's block edit rides its turn (the override): the log
// records the field, the composition overwrites her newest blocks
// with it, the log keeps her words verbatim, and the model never
// sees an override as an act -- only as state
r = await call(`/runs/${runId}/turn`, { method: 'POST', token: op, body: { line: '*A cooler wind picks up.*', agenda: ['climb the ridge', 'rest'] } });
ok('the override turn sends', r.status === 200, r.data.error ?? '');
r = await call(`/runs/${runId}/session`, { token: op });
const ovrTurn = [...r.data.entries].reverse().find((e) => e.t === 'msg' && e.m.role === 'user' && e.override);
ok('the override rides its GM turn as the record',
!!ovrTurn && JSON.stringify(ovrTurn.override.agenda) === '["climb the ridge","rest"]' && ovrTurn.override.status === undefined,
JSON.stringify(ovrTurn?.override ?? null));
ok('the override turn\'s prose stays pure', !/<\/?(status|agenda)>/.test(String(ovrTurn?.m.content ?? '')), String(ovrTurn?.m.content ?? '').slice(-80));
r = await call(`/runs/${runId}/status`, { token: op });
ok('the composed agenda is the override', JSON.stringify(r.data.agenda) === '["climb the ridge","rest"]', JSON.stringify(r.data.agenda));
ok('the untouched status derives unchanged',
JSON.stringify(r.data.status) === '["cuffed","belted","naked","barefoot","settled","curious about the clicking"]', JSON.stringify(r.data.status));
const view1b = renderView({ lines: jsonl(runId, 1, 'log.jsonl'), pendingAsk: null });
const lastHerB = [...view1b].reverse().find((m) => m.role === 'assistant' && typeof m.content === 'string' && m.content.trim());
ok('the composition stamps the override at her canon point',
/<agenda>\n- climb the ridge\n- rest\n<\/agenda>/.test(lastHerB.content), String(lastHerB.content).slice(-180));
ok('the log keeps her words verbatim (the over-cap emission is intact)',
jsonl(runId, 1, 'log.jsonl').some((e) => e.t === 'msg' && e.m.role === 'assistant' && /- item six\n- item seven/.test(e.m.content ?? '')),
'her emission was rewritten');
r = await call(`/runs/${runId}/turn`, { method: 'POST', token: op, body: { line: '( ooc with an edit )', status: ['x'] } });
ok('an override cannot ride an OOC turn', r.status === 400 && /OOC/.test(r.data.error), r.data.error ?? '');
// 12b. models: per-run overrides of the deployment defaults, the
// registry-gated picks, and the named sampling knobs
r = await call(`/runs/${forkId}/model`, { method: 'POST', token: ash, body: { player: 'mock', housekeeper: 'mock-cheap' } });
@@ -377,13 +408,15 @@ r = await call(`/runs/${forkId}/model`, { method: 'POST', token: ash, body: { ba
ok('unknown role rejected', r.status === 400);
r = await call(`/runs/${forkId}`, { token: ash });
ok('detail exposes models + defaults', r.data.run.models?.player === 'mock' && !!r.data.run.modelDefaults?.player && r.data.run.params?.player?.max_tokens === 4096 && !!r.data.run.paramDefaults, JSON.stringify(r.data.run.models));
// a turn on the knob-carrying run: the recording proves what was sent
// a turn on the knob-carrying run: the recording proves what was
// sent -- the run's knob under the mind layer (her restated mind
// rides over the run layer, the layering the tunables round built)
r = await call(`/runs/${forkId}/turn`, { method: 'POST', token: ash, body: { line: '*She keeps watch.*' } });
ok('gm turn on the fork (post-knobs)', r.status === 200, r.data.error ?? '');
r = await call(`/runs/${forkId}/session`, { token: ash });
const viaTurn = [...r.data.entries].reverse().find((e) => e.t === 'msg' && e.m.role === 'assistant');
ok('the recorded request carries the run\'s knobs',
!!viaTurn?.via && viaTurn.via.model === 'mock' && viaTurn.via.params.max_tokens === 4096 && viaTurn.via.params.temperature === undefined,
ok('the recorded request carries the run\'s knobs under the mind layer',
!!viaTurn?.via && viaTurn.via.model === 'mock' && viaTurn.via.params.max_tokens === 4096 && viaTurn.via.params.temperature === 1.2,
JSON.stringify(viaTurn?.via ?? null));
r = await call('/models', { token: ash });
ok('model listing (the registry)', r.status === 200 && r.data.phase === 'refined' && r.data.models.some((m) => m.id === 'mock' && m.label === 'Mock'), JSON.stringify(r.data.phase));
@@ -462,8 +495,13 @@ const log1 = jsonl(runId, 1, 'log.jsonl');
const carry2 = jsonl(runId, 2, 'carryover.jsonl');
ok('the tail moved out of session 1', carry2.length > 0 && log1.every((e) => !carry2.some((c) => JSON.stringify(c) === JSON.stringify(e))),
`${carry2.length} carried lines`);
ok('the carry holds whole exchanges', carry2[0]?.t === 'msg' && carry2[0]?.m?.role === 'user' && !carry2[0]?.conflictOnly
&& carry2.some((e) => e.t === 'msg' && e.m.role === 'assistant'), carry2[0]?.t ?? 'nothing carried');
ok('the boundary state note rides the carry head',
carry2[0]?.t === 'note' && carry2[0]?.kind === 'state'
&& JSON.stringify(carry2[0]?.agenda) === '["climb the ridge","rest"]'
&& JSON.stringify(carry2[0]?.status) === '["cuffed","belted","naked","barefoot","settled","curious about the clicking"]',
JSON.stringify(carry2[0] ?? null));
ok('the carry holds whole exchanges', carry2[1]?.t === 'msg' && carry2[1]?.m?.role === 'user' && !carry2[1]?.conflictOnly
&& carry2.some((e) => e.t === 'msg' && e.m.role === 'assistant'), carry2[1]?.t ?? 'nothing carried');
ok('the carry ends on her turn (no auto-send)', [...carry2].reverse().find((e) => e.t === 'msg' && !e.reminder)?.m?.role === 'assistant');
ok('no markers anywhere in the logs', log1.concat(carry2).every((e) => e.carried === undefined));
r = await call(`/runs/${runId}/carryover`, { token: op });
@@ -473,7 +511,7 @@ ok('the dormant preview renders the carry', r.status === 200 && r.data.session =
// the story reads whole, through dormancy, with no doubles
r = await call(`/runs/${runId}/story`, { token: op });
const gmTexts = r.data.sessions.flatMap((s) => s.turns.filter((t) => t.who === 'gm').map((t) => t.text));
ok('the story has every GM turn exactly once', gmTexts.length === 5 && new Set(gmTexts).size === 5, `${gmTexts.length} gm turns across ${r.data.sessions.length} sessions`);
ok('the story has every GM turn exactly once', gmTexts.length === 6 && new Set(gmTexts).size === 6, `${gmTexts.length} gm turns across ${r.data.sessions.length} sessions`);
ok('the story carries no OOC', r.data.sessions.every((s) => s.turns.every((t) => !/^\(/.test(t.text) && !/\( mock GM checking in \)/.test(t.text))), 'OOC leaked into the story');
ok('the story reads the dormant carryover at the live edge', r.data.sessions.some((s) => s.turns.length >= 10));
const storyPlayer = r.data.sessions.flatMap((s) => s.turns.filter((t) => t.who === 'player').map((t) => t.text));