variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
This commit is contained in:
+10
-9
@@ -1,11 +1,11 @@
|
||||
// server/fork.mjs — fork: a run copied whole, the owner replaced.
|
||||
// server/fork.mjs -- fork: a run copied whole, the owner replaced.
|
||||
//
|
||||
// Runs are entirely independent: no lineage is recorded, and the only
|
||||
// mark a fork bears is `forked: unixtime` in run.json (its `created`
|
||||
// carries over unchanged — the story's start date is a fact of the
|
||||
// carries over unchanged -- the story's start date is a fact of the
|
||||
// contents). No inconsistent state on disk at any point: the copy
|
||||
// lands staged under a dot-name and is swapped in by a same-volume
|
||||
// rename, which is atomic — no reader ever sees a half-run. The
|
||||
// rename, which is atomic -- no reader ever sees a half-run. The
|
||||
// caller holds the source run's activity lock, so the copy is never
|
||||
// taken mid-turn; a copied open session reopens honestly in the fork
|
||||
// (the log is the truth, same as boot-rebuild).
|
||||
@@ -14,7 +14,7 @@ import path from 'node:path';
|
||||
import { randomBytes } from 'node:crypto';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { requireRun } from './bundle.mjs';
|
||||
import { latestSession, lastHousekept, loadSession } from './session.mjs';
|
||||
import { liveSession, loadSession } from './session.mjs';
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const RUNS_DIR = path.join(ROOT, 'runs');
|
||||
@@ -34,10 +34,11 @@ export function forkRun(ctx, srcId, user) {
|
||||
meta.forked = Math.floor(Date.now() / 1000); // unixtime, UTC by definition
|
||||
fs.writeFileSync(metaPath, JSON.stringify(meta, null, 2) + '\n');
|
||||
fs.renameSync(staging, path.join(RUNS_DIR, id)); // same-volume rename: the atomic swap-in
|
||||
// an open, unhousekept session in the source is an open session in the
|
||||
// fork — its transcript reaches the fork's rings only after the fork
|
||||
// housekeeps it, same rule as the original
|
||||
const latest = latestSession(id);
|
||||
if (latest && latest !== lastHousekept(id)) ctx.sessions.set(id, loadSession(id, latest));
|
||||
// a live session in the source is a live session in the fork -- the
|
||||
// log is the truth, same as boot-rebuild; a dormant run forks
|
||||
// dormant (the review window copies honestly, unhousekept guard
|
||||
// included)
|
||||
const live = liveSession(id);
|
||||
if (live != null) ctx.sessions.set(id, loadSession(id, live));
|
||||
return { run: id };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user