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

feat([issue-1513]): constrain idea-stage beats to the issue's synopsis scope

Adam Eivy09b2dc25029c
diff --git a/data.reference/prompts/stages/pipeline-idea-expansion.md b/data.reference/prompts/stages/pipeline-idea-expansion.md
index 914ee2eb46..1a79bd468f 100644
--- a/data.reference/prompts/stages/pipeline-idea-expansion.md
+++ b/data.reference/prompts/stages/pipeline-idea-expansion.md
@@ -98,7 +98,7 @@ Synopsis (no beats yet):
```
{{/synopsis}}
-Your opening beat must follow naturally from how this issue closed. Don't repeat its closing image; advance from it.
+This prior issue's events are already told — treat them as a boundary, not material to re-dramatize. Your opening beat must follow naturally from how it closed, but do NOT replay its beats or re-stage its climax. Don't repeat its closing image; advance from it.
{{/priorIssue}}
{{#nextIssue}}
@@ -121,7 +121,7 @@ Synopsis (no beats yet):
```
{{/synopsis}}
-Your closing beat / cliffhanger must hand cleanly into this next issue. The protagonist's state, location, and outstanding stakes at the end of your beat sheet should set up its opening without contradicting it.
+This next issue's events are OUT OF SCOPE for your beat sheet — it is a boundary, not material to continue into. Do NOT dramatize, climax on, or pull forward any event the next issue owns; its climax belongs to it, not to you. Your closing beat / cliffhanger must hand cleanly into this next issue — the protagonist's state, location, and outstanding stakes at the end of your beat sheet should set up its opening without contradicting it — but stop AT this issue's cliffhanger, not past it.
{{/nextIssue}}
## Rough seed from the user
@@ -130,6 +130,12 @@ Your closing beat / cliffhanger must hand cleanly into this next issue. The prot
{{seed}}
```
+**This seed defines THIS issue's scope.** Dramatize only the events it assigns to this issue. Any neighboring issues shown above are hard boundaries — do NOT cross into them. It is better to land at the LOW end of the beat range than to absorb a neighbor's events to fill space; end on this issue's own cliffhanger.
+
+{{#paddingRisk}}
+**Scope warning — terse seed, long issue.** This issue's seed is short relative to its {{lengthTargets.pageTarget}}-page target, which tempts the beat sheet to pad by annexing the next issue's events. Do NOT do that. A focused beat sheet at the low end of the {{lengthTargets.beatsMin}}–{{lengthTargets.beatsMax}} range that stays in scope is correct; overrunning into the next issue is not. Expand by deepening the events the seed already implies — texture, complication, character beats — never by pulling forward what a later issue owns.
+{{/paddingRisk}}
+
{{#hasSourceMaterials}}
## Existing source material to back-fill from
@@ -156,7 +162,7 @@ A markdown document with the following sections, in this exact order:
1. **`# Issue Title`** — one line, your refined title for this issue/episode (override the working title if the seed implies a better one).
2. **`## Logline`** — one sentence pitching the issue.
3. **`## Theme`** — one sentence on the emotional/thematic core. What is this issue *about* underneath the plot?
-4. **`## Beat sheet`** — **{{lengthTargets.beatsMin}}–{{lengthTargets.beatsMax}} beats** numbered as a markdown list. Each beat is one sentence describing a concrete dramatic event. Cover **hook (Saga-style opening — a single arresting image or moment, not exposition) → setup → rising action → midpoint reversal → second-half escalation → climax → cliffhanger / lead-in to the next issue.** This beat sheet feeds a {{lengthTargets.proseWordsMin}}–{{lengthTargets.proseWordsMax}} word prose draft, which feeds a {{lengthTargets.pageTarget}}-page comic script — too few beats and the downstream stages have nothing to pace against. The final beat MUST be a cliffhanger, reveal, or strong lead-in to the next issue, not a tidy resolution.
+4. **`## Beat sheet`** — **{{lengthTargets.beatsMin}}–{{lengthTargets.beatsMax}} beats** numbered as a markdown list. Each beat is one sentence describing a concrete dramatic event. Cover **hook (Saga-style opening — a single arresting image or moment, not exposition) → setup → rising action → midpoint reversal → second-half escalation → climax → cliffhanger / lead-in to the next issue.** This beat sheet feeds a {{lengthTargets.proseWordsMin}}–{{lengthTargets.proseWordsMax}} word prose draft, which feeds a {{lengthTargets.pageTarget}}-page comic script — too few beats and the downstream stages have nothing to pace against. Every beat must stay within THIS issue's scope (the seed above); do not dramatize events the neighboring issues own. The final beat MUST be a cliffhanger, reveal, or strong lead-in to the next issue, not a tidy resolution — and it must be THIS issue's cliffhanger, not the next issue's climax.
5. **`## Setting`** — 2–3 sentences naming the locations this issue uses and how they look. Reference the world's visual style.
6. **`## New characters (if any)`** — for any character the seed introduces that isn't in the series bible, give a one-line `**Name** — physical + role description`. Skip the section if there are none.
7. **`## Open questions` (OPTIONAL — usually omit)** — ONLY include this section when something fundamentally cannot be decided without user input (e.g. the seed asks the writer to choose between two specific named entities, or references off-canvas information only the user knows). Do NOT use this section for choices you could make yourself by leaning on the series bible. If every beat is committed, omit the section entirely.
diff --git a/scripts/migrations/003-update-pipeline-stage-prompts.js b/scripts/migrations/003-update-pipeline-stage-prompts.js
index 746a7a593e..b02cc53dd5 100644
--- a/scripts/migrations/003-update-pipeline-stage-prompts.js
+++ b/scripts/migrations/003-update-pipeline-stage-prompts.js
@@ -49,7 +49,7 @@ export const ACCEPTED_OLD_MD5 = {
};
export const NEW_SHIPPED_MD5 = {
- 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997', // post-098 (ticking clock + {{.}} fixes)
+ 'pipeline-idea-expansion.md': 'c5b2e719e232a281b3829a5348cb29c1', // post-122 (scope-discipline + {{#paddingRisk}})
'pipeline-prose.md': '84523d531eeafa60959c65c553b2563f', // post-054-fence
'pipeline-comic-script.md': 'e9ee70bf18888492edada6633cd9928a', // post-063
'pipeline-tv-script.md': '376f779f4687b598f1c92ca4e770fd5a', // retired upstream (no data.reference)
diff --git a/scripts/migrations/004-augment-idea-expansion-context.js b/scripts/migrations/004-augment-idea-expansion-context.js
index 0d93fc387d..1822452551 100644
--- a/scripts/migrations/004-augment-idea-expansion-context.js
+++ b/scripts/migrations/004-augment-idea-expansion-context.js
@@ -22,7 +22,7 @@ export const ACCEPTED_OLD_MD5 = {
};
export const NEW_SHIPPED_MD5 = {
- 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997', // post-098 (ticking clock + {{.}} fixes)
+ 'pipeline-idea-expansion.md': 'c5b2e719e232a281b3829a5348cb29c1', // post-122 (scope-discipline + {{#paddingRisk}})
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/025-idea-stage-character-detail.js b/scripts/migrations/025-idea-stage-character-detail.js
index cb8d725ae0..bccb0df48c 100644
--- a/scripts/migrations/025-idea-stage-character-detail.js
+++ b/scripts/migrations/025-idea-stage-character-detail.js
@@ -37,7 +37,7 @@ export const ACCEPTED_OLD_MD5 = {
// New shipped hash — what data.reference carries post-migration.
export const NEW_SHIPPED_MD5 = {
- 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997', // post-098 (ticking clock + {{.}} fixes)
+ 'pipeline-idea-expansion.md': 'c5b2e719e232a281b3829a5348cb29c1', // post-122 (scope-discipline + {{#paddingRisk}})
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/054-source-agnostic-stage-prompts.js b/scripts/migrations/054-source-agnostic-stage-prompts.js
index 89175b03c2..a7cda31867 100644
--- a/scripts/migrations/054-source-agnostic-stage-prompts.js
+++ b/scripts/migrations/054-source-agnostic-stage-prompts.js
@@ -33,7 +33,7 @@ export const ACCEPTED_OLD_MD5 = {
// Post-change shipped hashes (the source-agnostic + tilde-fence templates this
// migration installs). Mirror these into setup-data.js's drift table.
export const NEW_SHIPPED_MD5 = {
- 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997', // post-098 (ticking clock + {{.}} fixes)
+ 'pipeline-idea-expansion.md': 'c5b2e719e232a281b3829a5348cb29c1', // post-122 (scope-discipline + {{#paddingRisk}})
'pipeline-prose.md': '84523d531eeafa60959c65c553b2563f',
'pipeline-comic-script.md': 'e9ee70bf18888492edada6633cd9928a',
'pipeline-teleplay.md': 'afa4215330bf856429d70d7e2f856605',
diff --git a/scripts/migrations/098-idea-stage-ticking-clock.js b/scripts/migrations/098-idea-stage-ticking-clock.js
index e24d0f830c..7dfb376634 100644
--- a/scripts/migrations/098-idea-stage-ticking-clock.js
+++ b/scripts/migrations/098-idea-stage-ticking-clock.js
@@ -37,11 +37,11 @@ export const ACCEPTED_OLD_MD5 = {
'pipeline-idea-expansion.md': ['49a208628290543ba2607a5ed48fdc8c'],
};
-// Post-change shipped hash (ticking-clock section + `{{.}}` → named-ref fixes).
-// Mirror this into every earlier migration that tracks the same file
-// (003/004/025/054) so their drift-catch tests stay green.
+// Post-change shipped hash. Bumped to the current shipped body whenever a later
+// migration edits this file, so the drift-catch test (NEW == live sample) stays
+// green. Latest: post-122 (scope-discipline + {{#paddingRisk}}).
export const NEW_SHIPPED_MD5 = {
- 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997',
+ 'pipeline-idea-expansion.md': 'c5b2e719e232a281b3829a5348cb29c1',
};
const { applyMigration, up } = makePromptReplaceMigration({
diff --git a/scripts/migrations/122-idea-stage-scope-discipline.js b/scripts/migrations/122-idea-stage-scope-discipline.js
new file mode 100644
index 0000000000..55be2f1b4f
--- /dev/null
+++ b/scripts/migrations/122-idea-stage-scope-discipline.js
@@ -0,0 +1,62 @@
+/**
+ * Constrain the idea / beat-sheet stage to THIS issue's synopsis scope so
+ * adjacent issues stop dramatizing the same arc beat (issue #1513).
+ *
+ * Two kinds of change ship in `pipeline-idea-expansion.md`:
+ *
+ * 1. Scope-boundary language. The prior/next-issue neighbor blocks and the
+ * beat-sheet instructions now frame neighboring issues as hard boundaries
+ * ("OUT OF SCOPE", "do NOT cross into them", "stop AT this issue's
+ * cliffhanger, not past it") rather than as material to continue into —
+ * directly targeting the observed failure where issue N's beats ran
+ * through issue N+1's climax.
+ *
+ * 2. A new `{{#paddingRisk}}` section (NEW template variable, which per
+ * CLAUDE.md requires this migration). It renders only when the issue's
+ * synopsis is terse relative to its length profile — the padding pressure
+ * that makes a long-profile issue absorb the next issue's events to hit
+ * the page target. `assessSynopsisScope` in `server/lib/issueLength.js`
+ * computes the flag; `buildIdeaContextAugment` feeds it into the prompt.
+ *
+ * `scripts/setup-data.js` only copies *missing* prompts, so existing installs
+ * keep their old template until this migration rewrites it. Customization-safe:
+ * only installs whose copy still hashes to the known pre-change shipped version
+ * are auto-updated; customized prompts are left intact and warned about.
+ *
+ * Strategy: hash-driven prompt-replace via `./_lib.js`. Idempotent.
+ */
+
+import { makePromptReplaceMigration } from './_lib.js';
+
+// Pre-change shipped hash: the post-098 (ticking-clock) idea-expansion body.
+export const ACCEPTED_OLD_MD5 = {
+ 'pipeline-idea-expansion.md': ['c50f016639d41cd8244f5ff13429f997'],
+};
+
+// Post-change shipped hash (scope-boundary language + {{#paddingRisk}} section).
+// Mirror this into every earlier migration that tracks the same file
+// (003/004/025/054/098) so their drift-catch tests stay green.
+export const NEW_SHIPPED_MD5 = {
+ 'pipeline-idea-expansion.md': 'c5b2e719e232a281b3829a5348cb29c1',
+};
+
+const { applyMigration, up } = makePromptReplaceMigration({
+ accepted: ACCEPTED_OLD_MD5,
+ current: NEW_SHIPPED_MD5,
+ label: 'idea-stage scope-discipline prompt',
+ customizedHint: (filename) =>
+ ` To constrain beats to the issue's scope manually, diff:\n` +
+ ` data.reference/prompts/stages/${filename}\n` +
+ ` against your current:\n` +
+ ` data/prompts/stages/${filename}\n` +
+ ` and add the scope-boundary language plus the {{#paddingRisk}} section.`,
+ skipFooter: (count) =>
+ `⚠️ ${count} prompt(s) could not be auto-updated because they were\n` +
+ ` customized. The idea stage still works, but its beats may run past\n` +
+ ` the issue's synopsis scope (and adjacent issues can duplicate the\n` +
+ ` same beat) until you merge the change. See\n` +
+ ` data.reference/prompts/stages/pipeline-idea-expansion.md.`,
+});
+
+export { applyMigration };
+export default { up };
diff --git a/scripts/migrations/122-idea-stage-scope-discipline.test.js b/scripts/migrations/122-idea-stage-scope-discipline.test.js
new file mode 100644
index 0000000000..2fca90691d
--- /dev/null
+++ b/scripts/migrations/122-idea-stage-scope-discipline.test.js
@@ -0,0 +1,14 @@
+import { describe } from 'vitest';
+
+import { runPromptMigrationTests } from './_testHelpers.js';
+import migration, { applyMigration, ACCEPTED_OLD_MD5, NEW_SHIPPED_MD5 } from './122-idea-stage-scope-discipline.js';
+
+describe('migration 122 — idea-stage scope-discipline prompt', () => {
+ runPromptMigrationTests({
+ migration,
+ applyMigration,
+ ACCEPTED_OLD_MD5,
+ NEW_SHIPPED_MD5,
+ prefix: 'migration-122-',
+ });
+});
diff --git a/scripts/setup-data-drift.test.js b/scripts/setup-data-drift.test.js
index 75c5a53534..b91066c1cb 100644
--- a/scripts/setup-data-drift.test.js
+++ b/scripts/setup-data-drift.test.js
@@ -24,7 +24,7 @@ const migrationsDir = join(dirname(fileURLToPath(import.meta.url)), 'migrations'
// sample-existence filter drops downstream — so its presence here documents
// that the sweep itself is expected to carry it.
const EXPECTED_STAGE_OLD = {
- 'pipeline-idea-expansion.md': ['1ee44cf95851ff8debf18729ebcd40b4', '1f3c5d077a5ef9a4b610335d5e3edd9c', '41facefbc0c0549d456bef9111f95ab9', '49a208628290543ba2607a5ed48fdc8c', 'aee25112b2c596f643b17c559b772c22', 'b5c47c94ffc74637983c95761ab0c66c'],
+ 'pipeline-idea-expansion.md': ['1ee44cf95851ff8debf18729ebcd40b4', '1f3c5d077a5ef9a4b610335d5e3edd9c', '41facefbc0c0549d456bef9111f95ab9', '49a208628290543ba2607a5ed48fdc8c', 'aee25112b2c596f643b17c559b772c22', 'b5c47c94ffc74637983c95761ab0c66c', 'c50f016639d41cd8244f5ff13429f997'],
'pipeline-prose.md': ['30ac30ec2b9d3e2a9eb869c181732cc6', 'bef1bc2767b78f585f2bd89f3d615130', 'bfea5aeeb471aae9749baee765b473a7', 'd1f8e3f1d214725b5aa67f309a81cd7d'],
'pipeline-comic-script.md': ['133d200d069c2e8173b7c129eea58f53', '1e0af305c27d0c80c4b482d2ebcb4a0d', '40e5fdc1a1e68a7419b7dad936366c1a', 'beab031951859ca13579cdb9c4dbe769', 'dea7d497d1cb38e7574f236f4ff8e644', 'e530fc76b89cedaef848ad7ec99c934c'],
'pipeline-teleplay.md': ['1280ef6b1ad68fa44070ca7478ec2a5f', '2568e14beaa574d43f8018a5def51d04', '376f779f4687b598f1c92ca4e770fd5a', '3f6fecc25573ed054b47db392250034a'],
@@ -44,7 +44,7 @@ const EXPECTED_STAGE_OLD = {
'pipeline-tv-script.md': ['3f6fecc25573ed054b47db392250034a'],
};
const EXPECTED_STAGE_NEW = {
- 'pipeline-idea-expansion.md': 'c50f016639d41cd8244f5ff13429f997',
+ 'pipeline-idea-expansion.md': 'c5b2e719e232a281b3829a5348cb29c1',
'pipeline-prose.md': '84523d531eeafa60959c65c553b2563f',
'pipeline-comic-script.md': 'e9ee70bf18888492edada6633cd9928a',
'pipeline-teleplay.md': 'afa4215330bf856429d70d7e2f856605',
diff --git a/server/lib/issueLength.js b/server/lib/issueLength.js
index 5fd1172e11..5358cc7ec8 100644
--- a/server/lib/issueLength.js
+++ b/server/lib/issueLength.js
@@ -138,3 +138,37 @@ export function computeIssueTargets(issue = {}) {
const preset = LENGTH_PROFILES[profile];
return { profile, ...preset };
}
+
+// Words a 'standard' (22-page) issue's synopsis should carry before its beat
+// sheet stops being padding-prone. Scaled by pageTarget/standard so a longer
+// profile expects proportionally more seed material. Calibrated against real
+// runs where a one-line synopsis ("the invitation arrives", ~4 words) on a
+// 44-page finale produced scope overrun into the next issue's climax.
+export const THIN_SYNOPSIS_BASE_WORDS = 25;
+
+const countWords = (text) =>
+ (typeof text === 'string' ? text.trim() : '')
+ ? text.trim().split(/\s+/).length
+ : 0;
+
+/**
+ * Assess whether an issue's synopsis (the idea-stage seed) is too thin for its
+ * length profile to expand without padding — the pressure that makes the beat
+ * stage absorb adjacent issues' events to hit the page target (issue #1513).
+ *
+ * Only LONG profiles (more pages than 'standard') trip the flag: terse
+ * one-line synopses are normal and fine at standard length, but on a finale
+ * they leave the model nothing to fill the page count with except the next
+ * issue's climax. `synopsisWords === 0` (no seed yet) never flags — an empty
+ * synopsis is a different problem, handled upstream.
+ *
+ * Returns a fully-populated object so callers can log/branch unconditionally.
+ */
+export function assessSynopsisScope(synopsis, targets = {}) {
+ const synopsisWords = countWords(synopsis);
+ const pageTarget = Number(targets.pageTarget) || STANDARD_PAGES;
+ const longProfile = pageTarget > STANDARD_PAGES;
+ const expectedWords = Math.round(THIN_SYNOPSIS_BASE_WORDS * (pageTarget / STANDARD_PAGES));
+ const paddingRisk = longProfile && synopsisWords > 0 && synopsisWords < expectedWords;
+ return { synopsisWords, expectedWords, longProfile, paddingRisk };
+}
diff --git a/server/lib/issueLength.test.js b/server/lib/issueLength.test.js
index 577167e973..3b31d06347 100644
--- a/server/lib/issueLength.test.js
+++ b/server/lib/issueLength.test.js
@@ -6,6 +6,8 @@ import {
CUSTOM_PAGE_MIN, CUSTOM_PAGE_MAX,
CUSTOM_MINUTE_MIN, CUSTOM_MINUTE_MAX,
computeIssueTargets,
+ assessSynopsisScope,
+ THIN_SYNOPSIS_BASE_WORDS,
} from './issueLength.js';
describe('computeIssueTargets — preset profiles', () => {
@@ -112,6 +114,56 @@ describe('computeIssueTargets — custom profile', () => {
});
});
+describe('assessSynopsisScope — padding-risk signal (#1513)', () => {
+ const finale = computeIssueTargets({ lengthProfile: 'finale' }); // 44pp
+ const standard = computeIssueTargets({ lengthProfile: 'standard' }); // 22pp
+ const extended = computeIssueTargets({ lengthProfile: 'extended' }); // 32pp
+
+ it('flags a terse synopsis on a long (finale) profile', () => {
+ const result = assessSynopsisScope('the Helioheart invitation arrives', finale);
+ expect(result.paddingRisk).toBe(true);
+ expect(result.longProfile).toBe(true);
+ expect(result.synopsisWords).toBe(4);
+ // expectedWords scales with pages: 25 * 44/22 = 50
+ expect(result.expectedWords).toBe(THIN_SYNOPSIS_BASE_WORDS * 2);
+ });
+
+ it('does NOT flag a terse synopsis on a standard profile (terse is normal there)', () => {
+ const result = assessSynopsisScope('the gala', standard);
+ expect(result.longProfile).toBe(false);
+ expect(result.paddingRisk).toBe(false);
+ });
+
+ it('does NOT flag a rich synopsis even on a long profile', () => {
+ // A solid paragraph that clears the scaled expected-words floor.
+ const rich = Array.from({ length: 60 }, (_, i) => `word${i}`).join(' ');
+ const result = assessSynopsisScope(rich, finale);
+ expect(result.synopsisWords).toBe(60);
+ expect(result.paddingRisk).toBe(false);
+ });
+
+ it('flags a moderately-thin synopsis on an extended profile', () => {
+ // extended = 32pp → expected 25 * 32/22 ≈ 36 words; 10 words is thin.
+ const result = assessSynopsisScope('a short ten word synopsis that does not say very much', extended);
+ expect(result.longProfile).toBe(true);
+ expect(result.paddingRisk).toBe(true);
+ });
+
+ it('never flags an empty synopsis (a different problem)', () => {
+ expect(assessSynopsisScope('', finale).paddingRisk).toBe(false);
+ expect(assessSynopsisScope(' ', finale).paddingRisk).toBe(false);
+ expect(assessSynopsisScope(null, finale).paddingRisk).toBe(false);
+ expect(assessSynopsisScope(undefined, finale).synopsisWords).toBe(0);
+ });
+
+ it('tolerates a missing/partial targets object via the standard fallback', () => {
+ const result = assessSynopsisScope('the invitation arrives', {});
+ // No pageTarget → defaults to standard pages → not a long profile.
+ expect(result.longProfile).toBe(false);
+ expect(result.paddingRisk).toBe(false);
+ });
+});
+
describe('LENGTH_PROFILE_NAMES contract', () => {
it('always includes the default profile and the custom sentinel', () => {
expect(LENGTH_PROFILE_NAMES).toContain(DEFAULT_LENGTH_PROFILE);
diff --git a/server/services/pipeline/textStages.js b/server/services/pipeline/textStages.js
index ec95bedee1..003196ed6d 100644
--- a/server/services/pipeline/textStages.js
+++ b/server/services/pipeline/textStages.js
@@ -21,7 +21,7 @@ import { getIssue, listIssues, updateStage, assertStageUnlocked, TEXT_STAGE_IDS
import { getSeriesCanon } from './seriesCanon.js';
import { getUniverse } from '../universeBuilder.js';
import { compareIssuesByPosition, NO_LINKED_UNIVERSE_PLACEHOLDER } from './arcPlanner.js';
-import { computeIssueTargets } from '../../lib/issueLength.js';
+import { computeIssueTargets, assessSynopsisScope } from '../../lib/issueLength.js';
import { renderEntitiesSummary } from '../../lib/universePromptRenderers.js';
import { composeStyleNotes } from '../../lib/styleGuide.js';
import { renderTickingClock } from '../../lib/storyArc.js';
@@ -102,10 +102,19 @@ async function buildIdeaContextAugment(series, issue) {
// `tickingClock.enabled === true`.
const tickingClock = renderTickingClock(arc?.tickingClock);
+ // 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.
+ const { paddingRisk } = assessSynopsisScope(
+ issue.stages?.idea?.input || '',
+ computeIssueTargets(issue),
+ );
+
if (!season) {
return {
arc: arcBlock,
tickingClock,
+ paddingRisk,
volume: null,
arcRole: issue.arcRole || null,
positionInVolume: null,
@@ -150,6 +159,7 @@ async function buildIdeaContextAugment(series, issue) {
return {
arc: arcBlock,
tickingClock,
+ paddingRisk,
volume: {
number: season.number,
title: season.title || '',
@@ -295,6 +305,9 @@ export async function generateStage(issueId, stageId, options = {}) {
});
if (stageId === 'idea') {
Object.assign(ctx, await buildIdeaContextAugment(series, issue));
+ if (ctx.paddingRisk) {
+ console.log(`⚠️ Pipeline idea — issue=${issueId.slice(0, 8)} terse synopsis vs ${ctx.lengthTargets?.profile} profile: scope-discipline guard engaged`);
+ }
}
// Catch only at this boundary so the stage record persists the failure
diff --git a/server/services/pipeline/textStages.test.js b/server/services/pipeline/textStages.test.js
index 1d22dbf29f..940c7affab 100644
--- a/server/services/pipeline/textStages.test.js
+++ b/server/services/pipeline/textStages.test.js
@@ -322,6 +322,30 @@ describe('pipeline text stage generator', () => {
expect(ctx.nextIssue).toMatchObject({ title: 'Midpoint', arcRole: 'midpoint', arcPosition: 3 });
});
+ it('idea context: paddingRisk flagged for a terse synopsis on a long (finale) profile', async () => {
+ const { series } = await seed();
+ const issue = await issuesSvc.createIssue({
+ seriesId: series.id,
+ title: 'The Invitation',
+ lengthProfile: 'finale',
+ stages: { idea: { input: 'the Helioheart invitation arrives', status: 'draft' } },
+ });
+ await textStages.generateStage(issue.id, 'idea');
+ expect(ctxFromCall(llmCalls[0]).paddingRisk).toBe(true);
+ });
+
+ it('idea context: paddingRisk NOT flagged for a terse synopsis on a standard profile', async () => {
+ const { series } = await seed();
+ const issue = await issuesSvc.createIssue({
+ seriesId: series.id,
+ title: 'The Gala',
+ lengthProfile: 'standard',
+ stages: { idea: { input: 'the gala', status: 'draft' } },
+ });
+ await textStages.generateStage(issue.id, 'idea');
+ expect(ctxFromCall(llmCalls[0]).paddingRisk).toBe(false);
+ });
+
it('idea context: neighbor exposes beats when expanded, synopsis when not', async () => {
const { series } = await seed();
await seriesSvc.updateSeries(series.id, { arc: { logline: 'L' } });
@@ -544,6 +568,23 @@ describe('pipeline-idea-expansion template render', () => {
expect(out).toContain('NEXT-SYNOPSIS-LINE'); // next neighbor's synopsis
});
+ it('renders the {{#paddingRisk}} scope warning only when the flag is set (#1513)', () => {
+ const withRisk = applyTemplate(ideaTemplate, renderCtx({ paddingRisk: true }));
+ expect(withRisk).toContain('Scope warning');
+ expect(withRisk).toContain('Do NOT do that');
+
+ const withoutRisk = applyTemplate(ideaTemplate, renderCtx({ paddingRisk: false }));
+ expect(withoutRisk).not.toContain('Scope warning');
+ });
+
+ it('frames neighboring issues as hard scope boundaries (#1513)', () => {
+ const out = applyTemplate(ideaTemplate, renderCtx());
+ // Next-issue block: its events are out of scope, not material to continue into.
+ expect(out).toContain('OUT OF SCOPE');
+ // The always-on seed scope note.
+ expect(out).toContain("This seed defines THIS issue's scope.");
+ });
+
it('renders the ticking-clock section when enabled and omits it otherwise', () => {
const clock = renderTickingClock({ enabled: true, label: 'TICK-LABEL', kind: 'deadline', stakes: 'TICK-STAKES' });
const withClock = applyTemplate(ideaTemplate, renderCtx({ tickingClock: clock }));