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
+153
View File
@@ -0,0 +1,153 @@
// web/knobs.mjs -- the sampling knobs: the definitions table and the
// per-role knob row.
//
// The knobs are named, well-known, widely supported. The definitions
// table is the single home of every knob text -- label, hint, bounds
// -- red-pen the prose here, in place. Bounds are display knowledge
// probed from this endpoint's own validation errors (the /model
// route's validation stays generic: a finite number). The provider's
// serving defaults are unknown and stay unstated; the only default
// anyone can honestly name is the deployment layer (server.json
// params), which rides the run detail as paramDefaults.
//
// Two defaults, never conflated: a knob unset means its value is NOT
// sent to the provider; a value present is sent, and the row marks it
// when it equals the deployment default. The explicit override toggle
// carries the distinction: off (the visible default) disables the
// input and saving sends nothing for the knob (null clears a
// previously-set value); on demands a number.
//
// The hint bar is shared by both roles -- one explanation at a time,
// driven by focus (a tap focuses), cleared when focus leaves the
// knobs entirely.
/** @typedef {import('../server/shapes.mjs').RoleParams} RoleParams */
import { el } from './dom.mjs';
/** One knob's definition: the texts are the product, the shape is
* schema-ready for later kinds (bools: what to expect on and off;
* enums: explanation-only) -- nothing else ships today. All five
* knobs are the GM's here; the mind verb (server/loop.mjs) sets
* only the four that are hers -- max_tokens is excluded by ruling
* (a budget, not a mind). */
/** @typedef {{ key: keyof RoleParams, kind: 'number', label: string, hint: string, bounds: string }} KnobDef */
/** @type {KnobDef[]} */
const DEFS = [
{
key: 'temperature',
kind: 'number',
label: 'temperature',
hint: 'How adventurous the word choice is. Higher: more varied and surprising, occasionally unhinged. Lower: more predictable and conservative; at 0 the same prompt tends to get the same words.',
bounds: 'This endpoint: 0 to 2.',
},
{
key: 'top_p',
kind: 'number',
label: 'top_p',
hint: 'Narrows the field to the most likely words that together cover this much probability. Higher: more words in play, more variety. Lower: fewer, safer choices; very low makes her repeat herself.',
bounds: 'This endpoint: above 0 (0 is refused), up to 1.',
},
{
key: 'top_k',
kind: 'number',
label: 'top_k',
hint: 'Like top_p but by count -- only the k most likely words are considered each step. Higher: more variety. Lower: more locked-in; at 1 she picks the single most likely word every time. -1 and 0 turn the filter off.',
bounds: 'No known bounds on this endpoint; -1 and 0 both mean the filter is off.',
},
{
key: 'repetition_penalty',
kind: 'number',
label: 'repetition_penalty',
hint: 'A direct nudge against repeating recent words and phrasings. 1 is no effect; raise it to make her evade repetition. Too high and she substitutes odd words to escape.',
bounds: 'Must be above 0 on this endpoint, no known max.',
},
{
key: 'max_tokens',
kind: 'number',
label: 'max_tokens',
hint: 'The response\'s hard length budget. Higher: room for long turns. Lower: cheaper and shorter, but the turn can cut off mid-sentence -- and on reasoning models thinking counts against this budget first, so a low cap can be eaten entirely before she writes a word.',
bounds: '1 or more on this endpoint; no enforced max (values above the model\'s output ceiling are accepted).',
},
];
/** The hint bar's text for one knob: label, the explanation, the
* bounds, and the honest default statement for this role's
* deployment layer. Never invents an unknown value. */
/** @param {KnobDef} def @param {number|undefined|null} dep @returns {string} */
function hintText(def, dep) {
const defLine = dep !== undefined && dep !== null
? `Unset = the deployment default (${dep}).`
: 'Unset = not sent; the provider\'s own default applies (unknown).';
return `${def.label.replace(/_/g, ' ')} -- ${def.hint} ${def.bounds} ${defLine}`;
}
/** One role's knob row.
* @param {string} role
* @param {RoleParams|undefined} current the run's own knobs
* @param {RoleParams|undefined|null} deployment the deployment layer (server.json params)
* @param {HTMLElement} hintBar the shared hint bar
* @returns {{ wrap: HTMLElement, read: () => Record<string, number|null> }}
*/
export function knobsBox(role, current, deployment, hintBar) {
const wrap = el('div', 'knobs');
wrap.appendChild(el('div', 'knobs-head', `${role} knobs`));
/** @type {Record<string, { tog: HTMLInputElement, inp: HTMLInputElement }>} */
const rows = {};
for (const def of DEFS) {
const row = el('div', 'knob');
const tog = /** @type {HTMLInputElement} */ (el('input'));
tog.type = 'checkbox';
tog.title = 'override';
const lab = el('label', null, `${def.label.replace(/_/g, ' ')} `);
const inp = /** @type {HTMLInputElement} */ (el('input'));
inp.type = 'number';
inp.step = 'any';
const mark = el('span', 'knob-default', ' \u00b7 deployment default');
lab.appendChild(inp);
lab.appendChild(mark);
row.appendChild(tog);
row.appendChild(lab);
wrap.appendChild(row);
const set = current?.[def.key];
tog.checked = set !== undefined;
if (set !== undefined) inp.value = String(set);
const dep = deployment?.[def.key];
// the toggle owns the state: off disables the input (the value
// stays for a change of mind), on demands a number; a value equal
// to the deployment default is still sent, and the row marks it
const sync = () => {
inp.disabled = !tog.checked;
mark.hidden = !(tog.checked && inp.value.trim() !== '' && Number(inp.value) === dep);
};
tog.addEventListener('change', sync);
inp.addEventListener('input', sync);
sync();
inp.addEventListener('focus', () => { hintBar.textContent = hintText(def, dep); });
rows[def.key] = { tog, inp };
}
// the bar keeps its text while focus moves inside the row, clears
// when it leaves the knobs entirely
wrap.addEventListener('focusout', (e) => {
if (!wrap.contains(/** @type {?Node} */ (e.relatedTarget))) hintBar.textContent = '';
});
const read = () => {
/** @type {Record<string, number|null>} */ const out = {};
for (const def of DEFS) {
const { tog, inp } = rows[def.key];
if (tog.checked) {
const v = inp.value.trim();
if (v === '' || !Number.isFinite(Number(v))) {
throw new Error(`${def.label}: a number is required -- or switch the override off`);
}
out[def.key] = Number(v);
} else if (current?.[def.key] !== undefined) {
out[def.key] = null; // clearing a previously-set knob
}
}
return out;
};
return { wrap, read };
}