the rewind and conflict-persistence rounds, plus the GM's reminder edit: the take-back and the honest error record.
The rewind (GM, 2026-11-17): "session rewind" came off the operator queue and was redesigned simpler than the turn-surgery proposal -- physical truncation, not typed cut events; fork is the preservation story (fork before rewinding keeps the branch, no fork no archaeology), and the derivation model made the simple design free: status, agenda, and the sheet are all scanState-derived from the log, so a cut re-derives every channel with zero compensation, and every log reader (the view, the scan, the carry walk, the story, housekeeping) sees the same shorter log with nothing new between them. As built: the send commits the rewind -- POST /turn takes optional rewind (a log line index naming one of your turns; that turn and everything after it leave the log, the send replaces it) and optional expect (the log line count the client composed against; the log only moves through sends, so a mismatch means a stale tab and refuses before anything rides -- the ask answer carries it too); gmTurn's order is pendingAsk-refusal -> expect -> expand -> truncate -> land, one commit inside the activity lock, a crash between truncate and land leaving a consistent shorter log and no rewound-but-waiting state ever existing; the floor is the start marker ({t:'note', kind:'start'} written once at start right after the carryover) -- the frozen opening never unwinds, the rule reads the LAST marker (a carried log may hold an older one inside its opening), and a pre-build log refuses loudly as unmarked; the player-facing records tools are OFF until rewind-compatible (their verbs mutate the session db, which a truncation does not compensate; the manifest carries ask_gm alone whatever the settings gate says, while the CLI's --gm filings never ride a turn and stand, rewind-safe by construction); and /retry never existed -- resending the same words after a rewind IS the retry (the GM had no recollection of where the idea came from; dropped, subsumed). The SPA stages the gesture client-side until the send: a per-GM-turn rewind control (the transcript walk's onRewind, offered live and ask-free only), two-click armed, the target's EXPANDED words auto-filling the composer (the log is truth, $vars baked), a composer tint plus a note naming the cut in entries (the colour alone says something is pending, not what dies), cancel restoring the pre-gesture state, text in the box disabling the buttons under the rename "to rewind delete your current input" (a visible affordance, not hiding), and a failed send keeping the gesture armed only on a 400 (anything else may have moved the log). The gm.md desync is parked to ROADMAP's deferred list (notes taken at turn 30 surviving a rewind to 20, orphaned from the narrative -- nothing mechanical is safe there, fork covers it meanwhile). Verified: typecheck green on both programs, smoke ALL PASS with +14 rewind assertions (the floor refusals, her-turn refusal, the stale-expect 409, the truncation 45->42 lines, the dead-range sheet record reverting, the story dropping the cut, the marker surviving), restart + reminder checks green, check-repo clean after staging, and a browser pass committing a real rewind through the UI end to end (the gesture staged, cancelled, re-staged, edited, sent: 20 turns to 8 on the table, the wire body exactly {line, expect, rewind}, zero console errors).
The conflict-persistence round (GM, 2026-11-18): conflicts stay in the contwin and are self-contained. The old view policy treated conflicts as transient (visible only while the latest word, elided after) -- overruled: a mistake remains visible so it is not made again. Self-contained means the conflict DESCRIBES ITS PROBLEM IN FULL, quoting the offending emission, because the block it answers strips from the view (STRIP_HERS takes her <model>/<mind>/<sheet>) -- an old conflict cannot lean on the turn it immediately follows, and the quote is the only visible trace of what went wrong. As built: renderView renders conflictOnly unconditionally (the lastGmIdx elision gone, the variable with it); a shared quote() helper (trim, collapse whitespace, cap at 160 -- enough to identify the mistake, never a wall) feeds the guards ("yours said: {...}" on <model> and <sheet>, "(you set: ...)" on the mind verb's per-key refusals, "-- yours: {the block}" on mind JSON that does not parse; the out-of-bounds mind already carried "(got 7)" and keeps its exact form); and the ripple caught: carry.mjs's visibleBytes counted conflicts as zero-cost on the grounds they "elide once the story moves on" -- carried conflicts now render in the new session, so they cost against the 96KB budget like the prose they are. The story keeps omitting conflicts (machinery, not deliverable) and invariants' one line still reads true, so no prompt-side change was needed. Verified: smoke ALL PASS with +3 assertions (both session-1 conflicts rendering in the view despite being old news, the model-guard quote, the sheet-guard quote), restart + reminder checks green, check-repo clean.
The GM's prompt-side edit rides the same commit: the reminder's decision passage gains the checked-action metrics -- three probes for when an action should be written as intent (external conditions: the lever; scope expansion: the mall; unilateral canonisation: the gasp at what is inside), each example attempt-form under the handbook's "the attempt, never the outcome", and the third deliberately bending that line with the price named in the same breath (the reaction is hers to have, the contents never hers to say, and the dud reveal embraced as a subversion vehicle -- purview taught as a negotiation, not a prohibition); the impulsive/irrational line now names the channel ("mention it in the narration"); the two tab-indented continuations normalized to the file's spaces.
Also: the smoke's final line now prints the draft id (a smoke draft survived cleanup because "run ids" never named it -- caught on the runs listing, deleted, the print is the fix). Docs: README's protocol passage carries the rewind and the conflict lifetime, with the records-off notes in the substrate section, the tiers table, and the layout; DECISIONS #15 gains the full amendment (the ruling record: a-g, expect, the ask refusal, records-off, the gm.md park); QUESTIONS' turn-surgery details closed (retry dropped, truncation ruled); ROADMAP's surgery sections built-and-amended, the operator queue line removed, the gm.md desync parked; DICTIONARY gains the rewind entry and amends the conflict and view entries. The box package and detention stay untracked WIP, untouched.
This commit is contained in:
+69
-10
@@ -10,13 +10,17 @@
|
||||
//
|
||||
// The append-only jsonl is the truth; the in-memory context is a view
|
||||
// rebuilt from it on boot. Entries are typed (bundle / msg / tool /
|
||||
// note / opening) so later features (turn surgery) can append their
|
||||
// own kinds without a format migration. The view renderer is pure
|
||||
// note / opening) so later features can append their own kinds without
|
||||
// a format migration. The one sanctioned break of append-only is the
|
||||
// rewind (2026-11-17): a rewind-send truncates the log to its target
|
||||
// and lands the new turn in one commit -- fork is the preservation
|
||||
// story, no fork no archaeology. The view renderer is pure
|
||||
// policy over the log: thinking never goes back, variant turns render
|
||||
// only the picked variant, old tool results elide to stubs
|
||||
// (the last few and every ask_gm answer stay), old GM-side
|
||||
// <status>/<conflict> blocks elide -- the current status rides the
|
||||
// newest GM turn.
|
||||
// <status>/<conflict> blocks elide from GM prose -- the current status
|
||||
// rides the newest GM turn -- and conflict messages never elide: a
|
||||
// mistake stays visible so it is not made again (GM, 2026-11-18).
|
||||
/** @typedef {import('./shapes.mjs').LogEvent} LogEvent */
|
||||
/** @typedef {import('./shapes.mjs').LiveSession} LiveSession */
|
||||
/** @typedef {import('./shapes.mjs').PendingAsk} PendingAsk */
|
||||
@@ -363,6 +367,56 @@ export function findStalledStop(runId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// --- rewind: the GM's take-back (GM, 2026-11-17) ------------------------------
|
||||
//
|
||||
// The in-place rollback of the live session, deliberately destructive:
|
||||
// the target GM turn and everything after it leave the log, and the
|
||||
// send that carries the rewind takes the target's place -- edit-and-
|
||||
// resend, the turn-surgery principle of DECISIONS #15. Where the old
|
||||
// proposal kept the discarded range as typed cut events, the ruling
|
||||
// here is physical truncation: fork is the preservation story (fork
|
||||
// before rewinding keeps the branch), and with no fork there is no
|
||||
// archaeology. Truncation is also why the feature is cheap -- every
|
||||
// reader of the log (the view, the state scan, the carry walk, the
|
||||
// story, housekeeping) sees the same shorter log with zero new
|
||||
// machinery; the rings never move mid-session, so nothing else needs
|
||||
// compensating. The floor is the start marker: the frozen opening
|
||||
// never unwinds. Called from the send path only, inside the run's
|
||||
// activity lock, after the new line expanded cleanly -- the commit is
|
||||
// one landing with the turn that replaces the cut.
|
||||
|
||||
/**
|
||||
* @param {LiveSession} s @param {number} idx the target GM turn's line index
|
||||
* @returns {number} the lines dropped
|
||||
*/
|
||||
export function rewindTo(s, idx) {
|
||||
if (!Number.isInteger(idx) || idx < 0 || idx >= s.lines.length) {
|
||||
throw err(400, `the rewind target ${JSON.stringify(idx)} is not a line of this session's log`);
|
||||
}
|
||||
const e = s.lines[idx];
|
||||
if (e.t !== 'msg' || e.m.role !== 'user' || e.conflictOnly) {
|
||||
throw err(400, 'the rewind target must be one of your turns (a GM turn)');
|
||||
}
|
||||
// the floor: the LAST start marker (a carried log may hold an older
|
||||
// one inside its opening -- only turns after the newest marker are
|
||||
// this session's live play)
|
||||
let floor = -1;
|
||||
for (const [i, x] of s.lines.entries()) {
|
||||
if (x.t === 'note' && x.kind === 'start') floor = i;
|
||||
}
|
||||
if (floor === -1) {
|
||||
throw err(409, 'this session predates the rewind build -- its opening boundary is unmarked, so nothing is rewindable');
|
||||
}
|
||||
if (idx <= floor) {
|
||||
throw err(400, 'the opening is frozen -- rewind reaches your turns after it only');
|
||||
}
|
||||
const dropped = s.lines.length - idx;
|
||||
s.lines = s.lines.slice(0, idx);
|
||||
writeLog(s.file, s.lines);
|
||||
derive(s); // mind and usage re-derive from the shorter log
|
||||
return dropped;
|
||||
}
|
||||
|
||||
// --- start: lint, freeze, consume, go live -------------------------------------
|
||||
|
||||
// the authored carryover's event vocabulary: her opening as msg
|
||||
@@ -577,6 +631,10 @@ export function startSession(runId, { override = false } = {}) {
|
||||
{ t: 'bundle', m: system, part: 'system' },
|
||||
...bundle.map((m, i) => /** @type {LogEvent} */ ({ t: 'bundle', m, part: partNames[i] })),
|
||||
...carry,
|
||||
// the rewind floor (GM, 2026-11-17): the opening -- authored or
|
||||
// carried -- is frozen; live play starts at this line, and a
|
||||
// rewind may only ever target GM turns below it
|
||||
{ t: 'note', kind: 'start' },
|
||||
];
|
||||
// the assembled context must be sound before anything lands:
|
||||
// tool pairing, variants resolution, every render invariant
|
||||
@@ -623,7 +681,6 @@ export function renderView(s, keepToolResults = 4) {
|
||||
const toolIdx = [];
|
||||
/** @type {number[]} */
|
||||
const reminderIdx = [];
|
||||
let lastGmIdx = -1;
|
||||
// the stamping pre-pass (the full-block protocol): the canon point
|
||||
// is her most recent prose turn -- the newest status and agenda
|
||||
// stamp at its tail, whatever their source (her emission, a GM
|
||||
@@ -635,7 +692,6 @@ export function renderView(s, keepToolResults = 4) {
|
||||
let lastProse = -1;
|
||||
s.lines.forEach((e, i) => {
|
||||
if (e.t === 'tool') toolIdx.push(i);
|
||||
if (e.t === 'msg' && e.m.role === 'user') lastGmIdx = i;
|
||||
if (e.t === 'msg' && e.reminder) reminderIdx.push(i);
|
||||
if (e.t === 'msg' && e.m.role === 'assistant') {
|
||||
const c = eff.has(i) ? eff.get(i) : e.m.content;
|
||||
@@ -691,10 +747,13 @@ export function renderView(s, keepToolResults = 4) {
|
||||
if (e.m.tool_calls?.length) m.tool_calls = e.m.tool_calls;
|
||||
msgs.push(m);
|
||||
} else if (e.conflictOnly) {
|
||||
// transient error traffic: visible while it is the latest word
|
||||
// (the model answers it), elided entirely once the story moves
|
||||
// on -- the log keeps it for provenance
|
||||
if (i === lastGmIdx) msgs.push({ role: e.m.role, content: String(e.m.content ?? '').trim() });
|
||||
// the self-heal channel stays in the contwin (GM, 2026-11-18):
|
||||
// a mistake remains visible so it is not made again. This is
|
||||
// why conflicts must be self-contained -- describe the problem
|
||||
// in full, quoting the offending emission, because the
|
||||
// emission itself strips from the view and an old conflict
|
||||
// cannot lean on the turn it answered
|
||||
msgs.push({ role: e.m.role, content: String(e.m.content ?? '').trim() });
|
||||
} else {
|
||||
// GM prose goes pure (the full-block protocol): the rides were
|
||||
// server-composited, never GM words -- strip from every GM
|
||||
|
||||
Reference in New Issue
Block a user