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): assess paddingRisk against seedInput override; pin template interpolation

Adam Eivyc60e956cf5fb
diff --git a/server/services/pipeline/textStages.js b/server/services/pipeline/textStages.js
index 37e2447863..76800abecc 100644
--- a/server/services/pipeline/textStages.js
+++ b/server/services/pipeline/textStages.js
@@ -77,7 +77,7 @@ function shapeNeighborForIdeaPrompt(iss) {
// + parent volume + immediate-neighbor issues. Other text stages (prose,
// comicScript, teleplay) don't need it — they derive from beats which
// already encode it.
-async function buildIdeaContextAugment(series, issue) {
+async function buildIdeaContextAugment(series, issue, seedOverride = '') {
const seasons = Array.isArray(series.seasons) ? series.seasons : [];
const season = issue.seasonId ? seasons.find((s) => s.id === issue.seasonId) : null;
@@ -104,9 +104,12 @@ async function buildIdeaContextAugment(series, issue) {
// Scope-discipline signal: a terse synopsis on a long length profile tempts
// the beat sheet to pad by absorbing the next issue's events (#1513). The
- // template gates a "do not pad past scope" warning on this flag.
+ // template gates a "do not pad past scope" warning on this flag. Assess the
+ // seed actually being expanded — an explicit seedInput override is what the
+ // template renders into {{seed}}, so the signal must track it, not the
+ // (possibly stale) stored synopsis.
const { paddingRisk } = assessSynopsisScope(
- issue.stages?.idea?.input || '',
+ seedOverride || issue.stages?.idea?.input || '',
computeIssueTargets(issue),
);
@@ -312,7 +315,7 @@ export async function generateStage(issueId, stageId, options = {}) {
sourceStageIds: options.sourceStageIds,
});
if (stageId === 'idea') {
- Object.assign(ctx, await buildIdeaContextAugment(series, issue));
+ Object.assign(ctx, await buildIdeaContextAugment(series, issue, options.seedInput));
if (ctx.paddingRisk) {
console.log(`⚠️ Pipeline idea — issue=${issueId.slice(0, 8)} terse synopsis vs ${ctx.lengthTargets?.profile} profile: scope-discipline guard engaged`);
}
diff --git a/server/services/pipeline/textStages.test.js b/server/services/pipeline/textStages.test.js
index c098ec03cc..1b28bd61a0 100644
--- a/server/services/pipeline/textStages.test.js
+++ b/server/services/pipeline/textStages.test.js
@@ -349,6 +349,22 @@ describe('pipeline text stage generator', () => {
expect(ctxFromCall(llmCalls[0]).paddingRisk).toBe(false);
});
+ it('idea context: paddingRisk tracks the seedInput override, not the stored synopsis', async () => {
+ const { series } = await seed();
+ // Stored synopsis is rich enough to clear the finale floor → not padding-prone.
+ const richStored = Array.from({ length: 60 }, (_, i) => `word${i}`).join(' ');
+ const issue = await issuesSvc.createIssue({
+ seriesId: series.id,
+ title: 'The Invitation',
+ lengthProfile: 'finale',
+ stages: { idea: { input: richStored, status: 'draft' } },
+ });
+ // Regenerating with a terse override seed must flag padding risk, because the
+ // override — not the stored synopsis — is what gets expanded.
+ await textStages.generateStage(issue.id, 'idea', { seedInput: 'the invitation arrives' });
+ expect(ctxFromCall(llmCalls[0]).paddingRisk).toBe(true);
+ });
+
it('idea context: neighbor exposes beats when expanded, synopsis when not', async () => {
const { series } = await seed();
await seriesSvc.updateSeries(series.id, { arc: { logline: 'L' } });
@@ -575,6 +591,10 @@ describe('pipeline-idea-expansion template render', () => {
const withRisk = applyTemplate(ideaTemplate, renderCtx({ paddingRisk: true }));
expect(withRisk).toContain('Scope warning');
expect(withRisk).toContain('Do NOT do that');
+ // Pin the dotted interpolation INSIDE the section — a regression to {{.}} or a
+ // broken lengthTargets ref would still render the static text above.
+ expect(withRisk).toContain('22-page target'); // {{lengthTargets.pageTarget}}
+ expect(withRisk).toContain('8–12 range'); // {{lengthTargets.beatsMin}}–{{lengthTargets.beatsMax}}
const withoutRisk = applyTemplate(ideaTemplate, renderCtx({ paddingRisk: false }));
expect(withoutRisk).not.toContain('Scope warning');