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): include unsaved seedInput in idea-stage character scoping

Adam Eivy3c0eebe9c6c2
diff --git a/server/services/pipeline/textStages.js b/server/services/pipeline/textStages.js
index 14afa913ae..ba75cc7166 100644
--- a/server/services/pipeline/textStages.js
+++ b/server/services/pipeline/textStages.js
@@ -222,13 +222,16 @@ export function scopeCharactersForIssue(allCharacters, scopeText) {
}
/**
- * Concatenate the text that defines an issue's scope — its title, synopsis
+ * Concatenate the text that defines an issue's scope — its title, the unsaved
+ * `seedInput` driving this run (the idea stage generates beats straight from it,
+ * so a character named only in the seed must still be matched), synopsis
* (`idea.input`), beat sheet (`idea.output`), and whatever source stages this
* generation adapts from — into one haystack for the character matcher.
*/
-function buildIssueScopeText(issue, sourceMaterials) {
+function buildIssueScopeText(issue, sourceMaterials, seedInput) {
return [
issue.title,
+ seedInput,
issue.stages?.idea?.input,
issue.stages?.idea?.output,
...sourceMaterials.map((s) => s.content),
@@ -280,7 +283,7 @@ function buildStageContext({ series, canon, world, issue, stageId, seedInput, so
// roster above keeps the whole cast known for naming/continuity.
const scopedCharacters = scopeCharactersForIssue(
canon?.characters || [],
- buildIssueScopeText(issue, sourceMaterials),
+ buildIssueScopeText(issue, sourceMaterials, seedInput),
);
return {
series: {
diff --git a/server/services/pipeline/textStages.test.js b/server/services/pipeline/textStages.test.js
index b5fac3ccbb..d910f30938 100644
--- a/server/services/pipeline/textStages.test.js
+++ b/server/services/pipeline/textStages.test.js
@@ -590,16 +590,36 @@ describe('pipeline text stage generator', () => {
expect(textStages.__testing.scopeCharactersForIssue([], 'x')).toEqual([]);
});
- it('buildIssueScopeText concatenates title, synopsis, beats, and source materials', () => {
+ it('buildIssueScopeText concatenates title, seed, synopsis, beats, and source materials', () => {
const issue = { title: 'The Hush', stages: { idea: { input: 'SYN', output: 'BEATS' } } };
const sourceMaterials = [{ content: 'SRC-A' }, { content: 'SRC-B' }];
- const text = textStages.__testing.buildIssueScopeText(issue, sourceMaterials);
+ const text = textStages.__testing.buildIssueScopeText(issue, sourceMaterials, 'SEED-TEXT');
expect(text).toContain('The Hush');
+ expect(text).toContain('SEED-TEXT');
expect(text).toContain('SYN');
expect(text).toContain('BEATS');
expect(text).toContain('SRC-A');
expect(text).toContain('SRC-B');
});
+
+ it('scopes idea-stage characters from the UNSAVED seed text, not just saved fields', async () => {
+ const { series } = await seed();
+ const world = await universeSvc.createUniverse({ name: 'Seed Verse' });
+ // Lead exists so the principal fallback is non-empty — proving the match comes
+ // from the seed text, not the fallback. The issue carries no saved idea text.
+ await universeSvc.updateUniverse(world.id, {
+ characters: [
+ { name: 'Lead', role: 'protagonist' },
+ { name: 'Mira', role: 'surveyor' },
+ ],
+ });
+ 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.
+ 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)).toEqual(['Mira']);
+ });
});
// End-to-end render guard for the shipped idea template. The tests above assert