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 (claude): idea backfill guard, sourceStageIds route test, story-builder prompt drift entry

[._.]/ Adam Eivyd3ca1fcb5ffe
diff --git a/scripts/setup-data.js b/scripts/setup-data.js
index 09ceab8c62..bbab268ad8 100644
--- a/scripts/setup-data.js
+++ b/scripts/setup-data.js
@@ -179,6 +179,10 @@ const SHIPPED_PROMPT_OLD_MD5 = {
// universe-character-expand: pre-027 shipped, auto-updatable to the post-027
// (`speechPattern` field added alongside `speechAccent`) hash.
'universe-character-expand.md': ['ef109eb8e12ddb664c11c790271b5139'],
+ // story-builder-idea-expand: pre-055 (seed-only) and post-055-pre-fence
+ // ({{sourceMaterial}} block, no guard) auto-updatable to the post-055-fence
+ // ({{sourceMaterial}} block + injection-guard sentence) hash.
+ 'story-builder-idea-expand.md': ['a23939626a226f7420cebfb45d47950c', '778c86e2caa120856c36e4d5a4da3355'],
// editorial-analysis: pre-042 (pipe-separated arcDirection enum + ≤160
// excerpt) auto-updatable to the post-042 (single-value example, ≤200) hash.
'pipeline-editorial-analysis.md': ['14d9879697c66d51830cc798040d5369'],
@@ -208,6 +212,7 @@ const SHIPPED_PROMPT_NEW_MD5 = {
'writers-room-places.md': 'a7f68e51dd6b4421d20f5bd9d855d9b4',
'cos-agent-briefing.md': 'dccb392a43cbd3dac900fee12c31619a',
'universe-character-expand.md':'67b6e73ed47f318451a730088b4cff14',
+ 'story-builder-idea-expand.md':'c12d76fefaaded2838023065bfc94bb0',
'pipeline-editorial-analysis.md':'daeb02bd54b0c099b21af659c6298cfe',
};
const SHIPPED_PROMPT_FILES = Object.keys(SHIPPED_PROMPT_OLD_MD5);
diff --git a/server/routes/pipeline.test.js b/server/routes/pipeline.test.js
index ebddfd707d..cc475b7af4 100644
--- a/server/routes/pipeline.test.js
+++ b/server/routes/pipeline.test.js
@@ -533,6 +533,16 @@ describe('pipeline routes', () => {
expect(r.body.stage.output).toContain('mock-output:idea');
});
+ it('POST /issues/:id/stages/:stageId/generate accepts sourceStageIds and rejects unknown stage ids', async () => {
+ const app = makeApp();
+ const ser = await request(app).post('/api/pipeline/series').send({ name: 'S', universeId: 'u-test' });
+ const iss = await request(app).post(`/api/pipeline/series/${ser.body.id}/issues`).send({ title: 'I' });
+ const ok = await request(app).post(`/api/pipeline/issues/${iss.body.id}/stages/prose/generate`).send({ sourceStageIds: ['comicScript'] });
+ expect(ok.status).toBe(200);
+ const bad = await request(app).post(`/api/pipeline/issues/${iss.body.id}/stages/prose/generate`).send({ sourceStageIds: ['bogus'] });
+ expect(bad.status).toBe(400);
+ });
+
it('POST /issues/:id/stages/:stageId/generate rejects visual stages', async () => {
const app = makeApp();
const ser = await request(app).post('/api/pipeline/series').send({ name: 'S', universeId: 'u-test' });
diff --git a/server/services/storyBuilder.js b/server/services/storyBuilder.js
index 23b586caf9..80560ffe9b 100644
--- a/server/services/storyBuilder.js
+++ b/server/services/storyBuilder.js
@@ -470,6 +470,12 @@ export async function generateStep(id, stepId, options = {}) {
// user started downstream. Rendered only when present, so the forward path
// (seed-only) is byte-for-byte unchanged.
const sourceMaterial = options.fromDownstream ? await collectIssueSourceText(session.seriesId) : '';
+ if (options.fromDownstream && !sourceMaterial) {
+ throw makeErr(
+ 'No issue content to backfill the idea from — write a comic script, teleplay, or prose on at least one issue first',
+ ERR_VALIDATION,
+ );
+ }
const { content, runId, providerId, model } = await runStagedLLM(
'story-builder-idea-expand',
{ universeName: session.title, seedIdea: session.seedIdea || '', sourceMaterial },
diff --git a/server/services/storyBuilder.test.js b/server/services/storyBuilder.test.js
index 6306ac1be4..2d6f4ca155 100644
--- a/server/services/storyBuilder.test.js
+++ b/server/services/storyBuilder.test.js
@@ -320,4 +320,11 @@ describe('generateStep backfill (fromDownstream)', () => {
expect(seenStage).toBe('story-builder-idea-expand');
expect(seenVars.sourceMaterial).toBe('');
});
+
+ it('idea backfill refuses when no issue has content', async () => {
+ installSpy();
+ const s = await sb.createStorySession({ title: 'Empty' });
+ await expect(sb.generateStep(s.id, 'idea', { fromDownstream: true }))
+ .rejects.toThrow(/No issue content/);
+ });
});