the 2026-11-16 rounds, the whole day in one commit: model discovery (the two-step op act -- discover scrapes the provider metadata, refine runs the deterministic battery over every id and hands the adjudicated results to the best passing model for the curated registry; state/models.json is the truth of selectable models and gates all model use, a fresh deployment has none; the five named sampling knobs ride run.json params over server.json params, sent only when set; the curator call retries once on the host's network hiccups, its output strictly validated with the machine-list fallback, and the do-not-deliberate line keeps its thinking tokens down); the pick rule reworked on the GM's rulings -- the dv endpoint's 5.2/5.3-max flip was an alias (one model behind both ids), the rank keys on the reasoning bucket not the raw token count (within-bucket differences are sampling noise, the thresholds sit in the endpoint's observed gaps) and full ties settle sort-lex-pick-bottom, with the mock registry carrying a canned tie pair (mock/mock-tie) and the smoke asserting the lex-bottom pick; the play-protocol batch (OOC GM turns carry no cache blocks, memory.json is authored draft applied by the start gate's reapply over a fresh db, /story filters OOC whole, the per-turn raw control on the table); the tunables UX round (web/knobs.mjs: the definitions table with the GM's hint texts and the probed this-endpoint bounds, the per-knob explicit override toggle replacing implicit empty-means-unset diffing, the shared focus-driven hint bar; the run detail and /model responses carry paramDefaults, the deployment layer -- the only default anyone can honestly name); request recording (every provider call lands its resolved model + effective params on the msg event as via, a failed call lands a req event with the failure, both surface on the raw tab and the per-turn raw control on no model-facing surface, a req riding the slidwin tail passes the start lint as conversation machinery; the housekeeping pass log names its model via the clerk's --model flag); the mind verb (<mind> JSON in a player turn sets its sampling for its next turn -- one-shot, max_tokens excluded, a budget not a mind; bounds enforced in KNOB_BOUNDS with the range named in the conflict and the heal restatement the statement that counts; derive() makes a statement live until a player reply consumes it, honest across restarts, session boundaries and forks -- an unconsumed mind rides on); the full-block protocol (the GM rewrote system/invariants/reminder to eliminate the diff verbs: she emits whole <status>/<agenda> at her turn tail, a present block is a whole-list set, absent means unchanged never blank, over-cap agendas evict from the bottom silently -- ruled a feature, silent to her, the note shows the GM; renderView strips every copy and stamps the newest of each kind at the tail of her most recent prose turn, her own emission, so the context reads as the same sequence of events the game had; GM prose goes pure, old logs' composited rides strip, they were never GM words; <mind> is write-only, its tags strip from the view; every turn of hers carries its <model> block -- the params it rode, bare JSON from the via record, the current call included, suppressed when nothing is set, emitting one refused with a pointer at <mind>; the clerk's status-apply/agenda-apply delta verbs RETIRED with their dispatch and collectors, status-set/agenda-set are the player path now; the story strips her blocks, the table chips them; the smoke imports renderView and asserts the view policy directly -- the pattern for testing view-only policy no API exposes); and the opening event RETIRED (the start gate seeds the clerk from her last authored turn's blocks -- the GM moved la-caramba's initial status into her opening turn; old carryovers keep their events as inert history; the event's pre-existing double-landing in every started log, pre-bundle and in-carry, died with the branch); smoke ALL PASS + restart + reminder + repo checks green, browser passes over the knob UX and the new chips and notes with zero console errors, typecheck green on both programs; README and DICTIONARY carry the durable design, HANDOFF trimmed to the map
This commit is contained in:
+85
-18
@@ -55,8 +55,15 @@ export 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)>([\s\S]*?)<\/\1>/g)) {
|
||||
tags.push({ kind: m[1], items: m[2].split('\n').flatMap((l) => l.split(',')).map((x) => x.trim()).filter(Boolean) });
|
||||
for (const m of body.matchAll(/<(lost|gained|add|drop|mind|status|agenda)>([\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'
|
||||
? [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 });
|
||||
}
|
||||
for (const t of tags) body = body.replace(new RegExp(`<${t.kind}>[\\s\\S]*?</${t.kind}>`), '');
|
||||
|
||||
@@ -131,14 +138,34 @@ export function renderContent(target, text, { extract }) {
|
||||
return { status, conflict, agenda };
|
||||
}
|
||||
|
||||
// the request record's line: the resolved model and the effective
|
||||
// params as sent (the merged layer actually sent). Shared by the raw
|
||||
// walk and the per-turn raw control. fail is present when the call
|
||||
// failed -- no message resulted.
|
||||
/** @param {{ model: string, params?: Record<string, number> }} via @param {?string} [fail] @returns {string} */
|
||||
export function viaLine(via, fail = null) {
|
||||
const ks = Object.entries(via.params ?? {});
|
||||
const p = ks.length ? ` -- ${ks.map(([k, v]) => `${k}: ${v}`).join(', ')}` : ' (no knobs set)';
|
||||
return fail ? `[request failed] ${via.model}${p} -- ${fail}` : `[request] ${via.model}${p}`;
|
||||
}
|
||||
|
||||
// the note line, shared by both walks
|
||||
/** @param {NoteEvent} e @returns {?string} */
|
||||
function noteText(e) {
|
||||
if (e.kind === 'session') return `session ${e.n} opened`;
|
||||
if (e.kind === 'ask') return `ask_gm: ${e.question}`;
|
||||
if (e.kind === 'status') return `status: lost ${JSON.stringify(e.applied?.lost ?? [])}, gained ${JSON.stringify(e.applied?.gained ?? [])}`;
|
||||
if (e.kind === 'agenda') return `agenda: added ${JSON.stringify(e.applied?.added ?? [])}, dropped ${JSON.stringify(e.applied?.dropped ?? [])}`;
|
||||
if (e.kind === 'status') {
|
||||
return e.set
|
||||
? `status set: ${JSON.stringify(e.set)}`
|
||||
: `status: lost ${JSON.stringify(e.applied?.lost ?? [])}, gained ${JSON.stringify(e.applied?.gained ?? [])}`;
|
||||
}
|
||||
if (e.kind === 'agenda') {
|
||||
return e.set
|
||||
? `agenda set: ${JSON.stringify(e.set)}${e.evicted?.length ? ` -- evicted ${JSON.stringify(e.evicted)}` : ''}`
|
||||
: `agenda: added ${JSON.stringify(e.applied?.added ?? [])}, dropped ${JSON.stringify(e.applied?.dropped ?? [])}`;
|
||||
}
|
||||
if (e.kind === 'pick') return `variant literature: ${e.count} offered, #${e.chosen + 1} picked`;
|
||||
if (e.kind === 'mind') return `mind: ${Object.entries(e.params ?? {}).map(([k, v]) => `${k} ${v}`).join(', ')} -- rides her next turn`;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -172,6 +199,11 @@ export function renderRaw(entries) {
|
||||
t.appendChild(el('div', 'machinery', `her opening status: ${JSON.stringify(e.status)}`));
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'req') {
|
||||
// a failed provider request: the record of what was attempted
|
||||
t.appendChild(el('div', 'machinery', viaLine(e, e.fail)));
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'note') {
|
||||
const text = noteText(e);
|
||||
if (text) t.appendChild(el('div', 'machinery', text));
|
||||
@@ -200,6 +232,7 @@ export function renderRaw(entries) {
|
||||
if (e.t === 'msg' && e.m.role === 'assistant') {
|
||||
const d = block('player');
|
||||
if (e.m.reasoning_content) d.appendChild(el('pre', 'raw-thinking', e.m.reasoning_content));
|
||||
if (e.via) d.appendChild(el('div', 'machinery', viaLine(e.via)));
|
||||
d.appendChild(el('pre', null, String(e.m.content ?? '')));
|
||||
for (const c of e.m.tool_calls ?? []) {
|
||||
d.appendChild(el('div', 'machinery', `[tool call] ${c.function.name}`));
|
||||
@@ -212,11 +245,15 @@ export function renderRaw(entries) {
|
||||
}
|
||||
|
||||
// the entry walk. onConflict receives a conflict block found on a GM
|
||||
// turn -- the play view owns where it lands (the status pane). The
|
||||
// opening event (her opening status) renders as machinery, mirroring
|
||||
// turn -- the play view owns where it lands (the status pane).
|
||||
// onRaw, when given, puts a small control on every GM/player turn
|
||||
// that shows that one entry's wire form inline -- the play view owns
|
||||
// the fetch (the raw session is the audit surface; the walks are
|
||||
// index-aligned, so table entry i is session entry i). The opening
|
||||
// event (her opening status) renders as machinery, mirroring
|
||||
// the wire policy: it is set once, never re-sent.
|
||||
/** @param {LogEvent[]} entries @param {{ onConflict?: (text: string) => void }} [opts] */
|
||||
export function renderTranscript(entries, { onConflict } = {}) {
|
||||
/** @param {LogEvent[]} entries @param {{ onConflict?: (text: string) => void, onRaw?: (idx: number, slot: HTMLElement) => Promise<void> }} [opts] */
|
||||
export function renderTranscript(entries, { onConflict, onRaw } = {}) {
|
||||
const t = $('transcript');
|
||||
t.textContent = '';
|
||||
/** @type {BundleEvent[]} */ const bundleParts = [];
|
||||
@@ -234,7 +271,8 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
bundleParts.length = 0;
|
||||
};
|
||||
|
||||
for (const e of entries) {
|
||||
for (let idx = 0; idx < entries.length; idx++) {
|
||||
const e = entries[idx];
|
||||
if (e.t === 'bundle') {
|
||||
// every part is inspectable, read-only: system (guards +
|
||||
// substrate + craft), backdrop, character, the rings
|
||||
@@ -259,14 +297,15 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
t.appendChild(el('div', 'machinery', `her opening status: ${JSON.stringify(e.status)}`));
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'req') continue; // a failed request's record -- the raw surfaces carry it
|
||||
if (e.t === 'msg') {
|
||||
if (e.m.role === 'user' && e.conflictOnly) {
|
||||
// the self-heal message: error traffic on its own, never GM prose
|
||||
t.appendChild(el('div', 'machinery', `[conflict] ${String(e.m.content).replace(/<\/?conflict>/g, '').trim()}`));
|
||||
continue;
|
||||
}
|
||||
if (e.m.role === 'user') gmTurn(e.m.content, 'GM');
|
||||
else if (e.m.role === 'assistant') playerTurn(e);
|
||||
if (e.m.role === 'user') gmTurn(e, idx, 'GM');
|
||||
else if (e.m.role === 'assistant') playerTurn(e, idx);
|
||||
continue;
|
||||
}
|
||||
if (e.t === 'tool') {
|
||||
@@ -278,26 +317,30 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
flushBundle();
|
||||
t.scrollTop = t.scrollHeight;
|
||||
|
||||
/** @param {?string} content @param {string} who */
|
||||
function gmTurn(content, who) {
|
||||
/** @param {MsgEvent} e @param {number} idx @param {string} who */
|
||||
function gmTurn(e, idx, who) {
|
||||
const d = el('div', 'turn gm');
|
||||
d.appendChild(el('div', 'who', who));
|
||||
const head = el('div', 'who', who);
|
||||
d.appendChild(head);
|
||||
const body = el('div');
|
||||
d.appendChild(body);
|
||||
const { conflict } = renderContent(body, content, { extract: true });
|
||||
const { conflict } = renderContent(body, e.m.content, { extract: true });
|
||||
if (conflict) onConflict?.(conflict);
|
||||
if (onRaw) addRawControl(head, d, idx);
|
||||
t.appendChild(d);
|
||||
}
|
||||
/** @param {MsgEvent} e */
|
||||
function playerTurn(e) {
|
||||
/** @param {MsgEvent} e @param {number} idx */
|
||||
function playerTurn(e, idx) {
|
||||
const d = el('div', 'turn player');
|
||||
d.appendChild(el('div', 'who', 'player'));
|
||||
const head = el('div', 'who', 'player');
|
||||
d.appendChild(head);
|
||||
const body = el('div');
|
||||
d.appendChild(body);
|
||||
renderContent(body, e.m.content, { extract: false });
|
||||
for (const c of e.m.tool_calls ?? []) {
|
||||
d.appendChild(el('div', 'machinery', `[tool call] ${c.function.name}`));
|
||||
}
|
||||
if (onRaw) addRawControl(head, d, idx);
|
||||
t.appendChild(d);
|
||||
}
|
||||
/** @param {NoteEvent} e */
|
||||
@@ -305,4 +348,28 @@ export function renderTranscript(entries, { onConflict } = {}) {
|
||||
const text = noteText(e);
|
||||
if (text) t.appendChild(el('div', 'machinery', text));
|
||||
}
|
||||
|
||||
// the per-turn raw control: the who row carries the button, the
|
||||
// card gains a slot under the body -- onRaw fills it on first open
|
||||
// (the caller owns the fetch and its errors), later clicks toggle
|
||||
/** @param {HTMLElement} head @param {HTMLElement} card @param {number} idx */
|
||||
function addRawControl(head, card, idx) {
|
||||
const btn = /** @type {HTMLButtonElement} */ (el('button', 'raw-toggle', 'raw'));
|
||||
head.appendChild(btn);
|
||||
btn.addEventListener('click', async () => {
|
||||
const slot = /** @type {?HTMLElement} */ (card.querySelector('.raw-slot'));
|
||||
if (slot && slot.childElementCount) {
|
||||
slot.hidden = !slot.hidden; // filled already -- just toggle
|
||||
return;
|
||||
}
|
||||
const fresh = slot ?? el('div', 'raw-slot');
|
||||
if (!slot) card.appendChild(fresh);
|
||||
btn.disabled = true;
|
||||
try {
|
||||
await onRaw?.(idx, fresh);
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user