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:
2026-11-16 21:32:02 +00:00
parent 193dc336be
commit 894737fcf3
30 changed files with 2193 additions and 518 deletions
+41 -16
View File
@@ -33,7 +33,8 @@ import {
latestSession, sessionMeta, sessionDir, listSessions, loadSession, stopSession, writeMeta,
} from './session.mjs';
import { effectiveContents } from './variants.mjs';
import { HttpError } from './loop.mjs';
import { HttpError, resolveParams } from './loop.mjs';
import { registry, usable } from './discovery.mjs';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
@@ -58,6 +59,7 @@ export function renderTranscript(lines) {
const e = lines[i];
if (e.t === 'bundle') continue; // context, not exchange -- provided as separate inputs
if (e.t === 'msg' && e.reminder) continue; // identical every turn -- context, not exchange
if (e.t === 'req') continue; // a failed request's record -- machinery, not exchange
if (e.t === 'msg') {
if (e.m.role === 'user' && e.conflictOnly) {
L.push('[conflict -- answered in-band]', String(e.m.content ?? '').replace(/<\/?conflict>/g, '').trim(), '');
@@ -79,15 +81,21 @@ export function renderTranscript(lines) {
}
if (e.t === 'note') {
if (e.kind === 'status') {
L.push(`[status] lost: ${JSON.stringify(e.applied?.lost ?? [])}, gained: ${JSON.stringify(e.applied?.gained ?? [])}${e.conflicts?.length ? ` -- conflicts: ${e.conflicts.join('; ')}` : ''}`, '');
L.push(e.set
? `[status] set: ${JSON.stringify(e.set)}`
: `[status] lost: ${JSON.stringify(e.applied?.lost ?? [])}, gained: ${JSON.stringify(e.applied?.gained ?? [])}${e.conflicts?.length ? ` -- conflicts: ${e.conflicts.join('; ')}` : ''}`, '');
} else if (e.kind === 'agenda') {
L.push(`[agenda] added: ${JSON.stringify(e.applied?.added ?? [])}, dropped: ${JSON.stringify(e.applied?.dropped ?? [])}, evicted: ${JSON.stringify(e.applied?.evicted ?? [])}${e.conflicts?.length ? ` -- conflicts: ${e.conflicts.join('; ')}` : ''}`, '');
L.push(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 ?? [])}, evicted: ${JSON.stringify(e.applied?.evicted ?? [])}${e.conflicts?.length ? ` -- conflicts: ${e.conflicts.join('; ')}` : ''}`, '');
} else if (e.kind === 'pick') {
L.push(`[variant pick] ${e.count} candidate turns offered, #${e.chosen + 1} picked`, '');
} else if (e.kind === 'ask') {
L.push(`[ask_gm pending] ${e.question}`, '');
} else if (e.kind === 'session') {
L.push(`[session ${e.n} opened]`, '');
} else if (e.kind === 'mind') {
L.push(`[mind] ${Object.entries(e.params ?? {}).map(([k, v]) => `${k} ${v}`).join(', ')} -- set for her next turn`, '');
}
}
}
@@ -160,7 +168,7 @@ export function trigger(ctx, runId, user) {
const meta = sessionMeta(runId, latest);
if (meta.phase !== 'dormant') throw new HttpError(409, `session ${latest} is ${meta.phase || 'unmarked'} -- nothing to housekeep`);
if (latest === 1) {
throw new HttpError(409, 'session one\'s memories are its package\'s memory.json -- edit them in setup; there is no session zero to re-run');
throw new HttpError(409, 'session one\'s memories are its memory.json -- edit it in setup and start (the start gate applies it); there is no session zero to re-run');
}
const job = /** @type {JobState} */ ({ state: 'running', phase: 'rerun', session: latest - 1, target: latest, started: new Date().toISOString() });
ctx.jobs.set(runId, job);
@@ -187,9 +195,17 @@ async function runStop(ctx, runId, n, user) {
async function runPass(ctx, runId, n, user) {
const job = /** @type {JobState} */ (ctx.jobs.get(runId));
const lines = loadSession(runId, n).lines;
const text = ctx.mock
? mockManifest(n)
: await callHousekeeper(ctx, runId, buildMessages(runId, n, lines), user);
// the pass names its model: the real pass resolves it, the mock
// pass marks itself
let text;
let model = 'mock';
if (ctx.mock) {
text = mockManifest(n);
} else {
const r = await callHousekeeper(ctx, runId, buildMessages(runId, n, lines), user);
text = r.content;
model = r.model;
}
const dir = path.join(runDir(runId), 'manifests');
fs.mkdirSync(dir, { recursive: true });
let mf;
@@ -202,7 +218,7 @@ async function runPass(ctx, runId, n, user) {
const manifestPath = path.join(dir, `${n}.json`);
fs.writeFileSync(manifestPath, JSON.stringify(mf, null, 2) + '\n');
job.manifest = `manifests/${n}.json`;
applyToDormant(runId, manifestPath, n);
applyToDormant(runId, manifestPath, n, model);
job.target = n + 1;
job.state = 'applied';
}
@@ -212,31 +228,40 @@ async function runPass(ctx, runId, n, user) {
/**
* @param {Ctx} ctx @param {string} runId
* @param {import('./shapes.mjs').ViewMessage[]} messages @param {?Actor} user
* @returns {Promise<string>}
* @returns {Promise<{ content: string, model: string }>}
*/
async function callHousekeeper(ctx, runId, messages, user) {
const meta = ctx.runMeta?.(runId) ?? /** @type {RunMeta} */ ({});
const reg = registry();
const model = meta.models?.housekeeper
?? ctx.cfg.models?.housekeeper
?? ctx.cfg.models?.player
?? reg?.defaults.housekeeper
?? reg?.defaults.player
?? null;
if (!model) throw new Error('no housekeeper model resolved (server.json models.housekeeper, or a per-run override)');
if (!model) throw new Error('no housekeeper model resolved (a per-run override, server.json models, or the registry\'s discovered default)');
if (!usable(reg, model)) {
throw new Error(`model '${model}' is not in the deployment's model registry${reg ? ' (or failed the inference probe)' : ' -- the op has not run discovery yet'}`);
}
const params = resolveParams(ctx, runId, 'housekeeper');
// attribution (#22): every LLM call names the acting user
console.log(`${new Date().toISOString().slice(11, 19)} llm ${model} u:${user?.id ?? '?'}`);
const data = await ctx.provider.chat(model, messages, undefined, ctx.cfg.params ?? {});
return data.choices[0].message.content ?? '';
const data = await ctx.provider.chat(model, messages, undefined, params);
return { content: data.choices[0].message.content ?? '', model };
}
export { callHousekeeper };
// The apply: rebase + apply + ready, into the dormant session n+1.
// Shared by the chain and the manual apply endpoint (hand-edited
// manifests). The rebase is the re-enterability: every run starts
// manifests). model, when given, is the pass's model -- the apply
// log names it (a hand apply has none). The rebase is the
// re-enterability: every run starts
// from a fresh copy of the finished session's frozen db (her status
// and agenda carry; the rings reset to the base the manifest lands
// on) -- so re-runs never double-apply, and hand edits made in
// between are overwritten, ruled fine.
/** @param {string} runId @param {string} manifestPath @param {number} n */
export function applyToDormant(runId, manifestPath, n) {
/** @param {string} runId @param {string} manifestPath @param {number} n @param {?string} [model] */
export function applyToDormant(runId, manifestPath, n, model = null) {
const target = sessionDir(runId, n + 1);
if (sessionMeta(runId, n + 1).phase !== 'dormant') {
throw new Error(`session ${n + 1} is not dormant -- housekeeping applies into the dormant session`);
@@ -246,7 +271,7 @@ export function applyToDormant(runId, manifestPath, n) {
fs.rmSync(path.join(target, 'canon'), { recursive: true, force: true });
fs.mkdirSync(path.join(target, 'db'), { recursive: true });
fs.copyFileSync(path.join(sessionDir(runId, n), 'db', 'memory.db'), path.join(target, 'db', 'memory.db'));
const r = clerk(runId, '--session', String(n + 1), 'apply', manifestPath);
const r = clerk(runId, '--session', String(n + 1), ...(model ? ['--model', model] : []), 'apply', manifestPath);
if (r.code !== 0) throw new Error(`apply rejected:\n${r.err || r.out}`);
writeMeta(runId, n + 1, { ready: true });
}