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): don't scope the idea stage (no roster in its template; needs full cast)

Adam Eivy8956c21fbf0e
diff --git a/server/services/pipeline/textStages.js b/server/services/pipeline/textStages.js
index 195f8e003c..1147928acd 100644
--- a/server/services/pipeline/textStages.js
+++ b/server/services/pipeline/textStages.js
@@ -34,6 +34,15 @@ const STAGE_TO_TEMPLATE = Object.freeze({
teleplay: 'pipeline-teleplay',
});
+// Stages whose template renders the compact `worldEntitiesSummary` roster and can
+// therefore safely receive a SCOPED `series.characters` block (#1511) — the roster
+// is the continuity safety net for the un-scoped cast. The idea stage is excluded:
+// it generates the beat sheet straight from the seed (it needs the whole cast as a
+// creative palette) and its template renders NO roster, so a scoped block there
+// would drop characters with no fallback. New stages default to the full cast
+// until explicitly added here.
+const ROSTER_BACKED_STAGES = new Set(['prose', 'comicScript', 'teleplay']);
+
// Human labels for the {{#sourceMaterials}} block so the LLM sees "Comic Script"
// rather than "comicScript". Mirrors the client's PIPELINE_STAGE_LABELS.
const STAGE_LABELS = Object.freeze({
@@ -315,13 +324,13 @@ function buildStageContext({ series, canon, world, issue, stageId, seedInput, so
? (renderEntitiesSummary(world, { maxPerKind: { characters: Infinity } }) || '(none)')
: NO_LINKED_UNIVERSE_PLACEHOLDER;
// Scope the heavyweight full-record character block to the cast this issue
- // actually involves (#1511) — full records only for characters named in the
- // issue's source text, principals as fallback, never empty. The compact
- // roster above keeps the whole cast known for naming/continuity.
- const scopedCharacters = scopeCharactersForIssue(
- canon?.characters || [],
- buildIssueScopeText(issue, sourceMaterials, seedInput),
- );
+ // actually involves (#1511) — full records for the principals plus characters
+ // named in the issue's source text; the compact roster above keeps the rest of
+ // the cast known for naming/continuity. Only the roster-backed stages are scoped
+ // (see ROSTER_BACKED_STAGES); the idea stage keeps the full cast.
+ const scopedCharacters = ROSTER_BACKED_STAGES.has(stageId)
+ ? scopeCharactersForIssue(canon?.characters || [], buildIssueScopeText(issue, sourceMaterials, seedInput))
+ : (canon?.characters || []);
return {
series: {
name: series.name,
diff --git a/server/services/pipeline/textStages.test.js b/server/services/pipeline/textStages.test.js
index e0696898c8..c3267ded14 100644
--- a/server/services/pipeline/textStages.test.js
+++ b/server/services/pipeline/textStages.test.js
@@ -638,12 +638,9 @@ describe('pipeline text stage generator', () => {
expect(text).toContain('SRC-B');
});
- it('scopes idea-stage characters from the UNSAVED seed text, not just saved fields', async () => {
+ it('does NOT scope the idea stage — it gets the full cast (no roster in that template)', async () => {
const { series } = await seed();
const world = await universeSvc.createUniverse({ name: 'Seed Verse' });
- // Both are non-principal (no lead/recurring role) so the principals floor is
- // empty — the only character in scope must come from the seed text match. The
- // issue carries no saved idea text.
await universeSvc.updateUniverse(world.id, {
characters: [
{ name: 'Bram', role: 'clerk' },
@@ -652,10 +649,31 @@ describe('pipeline text stage generator', () => {
});
await seriesSvc.updateSeries(series.id, { universeId: world.id });
const issue = await issuesSvc.createIssue({ seriesId: series.id, title: 'Fresh' });
- // Generate the idea straight from an unsaved seed that names only Mira.
+ // Even though the seed names only Mira, the idea stage must keep the WHOLE cast
+ // available (it generates from the seed and its template renders no roster).
await textStages.generateStage(issue.id, 'idea', { seedInput: 'A quiet hour with Mira at the foundry.' });
const ctx = ctxFromCall(llmCalls[0]);
+ expect(ctx.series.characters.map((c) => c.name).sort()).toEqual(['Bram', 'Mira']);
+ });
+
+ it('scopes a roster-backed stage (prose) from the UNSAVED seed text', async () => {
+ const { series } = await seed();
+ const world = await universeSvc.createUniverse({ name: 'Seed Verse' });
+ // Both non-principal (no floor) so the only in-scope character must come from
+ // the seed text match.
+ await universeSvc.updateUniverse(world.id, {
+ characters: [
+ { name: 'Bram', role: 'clerk' },
+ { name: 'Mira', role: 'surveyor' },
+ ],
+ });
+ await seriesSvc.updateSeries(series.id, { universeId: world.id });
+ const issue = await issuesSvc.createIssue({ seriesId: series.id, title: 'Fresh' });
+ await textStages.generateStage(issue.id, 'prose', { seedInput: 'A quiet hour with Mira at the foundry.' });
+ const ctx = ctxFromCall(llmCalls[0]);
expect(ctx.series.characters.map((c) => c.name)).toEqual(['Mira']);
+ // The un-scoped Bram still appears in the prose template's roster.
+ expect(ctx.worldEntitiesSummary).toContain('Bram');
});
});