the access round: spectator mode removed and reads made story-only -- the table, raw session, carryover, files, status, and the notepad are owner-only; the story is the one public read (any signed-in user, fork button on it that copies the run that made the story, never the view); #28's human-side open read overturned with the ruling, gm.md stays never model-facing; non-owners land in the story view (play/setup redirect on the 403, home cards link there directly), the story view names its owner and stands alone on the story response, which now carries display/owner/ownerName; the table gains a raw tab -- the whole log as it rode the wire (thinking, every variant block, every reminder copy, full tool results, rides inline) next to the curated projection, live sessions only, sticky across turn re-renders; --debug mode for easy testing: every request is a fixed superuser that bypasses the users db entirely, no invite dance, loopback-bound regardless of config (found live: the SPA boot only asked the server who it was when a token existed, so tokenless browsers never learned they were the debug user -- boot now always asks); lint rule 10: no laptop-visible facts anywhere and all commits always from Mute -- the username and home paths are derived at runtime so the checker never contains them, scanned over the tracked tree, every historical blob, and commit messages, identity enforced on author and committer on every ref plus git config; the queue split: resolved questions relocated to DECISIONS.md verbatim by number (day's words kept, reversals annotate never rewrite, the agenda/reminder trio gets its own section), QUESTIONS is open items only (stale OPENs resolved on the way: #10 by the 2026-11-13 pairing default, #11 by the raw tab); smoke reworked to the story-only battery -- ash 403s on every run surface, 200 on the story alone, the ownerless-run check rides the runs list; all twelve QUESTIONS-number citations re-pointed at DECISIONS; smoke ALL PASS in a worktree (111 checks), two-user browser pass (the non-owner's whole run surface is a 403 detail and a 200 story, back-to-table hidden, owner views intact), raw-tab browser pass (curated table leak-free, raw shows the whole variants block, tabs vanish on dormancy), typecheck green on both programs, check-repo clean

This commit is contained in:
2026-11-15 22:37:06 +00:00
parent 8d4a6b91df
commit e763d6c146
20 changed files with 881 additions and 575 deletions
+11 -12
View File
@@ -8,7 +8,7 @@
// extensionless path.
import { $ } from './dom.mjs';
import { api, authToken, clearToken } from './client.mjs';
import { api, clearToken } from './client.mjs';
import { state } from './state.mjs';
import { navigate, registerViews, render } from './router.mjs';
import * as claim from './view-claim.mjs';
@@ -29,18 +29,17 @@ registerViews({
story: { el: 'view-story', enter: story.enter },
});
// boot: restore the session from the stored token; a rejected or
// absent token leaves me signed out, and every path leads to the
// claim view
// boot: ask the server who we are -- the stored token rides the
// request when one exists; a null user (or a rejected token) leaves
// me signed out, and every path leads to the claim view. Tokenless
// browsers ask too: a debug-mode server answers with its fixed user
(async () => {
if (authToken()) {
try {
const s = await api('/session');
state.me = s.user;
if (!state.me) clearToken();
} catch {
state.me = null;
}
try {
const s = await api('/session');
state.me = s.user;
if (!state.me) clearToken();
} catch {
state.me = null;
}
render();
})();
+5
View File
@@ -100,12 +100,17 @@
</section>
<section id="view-play" hidden>
<nav id="table-tabs" hidden>
<button id="tab-table" class="tab">table</button>
<button id="tab-raw" class="tab">raw</button>
</nav>
<div id="transcript" aria-live="polite"></div>
</section>
<section id="view-story" hidden>
<div class="story-head">
<h1 id="story-title"></h1>
<button id="story-fork">fork this run</button>
<button id="story-back">back to the table</button>
</div>
<div id="story"></div>
+1 -1
View File
@@ -27,7 +27,7 @@ export {};
/** GET /runs/:id/story -- the whole deliverable, read-only: every
* non-dropped literature turn, across all sessions in order. */
/** @typedef {{ run: string, sessions: { session: number, turns: { who: string, text: string }[] }[] }} StoryResponse */
/** @typedef {{ run: string, display: string, owner: ?string, ownerName: ?string, sessions: { session: number, turns: { who: string, text: string }[] }[] }} StoryResponse */
/** GET /api/runs/:id/files -- the editor surface: a fixed whitelist,
* each file with its phase-truth mode. */
+12
View File
@@ -256,6 +256,18 @@ h1 { font-size: 15px; letter-spacing: 0.1em; color: var(--dim); font-weight: nor
/* --- transcript (play) --- */
/* --- the table's tabs: the curated table and the raw audit log --- */
#table-tabs { display: flex; gap: 6px; margin: 0 0 14px; }
#table-tabs .tab { font-size: 12px; padding: 2px 14px; }
#table-tabs .tab.active { border-color: var(--accent); color: var(--accent); }
/* raw blocks: labeled wire dumps -- plain text, no register rendering */
.raw-block { margin: 0 0 16px; max-width: 860px; }
.raw-block .who { font-size: 11px; letter-spacing: 0.12em; color: var(--dim); margin-bottom: 3px; }
.raw-block pre { margin: 0 0 6px; white-space: pre-wrap; font: inherit; }
.raw-block pre.raw-thinking { color: var(--dim); }
.turn { margin: 0 0 20px; max-width: 760px; }
.turn .who { font-size: 11px; letter-spacing: 0.12em; color: var(--dim); margin-bottom: 3px; }
.turn.gm .who { color: var(--accent); }
+81 -6
View File
@@ -131,6 +131,86 @@ export function renderContent(target, text, { extract }) {
return { status, conflict, agenda };
}
// the note line, shared by both walks
/** @param {NoteEvent} e @returns {?string} */
function noteText(e) {
if (e.kind === 'session') return `session ${e.n} opened`;
if (e.kind === 'ask') return `ask_gm: ${e.question}`;
if (e.kind === 'status') return `status: lost ${JSON.stringify(e.applied?.lost ?? [])}, gained ${JSON.stringify(e.applied?.gained ?? [])}`;
if (e.kind === 'agenda') return `agenda: added ${JSON.stringify(e.applied?.added ?? [])}, dropped ${JSON.stringify(e.applied?.dropped ?? [])}`;
if (e.kind === 'pick') return `variant literature: ${e.count} offered, #${e.chosen + 1} picked`;
return null;
}
// the raw walk: the audit surface over the same log -- everything as
// it rode the wire. Thinking, whole variant blocks, every reminder
// copy, full tool results, the rides inline in the GM prose; plain
// labeled blocks, no register rendering -- the table is the reading
// surface, this is the wire.
/** @param {LogEvent[]} entries */
export function renderRaw(entries) {
const t = $('transcript');
t.textContent = '';
/** @param {string} who @returns {HTMLElement} */
const block = (who) => {
const d = el('div', 'raw-block');
d.appendChild(el('div', 'who', who));
t.appendChild(d);
return d;
};
for (const e of entries) {
if (e.t === 'bundle') {
// the bundle rides collapsed here too -- it is the same content
// the table shows, and it is huge
const d = el('details', 'bundle');
d.appendChild(el('summary', null, `bundle -- ${e.part}`));
d.appendChild(el('pre', null, e.m.content));
t.appendChild(d);
continue;
}
if (e.t === 'opening') {
t.appendChild(el('div', 'machinery', `her opening status: ${JSON.stringify(e.status)}`));
continue;
}
if (e.t === 'note') {
const text = noteText(e);
if (text) t.appendChild(el('div', 'machinery', text));
continue;
}
if (e.t === 'tool') {
const d = block(e.ask ? 'ruling' : 'tool result');
d.appendChild(el('pre', null, String(e.m.content)));
continue;
}
if (e.t === 'msg' && e.reminder) {
// every copy shows: the raw log keeps each as-sent chunk, and
// the audit surface keeps them all (the table elides superseded
// ones)
const d = el('details', 'bundle');
d.appendChild(el('summary', null, 'turn reminder -- as sent'));
d.appendChild(el('pre', null, String(e.m.content ?? '')));
t.appendChild(d);
continue;
}
if (e.t === 'msg' && e.m.role === 'user') {
const d = block(e.conflictOnly ? 'gm -- conflict only' : 'gm');
d.appendChild(el('pre', null, String(e.m.content ?? '')));
continue;
}
if (e.t === 'msg' && e.m.role === 'assistant') {
const d = block('player');
if (e.m.reasoning_content) d.appendChild(el('pre', 'raw-thinking', e.m.reasoning_content));
d.appendChild(el('pre', null, String(e.m.content ?? '')));
for (const c of e.m.tool_calls ?? []) {
d.appendChild(el('div', 'machinery', `[tool call] ${c.function.name}`));
if (c.function.arguments) d.appendChild(el('pre', null, String(c.function.arguments)));
}
continue;
}
}
t.scrollTop = t.scrollHeight;
}
// the entry walk. onConflict receives a conflict block found on a GM
// turn -- the play view owns where it lands (the status pane). The
// opening event (her opening status) renders as machinery, mirroring
@@ -222,12 +302,7 @@ export function renderTranscript(entries, { onConflict } = {}) {
}
/** @param {NoteEvent} e */
function renderNote(e) {
let text = null;
if (e.kind === 'session') text = `session ${e.n} opened`;
else if (e.kind === 'ask') text = `ask_gm: ${e.question}`;
else if (e.kind === 'status') text = `status: lost ${JSON.stringify(e.applied?.lost ?? [])}, gained ${JSON.stringify(e.applied?.gained ?? [])}`;
else if (e.kind === 'agenda') text = `agenda: added ${JSON.stringify(e.applied?.added ?? [])}, dropped ${JSON.stringify(e.applied?.dropped ?? [])}`;
else if (e.kind === 'pick') text = `variant literature: ${e.count} offered, #${e.chosen + 1} picked`;
const text = noteText(e);
if (text) t.appendChild(el('div', 'machinery', text));
}
}
+3 -2
View File
@@ -27,8 +27,9 @@ export async function enter(arg, seq) {
card.appendChild(el('span', 'card-name', `${r.display ?? r.id}${ownershipTag(r, mine)}`));
card.appendChild(el('span', 'card-meta', `${r.package} \u00b7 ${r.forked ? `forked ${fmtUnix(r.forked)}` : `started ${r.created ?? '?'}`} \u00b7 ring A ${r.fill?.a ?? 0} / B ${r.fill?.b ?? 0} \u00b7 ${r.id}${r.models?.player ? ` \u00b7 ${r.models.player}` : ''}`));
card.appendChild(el('span', `card-state ${runStateClass(r)}`, runStateText(r)));
// another user's draft is read-only: the play view says so; your own opens the editor
card.addEventListener('click', () => navigate(r.phase === 'dormant' && r.sessions === 1 && mine ? `/runs/${r.id}/setup` : `/runs/${r.id}`));
// your own draft opens the editor; anyone else's run opens at
// the story -- the table is the owner's
card.addEventListener('click', () => navigate(!mine ? `/runs/${r.id}/story` : r.phase === 'dormant' && r.sessions === 1 ? `/runs/${r.id}/setup` : `/runs/${r.id}`));
list.appendChild(card);
}
await renderAdmin(seq);
+53 -42
View File
@@ -17,7 +17,13 @@ import { banner, hideBanner, renderMeter, setBusy, setSessionInfo } from './chro
import { navigate, render, runGone } from './router.mjs';
import { logEvent } from './log.mjs';
import { armedButton, modelList, modelsBox, paneEditor } from './widgets.mjs';
import { renderTranscript } from './transcript.mjs';
import { renderRaw, renderTranscript } from './transcript.mjs';
// the table's two faces: the curated projection (the table) and the
// raw audit log. Sticky across the re-renders a turn triggers;
// switching runs resets to the table.
/** @type {?string} */ let rawRun = null;
let rawOpen = false;
// her two blocks, split along the seam: how she is (the status) vs
// what she means to do (the agenda). Both render compact, mirroring
@@ -62,6 +68,7 @@ export function leave() {
/** @param {?string} id @param {number} seq @returns {Promise<void>} */
export async function enter(id, seq) {
if (id == null) return; // unreachable: the router only enters play with a run id
if (rawRun !== id) { rawRun = id; rawOpen = false; } // a new run starts at the table
statusPane.reset();
agendaPane.reset();
$('conflict').hidden = true;
@@ -80,41 +87,44 @@ async function refreshPlay(id, seq) {
detail = await api(`/runs/${id}`);
} catch (e) {
if (e.status === 404) return runGone(id, location.pathname);
// the table is the owner's: everyone else reads the story
if (e.status === 403) return navigate(`/runs/${id}/story`);
return banner(`could not reach the server: ${e.message}`); // stay put -- transient
}
if (seq !== state.seq) return;
const mine = !!(state.me && detail.run.owner === state.me.id);
if (detail.draft) {
if (mine) return navigate(`/runs/${id}/setup`);
// someone else's unstarted run: nothing to read but its existence
setSessionInfo(`${detail.display} -- a draft, not yours`);
$('transcript').textContent = '';
$('transcript').appendChild(el('div', 'hint', 'this run is still a draft -- fork it to make it yours and edit it'));
return;
}
if (detail.draft) return navigate(`/runs/${id}/setup`); // the owner's draft opens the editor
setSessionInfo((detail.phase === 'live'
setSessionInfo(detail.phase === 'live'
? `${detail.display} -- session ${detail.session}${detail.pendingAsk ? ' -- waiting for your answer' : ''}`
: `${detail.display} -- session ${detail.sessions} dormant`)
+ (mine ? '' : detail.run.owner == null ? ' -- ownerless' : ' -- spectating'));
: `${detail.display} -- session ${detail.sessions} dormant`);
renderMeter(detail);
statusPane.set(detail.status);
agendaPane.set(detail.agenda);
$('conflict').hidden = true;
// spectator mode: read everything, mutate nothing -- the fork is the
// way in. Ownerless runs are spectators for everyone alike.
statusPane.setEditable(mine);
agendaPane.setEditable(mine);
/** @type {HTMLTextAreaElement} */ ($('gm-notes')).readOnly = !mine;
// the owner's table: everything here edits -- anyone else was
// redirected to the story above
statusPane.setEditable(true);
agendaPane.setEditable(true);
/** @type {HTMLTextAreaElement} */ ($('gm-notes')).readOnly = false;
$('table-tabs').hidden = true; // the tabs are the live session's
if (detail.phase === 'live') {
// the table: the live session's projection -- thinking never
// crosses the wire, variant turns carry only the picked one (the
// raw /session is the audit surface, one fetch away)
/** @type {TableResponse} */ const session = await api(`/runs/${id}/table`);
if (seq !== state.seq) return;
renderTranscript(session.entries, { onConflict: showConflict });
// the table has two faces: the curated projection (thinking never
// crosses the wire, variant turns carry only the picked one) and
// the raw audit log (everything as it rode the wire)
$('table-tabs').hidden = false;
$('tab-table').classList.toggle('active', !rawOpen);
$('tab-raw').classList.toggle('active', rawOpen);
if (rawOpen) {
/** @type {TableResponse} */ const session = await api(`/runs/${id}/session`);
if (seq !== state.seq) return;
renderRaw(session.entries);
} else {
/** @type {TableResponse} */ const session = await api(`/runs/${id}/table`);
if (seq !== state.seq) return;
renderTranscript(session.entries, { onConflict: showConflict });
}
} else if (detail.phase === 'dormant') {
// the review window: the carryover is the preview of the next
// contwin's opening, rendered exactly as the table will hold it
@@ -123,34 +133,30 @@ async function refreshPlay(id, seq) {
$('transcript').textContent = '';
if (carry && carry.entries.length) renderTranscript(carry.entries, {});
else $('transcript').appendChild(el('div', 'hint', 'nothing carries -- the next session opens on the bundle alone'));
if (mine) $('transcript').prepend(dormantBar(detail, carry));
$('transcript').prepend(dormantBar(detail, carry));
} else {
$('transcript').textContent = '';
}
// controls
$('session-open').hidden = detail.phase !== 'dormant' || !mine;
$('session-open').hidden = detail.phase !== 'dormant';
if (!$('session-open').hidden) $('session-open').textContent = `start session ${detail.sessions}`;
$('hk-run').hidden = detail.phase !== 'live' || !mine;
$('hk-rerun').hidden = !(detail.phase === 'dormant' && detail.sessions >= 2) || !mine;
$('hk-replay').hidden = !((detail.phase === 'live') || (detail.phase === 'dormant' && detail.sessions >= 2)) || !mine;
$('hk-override-row').hidden = !(detail.phase === 'dormant' && detail.ready === false) || !mine;
setInput(detail.phase === 'live' && !detail.pendingAsk && mine);
/** @type {HTMLInputElement} */ ($('gm-input')).placeholder = mine
? 'GM line -- Enter sends, Shift+Enter newlines'
: 'spectating -- fork this run to continue it as yours';
$('hk-run').hidden = detail.phase !== 'live';
$('hk-rerun').hidden = !(detail.phase === 'dormant' && detail.sessions >= 2);
$('hk-replay').hidden = !((detail.phase === 'live') || (detail.phase === 'dormant' && detail.sessions >= 2));
$('hk-override-row').hidden = !(detail.phase === 'dormant' && detail.ready === false);
setInput(detail.phase === 'live' && !detail.pendingAsk);
/** @type {HTMLInputElement} */ ($('gm-input')).placeholder = 'GM line -- Enter sends, Shift+Enter newlines';
// models: the owner's per-run overrides
$('models-pane').hidden = !mine;
if (mine) {
const mlist = await modelList();
if (seq !== state.seq) return;
models.fill(detail.run.models, detail.run.modelDefaults, mlist);
}
$('models-pane').hidden = false;
const mlist = await modelList();
if (seq !== state.seq) return;
models.fill(detail.run.models, detail.run.modelDefaults, mlist);
// pending ask: the modal re-presents after a refresh -- the owner's
// to answer; a spectator follows the thread in the transcript
if (detail.pendingAsk && mine) {
// to answer
if (detail.pendingAsk) {
$('ask-question').textContent = detail.pendingAsk;
/** @type {HTMLDialogElement} */ ($('ask-modal')).showModal();
/** @type {HTMLInputElement} */ ($('ask-answer')).focus();
@@ -431,6 +437,11 @@ $('ask-answer').addEventListener('keydown', (e) => {
$('session-open').addEventListener('click', startRun);
$('hk-replay').addEventListener('click', replayHousekeeping);
$('fork-btn').addEventListener('click', forkRun);
// the table's tabs: switching re-renders -- the same pass a turn
// takes, fetching the face that is open
$('tab-table').addEventListener('click', () => { if (rawOpen) { rawOpen = false; render(); } });
$('tab-raw').addEventListener('click', () => { if (!rawOpen) { rawOpen = true; render(); } });
$('story-link').addEventListener('click', () => { if (state.runId) navigate(`/runs/${state.runId}/story`); });
$('gm-notes').addEventListener('input', notesInput);
$('gm-notes').addEventListener('blur', saveNotes);
+2 -1
View File
@@ -61,11 +61,12 @@ export async function enter(id, seq) {
]);
} catch (e) {
if (e.status === 404) return runGone(id, location.pathname);
// the editor is the owner's: everyone else reads the story
if (e.status === 403) return navigate(`/runs/${id}/story`);
return banner(`could not reach the server: ${e.message}`); // stay put -- transient
}
if (seq !== state.seq) return;
if (detail.phase !== 'dormant') return navigate(`/runs/${id}`); // live sessions live in play
if (!state.me || detail.run.owner !== state.me.id) return navigate(`/runs/${id}`); // not yours: read-only -- fork to edit (the router guarantees signed-in)
files = filesResp.files;
repoPrompts = {
+30 -9
View File
@@ -5,17 +5,17 @@
// adjudication review reads ("machinery seams show as prose seams").
// OOC, tools, verbs, thinking, rings: all out, by ruling; carried
// copies never re-render, each turn appears once from its home
// session. Readable by anyone signed in -- spectators read
// everything.
// session. Readable by any signed-in user; the fork button copies
// the run that made the story, never the view.
import { $, el } from './dom.mjs';
import { api } from './client.mjs';
import { state } from './state.mjs';
import { banner } from './chrome.mjs';
import { logEvent } from './log.mjs';
import { navigate, runGone } from './router.mjs';
import { renderContent } from './transcript.mjs';
/** @typedef {import('./shapes.mjs').RunDetail} RunDetail */
/** @typedef {import('./shapes.mjs').StoryResponse} StoryResponse */
/** @type {?string} */ let storyRun = null;
@@ -24,18 +24,23 @@ import { renderContent } from './transcript.mjs';
export async function enter(id, seq) {
if (id == null) return; // unreachable: the router only enters the story with a run id
storyRun = id;
/** @type {RunDetail} */ let detail;
/** @type {HTMLButtonElement} */ ($('story-fork')).disabled = false;
/** @type {StoryResponse} */ let story;
try {
detail = await api(`/runs/${id}`);
story = await api(`/runs/${id}/story`);
} catch (e) {
if (e.status === 404) return runGone(id, 'the story view');
return banner(`could not reach the server: ${e.message}`);
}
if (seq !== state.seq) return;
$('story-title').textContent = `${detail.display} -- the story`;
/** @type {?StoryResponse} */ const story = await api(`/runs/${id}/story`).catch(() => null);
if (seq !== state.seq) return;
if (!story) return banner('the story could not be read');
// whose story this is rides the response -- the story is the one
// surface a non-owner gets, so it names its owner
const whose = story.owner == null ? ' -- ownerless'
: (state.me && story.owner !== state.me.id) ? ` -- ${story.ownerName ?? 'another user'}'s` : '';
$('story-title').textContent = `${story.display} -- the story${whose}`;
// "back to the table" is the owner's alone -- for anyone else the
// table would 403 and bounce straight back here
$('story-back').hidden = !(state.me && story.owner === state.me.id);
const box = $('story');
box.textContent = '';
if (!story.sessions.length) {
@@ -59,3 +64,19 @@ export async function enter(id, seq) {
$('story-back').addEventListener('click', () => {
if (storyRun) navigate(`/runs/${storyRun}`);
});
// the fork copies the run that made this story and lands you in the
// fork's play view -- any signed-in user, any run
$('story-fork').addEventListener('click', async () => {
if (!storyRun) return;
const btn = /** @type {HTMLButtonElement} */ ($('story-fork'));
btn.disabled = true;
try {
const r = await api(`/runs/${storyRun}/fork`, { method: 'POST', body: {} });
logEvent('nav', `forked ${storyRun} -> ${r.run}`);
navigate(`/runs/${r.run}`);
} catch (e) {
btn.disabled = false;
banner(`the fork failed: ${e.message}`);
}
});
+1 -1
View File
@@ -35,7 +35,7 @@ export function armedButton(btn, { label, confirm, fire }) {
// a pane: body line + edit button + inline editor. save(items)
// resolves on success and throws on failure -- a failed save keeps
// the editor open, nothing was changed. setEditable(false) is the
// spectator state: no edit button, an open editor cancels.
// not-the-owner state: no edit button, an open editor cancels.
/** @typedef {{ section: string|HTMLElement, body: string|HTMLElement, empty: string, placeholder: string, rows: number, format: (items: string[]) => string, toText: (items: string[]) => string, fromText: (text: string) => string[], save: (items: string[]) => Promise<unknown> }} PaneOpts */
/** @typedef {{ set: (next?: ?string[]) => void, setEditable: (ok: boolean) => void, reset: () => void, items: string[] }} Pane */
/** @param {PaneOpts} opts @returns {Pane} */