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: keep whole-plan shot consistency review compact (#13204)
[._.]/ Adam Eivyf32cbb65e1f3
diff --git a/docs/features/fableloom.md b/docs/features/fableloom.mdindex 23fdafba4a..1c6690dfca 100644--- a/docs/features/fableloom.md+++ b/docs/features/fableloom.md@@ -426,6 +426,6 @@ The shot planner starts a background run with `POST /api/fableloom/:id/episodes/`GET .../shots/status` reattaches to its latest state; `POST .../shots/cancel` stops after the active provider call.The UI receives `fableloom:shots:run` snapshots and reloads status on reconnect. The legacy `POST .../shots/plan` waits for the same durable worker and returns the completed plan for existing callers; its HTTP connection does not own that worker. Both start paths accept explicit resume.-Draft and review run on one source scene at a time with the episode's compact graph digest. A final text consistency review receives the complete shot plan and graph, without the complete teleplay. Existing stage and provider timeout settings stay in effect; large inputs show a reminder to check the effective timeout. Stage failures name the stage, round, scene and provider.+Draft and review run on one source scene at a time with the episode's compact graph digest. A final text consistency review receives every shot action/dialogue, the graph, and scene-boundary compositions; full render prompts were already reviewed per scene, and the complete teleplay is not resent. Existing stage and provider timeout settings stay in effect; large inputs show a reminder to check the effective timeout. Stage failures name the stage, round, scene and provider.Each draft and review is saved before the next call. After a restart the run is reported failed with those steps preserved; no AI work starts at boot. Resume sends `{ "resume": true }` to the start endpoint, retaining the original route, direction and apply choice, and reuses completed steps. Changed episodes require a fresh plan. New previews explicitly start a fresh run. Applying still requires a complete, validated, reviewed plan matching the episode revision; cancellation prevents application after an in-flight call.diff --git a/server/routes/hostControlFableLoom.test.js b/server/routes/hostControlFableLoom.test.jsindex 9f71b5ea0e..2d414f940f 100644--- a/server/routes/hostControlFableLoom.test.js+++ b/server/routes/hostControlFableLoom.test.js@@ -210,7 +210,7 @@ describe('FableLoom agent workflow authority (#10668)', () => {['patch', node, { prose: 'Example prose' }, fableLoom.updateNode],['post', `${episode}/outline/validate`, {}, fableLoom.validateEpisodeOutline],['post', `${episode}/shots/cancel`, {}, shotRuns.cancelEpisodeShotRun],- ['get', `${episode}/shots/status`, {}, shotRuns.getEpisodeShotRun],+ ['get', `${episode}/shots/status`, undefined, shotRuns.getEpisodeShotRun],['post', `${episode}/production/plan`, {}, fableLoom.planEpisodeProduction],['post', `${episode}/continuity/review`, {}, fableLoom.reviewEpisodeContinuity],['post', `${episode}/production/batch/example-run/cancel`, {}, fableLoom.cancelEpisodeProductionBatch],diff --git a/server/services/fableLoom/shots.js b/server/services/fableLoom/shots.jsindex 4334d972ab..10c6a7846d 100644--- a/server/services/fableLoom/shots.js+++ b/server/services/fableLoom/shots.js@@ -179,10 +179,16 @@ export async function runEpisodeShotAutopilot(id, episodeId, {if (compiled.validation.issues.length) throw new ServerError(compiled.validation.issues.map((i) => i.message).join('\n'), { status: 422, code: 'SHOT_PLAN_INVALID' });// One whole-plan review, without the episode teleplay. It checks connections// between the scene plans already reviewed against their full dramatic source.+ const consistencyPlan = compiled.groups.map(({ sceneId, shots }) => ({+ sceneId,+ shots: shots.map(({ title, action, dialogue, durationSeconds, protagonistPresence, visibleCharacterIds }) => ({ title, action, dialogue, durationSeconds, protagonistPresence, visibleCharacterIds })),+ entryComposition: { framing: shots[0].framing, imagePrompt: shots[0].imagePrompt },+ ...(shots.length > 1 ? { exitComposition: { framing: shots.at(-1).framing, imagePrompt: shots.at(-1).imagePrompt } } : {}),+ }));const planHash = createHash('sha256').update(JSON.stringify(compiled.groups)).digest('hex');let review = checkpoint.consistency.findLast((entry) => entry.planHash === planHash)?.review;if (!review) {- const result = await execute('fableloom-review-shots', { source: JSON.stringify({ ...context, scope: 'Whole-plan consistency check. Each group already passed review against its full dramatic source; check the combined plan and graph without requesting the teleplay.', scenes: context.sceneDigest }), shots: JSON.stringify(compiled.groups) }, checkpoint.consistency.length + 1, null);+ const result = await execute('fableloom-review-shots', { source: JSON.stringify({ ...context, scope: 'Whole-plan narrative and boundary-continuity check. Each full shot group already passed source, filmability and within-group visual review. Check the combined actions/dialogue and graph, with entry/exit compositions at group boundaries (a single-shot group exits in its entry composition). Do not request the teleplay or intermediate render prompts.', scenes: context.sceneDigest }), shots: JSON.stringify(consistencyPlan) }, checkpoint.consistency.length + 1, null);review = result.content;checkpoint.consistency.push({ planHash, review });await persist();diff --git a/server/services/fableLoom/shots.test.js b/server/services/fableLoom/shots.test.jsindex c82c5a62da..36f7c77b19 100644--- a/server/services/fableLoom/shots.test.js+++ b/server/services/fableLoom/shots.test.js@@ -130,7 +130,7 @@ describe('shot checkpoints and bounded inputs', () => {for (let i = 0; i < 20; i += 1) loom = await addNode(loom.id, ep, { title: `Scene ${i}`, playbackMode: 'cut', prose: `UNIQUE_${i}_` + 'A courier waits. '.repeat(65), isEnding: i === 19 });const nodes = loom.episodes[0].nodes;for (let i = 0; i < 19; i += 1) loom = await updateNode(loom.id, ep, nodes[i].id, { transitions: [{ targetNodeId: nodes[i + 1].id, intent: 'continue' }] });- const groups = nodes.map(node => ({ sceneId: node.id, shots: [shot(node.title)] }));+ const groups = nodes.map(node => ({ sceneId: node.id, shots: Array.from({ length: 6 }, (_, index) => ({ ...shot(`${node.title} cut ${index}`), imagePrompt: 'The gate and lamp retain their established screen positions. '.repeat(20), videoPrompt: 'The courier waits in this same composition. '.repeat(25) })) }));mockPlan(groups);await expect(runEpisodeShotAutopilot(loom.id, ep)).resolves.toMatchObject({ validation: { stats: { ready: true } } });expect(runStagedLLM).toHaveBeenCalledTimes(41);@@ -142,6 +142,10 @@ describe('shot checkpoints and bounded inputs', () => {expect(variables.source.length).toBeLessThan(9000);}expect(calls.at(-1)[1].source).not.toContain('UNIQUE_');+ const consistency = JSON.parse(calls.at(-1)[1].shots);+ expect(consistency[0].entryComposition.imagePrompt).toBe(groups[0].shots[0].imagePrompt);+ expect(consistency[0].shots[0]).not.toHaveProperty('imagePrompt');+ expect(calls.at(-1)[1].shots.length).toBeLessThan(JSON.stringify(groups).length / 2);});it('reports a durable interrupted run without calling a provider, then resumes explicitly', async () => {const { startEpisodeShotRun, getEpisodeShotRun } = await import('./shotRuns.js');