the provider round and the provider-flow round, plus the template and box packages

the provider round (2026-11-18, batteries-included): providers are first-class entities, the config is server-written state (state/config.json), and a fresh clone boots playable -- the opencode/free singleton auto-added and discovered on the empty list, playable with zero secrets. Every request resolves a full spec {provider, model, effort}: no unset effort, the per-run params layer retired, the mind verb the only sampling source. The registry is per-provider sections (state/models.json), refine caches adjudications under the double spec tuple (state/refine-cache.json), run picks are invalidatable (a removed provider or drifted model blocks the run with the note naming what died), and the housekeeper inherits the player spec's provider default (#16 closed). The no-legacy pass died the same day it shipped: bootImport deleted (server.json is bind + contwin), the registry's v1/v2 in-memory migrations deleted (models.json rewritten on disk into the per-provider shape), bare-string model picks deleted (Chloe's run.json migrated to spec objects, shape-preserving), the clerk's create model arg deleted, apiKeyEnv and the contextWindow alias gone. The live arc proven from a bare boot: invite minted, o/f auto-added, a custom provider with a bogus key (the recognizable 401), the auth fixed (13 models), the default pair selected, and a real glm-5.3 turn through the full path. Two live findings: opencode.ai serves 89 models keyless but 401s an empty Bearer header (the auth header rides only when a key exists), and the failure log line rides stderr.

the provider-flow round (2026-11-19, GM-designed): discovery IS the probe. The add takes only the endpoint -- {slug, baseUrl} or {builtin: true}, an apiKey in the body 400s (the auth route is the only key path) -- and a working keyless listing never sees a key field. A 401/403 stands the provider broken: the entity carries a probe record (outcome ok/auth/error, detail, at), the card opens the ask, and only the explicit acts move the record -- add, key, remove-key, discover; usage errors are transient and the op's to fix, nothing in the runtime flips provider state. The auth route is probe-then-save: the candidate key checks on reception, saves only on success -- a still-refused key never reaches the config, the previous state returns, the ask repeats. Every other discovery failure refuses the add outright with rollback: an endpoint that cannot answer is not a provider, nothing stands (the old code let it stand on any failure). The remove-key control (custom providers, armed) clears and re-probes: a provider gone public lands working keyless, a locked one re-opens the ask -- which is the key-replacement path. o/f never asks in any state: its auth failures are upstream breakage to show, not a prompt. The universal retry rule: NO automatic retries anywhere -- every inference call is user-initiated (the send, the housekeeping run, the refine) and every act has its manual retry; the curator's one auto-retry (the 2026-11-17 hiccup lesson) is deleted, the machine-label fallback the designed outcome. And failures never cache (GM: a failure is the absence of a measurement, not a measurement) -- the adjudication cache skips inference:false entries, the receipt line says "never cached, retried at every refine", and a transient battery error can never pin a false verdict; gev's 400s cost one cheap probe per refine and self-heal the day the backend learns tools. En-route fix the smoke earned: the create route validated body.spec AFTER the clerk built the run dir -- a refused spec left an orphan run (restart-check's exact count caught the sixth run); the spec validates first now, nothing lands on refusal.

the sheet's transport at the lint: the record is the only channel, the tag is view machinery composed by renderView, never authored by anyone -- the authored gate names the tag in any content (hers would never apply and primes the guarded emission; GM prose rides the view and story raw, the GM-side strips do not know it), names a sheet record on her turn, and checks object-ness on GM-turn records and boundary state notes both kinds; her emitted sheet in a carried tail stays legitimate history (the log keeps guard-conflicted emissions verbatim, and a stop can move one into the slidwin). The carryover editor teaches its own format now: a per-file hint between the editor and the save bar (one JSON object per line; status and agenda ride her turns; the sheet rides yours as the "sheet" field, never as a tag; the sigils and $VARS expand at start on the authored opening only).

the packages: template (the base for new packages -- the mood-indexed voice examples, the settings comment convention, non-playable as-is) and box (the sheet's first consumer: an incremental-game economy as ERP, GP and BP as two currencies with the room pushing her to fund her own punishments; the opening turn third-person per the typography ruling, ending on the display that needs a second read; the amnesiac rings empty by design; the erased name reading "(redacted)" after sigil expansion). The review found and fixed: both carryovers were pretty-printed JSON with duplicate keys -- unstartable under every per-line reader, flattened to true JSONL; the box's opening sheet rode her authored prose -- dead on every surface (the scan reads GM-turn records only, the strips eat it) and priming the exact emission the guard conflicts -- moved to the GM turn's sheet record, the override's shape; the gm.md "take of leave" typo fixed in all three packages.

the lint's rule 4 scoped to the substrate (GM, 2026-11-19): a banned word in a package's prose is fine -- the packages are the fiction and their words are the story's; README and the root prompts stay patrolled, and the box's "Or windows" is an architectural plural in a padded cell.

verified: typecheck green both programs; smoke ALL PASS (+27 the provider-flow battery: apiKey-on-add 400, the dead-endpoint refusal with config rollback, the auth-standing card with its probe record, probe-then-save both ways, the remove-key round trip, the o/f guards, the failures-never-cache proof over mock-fail -- verdict with the marker, absent from the cache file, re-probed fresh while the passing three serve from cache, not selectable, no orphan run; +8 the sheet-transport lint battery); restart + reminder checks green; a browser pass driving the whole add-flow machine on a mock+debug server (the hidden key field opening on the 401, the key landing through the auth route, the remove-key round trip re-opening the ask, the dead add refusing with the banner and no card, zero console errors beyond the expected 401/500 resource lines); check-repo clean with the box's windows. detention stays untracked WIP, untouched.
This commit is contained in:
2026-11-19 08:35:23 +00:00
parent 14b9b01d86
commit e60fd63d2b
42 changed files with 3071 additions and 1086 deletions
+34 -201
View File
@@ -1,211 +1,44 @@
// web/knobs.mjs -- the sampling knobs: the definitions table and the
// per-role knob row.
// web/knobs.mjs -- the reasoning-effort ladder and its select.
//
// 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, or one of the
// effort ladder's levels). 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 -- reasoning_effort is the one
// exception: the registry measured a per-model default (the maximum
// observed mean thinking), so its unset state honestly sends.
// The per-run sampling knobs are retired (GM, 2026-11-18): params are
// per-turn and only hers -- the <mind> verb sets them for one turn,
// nothing stores them. Reasoning effort is a property of the model
// pick (there is no unset effort), so its select lives inside the
// model picks (widgets.mjs's modelsBox) and the provider selection
// (view-home's admin block), not a knob row. The ladder mirrors
// server/discovery.mjs's EFFORT_LEVELS (the web cannot import server
// runtime code); keep them in step.
//
// 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 (a level, for the enum).
//
// 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 */
// The old knobs' teaching surface -- what temperature means, what
// top_p does -- was prompt-side all along: invariants.md documents
// the mind verb, and the model answers with native JSON. The GM-side
// texts died with the rows; the four bounds live on in the server's
// mind-verb validator (server/loop.mjs, KNOB_BOUNDS).
import { el } from './dom.mjs';
// the reasoning-effort ladder -- mirrors server/discovery.mjs's
// EFFORT_LEVELS (the web cannot import server runtime code); keep
// them in step
const EFFORT_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
// EFFORT_LEVELS; keep them in step
export const EFFORT_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
/** One knob's definition: the texts are the product. Two kinds ship:
* numbers, and the effort enum (a select over the ladder). All six
* 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), reasoning_effort is hidden from her
* entirely (not her call). */
/** @typedef {{ key: keyof RoleParams, kind: 'number', label: string, hint: string, bounds: string }} NumberDef */
/** @typedef {{ key: keyof RoleParams, kind: 'enum', label: string, hint: string }} EnumDef */
/** @typedef {NumberDef|EnumDef} 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).',
},
{
key: 'reasoning_effort',
kind: 'enum',
label: 'reasoning effort',
hint: 'How hard the model thinks before answering. Higher levels reason more thoroughly and cost more (thinking bills as output tokens); lower levels answer faster. The level is a request, not a guarantee -- the model adapts to the task. Not hers to set: the mind verb never carries it.',
},
];
/** 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. The enum knob
* states its own honest default: the measured pick. */
/** @param {KnobDef} def @param {number|string|undefined|null} dep @param {?{ measured: Record<string, number>, fallback: ?string }} [effort] @returns {string} */
function hintText(def, dep, effort) {
if (def.kind === 'enum') {
const table = effort
? `Measured mean thinking for this model: ${Object.entries(effort.measured).map(([k, v]) => `${k} ${v}`).join(', ')}.`
: 'No effort measurements for this model (an unrefined registry, or the model shows no thinking).';
const rides = (dep !== undefined && dep !== null ? String(dep) : null) ?? effort?.fallback ?? null;
const defLine = rides
? `Unset = ${rides} rides (the measured default: the level with the highest observed thinking).`
: 'Unset = not sent; the model id\'s own baked default applies.';
return `${def.label} -- ${def.hint} ${table} ${defLine}`;
}
const d = /** @type {NumberDef} */ (def);
const defLine = dep !== undefined && dep !== null
? `Unset = the deployment default (${dep}).`
: 'Unset = not sent; the provider\'s own default applies (unknown).';
return `${d.label.replace(/_/g, ' ')} -- ${d.hint} ${d.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
* @param {?{ measured: Record<string, number>, fallback: ?string }} [effort] the current model's measured effort ladder (null: none)
* @returns {{ wrap: HTMLElement, read: () => Record<string, number|string|null> }}
/** A select over the ladder. The '' option's label names what an
* absent choice means at the call site (the measured default in the
* model box, "pick a level" in the selection prompt) -- the caller
* owns the sentence, this builds the options.
* @param {?string} current the pre-selected level ('' when none)
* @param {string} unsetLabel the '' option's label
* @returns {HTMLSelectElement}
*/
export function knobsBox(role, current, deployment, hintBar, effort = null) {
const wrap = el('div', 'knobs');
wrap.appendChild(el('div', 'knobs-head', `${role} knobs`));
/** @type {Record<string, { tog: HTMLInputElement, inp: HTMLInputElement, sel: ?HTMLSelectElement }>} */
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 mark = el('span', 'knob-default', ' \u00b7 deployment default');
/** @type {?HTMLSelectElement} */ let sel = null;
const inp = /** @type {HTMLInputElement} */ (el('input'));
if (def.kind === 'enum') {
// the effort row: a select over the ladder; unset sends the
// measured default (the registry's pick for the current model)
sel = /** @type {HTMLSelectElement} */ (el('select'));
const rides = deployment?.[def.key] ?? effort?.fallback ?? null;
const unset = /** @type {HTMLOptionElement} */ (el('option', null, rides ? `(default: ${rides})` : '(not sent)'));
unset.value = '';
sel.appendChild(unset);
for (const lv of EFFORT_LEVELS) {
const o = /** @type {HTMLOptionElement} */ (el('option', null, lv));
o.value = lv;
sel.appendChild(o);
}
lab.appendChild(sel);
} else {
inp.type = 'number';
inp.step = 'any';
lab.appendChild(inp);
}
lab.appendChild(mark);
row.appendChild(tog);
row.appendChild(lab);
wrap.appendChild(row);
const set = current?.[def.key];
tog.checked = set !== undefined;
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 level);
// a value equal to the deployment default is still sent, and
// the row marks it
const sync = () => {
const field = /** @type {HTMLInputElement|HTMLSelectElement} */ (sel ?? inp);
field.disabled = !tog.checked;
const v = sel ? sel.value : inp.value.trim();
mark.hidden = !(tog.checked && v !== '' && v === String(dep ?? '\u0000'));
};
tog.addEventListener('change', sync);
if (sel) sel.addEventListener('change', sync);
else inp.addEventListener('input', sync);
sync();
const focusEl = /** @type {HTMLElement} */ (sel ?? inp);
focusEl.addEventListener('focus', () => { hintBar.textContent = hintText(def, dep, effort); });
if (sel && set !== undefined) sel.value = String(set);
else if (!sel && set !== undefined) inp.value = String(set);
rows[def.key] = { tog, inp, sel };
export function effortSelect(current, unsetLabel) {
const sel = /** @type {HTMLSelectElement} */ (el('select'));
const unset = /** @type {HTMLOptionElement} */ (el('option', null, unsetLabel));
unset.value = '';
sel.appendChild(unset);
for (const lv of EFFORT_LEVELS) {
const o = /** @type {HTMLOptionElement} */ (el('option', null, lv));
o.value = lv;
sel.appendChild(o);
}
// 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|string|null>} */ const out = {};
for (const def of DEFS) {
const { tog, inp, sel } = rows[def.key];
if (tog.checked) {
if (sel) {
const v = sel.value;
if (!v) throw new Error(`${def.label}: a level is required -- or switch the override off`);
out[def.key] = v;
} else {
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 };
sel.value = EFFORT_LEVELS.includes(String(current)) ? String(current) : '';
return sel;
}