Skip to content

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

address review (codex): make render tools respect route-level persistence

[._.]/ Adam Eivy8ddb93813f3a
diff --git a/server/services/creative/toolRegistry.test.js b/server/services/creative/toolRegistry.test.js
index 34214c34da..840a06bca3 100644
--- a/server/services/creative/toolRegistry.test.js
+++ b/server/services/creative/toolRegistry.test.js
@@ -43,7 +43,11 @@ vi.mock('../domainUsage.js', () => ({
// Mock every wrapped entry point — keeps the real services (and their heavy
// import side effects) out, and makes each tool's execute an observable spy.
-vi.mock('../universeBuilder.js', () => ({ createUniverse: vi.fn(async () => ({ id: 'u1' })) }));
+vi.mock('../universeBuilder.js', () => ({
+ createUniverse: vi.fn(async () => ({ id: 'u1' })),
+ needsEntryIdPersist: vi.fn(async () => false),
+ updateUniverse: vi.fn(async () => ({})),
+}));
vi.mock('../universeBuilderExpand.js', () => ({ expandWorldTemplate: vi.fn(async () => ({ logline: 'x' })) }));
vi.mock('../universeBuilderRender.js', () => ({ renderUniverseJobs: vi.fn(async () => ({ jobs: [] })) }));
vi.mock('../storyBuilder.js', () => ({
@@ -56,7 +60,6 @@ vi.mock('../writersRoom/evaluator.js', () => ({ runAnalysis: vi.fn(async () => (
vi.mock('../pipeline/series.js', () => ({ createSeries: vi.fn(async () => ({ id: 'ser1' })) }));
vi.mock('../pipeline/seriesGenerate.js', () => ({ generateSeriesConcept: vi.fn(async () => ({ name: 'C' })) }));
vi.mock('../pipeline/textStages.js', () => ({ generateStage: vi.fn(async () => ({ stage: 'st' })) }));
-vi.mock('../pipeline/visualStages.js', () => ({ enqueueComicCover: vi.fn(async () => ({ jobId: 'j1' })) }));
vi.mock('../pipeline/seriesAutopilot.js', () => ({ startSeriesAutopilot: vi.fn(async () => ({ runId: 'ap1' })) }));
vi.mock('../mediaJobQueue/index.js', () => ({ enqueueJob: vi.fn(() => ({ jobId: 'mj1' })) }));
vi.mock('../catalogDB.js', () => ({ listIngredients: vi.fn(async () => ({ items: [] })) }));
diff --git a/server/services/creative/tools/pipeline.js b/server/services/creative/tools/pipeline.js
index 1bac882059..cbc0deca44 100644
--- a/server/services/creative/tools/pipeline.js
+++ b/server/services/creative/tools/pipeline.js
@@ -8,9 +8,17 @@ import { z } from 'zod';
import { createSeries } from '../../pipeline/series.js';
import { generateSeriesConcept } from '../../pipeline/seriesGenerate.js';
import { generateStage } from '../../pipeline/textStages.js';
-import { enqueueComicCover } from '../../pipeline/visualStages.js';
import { startSeriesAutopilot } from '../../pipeline/seriesAutopilot.js';
-import { COST_FREE, COST_LLM, COST_RENDER } from './shared.js';
+import { COST_FREE, COST_LLM } from './shared.js';
+
+// NOTE: a `pipeline_enqueueComicCover` tool is intentionally NOT registered yet.
+// The bare `enqueueComicCover()` service only queues the job — the cover's
+// filename hook attaches the completed render only if the issue's active cover
+// slot already carries the returned jobId, and that slot write lives in the
+// route factory (routes/pipeline/covers.js#makeCoverRenderHandler), not the
+// service. Wrapping the bare service would silently drop orchestrated covers;
+// wrapping it faithfully needs the route's enqueue+persist flow extracted into a
+// shared service first. Tracked as follow-up #2220.
export const PIPELINE_TOOLS = [
{
@@ -62,22 +70,6 @@ export const PIPELINE_TOOLS = [
},
execute: ({ issueId, stageId, options }) => generateStage(issueId, stageId, options || {}),
},
- {
- name: 'pipeline_enqueueComicCover',
- description: 'Enqueue a comic-cover image render for an issue. Long-running: returns a job handle; completion arrives via media-job events.',
- costClass: COST_RENDER,
- longRunning: true,
- schema: z.object({ issueId: z.string().min(1), options: z.record(z.any()).optional() }),
- parameters: {
- type: 'object',
- properties: {
- issueId: { type: 'string', description: 'Issue id to render a cover for.' },
- options: { type: 'object', description: 'Optional cover render options (variant, fromProof).' },
- },
- required: ['issueId'],
- },
- execute: ({ issueId, options }) => enqueueComicCover(issueId, options || {}),
- },
{
name: 'pipeline_startSeriesAutopilot',
description: 'Start (or no-op resume) the Series Autopilot for a series. Long-running: returns a run handle; progress and pauses arrive via events. Autopilot has its own cos-off gate; the orchestrator gate applies first.',
diff --git a/server/services/creative/tools/universe.js b/server/services/creative/tools/universe.js
index 5626869a1d..03eb1d4d55 100644
--- a/server/services/creative/tools/universe.js
+++ b/server/services/creative/tools/universe.js
@@ -4,7 +4,7 @@
*/
import { z } from 'zod';
-import { createUniverse } from '../../universeBuilder.js';
+import { createUniverse, needsEntryIdPersist, updateUniverse } from '../../universeBuilder.js';
import { expandWorldTemplate } from '../../universeBuilderExpand.js';
import { renderUniverseJobs } from '../../universeBuilderRender.js';
import { COST_FREE, COST_LLM, COST_RENDER } from './shared.js';
@@ -66,7 +66,18 @@ export const UNIVERSE_TOOLS = [
},
required: ['universeId'],
},
- // mapServiceError is an identity rethrow — the dispatcher owns error surfacing.
- execute: ({ universeId, body }) => renderUniverseJobs(universeId, body || {}, (err) => err),
+ // Mirror the render route's preflight (routes/universeBuilder.js): for a
+ // non-canon render of a legacy universe, persist the transient
+ // variation/sheet entry ids first (a no-op `updateUniverse` write) so they
+ // stay stable across enqueue → completion and the filename hook can attach
+ // rendered files back to the source rows. mapServiceError is an identity
+ // rethrow — the dispatcher owns error surfacing.
+ execute: async ({ universeId, body }) => {
+ const opts = body || {};
+ if (opts.promptMode !== 'canon' && await needsEntryIdPersist(universeId)) {
+ await updateUniverse(universeId, () => ({}));
+ }
+ return renderUniverseJobs(universeId, opts, (err) => err);
+ },
},
];