Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([issue-730]): address review — lock re-baselines only its own step
[._.]/ Adam Eivy10bfddcc5fae
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 2a72360309..4e86abefb5 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -45,7 +45,7 @@## Changed-- **[issue-730] Story Builder sessions can opt into cross-machine resume** — a Story Builder session is private to one machine by default, but you can now turn on cross-machine resume per session. When it's on, the "needs another look" warnings on locked steps follow a snapshot the session carries with it, so a change another of your machines makes to the same universe no longer makes every locked step look stale the moment the session travels over. A reconcile action lets you re-baseline against the current world whenever you want.+- **[issue-730] Groundwork for cross-machine Story Builder sessions** — Story Builder sessions stay private to one machine, but the staleness model that powers the "needs another look" warnings on locked steps is now sync-safe: when a session opts into cross-machine resume, those warnings follow a snapshot the session carries with it instead of re-checking the live world, so a change another of your machines makes to the same universe won't make every locked step look stale once the session can travel between machines. Internal foundation — the cross-machine sync itself lands in a follow-up.- **[issue-738] Cross-Domain Insights Engine design** — design groundwork for narrative insights connecting genome, health, taste, and creative output, including a dismissable/acceptable insight model and a structured facts table feeding the LLM.- **[issue-727] Abandoned imports no longer leave empty universes lying around** — starting an import and walking away before you commit it used to leave a blank universe and series behind in your library. Those scratch records are now hidden from sync and automatically cleaned up after a week if you never finish the import, while committing one keeps it for good.- **Codex TUI runs fully bypassed** — Codex now launches in TUI mode with `--dangerously-bypass-approvals-and-sandbox` (the same full-yolo posture the headless CLI path already used), instead of only `--ask-for-approval never`. The previous flag suppressed approval prompts but kept Codex's sandbox on, so tool calls that needed real file or network writes still got blocked. Provider configs that pin their own `--ask-for-approval` / `--sandbox` policy are left untouched.diff --git a/server/services/storyBuilder.js b/server/services/storyBuilder.jsindex eba202eb08..05f96f6111 100644--- a/server/services/storyBuilder.js+++ b/server/services/storyBuilder.js@@ -454,14 +454,19 @@ async function writeSyncState(id, enabled, hashes) {}/**- * Re-snapshot a session's `syncedHashes` baseline to the CURRENT live records,- * and turn sync on if it wasn't already. This is the explicit "adopt this- * machine's universe/series state as the new staleness baseline" gesture — the- * only thing that moves the carried baseline on a synced session. Returns the- * saved session.+ * Re-snapshot a sync-enabled session's `syncedHashes` baseline to the CURRENT+ * live records. This is the explicit "adopt this machine's universe/series+ * state as the new staleness baseline" gesture — the only thing that moves the+ * carried baseline across steps on a synced session. Rejects a local-only+ * session: reconcile is a re-baseline gesture, NOT a sync-enable one (use+ * `setStorySessionSync` to turn sync on), so calling it on a session with+ * sync off is a no-op-with-surprising-side-effect we'd rather surface loudly.*/export async function reconcileStorySession(id) {const session = await getStorySession(id);+ if (session.sync !== true) {+ throw makeErr('Cross-machine resume is off for this session — enable it before reconciling', ERR_VALIDATION);+ }const { hashes } = await computeCurrentHashes(session);return writeSyncState(id, true, hashes);}@@ -530,13 +535,19 @@ export async function lockStep(id, stepId) {upstreamHash: hashes[stepId],};// A sync-enabled session keys staleness off its carried baseline, not live- // records — so locking must also move the baseline to live (#730). Otherwise- // the just-locked step would compare its fresh `upstreamHash` against a- // stale `syncedHashes` entry and report itself stale on the next read.+ // records — so locking must also move the baseline to live for THIS step+ // (#730). Otherwise the just-locked step would compare its fresh+ // `upstreamHash` against a stale `syncedHashes` entry and report itself+ // stale on the next read. Re-baseline ONLY `stepId`: merging the whole live+ // `hashes` map would move every OTHER locked step's baseline to the current+ // (possibly peer-edited) records, re-introducing the exact false-positive+ // #730 exists to prevent. Cross-step re-baselining is the reconcile gesture.const next = sanitizeSession({...cur,steps,- ...(cur.sync === true ? { syncedHashes: { ...(cur.syncedHashes || {}), ...hashes } } : {}),+ ...(cur.sync === true+ ? { syncedHashes: { ...(cur.syncedHashes || {}), [stepId]: hashes[stepId] } }+ : {}),updatedAt: nowIso(),});await store().saveOneNow(next.id, next);diff --git a/server/services/storyBuilder.test.js b/server/services/storyBuilder.test.jsindex 169d8f5f5f..4b2a5b86f2 100644--- a/server/services/storyBuilder.test.js+++ b/server/services/storyBuilder.test.js@@ -398,6 +398,36 @@ describe('storyBuilder — sync-safe staleness (#730)', () => {expect(view.staleSteps).toContain('plotArc');});+ it('locking a step does NOT re-baseline OTHER already-locked steps', async () => {+ // Regression: locking step C must re-baseline only C, not move every locked+ // step's baseline to the current (possibly peer-edited) records — otherwise+ // a peer edit suppressed for an earlier-locked step would resurface as stale+ // the moment any unrelated step is locked, the exact #730 false-positive.+ const s = await sb.createStorySession({ title: 'X' });+ await sb.setStorySessionSync(s.id, true);+ await seriesSvc.updateSeries(s.seriesId, { arc: { logline: 'spine', summary: 'sum' } });+ await universeSvc.updateUniverse(s.universeId, {+ logline: 'a world of salt', premise: 'the foundry goes silent',+ });+ await sb.lockStep(s.id, 'plotArc'); // baseline[plotArc] = live now+ // Peer edits the arc out-of-band — suppressed for the synced session.+ await seriesSvc.updateSeries(s.seriesId, { arc: { logline: 'PEER spine', summary: 'sum' }, locked: {} });+ let view = await sb.getStorySessionView(s.id);+ expect(view.staleSteps).not.toContain('plotArc');+ // Lock an UNRELATED step. The buggy whole-map merge would move+ // baseline[plotArc] to the peer-edited arc → plotArc would flag stale.+ await sb.lockStep(s.id, 'universeAesthetic');+ view = await sb.getStorySessionView(s.id);+ expect(view.staleSteps).not.toContain('plotArc');+ expect(view.staleSteps).not.toContain('universeAesthetic');+ });++ it('reconcile rejects a local-only session (it is a re-baseline, not an enable)', async () => {+ const s = await sb.createStorySession({ title: 'X' });+ expect(s.sync).toBe(false);+ await expect(sb.reconcileStorySession(s.id)).rejects.toMatchObject({ code: sb.ERR_VALIDATION });+ });+it('sanitizer drops bogus / unknown-step entries from a hand-edited syncedHashes', async () => {const cleaned = sb.sanitizeSession({id: 'stb-x', title: 'X', sync: true,