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: use 0-1 BFS for dramatic audience-connection depth (#13207)
Adam Eivy44d41e2d552c
diff --git a/server/lib/fableLoomGraph.js b/server/lib/fableLoomGraph.jsindex d128706a2e..fe99fc2123 100644--- a/server/lib/fableLoomGraph.js+++ b/server/lib/fableLoomGraph.js@@ -80,15 +80,20 @@ function computeDramaticDepths(episode, depthById) {const groupOf = (id) => byId.get(id)?.shot?.dramaticSceneId || id;const dramatic = new Map();if (!depthById.has(episode?.startNodeId)) return dramatic;+ // 0-1 BFS: same-scene hops cost 0 (front of deque), scene changes cost 1 (back);+ // relax on pop so each node holds its true minimum, not its first-discovered cost.dramatic.set(episode.startNodeId, 0);- const queue = [episode.startNodeId];- for (let i = 0; i < queue.length; i += 1) {- const id = queue[i];+ const deque = [episode.startNodeId];+ while (deque.length) {+ const id = deque.shift();+ const base = dramatic.get(id);for (const tr of asArray(byId.get(id)?.transitions)) {const target = tr?.targetNodeId;- if (byId.has(target) && !dramatic.has(target)) {- dramatic.set(target, dramatic.get(id) + (groupOf(id) === groupOf(target) ? 0 : 1));- queue.push(target);+ if (!byId.has(target)) continue;+ const cost = groupOf(id) === groupOf(target) ? 0 : 1;+ if (!dramatic.has(target) || base + cost < dramatic.get(target)) {+ dramatic.set(target, base + cost);+ if (cost === 0) deque.unshift(target); else deque.push(target);}}}diff --git a/server/lib/fableLoomGraph.test.js b/server/lib/fableLoomGraph.test.jsindex 09e03c121b..bdcf877239 100644--- a/server/lib/fableLoomGraph.test.js+++ b/server/lib/fableLoomGraph.test.js@@ -156,6 +156,26 @@ describe('analyzeEpisodeGraph', () => {}).issues.map((issue) => issue.code)).toContain(GRAPH_ISSUE_CODES.LATE_AUDIENCE_CONNECTION);});+ it('uses the shortest dramatic depth when a multi-scene detour is listed before a same-scene shortcut', () => {+ const mk = (id, scene, targets, extra = {}) => ({+ id, title: id, playbackMode: 'cut', audienceConnection: 'disconnected', isEnding: false,+ shot: { dramaticSceneId: scene },+ transitions: targets.map((t, i) => tr(`${id}-${i}`, t, `go ${t}`)),+ ...extra,+ });+ const nodes = [+ mk('n0', 'S', ['x1', 'y1']),+ mk('x1', 'X1', ['x2']), mk('x2', 'X2', ['x3']), mk('x3', 'X3', ['x4']), mk('x4', 'X4', ['c']),+ mk('y1', 'S', ['y2']), mk('y2', 'S', ['y3']), mk('y3', 'S', ['y4']), mk('y4', 'S', ['c']),+ mk('c', 'S', ['end'], { audienceConnection: 'connected', playbackMode: 'decision' }),+ mk('end', 'E', [], { isEnding: true }),+ ];+ const { issues } = analyzeEpisodeGraph({ startNodeId: 'n0', nodes }, {+ participationMode: 'helper', requireAudienceIntroduction: true,+ });+ expect(issues.map((issue) => issue.code)).not.toContain(GRAPH_ISSUE_CODES.LATE_AUDIENCE_CONNECTION);+ });+it('warns when a helper audience is not connected until after the opening sequence', () => {const nodes = Array.from({ length: 6 }, (_, index) => ({id: `n${index}`,