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:
+66
-66
@@ -27,7 +27,8 @@
|
||||
import { toolList, runTool, assembleReminder, expandVars } from './bundle.mjs';
|
||||
import { renderView, cleanBlockList, AGENDA_CAP, rewindTo } from './session.mjs';
|
||||
import { parseVariants, pickVariant } from './variants.mjs';
|
||||
import { registry, usable } from './discovery.mjs';
|
||||
import { providerFor } from './provider.mjs';
|
||||
import { findModel } from './discovery.mjs';
|
||||
|
||||
export class HttpError extends Error {
|
||||
/**
|
||||
@@ -149,43 +150,43 @@ async function runLoop(ctx, runId, user) {
|
||||
let heals = 0;
|
||||
for (;;) {
|
||||
const view = renderView(s);
|
||||
// the request's resolved params: the mind layer rides over the
|
||||
// run and deployment layers, the effort knob resolves its own
|
||||
// layers (its unset state sends the registry's measured default).
|
||||
// The current call's <model> block shows her the knobs that are
|
||||
// hers to answer with <mind> -- reasoning_effort is filtered out
|
||||
// (hidden from the model, GM 2026-11-16: not her call); nothing
|
||||
// set means no block (the absent grammar); the via record lands
|
||||
// the same truth unfiltered, the raw surfaces carry it
|
||||
/** @type {string} */ let model;
|
||||
if (ctx.mock) model = 'mock';
|
||||
else model = resolveModel(ctx, runId);
|
||||
const params = { ...resolveParams(ctx, runId, 'player'), ...(s.mind ?? {}) };
|
||||
const effort = resolveEffort(ctx, runId, 'player', model);
|
||||
if (effort !== null) params.reasoning_effort = effort;
|
||||
// the request's resolved spec: the full inference identity
|
||||
// {provider, model, effort} (GM, 2026-11-18) -- there is no unset
|
||||
// effort, it is a property of the pick. The mind layer is the
|
||||
// only params source now: per-turn, hers, spent on completion
|
||||
// (the per-run knob layer is retired). The current call's
|
||||
// <model> block shows her the knobs that are hers to answer with
|
||||
// <mind> -- reasoning_effort is filtered out (hidden from the
|
||||
// model: not her call, it rides the spec); nothing set means no
|
||||
// block (the absent grammar); the via record lands the same
|
||||
// truth unfiltered, the raw surfaces carry it
|
||||
const spec = resolveSpec(ctx, runId, 'player');
|
||||
const provider = providerFor(ctx, spec.provider);
|
||||
const params = { ...(s.mind ?? {}) };
|
||||
params.reasoning_effort = spec.effort;
|
||||
const shown = { ...params };
|
||||
delete shown.reasoning_effort;
|
||||
if (Object.keys(shown).length) {
|
||||
view.push({ role: 'system', content: `<model>${JSON.stringify(shown)}</model>` });
|
||||
}
|
||||
let msg;
|
||||
/** @type {{ model: string, params: import('./shapes.mjs').RoleParams }} */ let via;
|
||||
/** @type {{ model: string, provider?: string, params: import('./shapes.mjs').RoleParams }} */ let via;
|
||||
if (ctx.mock) {
|
||||
// the synthetic marker: no provider call happens, but the knobs
|
||||
// resolve for real (the mind layer included), so the smoke can
|
||||
// assert the recording
|
||||
// the synthetic marker: no provider call happens, but the spec
|
||||
// and the knobs resolve for real, so the smoke can assert the
|
||||
// recording
|
||||
msg = mockModel(s, view);
|
||||
via = { model: 'mock', params };
|
||||
via = { model: spec.model, provider: spec.provider, params };
|
||||
} else {
|
||||
via = { model, params };
|
||||
via = { model: spec.model, provider: spec.provider, params };
|
||||
// attribution (#22): every LLM call names the acting user
|
||||
console.log(`${new Date().toISOString().slice(11, 19)} llm ${model} u:${user?.id ?? '?'}`);
|
||||
console.log(`${new Date().toISOString().slice(11, 19)} llm ${spec.model} u:${user?.id ?? '?'}`);
|
||||
// the turn meter's live record: one per provider call (a heal
|
||||
// or tool round restarts it), fed by the streaming deltas
|
||||
s.progress = { phase: 'thinking', thinking: 0, prose: 0, started: Date.now() };
|
||||
let data;
|
||||
try {
|
||||
data = await ctx.provider.chat(model, view, tools, params, (p) => {
|
||||
data = await provider.chat(spec.model, view, tools, params, (p) => {
|
||||
if (!s.progress) return;
|
||||
s.progress.phase = p.phase;
|
||||
if (p.phase === 'thinking') s.progress.thinking = p.chars;
|
||||
@@ -193,7 +194,7 @@ async function runLoop(ctx, runId, user) {
|
||||
});
|
||||
} catch (e) {
|
||||
s.progress = null;
|
||||
s.append({ t: 'req', model, params, fail: String(e.message ?? e).split('\n')[0].slice(0, 200) });
|
||||
s.append({ t: 'req', model: spec.model, provider: spec.provider, params, fail: String(e.message ?? e).split('\n')[0].slice(0, 200) });
|
||||
throw e;
|
||||
}
|
||||
msg = data.choices[0].message;
|
||||
@@ -306,55 +307,54 @@ async function runLoop(ctx, runId, user) {
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {Ctx} ctx @param {string} runId @returns {string} */
|
||||
function resolveModel(ctx, runId) {
|
||||
const meta = ctx.runMeta(runId) ?? /** @type {import('./shapes.mjs').RunMeta} */ ({});
|
||||
const reg = registry();
|
||||
// resolution: the run's pick, the op's server.json pick, the
|
||||
// registry's discovered default -- then the registry gate: model
|
||||
// use is disabled until the op discovers, and a model the battery
|
||||
// disqualified never plays
|
||||
const model = meta.models?.player ?? ctx.cfg.models?.player ?? reg?.defaults.player ?? null;
|
||||
if (!model) {
|
||||
throw new HttpError(409, reg
|
||||
? 'no player model resolved -- set one for this run (POST /model), or a deployment default (server.json, or the registry\'s discovered pick)'
|
||||
: 'no models discovered yet -- the op runs discovery from the admin block first');
|
||||
/** A model spec as run.json carries it: the {provider, model,
|
||||
* effort} object (the no-legacy rule, GM, 2026-11-18 -- the
|
||||
* bare-string era migrated away in the same pass). Malformed
|
||||
* records refuse loud.
|
||||
* @param {unknown} raw @param {'player'|'housekeeper'} role @returns {?import('./shapes.mjs').ModelSpec} */
|
||||
function specFromMeta(raw, role) {
|
||||
if (raw == null) return null;
|
||||
if (typeof raw === 'object' && !Array.isArray(raw)) {
|
||||
const o = /** @type {{ provider?: unknown, model?: unknown, effort?: unknown }} */ (raw);
|
||||
if (typeof o.provider === 'string' && typeof o.model === 'string' && typeof o.effort === 'string') {
|
||||
return { provider: o.provider, model: o.model, effort: o.effort };
|
||||
}
|
||||
throw new HttpError(409, `the run's ${role} model record is malformed -- set it again in the model box`);
|
||||
}
|
||||
if (!usable(reg, model)) {
|
||||
throw new HttpError(409, `model '${model}' is not in the deployment's model registry${reg ? ' (or failed the inference probe)' : ''} -- pick a discovered model`);
|
||||
}
|
||||
return model;
|
||||
throw new HttpError(409, `the run's ${role} model record is malformed -- set it again in the model box`);
|
||||
}
|
||||
|
||||
/** The effective sampling knobs for a role: the deployment default
|
||||
* layer (server.json params) under the run's own overrides. */
|
||||
/** @param {Ctx} ctx @param {string} runId @param {'player'|'housekeeper'} role @returns {import('./shapes.mjs').RoleParams} */
|
||||
function resolveParams(ctx, runId, role) {
|
||||
const meta = ctx.runMeta(runId) ?? /** @type {import('./shapes.mjs').RunMeta} */ ({});
|
||||
return {
|
||||
...(ctx.cfg.params?.[role] ?? {}),
|
||||
...(meta.params?.[role] ?? {}),
|
||||
};
|
||||
/** The invalidation gate (GM, 2026-11-18): the settings the run
|
||||
* came with must still be carried. A provider gone from the
|
||||
* config, a model gone from its provider's registry, a model the
|
||||
* battery disqualified -- all one state: the run blocks until the
|
||||
* GM sets it up again. The error IS the table's note.
|
||||
* @param {Ctx} ctx @param {import('./shapes.mjs').ModelSpec} spec @param {'player'|'housekeeper'} role @returns {import('./shapes.mjs').ModelSpec} */
|
||||
function gateSpec(ctx, spec, role) {
|
||||
if (!ctx.providerCfg.providers.some((p) => p.slug === spec.provider)) {
|
||||
throw new HttpError(409, `the run's ${role} model rides provider '${spec.provider}', which is no longer configured -- set it up again in the model box`);
|
||||
}
|
||||
const m = findModel(spec.provider, spec.model);
|
||||
if (!m) {
|
||||
throw new HttpError(409, `the run's ${role} model '${spec.model}' is not in provider '${spec.provider}'s registry (the discovered ids drifted) -- set it up again in the model box`);
|
||||
}
|
||||
if (m.inference === false) {
|
||||
throw new HttpError(409, `the run's ${role} model '${spec.model}' failed the inference battery -- set it up again in the model box`);
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
|
||||
// The reasoning-effort knob's own resolution (GM, 2026-11-16): unlike
|
||||
// the numeric knobs its unset state SENDS -- the registry measured a
|
||||
// default, so one honestly exists. Layers: the run's override, then
|
||||
// the deployment layer (server.json params), then the registry's
|
||||
// per-model pick -- the level with the highest observed mean
|
||||
// thinking. An explicit null clears the layers: nothing rides, the
|
||||
// model id's baked default applies. Hidden from the model entirely:
|
||||
// never in the mind verb, never in the <model> display block -- it
|
||||
// rides the via record, the raw surfaces carry it.
|
||||
/** @param {Ctx} ctx @param {string} runId @param {'player'|'housekeeper'} role @param {string} model @returns {?string} */
|
||||
function resolveEffort(ctx, runId, role, model) {
|
||||
/** Resolve one role's spec: the run's pick, gated for validity. No
|
||||
* pick is a loud refusal -- the create flow lands one, so only
|
||||
* picked-clean runs hit this.
|
||||
* @param {Ctx} ctx @param {string} runId @param {'player'|'housekeeper'} role @returns {import('./shapes.mjs').ModelSpec} */
|
||||
function resolveSpec(ctx, runId, role) {
|
||||
const meta = ctx.runMeta(runId) ?? /** @type {import('./shapes.mjs').RunMeta} */ ({});
|
||||
const set = meta.params?.[role]?.reasoning_effort ?? ctx.cfg.params?.[role]?.reasoning_effort ?? undefined;
|
||||
if (set !== undefined) return set === null ? null : String(set);
|
||||
const m = registry()?.models.find((x) => x.id === model);
|
||||
return m?.effortDefault ?? null;
|
||||
const spec = specFromMeta(meta.models?.[role], role);
|
||||
if (!spec) throw new HttpError(409, `no ${role} model set for this run -- pick one in the model box`);
|
||||
return gateSpec(ctx, spec, role);
|
||||
}
|
||||
export { resolveModel, resolveParams, resolveEffort };
|
||||
export { specFromMeta, gateSpec, resolveSpec };
|
||||
|
||||
// --- the mind verb ------------------------------------------------------------
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user