From eebc1993dd35121eadebb72e68c8b4b9ba7055b2 Mon Sep 17 00:00:00 2001 From: Mute Date: Mon, 16 Nov 2026 23:52:58 +0000 Subject: [PATCH] the night rounds: the GM-input rework and the reasoning-effort knob -- the workbench renders no faces: the composer overlay and the transcript share colour-only tokens (.narration dim, .emph accent), source verbatim, asterisks tinted and kept on screen, so the input's caret can never drift (the old overlay's real bold/italic shifted advance widths -- keeping every character preserved count, not width; the scrollbar-gutter match killed the second drift source); the story view carries its OWN renderer (view-story storyBody/storySpans) -- the book keeps real bold/italic with the asterisks spent, narration italic via #story-scoped CSS, one rule for the tool and typography for the deliverable, deliberately separate; the composer is turn-shaped: rows=6 floor, field-sizing: content grows it with the turn (the thing the GM remembered Firefox doing -- it was never in use), max-height 50vh caps with internal scroll, the footer moved under the transcript's column only so the input's width is the pane's; the transcript's stick-to-bottom was DEAD CODE all along (#transcript has no height or overflow -- main is the scroller, the scrollTop assignments were no-ops in every browser): stickBottom scrolls main and re-asserts next frame (Firefox's scroll anchoring can reclaim a same-tick scroll around a content wipe), main carries overflow-anchor: none; the prose pane drops its machinery by ruling: the status/agenda chips and the retired delta tags strip (the panes carry the derived state), the reminder card never renders (it is the same every turn -- the raw tab keeps every copy), and the status/agenda note receipts (the old delta applies and the whole-list sets alike) skip the prose walk while the raw keeps them; the model dropdown collapsed to one plain list of ids sorted, ceilings riding along (the family grouping left the user guessing what a family name means, and the curator's tier labels only made sense inside their groups); and the reasoning-effort round: the battery probes the ladder (probeEfforts -- each of none/minimal/low/medium/high/xhigh/max measured for mean thinking, two samples, efforts recorded per model, effortDefault the argmax mean over minimal..max, 'none' never a candidate -- it is the off switch; null when the model shows no thinking), the knob is first-class and the GM's alone (GM, 2026-11-16: hidden from the model, not her call -- never in the mind verb, never in the display block, and renderView's via-derived block filters it too, both surfaces; it rides the via record for the raw surfaces), its unset state SENDS the measured max-mean default (the one knob with an honestly nameable default -- the registry measured it; layers run override > deployment > registry per-model, explicit null clears to nothing), the first non-numeric knob (RoleParams carries the string, the /model route validates against the ladder, the knob row a select whose unset label names what rides and rebuilds on model-select change); the GLM ladder verified live by hand before the build (low suppresses to a third of baseline, max elevates about double, the whole ladder accepted on both families without 400s, and reasoning_effort 'none' doubles as a standardized thinking-off switch); the model dropdown, the composer, and the knob UX browser-proven with zero console errors (the pass caught the unreachable-helpers bug: code after a factory's return never runs, a hoisted function referencing the uninitialized const throws silently mid-fill and stale rows render); smoke ALL PASS with the effort battery (the canned mock ladders, the default riding a bare turn's via, the override riding the next turn, the bogus-level 400, the null clear, no reasoning_effort in any block) + restart + reminder + repo checks green, typecheck green on both programs; ROADMAP gains the distant extension point (n-choice inference composed by a turn-editor agent) and the operator's queue moved there from QUESTIONS by the GM; HANDOFF prepared as the handoff (the typing-round bullet trimmed into the rounds list, the server line now truthful -- the debug server runs, the registry bullet carries the six-knob state and the pending-effort refine) --- AGENTS.md | 61 +++++++++++++++++++ HANDOFF.md | 67 +++++++++++++-------- QUESTIONS.md | 10 ---- README.md | 30 +++++++--- ROADMAP.md | 28 +++++++++ server/discovery.mjs | 53 +++++++++++++++-- server/housekeeping.mjs | 8 ++- server/loop.mjs | 46 ++++++++++++--- server/main.mjs | 17 +++++- server/session.mjs | 9 ++- server/shapes.mjs | 15 +++-- test/smoke.mjs | 26 ++++++-- web/index.html | 2 +- web/knobs.mjs | 128 +++++++++++++++++++++++++++++----------- web/style.css | 32 +++++++--- web/transcript.mjs | 79 ++++++++++++++++--------- web/view-play.mjs | 7 ++- web/view-story.mjs | 59 +++++++++++++++++- web/widgets.mjs | 73 +++++++++++++---------- 19 files changed, 571 insertions(+), 179 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 670cfd1..cccb38e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -137,6 +137,41 @@ memory the agent owes itself across sessions. ## State pointers +- **The reasoning-effort round is BUILT (2026-11-16, late night): the + battery probes the effort ladder, the knob is first-class, hidden + from the model, and its default SENDS.** The probe (discovery.mjs + probeEfforts): each level of EFFORT_LEVELS (none/minimal/low/ + medium/high/xhigh/max -- mirrored in web/knobs.mjs, keep in step) + measured for mean thinking (2 samples), efforts recorded per + model, effortDefault = the argmax mean over minimal..max ('none' + is the off switch, never a default candidate; null when the model + shows no thinking or nothing moved). The knob (GM's rulings: not + her call, hidden entirely -- never in the mind verb, never in the + display block, BOTH the loop's live push and renderView's + via-derived block filter it; it rides the via record, raw shows + it): resolveEffort layers run override > deployment (server.json) + > registry per-model default, explicit null clears to nothing. + UNLIKE the numeric knobs the unset state sends -- the registry + measured the default, so it is honest. First non-numeric knob: + RoleParams carries reasoning_effort?: string, the /model route + validates against the ladder, the knob row is a select whose + unset label names what rides ('(default: max)'), and the rows + rebuild on model-select change (the effort context follows the + picked model -- modelsBox's rebuildKnobs). Lessons: the loop's + mock path hardcodes model 'mock' (resolveModel never runs under + --mock, which is why cfg's real glm-5.3 never 409s the smoke); + declare helpers BEFORE the factory's return statement -- code + after return is unreachable, a hoisted function referencing an + uninitialized const throws silently mid-fill and stale rows + render (the browser pass caught it); renderView renders the via + record as the turn's block -- a second surface + beyond the loop's live push, both need the effort filter. The + dv endpoint honors the ladder on the GLMs (probed live: low + suppresses to a third of baseline, max elevates ~2x), accepts + the whole ladder on both families without 400s, and + reasoning_effort 'none' doubles as a standardized thinking-off + switch. The registry on disk predates the probe -- efforts land + at the next refine (the GM's one click, post-curator-review). - **The state-scan round is BUILT (2026-11-16, evening): the log is the one truth for status and agenda, the db tiers are retired.** scanState (server/session.mjs) derives each kind newest-wins @@ -177,6 +212,32 @@ memory the agent owes itself across sessions. the browser heuristically caches ES modules across reloads -- after editing web/ warm them with fetch(url, {cache:'reload'}) from evaluate before judging the page stale or fresh. +- **The GM-input round is BUILT (2026-11-16, night): the composer + reads like a turn, the tokens are colour-only, the stick-to-bottom + works.** The overlay's real bold/italic faces shifted advance + widths and dragged the caret (the "every character stays" trick + preserved count, not width) -- the ruling: no faces on the + workbench at all. One rule, colour-only, source verbatim + (asterisks tinted, kept on screen): the input overlay and the + transcript share the same token classes (.narration dim, + .emph accent), zero drift by construction; the scrollbar-gutter + match killed the second drift source (the textarea's gutter + appearing on scroll while the pre had overflow hidden). The story + view got its OWN renderer (view-story.mjs storyBody/storySpans): + the book keeps real faces, asterisks spent, narration italic via + #story-scoped CSS -- one rule for the tool, typography for the + deliverable, deliberately separate. The composer: rows=6 floor, + field-sizing: content grows it with the turn, max-height 50vh + caps with internal scroll (rows is the no-support fallback -- + field-sizing is the thing the GM remembered Firefox doing; it + wasn't in use, now it is). The footer moved under the transcript's + column only (the input's width is the pane's width), padding + aligned to main's. The pane stick-to-bottom was DEAD CODE all + along: #transcript has no height/overflow (main is the scroller), + so scrollTop assignments on it were no-ops in every browser -- + stickBottom() now scrolls main, re-asserts on the next frame + (Firefox's scroll anchoring can reclaim a same-tick scroll around + a content wipe), main carries overflow-anchor: none. - **The 2026-11-16 rounds are built and live-proven: the play-protocol batch and model discovery.** The protocol batch: OOC GM turns (paren-led, post-expansion) carry no status/agenda blocks; diff --git a/HANDOFF.md b/HANDOFF.md index c34df70..8d0ad48 100644 --- a/HANDOFF.md +++ b/HANDOFF.md @@ -9,18 +9,8 @@ file is the "where did we leave off" map. ## Where we are -- **The JSDoc typing round is COMPLETE, all four phases (2026-11-15, - through `8d4a6b9`): the server core (`f81b188`), the clerk, and - web/.** tsc runs as a no-emit checker over plain `.mjs` with JSDoc - annotations (`npm run typecheck` -- two programs: `tsconfig.json` - for server + tool, `tsconfig.web.json` for the SPA's DOM libs); - the shared shapes live in `server/shapes.mjs`, the db row shapes - local to their owners, the SPA's response envelopes in - `web/shapes.mjs`. The audit lists live in the commit messages; - the type gate and its working lessons live in AGENTS. - -- **Everything is built, proven, and committed (through `8d4a6b9`, - 2026-11-15, plus the 2026-11-16 rounds -- see the git log).** The +- **Everything is built, proven, and committed (through the + 2026-11-16 night rounds -- see the git log).** The full scope, each round mock-proven end to end and live-proven where live could reach: the MVP substrate (clerk, server, housekeeping job, SPA), multiuser (token identity, invites, fork, @@ -63,7 +53,22 @@ file is the "where did we leave off" map. the state note at the carry head (the resume-reconcile skips it); the start gate's n=1 seeding died (her authored opening turn IS the seed); continuation carryovers are writable in the - file editor during dormancy. The design record lives in README / + file editor during dormancy), and the GM-input round (2026-11-16, + night): the workbench renders no faces -- the composer overlay and + the transcript share colour-only tokens, source verbatim (the + caret-drift died with the faces), the story view carries its own + renderer (the book keeps bold/italic, asterisks spent), the + composer is turn-shaped (six-line floor, field-sizing growth, + 50vh cap, the input's width is the pane's), and the transcript's + stick-to-bottom actually scrolls now (it was dead code -- main is + the scroller, not the div), and the reasoning-effort round + (2026-11-16, late night): the battery probes the effort ladder + per model (efforts + effortDefault in the registry), the knob is + first-class and the GM's alone -- hidden from the model (never in + the mind verb, never in the block, riding the via record + for the raw surfaces), its unset state sends the measured + max-mean default, explicit null clears, the knob row a select + that follows the picked model. The design record lives in README / DICTIONARY / ROADMAP; the build history in the git log. - **The project is named: Tiny Worlds.** The invariant it names is stated in README's premise -- each package is a tiny world on @@ -99,9 +104,12 @@ file is the "where did we leave off" map. deterministic battery + the curator pass), the registry (state/models.json -- the truth of selectable models; a fresh deployment has none and model use is disabled), registry-gated - model routes and turn loop, and the five named knobs - (temperature, top_p, top_k, repetition_penalty, max_tokens) per - role, run layer over deployment layer, sent only when set. + model routes and turn loop, and the named knobs per + role, run layer over deployment layer -- the five numeric ones + (temperature, top_p, top_k, repetition_penalty, max_tokens) sent + only when set, plus reasoning_effort (2026-11-16, late night -- + the sixth, an enum whose unset state sends the measured default; + see the rounds bullet above). Live-verified against the real endpoint across three refine runs: gev fails the tool probe and drops (capability detection, no names in code), off-switch spellings verified per model, the @@ -120,13 +128,16 @@ file is the "where did we leave off" map. (mock / mock-tie, same bucket, same windows) and the smoke asserts the lex-bottom pick. The on-disk registry still names glm-5.2-max as its default (the coin-flip run) -- inert while server.json - pins its own pick, and the next refine re-picks deterministically - (glm-5.3-max, the lex bottom). PENDING: the curator.md review + pins its own pick; the next refine re-picks deterministically + (glm-5.3-max, the lex bottom) and brings the effort measurements + (the registry predates the probe). PENDING: the curator.md review (GM-led, the housekeeper.md precedent). -- **The server is stopped; state/ holds only the registry** - (models.json, the alias-aware curated run). The auth side is - pristine -- no users, so the next start mints the real bootstrap - invite to state/bootstrap-invite.txt and the console. +- **The server runs in debug mode** (the GM's session: + `node server/main.mjs --debug` -- auth bypassed, loopback-bound). + state/ holds the registry (models.json, the alias-aware curated + run) plus the debug boot's bootstrap-invite mint (no user ever + claimed; the first NORMAL start mints the real bootstrap invite + to state/bootstrap-invite.txt and the console). ## Immediate next steps, in order @@ -166,7 +177,10 @@ file is the "where did we leave off" map. calibration), and whether she ever states a ``. The override's own watchable: whether a GM block edit reads as her state to her (it must -- the composition is the design) and - whether she adopts or fights it on her next emission. + whether she adopts or fights it on her next emission. The + effort knob's watchable: whether max-effort changes her texture + and her cost curve -- the first knob that changes how much she + thinks, not how she samples. Variantary: the metric's curve (`/story` variance -- how often, how many candidates), coin-flip personality (choices offloaded to chance that should be character), and whether her variants @@ -180,7 +194,12 @@ file is the "where did we leave off" map. - **A knob riding a real request** -- the knobs, their explicit-override UX, and the request recording are smoke- and browser-proven, but no live turn has carried one; the max-reasoning defaults are likewise - unplayed (Chloe runs -high; no turn has run on a -max model). + unplayed (Chloe runs -high; no turn has run on a -max model). The + effort knob doubly so: the registry on disk predates the probe, so + no live turn has carried reasoning_effort either -- the first + refine (the op's one click, post-curator-review) brings the + measured defaults, and the GLM ladder is already verified live by + hand (low suppresses, max elevates). - **The full-block protocol against a live model** -- whole-list emission, the stamping, the `` blocks, and whether she ever states a `` are all unexercised live; Chloe's session two diff --git a/QUESTIONS.md b/QUESTIONS.md index f3dba1a..7b425d2 100644 --- a/QUESTIONS.md +++ b/QUESTIONS.md @@ -6,16 +6,6 @@ the reasoning as written) is DECISIONS.md, keyed by the same numbers; durable decisions also graduate into README.md, ROADMAP.md, DICTIONARY.md, or the prompts. Tiered by urgency, FIFO within a tier. -## Operator's queue (don't edit, don't work on) - -- what's the "n" parameter? -- the model tends to summarise GM's turns or quote from them -- italics is cursed in the editor -- calibration package: escape room -- calibration package: the detention -- user manual -- session rewind - ## Open ### 16. Housekeeping model configuration -- OPEN (mechanism settled) diff --git a/README.md b/README.md index 7f6589c..288637d 100644 --- a/README.md +++ b/README.md @@ -554,11 +554,21 @@ and housekeeper defaults (the op's explicit pick -- it beats the registry's discovered default), `contwin` (the context window; the old `contextWindow` key still accepted) drives the context meter, `params` holds the deployment-default sampling knobs per role -(temperature, top_p, top_k, repetition_penalty, max_tokens) -- a +(temperature, top_p, top_k, repetition_penalty, max_tokens, +reasoning_effort) -- a run carries its own overrides for models and knobs in `run.json`, -merged over the deployment layer, sent only when set. The knob UX +merged over the deployment layer. The five numeric knobs send only +when set (the provider's serving defaults are unknowable, so no +default is honestly nameable); reasoning_effort is the exception -- +the battery measured a per-model default (the effort level with the +highest observed mean thinking), so its unset state sends that, and +an explicit null clears to nothing (the model id's baked default +applies). It is the GM's knob alone: hidden from the model, never +in the mind verb, never in the `` display block -- it rides +the via record, the raw surfaces carry it. The knob UX (web/knobs.mjs) is explicit: a per-knob override toggle (off = unset, -the input disabled; on demands a number), the definitions table +the input disabled; on demands a number, a level for the enum), the +definitions table carrying every text -- label, hint, this endpoint's probed bounds -- and one shared hint bar driven by focus; unset and set-to-the- deployment-default are distinct states, the run detail exposes the @@ -583,9 +593,13 @@ surface: API metadata only, zero inference, the preliminary list. **Refine** runs the deterministic battery over that list -- the tool-manifest ping (the exact request shape a player turn takes; a model that cannot take it is not an inference model and stays out of -the selectors), two reasoning samples on a fixed puzzle, and the +the selectors), two reasoning samples on a fixed puzzle, the disable-thinking probe whose working spelling is recorded as a -discovered fact -- then hands the adjudicated results to the +discovered fact, and the reasoning-effort probe: each level of the +ladder (`none` through `max`) measured for mean thinking, the +per-model default being the level with the highest observed mean +(GM, 2026-11-16: maximum thinking by default, overridable) -- then +hands the adjudicated results to the best-measured model (repo craft: `curator.md`) for the presentation layer: families, labels, descriptions, role eligibility. The curator's output is strictly validated; any @@ -740,8 +754,10 @@ web/ the SPA -- no build, vanilla ES modules, path-routed; override toggle and the shared hint bar transcript.mjs register rendering (speech / narration / OOC) and the session-log entry walk (historical opening - events render as machinery); renderContent is shared with the - story view + events render as machinery); colour-only tokens, + source verbatim -- the workbench renders no faces + (the book does: the story view carries its own + renderer) view-*.mjs one module per view -- claim, home, new, setup, play (the table), story (the whole deliverable, read-only) -- each owning its elements, its state, and its wiring diff --git a/ROADMAP.md b/ROADMAP.md index 6aac5e6..11073b4 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -4,6 +4,16 @@ Reviewed 2026-11-11 via web survey: consumer companion apps, power frontends, agent RP frameworks, memory research. Items below are meant to be worked through one by one; statuses in caps, decisions dated. +## Operator's queue (don't edit, don't work on) + +- the model tends to summarise GM's turns or quote from them +- teach the model to stop using italics for emphasis +- revisit what fetch does and SPA reactivity +- calibration package: escape room +- calibration package: the detention +- user manual +- session rewind + ## The landscape (what exists, as of the review) | Family | Exemplars | Memory approach | @@ -518,6 +528,24 @@ duplicate handbook cut is the GM's red pen). dormancy) but has no editing surface yet; the dormant view renders it raw, read-only. The proper editor is its own task. +## Distant extension points (someday, not scheduled) + +- **n-choice inference composed by a turn-editor agent.** The + provider's `n` parameter asks for several statistically independent + completions of the same prompt -- the same moment re-rolled by the + dice, where variant literature is her deliberate alternatives. The + composition: request n choices, hand them to a turn-editor agent + that splices/edits them into the one turn that lands. Open + questions if it ever earns a keep: who edits (the agent's brief, + the GM's veto), what the log keeps (every choice belongs on the + raw surface, and the variance metric wants them -- today the loop + reads choices[0] only), cost (every choice bills its completion + tokens), provider support (patchy outside the first-party APIs -- + the discovery battery would need to probe it), and the knob + surface (`n` is not a named knob; whose is it to set?). Until + then, variant literature plus the crypto pick is the ruled + mechanism for chance in play. + ## Rejected, with reasons - **Keyword-triggered lorebook injection** -- push pollutes context and diff --git a/server/discovery.mjs b/server/discovery.mjs index d982748..d15dcd6 100644 --- a/server/discovery.mjs +++ b/server/discovery.mjs @@ -113,6 +113,12 @@ export async function discover(ctx) { // --- step two: refine (the battery + the curator) ----------------------------- +// the reasoning-effort ladder: the spellings the OpenAI-compatible +// world agrees on. `none` doubles as the standardized thinking-off +// switch. Mirrored in web/knobs.mjs for the select -- keep them in +// step. +export const EFFORT_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']; + /** One model's measured thinking under given request params. * @param {Ctx} ctx @param {string} id @param {Record} params @returns {Promise} */ async function thinkingTokens(ctx, id, params) { @@ -120,9 +126,32 @@ async function thinkingTokens(ctx, id, params) { return Number(data.usage?.completion_tokens_details?.reasoning_tokens ?? 0); } +/** The reasoning-effort probe: each level's measured mean thinking + * (two samples, the battery's granularity). The default is the + * level with the highest observed mean -- `none` is never a + * candidate, it is the off switch, not a thinking level (GM, + * 2026-11-16: maximum observable thinking by default, overridable + * by the user). A model that shows no thinking, or that no level + * moves, gets null -- nothing rides. + * @param {Ctx} ctx @param {string} id @returns {Promise<{ efforts: Record, effortDefault: ?string }>} */ +async function probeEfforts(ctx, id) { + /** @type {Record} */ const efforts = {}; + for (const level of EFFORT_LEVELS) { + const xs = []; + for (let i = 0; i < 2; i++) { + try { xs.push(await thinkingTokens(ctx, id, { reasoning_effort: level })); } catch { xs.push(0); } + } + efforts[level] = Math.round(xs.reduce((a, b) => a + b, 0) / xs.length); + } + const candidates = EFFORT_LEVELS.filter((l) => l !== 'none'); + const best = candidates.reduce((acc, l) => (efforts[l] > efforts[acc] ? l : acc), candidates[0]); + return { efforts, effortDefault: efforts[best] > 0 ? best : null }; +} + /** The deterministic battery over one model: the tool ping (the * exact request shape a player turn takes), the reasoning samples, - * the off-switch probe. Every failure is a verdict, never an abort. + * the off-switch probe, the effort ladder. Every failure is a + * verdict, never an abort. * @param {Ctx} ctx @param {RegistryModel} m @returns {Promise} */ async function probeOne(ctx, m) { const base = { ...m }; @@ -131,17 +160,21 @@ async function probeOne(ctx, m) { // the canned battery: all three stand-ins are inference models; // mock and mock-tie are a deliberate tie pair (same deep bucket, // same windows -- only the lex rule can part them), the cheap - // tier standard + // tier standard. The canned effort ladders exercise both shapes: + // the full ladder with max on top, and a capped ladder whose + // default is high return m.id === 'mock-cheap' - ? { ...base, inference: true, think: 120, reasoning: 'standard', offSwitch: null, latency: 5 } - : { ...base, inference: true, think: 300, reasoning: 'deep', offSwitch: null, latency: 7 }; + ? { ...base, inference: true, think: 120, reasoning: 'standard', offSwitch: null, latency: 5, + efforts: { none: 0, minimal: 20, low: 60, medium: 90, high: 120 }, effortDefault: 'high' } + : { ...base, inference: true, think: 300, reasoning: 'deep', offSwitch: null, latency: 7, + efforts: { none: 0, minimal: 40, low: 100, medium: 200, high: 300, xhigh: 400, max: 500 }, effortDefault: 'max' }; } const t0 = Date.now(); try { await ctx.provider.chat(m.id, [{ role: 'user', content: 'Say OK.' }], [ASK_GM_TOOL], { max_tokens: 400 }); } catch (e) { const fail = String(e.message ?? e).split('\n')[0].slice(0, 200); - return { ...base, inference: false, fail, reasoning: null, offSwitch: null, latency: Date.now() - t0 }; + return { ...base, inference: false, fail, reasoning: null, offSwitch: null, efforts: null, effortDefault: null, latency: Date.now() - t0 }; } const latency = Date.now() - t0; const samples = []; @@ -157,7 +190,14 @@ async function probeOne(ctx, m) { } } catch { /* no off switch -- recorded as absent */ } } - return { ...base, inference: true, think, reasoning: bucket(think), offSwitch, latency }; + /** @type {Record|null} */ let efforts = null; + /** @type {?string} */ let effortDefault = null; + if (think > 0) { + try { + ({ efforts, effortDefault } = await probeEfforts(ctx, m.id)); + } catch { /* the ladder is optional knowledge -- absent on a flaky endpoint */ } + } + return { ...base, inference: true, think, reasoning: bucket(think), offSwitch, efforts, effortDefault, latency }; } // the pick rule, deterministic: the deepest reasoning bucket, then @@ -199,6 +239,7 @@ async function curate(ctx, probed, best, user) { const facts = probed.map((m) => ({ id: m.id, input: m.input, output: m.output, inference: m.inference ?? false, fail: m.fail ?? null, reasoning: m.reasoning ?? null, hasOffSwitch: !!m.offSwitch, latencyMs: m.latency ?? null, + effortDefault: m.effortDefault ?? null, })); const messages = /** @type {import('./shapes.mjs').ViewMessage[]} */ ([ { role: 'system', content: fs.readFileSync(CURATOR_PROMPT, 'utf8').trim() }, diff --git a/server/housekeeping.mjs b/server/housekeeping.mjs index 0418105..2943b92 100644 --- a/server/housekeeping.mjs +++ b/server/housekeeping.mjs @@ -33,7 +33,7 @@ import { latestSession, sessionMeta, sessionDir, listSessions, loadSession, stopSession, writeMeta, } from './session.mjs'; import { effectiveContents } from './variants.mjs'; -import { HttpError, resolveParams } from './loop.mjs'; +import { HttpError, resolveParams, resolveEffort } from './loop.mjs'; import { registry, usable } from './discovery.mjs'; const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); @@ -243,7 +243,11 @@ async function callHousekeeper(ctx, runId, messages, user) { 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'); + const params = { ...resolveParams(ctx, runId, 'housekeeper') }; + // the effort knob's own layers (its unset state sends the + // registry's measured default for this model) + const effort = resolveEffort(ctx, runId, 'housekeeper', model); + if (effort !== null) params.reasoning_effort = effort; // 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, params); diff --git a/server/loop.mjs b/server/loop.mjs index e18fe8e..e6a6e5f 100644 --- a/server/loop.mjs +++ b/server/loop.mjs @@ -129,15 +129,26 @@ async function runLoop(ctx, runId, user) { for (;;) { const view = renderView(s); // the request's resolved params: the mind layer rides over the - // run and deployment layers. The current call's block - // shows them to her when anything is set -- nothing set means no - // block (the absent grammar); the via record lands the same truth + // run and deployment layers, the effort knob resolves its own + // layers (its unset state sends the registry's measured default). + // The current call's block shows her the knobs that are + // hers to answer with -- 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 ?? {}) }; - if (Object.keys(params).length) { - view.push({ role: 'system', content: `${JSON.stringify(params)}` }); + const effort = resolveEffort(ctx, runId, 'player', model); + if (effort !== null) params.reasoning_effort = effort; + const shown = { ...params }; + delete shown.reasoning_effort; + if (Object.keys(shown).length) { + view.push({ role: 'system', content: `${JSON.stringify(shown)}` }); } let msg; - /** @type {{ model: string, params: Record }} */ let via; + /** @type {{ model: 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 @@ -145,7 +156,6 @@ async function runLoop(ctx, runId, user) { msg = mockModel(s, view); via = { model: 'mock', params }; } else { - const model = resolveModel(ctx, runId); via = { model, params }; // attribution (#22): every LLM call names the acting user console.log(`${new Date().toISOString().slice(11, 19)} llm ${model} u:${user?.id ?? '?'}`); @@ -275,7 +285,7 @@ function resolveModel(ctx, runId) { /** 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 {Record} */ +/** @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 { @@ -283,7 +293,25 @@ function resolveParams(ctx, runId, role) { ...(meta.params?.[role] ?? {}), }; } -export { resolveModel, resolveParams }; + +// 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 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) { + 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; +} +export { resolveModel, resolveParams, resolveEffort }; // --- the mind verb ------------------------------------------------------------ // diff --git a/server/main.mjs b/server/main.mjs index 0066096..7e72e0f 100644 --- a/server/main.mjs +++ b/server/main.mjs @@ -603,8 +603,10 @@ route('POST', '/api/runs/:id/vars', async ({ params, body, user }) => { // pick), selected from the registry (GET /api/models). Owner-only, // changeable at any time -- every call resolves fresh, so a // mid-session switch simply takes the next turn. null clears a role -// back to its deployment default; a null knob clears the knob. -const KNOBS = ['temperature', 'top_p', 'top_k', 'repetition_penalty', 'max_tokens']; +// back to its deployment default; a null knob clears the knob (for +// reasoning_effort, clearing means the registry's measured default +// rides again). +const KNOBS = ['temperature', 'top_p', 'top_k', 'repetition_penalty', 'max_tokens', 'reasoning_effort']; route('POST', '/api/runs/:id/model', async ({ params, body, user }) => { const id = params.id; bundle.requireRun(id); @@ -640,6 +642,14 @@ route('POST', '/api/runs/:id/model', async ({ params, body, user }) => { } for (const [k, v] of Object.entries(knobs)) { if (!KNOBS.includes(k)) throw new HttpError(400, `unknown knob: ${k} -- ${KNOBS.join(', ')}`); + if (k === 'reasoning_effort') { + // the enum knob: one of the ladder's levels, or null to + // clear back to the measured default + if (v !== null && !discovery.EFFORT_LEVELS.includes(String(v))) { + throw new HttpError(400, `params.${role}.reasoning_effort must be one of ${discovery.EFFORT_LEVELS.join(', ')} -- or null to ride the model's measured default`); + } + continue; + } if (v !== null && !Number.isFinite(v)) throw new HttpError(400, `params.${role}.${k} must be a number, or null to clear`); } } @@ -649,7 +659,8 @@ route('POST', '/api/runs/:id/model', async ({ params, body, user }) => { if (knobs === undefined) continue; const cur = { ...(rp[role] ?? {}) }; for (const [k, v] of Object.entries(knobs)) { - if (v === null) delete cur[/** @type {'temperature'|'top_p'|'top_k'|'repetition_penalty'|'max_tokens'} */ (k)]; + if (v === null) delete cur[/** @type {keyof import('./shapes.mjs').RoleParams} */ (k)]; + else if (k === 'reasoning_effort') cur[/** @type {'reasoning_effort'} */ (k)] = String(v); else cur[/** @type {'temperature'|'top_p'|'top_k'|'repetition_penalty'|'max_tokens'} */ (k)] = Number(v); } if (Object.keys(cur).length) rp[role] = cur; diff --git a/server/session.mjs b/server/session.mjs index bf1fd34..980cfa0 100644 --- a/server/session.mjs +++ b/server/session.mjs @@ -653,7 +653,14 @@ export function renderView(s, keepToolResults = 4) { if (typeof content === 'string') { content = content.replace(STRIP_HERS, '').trim(); if (e.via && Object.keys(e.via.params ?? {}).length) { - content = `${JSON.stringify(e.via.params)}\n${content}`; + // the via-derived block is the mind verb's read side: + // reasoning_effort is hidden from her (GM, 2026-11-16 -- + // not her call), it rides the raw surfaces only + const shownVia = { ...e.via.params }; + delete shownVia.reasoning_effort; + if (Object.keys(shownVia).length) { + content = `${JSON.stringify(shownVia)}\n${content}`; + } } if (i === lastProse) { // the canonical stamp: status comma-separated (the wire diff --git a/server/shapes.mjs b/server/shapes.mjs index c479de6..20e76ec 100644 --- a/server/shapes.mjs +++ b/server/shapes.mjs @@ -88,15 +88,22 @@ export {}; /** @typedef {{ package: string, created?: string, owner?: ?string, forked?: number, models?: { player?: ?string, housekeeper?: ?string }, params?: { player?: ?RoleParams, housekeeper?: ?RoleParams } }} RunMeta */ /** The named sampling knobs, per role -- the well-known, widely - * supported set. Numbers ride the wire verbatim; null clears. */ -/** @typedef {{ temperature?: number, top_p?: number, top_k?: number, repetition_penalty?: number, max_tokens?: number }} RoleParams */ + * supported set, plus the reasoning-effort enum (GM, 2026-11-16: + * first-class, hidden from the model -- not her call). Numbers ride + * the wire verbatim; null clears; reasoning_effort is one of the + * effort ladder's levels. */ +/** @typedef {{ temperature?: number, top_p?: number, top_k?: number, repetition_penalty?: number, max_tokens?: number, reasoning_effort?: string }} RoleParams */ /** One model of the discovered registry. Preliminary entries carry * the scrape only (status unrefined); refined entries carry the * battery's verdicts and the curator's presentation. think is the * battery's best measured thinking-token count -- the pick rule - * ranks on it (the bucket is display). */ -/** @typedef {{ id: string, input: ?number, output: ?number, status?: 'unrefined', inference?: boolean, fail?: string, think?: ?number, reasoning?: 'off'|'low'|'standard'|'deep'|null, offSwitch?: Record|null, latency?: ?number, family?: ?string, label?: ?string, description?: ?string, roles?: { player: boolean, housekeeper: boolean } }} RegistryModel */ + * ranks on it (the bucket is display). efforts is the + * reasoning-effort probe: the measured mean thinking per level of + * the ladder; effortDefault is the level with the highest observed + * mean (GM, 2026-11-16: maximum thinking by default, overridable) + * -- null when the model shows no thinking or no level moved it. */ +/** @typedef {{ id: string, input: ?number, output: ?number, status?: 'unrefined', inference?: boolean, fail?: string, think?: ?number, reasoning?: 'off'|'low'|'standard'|'deep'|null, offSwitch?: Record|null, efforts?: ?Record, effortDefault?: ?string, latency?: ?number, family?: ?string, label?: ?string, description?: ?string, roles?: { player: boolean, housekeeper: boolean } }} RegistryModel */ /** state/models.json: the deployment's model registry -- the truth of * what is selectable. Written by discovery (the scrape) and refine diff --git a/test/smoke.mjs b/test/smoke.mjs index 8b1c81c..c6891bd 100644 --- a/test/smoke.mjs +++ b/test/smoke.mjs @@ -3,7 +3,10 @@ // user, the model registry (a fresh deployment has no models, // discover scrapes, refine runs the battery + the curator, registry- // gated picks, the pick rule's lex tie-break, the named sampling -// knobs, the request record -- resolved model + effective params on +// knobs, the reasoning-effort knob (the battery's effort probe, the +// max-mean default that sends, the override that rides the turn, +// hidden from the model), the request record -- resolved model + +// effective params on // every turn, the pass log's model), the mind verb (the player sets // its sampling for its next turn: one-shot, JSON, bounds enforced, // conflict-healed, carried unconsumed across a session boundary, @@ -125,6 +128,10 @@ ok('the refined registry carries verdicts and curation', reg.data.phase === 'ref && reg.data.models.some((m) => m.id === 'mock' && m.inference === true && m.reasoning === 'deep' && m.label === 'Mock' && m.family === 'mock') && reg.data.models.some((m) => m.id === 'mock-tie' && m.reasoning === 'deep' && m.label === 'Mock (tie)') && reg.data.models.some((m) => m.id === 'mock-cheap' && m.reasoning === 'standard'), JSON.stringify(reg.data.models)); +ok('the effort probe: measured ladders and the max-mean defaults', + reg.data.models.some((m) => m.id === 'mock' && m.effortDefault === 'max' && m.efforts?.max === 500 && m.efforts?.none === 0) + && reg.data.models.some((m) => m.id === 'mock-cheap' && m.effortDefault === 'high' && m.efforts?.max === undefined), + JSON.stringify(reg.data.models.filter((m) => m.efforts).map((m) => ({ id: m.id, effortDefault: m.effortDefault })))); const regFile = JSON.parse(readFileSync(`${ROOT}/state/models.json`, 'utf8')); ok('the pick rule: deepest reasoning wins, full ties settle sort-lex-pick-bottom', regFile.defaults.player === 'mock-tie' && regFile.defaults.housekeeper === 'mock-tie', JSON.stringify(regFile.defaults)); @@ -196,8 +203,8 @@ ok('raw session keeps the whole block', r.data.entries.some((e) => e.t === 'msg' const pickNote = r.data.entries.find((e) => e.t === 'note' && e.kind === 'pick'); ok('pick note logged (the metric)', !!pickNote && pickNote.count === 2 && [0, 1].includes(pickNote.chosen), JSON.stringify(pickNote ?? null)); const viaMsg = r.data.entries.find((e) => e.t === 'msg' && e.m.role === 'assistant' && e.via); -ok('the request record rides the turn (resolved model + effective params)', - !!viaMsg && viaMsg.via.model === 'mock' && JSON.stringify(viaMsg.via.params) === '{}', JSON.stringify(viaMsg?.via ?? null)); +ok('the request record rides the turn (resolved model + effective params, the measured effort default included)', + !!viaMsg && viaMsg.via.model === 'mock' && JSON.stringify(viaMsg.via.params) === '{"reasoning_effort":"max"}', JSON.stringify(viaMsg?.via ?? null)); r = await call(`/runs/${runId}/table`, { token: op }); ok('the table carries only the picked variant', r.data.entries.every((e) => e.t !== 'msg' || e.m.role !== 'assistant' || !/<\/?variants?>/.test(e.m.content ?? '')), 'variant syntax leaked into the table'); ok('the picked turn is her turn on the table', r.data.entries.some((e) => e.t === 'msg' && e.m.role === 'assistant' && e.m.content.includes(`cuffed, belted, naked, barefoot, ${pickedStatus}`)), pickedStatus); @@ -304,6 +311,8 @@ ok('an emitted block strips from the view', her1.every((m) => !/\n/.test(String(m.content ?? ''))), ''); ok('each past turn carries its block when params rode', her1.some((m) => String(m.content ?? '').startsWith('{"temperature":1.2}')), ''); +ok('the block hides the effort knob (not her call)', + her1.every((m) => !/reasoning_effort/.test(String(m.content ?? ''))), 'the effort leaked into her display'); ok('GM prose goes pure in the view', view1.filter((m) => m.role === 'user').every((m) => !/<\/?(status|agenda)>/.test(String(m.content ?? ''))), ''); @@ -396,6 +405,14 @@ ok('set knobs', r.status === 200 && r.data.params.player?.temperature === 0.7 && ok('knobs stamped in run.json', meta(forkId).params?.player?.temperature === 0.7); r = await call(`/runs/${forkId}/model`, { method: 'POST', token: ash, body: { params: { player: { temperature: null } } } }); ok('a null knob clears', r.status === 200 && r.data.params.player?.temperature === undefined && r.data.params.player?.max_tokens === 4096, JSON.stringify(r.data.params)); +r = await call(`/runs/${forkId}/model`, { method: 'POST', token: ash, body: { params: { player: { reasoning_effort: 'low' } } } }); +ok('the effort knob sets', r.status === 200 && r.data.params.player?.reasoning_effort === 'low', JSON.stringify(r.data.params)); +r = await call(`/runs/${forkId}/model`, { method: 'POST', token: ash, body: { params: { player: { reasoning_effort: 'turbo' } } } }); +ok('a bogus effort level refuses', r.status === 400 && /must be one of/.test(r.data.error), r.data.error ?? ''); +r = await call(`/runs/${forkId}/model`, { method: 'POST', token: ash, body: { params: { player: { reasoning_effort: null } } } }); +ok('a null effort clears back to the measured default', r.status === 200 && r.data.params.player?.reasoning_effort === undefined, JSON.stringify(r.data.params)); +r = await call(`/runs/${forkId}/model`, { method: 'POST', token: ash, body: { params: { player: { reasoning_effort: 'low' } } } }); +ok('the effort override stays for the turn', r.status === 200 && r.data.params.player?.reasoning_effort === 'low', JSON.stringify(r.data.params)); r = await call(`/runs/${forkId}/model`, { method: 'POST', token: ash, body: { params: { player: { vibes: 1 } } } }); ok('an unknown knob refuses', r.status === 400 && /unknown knob/.test(r.data.error), r.data.error ?? ''); r = await call(`/runs/${forkId}/model`, { method: 'POST', token: ash, body: { player: 'not-a-model' } }); @@ -416,7 +433,8 @@ ok('gm turn on the fork (post-knobs)', r.status === 200, r.data.error ?? ''); r = await call(`/runs/${forkId}/session`, { token: ash }); const viaTurn = [...r.data.entries].reverse().find((e) => e.t === 'msg' && e.m.role === 'assistant'); ok('the recorded request carries the run\'s knobs under the mind layer', - !!viaTurn?.via && viaTurn.via.model === 'mock' && viaTurn.via.params.max_tokens === 4096 && viaTurn.via.params.temperature === 1.2, + !!viaTurn?.via && viaTurn.via.model === 'mock' && viaTurn.via.params.max_tokens === 4096 && viaTurn.via.params.temperature === 1.2 + && viaTurn.via.params.reasoning_effort === 'low', JSON.stringify(viaTurn?.via ?? null)); r = await call('/models', { token: ash }); ok('model listing (the registry)', r.status === 200 && r.data.phase === 'refined' && r.data.models.some((m) => m.id === 'mock' && m.label === 'Mock'), JSON.stringify(r.data.phase)); diff --git a/web/index.html b/web/index.html index ff393e0..f57438c 100644 --- a/web/index.html +++ b/web/index.html @@ -173,7 +173,7 @@