the debug round: server.json deleted, the bind hardcoded to loopback (RP_PORT for the port), the debug superuser token-gated behind a printed, persisted token, and the context meter reading the discovered per-model contwin

The rulings (developer, 2026-11-19, in conversation): a deployment basically always needs a fronting proxy, so the listen address is code -- loopback, no override (an op who wants otherwise owns their own socat); the port rides the RP_PORT env var (the RP_BASE twin the test scripts use, default 7350, garbage refused loud); server.json is deleted entirely, file and reader both, because it held no meaningful configuration once the bind died -- only the dead bind and the declared contwin; and contwin is provider/model dependent, never a deployment global, so the meter must DISCOVER it, not read a declaration.

The meter: the run detail's context block now derives its window from the registry -- modelState's resolved player spec, findModel, the model's input ceiling -- null when the provider states none or no pick stands, pct computed against that. A dividend named in review: pct is uncapped, so a mid-run re-pick onto a smaller model shows the meter over 100% BEFORE the first send refuses (the endpoint's own context-length 400 is the designed refusal -- no pre-request check, nothing truncates, the failed call lands its req event, the composer keeps the line per the standing rule).

Debug mode reworked around its real purpose (skip the invite dance on a fresh server, mocks in particular): the old shape -- every request the superuser, no auth at all -- left any debug server that somehow reached a network fully open. Now one fixed superuser behind a real bearer token: minted into state/debug-token.txt (the bootstrap-invite precedent -- a raw secret on disk so a restart never invalidates what the tester already pasted; the developer ruled persist), printed at every boot, and the claim screen gains the paste path ("or paste a token": store it, verify through the public /session, land or banner). The paste path is generic surface, not debug-only: tokens are returned once and never listed, so a pasted saved token is the only browser-migration path that existed to build. The public /session carries a debug flag so the claim hint says "paste the token the server printed at boot" instead of pointing at the bootstrap file debug never mints. Debug browser passes now exercise the real auth path (the 401, the u: attribution line) instead of bypassing it.

En-route mock fidelity fix the smoke earned: the mock path never set s.usage (no provider call happens), so every usage and context surface was null under the smoke -- the first cut of the new gauge assertion failed on exactly that. The mock now carries a synthetic usage (the assembled view's chars over 4), riding the msg events like the real path's, so the detail's usage and the context gauge are smoke-assertable: contwin 524288 straight from the mock's registry input ceiling, pct computed.

Verified: typecheck green both programs; smoke ALL PASS (+1, the discovered-gauge assertion); restart + reminder checks green (5 runs again); a browser pass on --mock --debug end to end -- the wrong token banners "token rejected" and stays on claim, the printed token lands as Debug the op, the stored token survives a server restart (the persistence proof), zero console errors; check-repo clean (it caught the round's own "window" in the new README passage -- contwin is the word); the dev machine's server.json deleted and the debug server restarted on the real state (Chloe and Irene rebuilt, the token minted into the real state/). Docs: README's deployment and debug passages, the config passage, and the layout tree (the server.example.json lines gone with the file); DICTIONARY's meter and contwin entries (the config key died with the file -- the dated rename record keeps its day's words); AGENTS's server entry and the two server.json gotchas; HANDOFF's round record and the push-queue count (now eight). The developer's operator-queue line ("revisit the debug mode, hardcode loopback") is struck by them in the same commit. packages/detention stays untracked WIP, untouched.
This commit is contained in:
2026-11-19 10:31:03 +00:00
parent ccdd9ea129
commit 4b8fbd7471
16 changed files with 214 additions and 87 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ export function setSessionInfo(text) {
/** The run detail (GET /runs/:id) carries the meter's numbers; null
* is the router's "no run addressed" reset.
* @param {?{ context?: ?{ used?: ?number, pct?: ?number, contwin?: ?boolean } }} [detail] */
* @param {?{ context?: ?{ used?: ?number, pct?: ?number, contwin?: ?number } }} [detail] */
export function renderMeter(detail) {
const fill = $('context-fill');
const label = $('context-label');
+6
View File
@@ -29,6 +29,12 @@
<button type="submit" class="primary">claim</button>
</div>
</form>
<form id="token-form">
<label class="field">or paste a token <input id="token-paste" autocomplete="off"></label>
<div class="form-actions">
<button type="submit">sign in</button>
</div>
</form>
</section>
<section id="view-home" hidden>
+1 -1
View File
@@ -25,7 +25,7 @@ export {};
* her two blocks, the fill, the context meter's numbers. models is
* run.json verbatim (the spec picks); modelState is the resolved
* truth. */
/** @typedef {{ run: { id: string, package: ?string, created: ?string, forked: ?number, owner: ?string, ownerName: ?string, models: { player?: ?{ provider: string, model: string, effort: string }, housekeeper?: ?{ provider: string, model: string, effort: string } }, modelState: { player: RoleHealth, housekeeper: RoleHealth }, providerDefaults: { slug: string, default: ?{ model: string, effort: string } }[] }, display: string, open: boolean, phase: ?string, session: ?number, sessions: number, draft: boolean, ready: ?boolean, status: string[], agenda: string[], sheet: ?Record<string, unknown>, records: number, fill: Record<string, number>, events: number, pendingAsk: ?string, usage: ?{ promptTokens: number, completionTokens: number }, context: ?{ used: number, contwin: ?boolean, pct: ?number } }} RunDetail */
/** @typedef {{ run: { id: string, package: ?string, created: ?string, forked: ?number, owner: ?string, ownerName: ?string, models: { player?: ?{ provider: string, model: string, effort: string }, housekeeper?: ?{ provider: string, model: string, effort: string } }, modelState: { player: RoleHealth, housekeeper: RoleHealth }, providerDefaults: { slug: string, default: ?{ model: string, effort: string } }[] }, display: string, open: boolean, phase: ?string, session: ?number, sessions: number, draft: boolean, ready: ?boolean, status: string[], agenda: string[], sheet: ?Record<string, unknown>, records: number, fill: Record<string, number>, events: number, pendingAsk: ?string, usage: ?{ promptTokens: number, completionTokens: number }, context: ?{ used: number, contwin: ?number, pct: ?number } }} RunDetail */
/** One provider's /api/models payload: its registry section (phase
* 'none' when never discovered), the op's default spec, the
+34 -6
View File
@@ -1,9 +1,12 @@
// web/view-claim.mjs -- the invite claim: the only public screen.
// A single-use invite code is exchanged for a persistent token; the
// display name is a freeform label, collisions allowed.
// web/view-claim.mjs -- the invite claim and the token paste: the
// only public screen. A single-use invite code is exchanged for a
// persistent token; the display name is a freeform label, collisions
// allowed. The paste path takes a token straight into the store --
// the debug token's way in, and the only browser-migration path for
// a saved token (tokens are returned once, never listed).
import { $ } from './dom.mjs';
import { api, setToken } from './client.mjs';
import { api, setToken, clearToken } from './client.mjs';
import { state } from './state.mjs';
import { banner } from './chrome.mjs';
import { logEvent } from './log.mjs';
@@ -13,12 +16,18 @@ import { navigate } from './router.mjs';
export async function enter(arg, seq) {
/** @type {HTMLInputElement} */ ($('claim-code')).value = '';
/** @type {HTMLInputElement} */ ($('claim-name')).value = '';
/** @type {HTMLInputElement} */ ($('token-paste')).value = '';
let fresh = false;
try { fresh = (await api('/session')).fresh; } catch { /* public: works signed out; a dead server shows the plain hint */ }
let debug = false;
try { ({ fresh = false, debug = false } = await api('/session')); } catch { /* public: works signed out; a dead server shows the plain hint */ }
if (seq !== state.seq) return;
$('claim-hint').textContent = fresh
/** @type {string} */
let hint;
if (debug) hint = 'debug server -- paste the token the server printed at boot';
else hint = fresh
? 'this deployment has no users yet -- the superuser invite is in state/bootstrap-invite.txt on the server'
: 'a single-use invite code, from the operator';
$('claim-hint').textContent = hint;
/** @type {HTMLInputElement} */ ($('claim-code')).focus();
}
@@ -34,3 +43,22 @@ $('claim-form').addEventListener('submit', async (e) => {
banner(err.message);
}
});
// the paste path: store the token, then verify it the same way the
// app boot does -- the public /session resolves it to a user or null
$('token-form').addEventListener('submit', async (e) => {
e.preventDefault();
const t = /** @type {HTMLInputElement} */ ($('token-paste')).value.trim();
if (!t) return;
try {
setToken(t);
const r = await api('/session');
if (!r.user) { clearToken(); banner('token rejected'); return; }
state.me = r.user;
logEvent('nav', `signed in: ${r.user.name}${r.user.superuser ? ' (op)' : ''}`);
navigate('/');
} catch (err) {
clearToken();
banner(err.message);
}
});