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

fix: read the prose STAGE, not comicScript-precedence manuscript, for comic.prose-sync (#1589)

Adam Eivy8e40d4976fcc
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 36703693e6..60a0120db4 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -65,7 +65,7 @@
- **[issue-1588] A new opt-in editorial check catches contradictions to real-world facts — Paris placed in Germany, an anachronistic technology, a physiologically impossible feat.** Distinct from the internal timeline/canon check (#1581), nothing reconciled grounded fiction against *external* truth, so a checkable howler in a historical or hard-SF series — a city in the wrong country, an event dated before the war it belongs to, a survivable injury that isn't — could ship and quietly torch the story's credibility. The new **Research / fact accuracy** check (`research.fact-accuracy`) scans the stitched manuscript against an **author-supplied fact reference** and flags geography, history/chronology, and science/physiology claims that contradict it. It is deliberately **opt-in and gated**: it runs only when a series is marked **fact-critical** *and* a non-empty fact reference is supplied, so it never second-guesses deliberate invention in pure fantasy. A new **Fact accuracy** section in the series bible (Pipeline → series) carries the toggle + reference textarea; the reference is a fingerprinted editorial source (`series.factReference`), so editing it re-runs the check, and findings surface in the existing editorial-review UI and Series Autopilot under a new **Fact accuracy** category. Both new series fields (`factCritical`, `factReference`) are wire-gated (pipelineSeries schema v7) so an older federated peer can't strip-then-LWW the loss. (`server/lib/editorial/checkRegistry.js`, `server/services/pipeline/series.js`, `client/src/pages/PipelineSeries.jsx`, `data.reference/prompts/stages/pipeline-editorial-fact-accuracy.md`, `scripts/migrations/135-editorial-fact-accuracy-stage.js`)
-- **[issue-1589] A new editorial check catches comic↔prose drift in hybrid issues — a plot beat the prose narrates that no panel shows, panel dialogue that contradicts the prose, or events ordered differently across the two media.** The existing `comic.*` checks validate comic content *in isolation* (lettering load, balloon attribution, panel rhythm), but for an issue told as **both prose and comic** nothing checked that the two media tell the *same* story — so a character the prose stabs could stand unharmed in the panels, a line could be put in a different character's mouth on the page, or the comic could reorder events the prose places in a fixed sequence, all unflagged. The new **Comic ↔ prose synchronization** check (`comic.prose-sync`) pairs each hybrid issue's prose narration with its authoritative comic pages (each panel's visual description, dialogue, captions, and SFX) and flags three substantive divergences: an **unshown beat** (a consequential event the prose narrates that no panel depicts), **contradicted dialogue** (a line said with materially different meaning or attributed to a different speaker), and a **chronology disagreement** (the two media ordering the same events incompatibly). It is deliberately tuned to *ignore* ordinary medium translation — comics legitimately compress, cut, reorder for page rhythm, and externalize interior narration into image — so a faithful adaptation that simply differs in density isn't flagged. It runs one model call per issue that has both prose and comic content (capped per run), reads the per-issue manuscript prose plus the `comicScript.pacing` comic content, and anchors every finding to its issue; its findings go stale and re-run when either the prose or the comic for that issue drifts. It's a default-on, issue-scope check that surfaces in the existing editorial-review UI and Series Autopilot like every other check, marking a flat contradiction or a dropped consequential beat medium-severity. (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-comic-prose-sync.md`, `scripts/migrations/135-editorial-comic-prose-sync-stage.js`)
+- **[issue-1589] A new editorial check catches comic↔prose drift in hybrid issues — a plot beat the prose narrates that no panel shows, panel dialogue that contradicts the prose, or events ordered differently across the two media.** The existing `comic.*` checks validate comic content *in isolation* (lettering load, balloon attribution, panel rhythm), but for an issue told as **both prose and comic** nothing checked that the two media tell the *same* story — so a character the prose stabs could stand unharmed in the panels, a line could be put in a different character's mouth on the page, or the comic could reorder events the prose places in a fixed sequence, all unflagged. The new **Comic ↔ prose synchronization** check (`comic.prose-sync`) pairs each hybrid issue's prose narration with its authoritative comic pages (each panel's visual description, dialogue, captions, and SFX) and flags three substantive divergences: an **unshown beat** (a consequential event the prose narrates that no panel depicts), **contradicted dialogue** (a line said with materially different meaning or attributed to a different speaker), and a **chronology disagreement** (the two media ordering the same events incompatibly). It is deliberately tuned to *ignore* ordinary medium translation — comics legitimately compress, cut, reorder for page rhythm, and externalize interior narration into image — so a faithful adaptation that simply differs in density isn't flagged. It runs one model call per issue that has both prose and comic content (capped per run), reading each issue's **`prose`-stage** text (specifically, not the stitched manuscript — which prefers the comic script for a hybrid issue) plus the `comicScript.pacing` comic content, and anchors every finding to its issue; its findings go stale and re-run when either the prose or the comic for that issue drifts. It's a default-on, issue-scope check that surfaces in the existing editorial-review UI and Series Autopilot like every other check, marking a flat contradiction or a dropped consequential beat medium-severity. (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-comic-prose-sync.md`, `scripts/migrations/135-editorial-comic-prose-sync-stage.js`)
## Series Autopilot
diff --git a/server/lib/editorial/README.md b/server/lib/editorial/README.md
index d8786a721f..a9250ac91c 100644
--- a/server/lib/editorial/README.md
+++ b/server/lib/editorial/README.md
@@ -86,7 +86,8 @@ Declare every input the check's `run(ctx)` reads in its `sources` array (a
non-empty subset of `EDITORIAL_SOURCES`: `manuscript`, `canon`,
`series.styleGuide`, `series.arc.tickingClock`, `series.arc.readerMap`,
`series.arc.themes`, `reverseOutline`, `reverseOutline.plotlines`,
-`editorialArcs`, `series.characterArcs`, `storyboard.shots`, `comicScript`).
+`editorialArcs`, `series.characterArcs`, `storyboard.shots`, `comicScript`,
+`prose`).
The `series.arc.themes` token (#1317) fingerprints the AUTHORED arc themes the
`theme.coherence` check reconciles the prose against (lives on the already-loaded
series record, no extra I/O — adding/editing a declared theme stales its findings).
@@ -122,11 +123,14 @@ reads the same content (via the shared `comicLetteringIssues`) to count
balloon/panel/page word load, so a finding stales exactly when the comic text the
check read changes — not when an unrelated image renders. The LLM check
`comic.prose-sync` (#1589) is the CROSS-MEDIA sibling: for a hybrid comic+prose
-issue it pairs that issue's prose (a `manuscript` section, via `needsManuscript`)
-with its comic content (`comicScript.pacing`) and flags substantive divergences —
-an unshown beat, contradicted dialogue, or a chronology disagreement — making one
-model call per hybrid issue and fingerprinting both the prose and the comic so a
-finding stales when either drifts. When a new check reads a
+issue it pairs that issue's **`prose`-stage** text with its comic content
+(`comicScript.pacing`) and flags substantive divergences — an unshown beat,
+contradicted dialogue, or a chronology disagreement — making one model call per
+hybrid issue and fingerprinting both the prose and the comic so a finding stales
+when either drifts. It declares the `prose` source (not `manuscript`) on purpose:
+the stitched manuscript picks `comicScript` over `prose` for a hybrid issue, so a
+`manuscript` source would compare the comic against itself; both halves are read off
+the already-loaded `ctx.issues` (the `prose` stage via `proseStageIssues`). When a new check reads a
`ctx.series` field (or another artifact) that isn't yet a token, add the token to
`EDITORIAL_SOURCES` and a matching resolver in the runner's `SOURCE_RESOLVERS`.
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.js
index 4eec0a0004..ff320323c5 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -159,6 +159,12 @@ export const EDITORIAL_SOURCES = Object.freeze([
'comicScript',
'comicScript.pacing',
'comicScript.layout',
+ // Each issue's PROSE-stage text SPECIFICALLY (#1589) — NOT the default manuscript
+ // precedence (comicScript ▸ teleplay ▸ prose), which for a hybrid issue returns
+ // the comic script. The comic↔prose-sync check reads this to compare prose against
+ // the comic; fingerprinting it separately means a prose edit stales a sync finding
+ // without a comic-only edit doing so (and vice-versa, via comicScript.pacing).
+ 'prose',
]);
// Default per-run finding cap for user-defined checks (#1346) — mirrors the
@@ -1994,17 +2000,29 @@ function balloonAttributionFinding(v, number) {
// ≈ 6k tokens, which fits alongside the comic block on every supported provider.
export const PROSE_SYNC_PROSE_CHAR_CAP = 24_000;
-// Per-issue prose keyed by issue number, from the collected manuscript sections
-// (`ctx.sections` — `collectManuscriptSections` emits ONE section per issue, see
-// arcPlanner/context.js). Skips sections with no usable number or empty content.
-export function proseByIssueNumber(sections) {
- const map = new Map();
- for (const s of (Array.isArray(sections) ? sections : [])) {
- if (!Number.isInteger(s?.number)) continue;
- const content = typeof s?.content === 'string' ? s.content : '';
- if (content.trim()) map.set(s.number, content);
- }
- return map;
+// Extract an issue's PROSE-stage text. Inlines arcPlanner's `stageTextOf` (output
+// then input) to keep the registry import-pure (no service import). Reads the
+// `prose` stage SPECIFICALLY — NOT the default manuscript precedence (comicScript ▸
+// teleplay ▸ prose), which for a hybrid comic+prose issue would return the comic
+// script, not the prose (the bug this check exists to avoid). Returns '' when the
+// issue has no prose-stage text.
+function proseStageText(issue) {
+ const stage = issue?.stages?.prose;
+ const output = typeof stage?.output === 'string' ? stage.output.trim() : '';
+ if (output) return output;
+ return typeof stage?.input === 'string' ? stage.input.trim() : '';
+}
+
+// Per-issue PROSE-stage content, as `{ number, prose }`, sorted by issue number.
+// The single source of truth for "the prose half" of the comic↔prose-sync check —
+// read by BOTH the check's `run` AND the runner's `prose` staleness resolver
+// (mirrors `comicLetteringIssues` for the comic half), so the fingerprinted text is
+// exactly what the check compares. Only issues with prose-stage text contribute.
+export function proseStageIssues(issues) {
+ return (Array.isArray(issues) ? issues : [])
+ .map((i) => ({ number: Number.isInteger(i?.number) ? i.number : null, prose: proseStageText(i) }))
+ .filter((i) => i.prose)
+ .sort((a, b) => (a.number ?? 0) - (b.number ?? 0));
}
// Render an issue's parsed comic pages into a compact, model-readable block —
@@ -2040,14 +2058,18 @@ export function renderComicForProseSync(pages) {
return lines.join('\n');
}
-// The issues that have BOTH drafted prose AND comic content — the comparable set
-// for the comic↔prose sync check. Returns `[{ number, prose, comic }]` sorted by
-// issue number (`comicLetteringIssues` already sorts), prose sliced to
+// The issues that have BOTH drafted PROSE-stage text AND comic content — the
+// comparable set for the comic↔prose sync check. Returns `[{ number, prose, comic }]`
+// sorted by issue number (`comicLetteringIssues` already sorts), prose sliced to
// PROSE_SYNC_PROSE_CHAR_CAP. An issue with comic but no prose (or prose but no
-// comic) has nothing to cross-check and is skipped. Pure: reads ctx.issues +
-// ctx.sections only.
+// comic) has nothing to cross-check and is skipped. Pure: reads ctx.issues only —
+// both halves come off the already-loaded issue records (the prose STAGE, not the
+// comicScript-precedence manuscript section).
export function proseSyncPairs(ctx) {
- const proseByIssue = proseByIssueNumber(ctx?.sections);
+ const proseByIssue = new Map();
+ for (const { number, prose } of proseStageIssues(ctx?.issues)) {
+ if (Number.isInteger(number)) proseByIssue.set(number, prose);
+ }
const pairs = [];
for (const { number, pages } of comicLetteringIssues(ctx?.issues)) {
if (!Number.isInteger(number)) continue;
@@ -2595,12 +2617,14 @@ export const EDITORIAL_CHECKS = [
},
{
id: 'comic.prose-sync',
- // Reads each issue's PROSE (manuscript sections, via needsManuscript) and its
- // authoritative COMIC content (`comicScript.pacing` — description + dialogue +
- // caption + SFX). Fingerprints BOTH so a finding stales when either the prose
- // or the comic for that issue drifts. comicScript.pacing also makes the runner
- // fetch the per-issue `issues` this check parses for comic pages.
- sources: ['manuscript', 'comicScript.pacing'],
+ // Reads each issue's PROSE-stage text (`prose`) and its authoritative COMIC
+ // content (`comicScript.pacing` — description + dialogue + caption + SFX), BOTH
+ // off the already-loaded issue records. Declaring `prose` (not `manuscript`) is
+ // load-bearing: the stitched manuscript picks comicScript over prose for a hybrid
+ // issue, so a `manuscript` source would compare the comic against itself. Both
+ // tokens are fingerprinted so a finding stales when either the prose or the comic
+ // for that issue drifts; both also make the runner fetch the per-issue `issues`.
+ sources: ['prose', 'comicScript.pacing'],
label: 'Comic ↔ prose synchronization (hybrid issues)',
description:
'LLM cross-media check for hybrid comic+prose issues: pairs each issue\'s prose narration with its authoritative comic pages and flags SUBSTANTIVE divergences — a plot beat the prose narrates that no panel shows, panel dialogue that contradicts the prose (different words or a different speaker), or a chronology disagreement (events ordered differently across the two media). Comics legitimately compress and cut, so it flags only material mismatches, not ordinary medium-translation trims. Runs one model call per issue that has both prose and comic content, anchoring every finding to its issue.',
@@ -2609,10 +2633,6 @@ export const EDITORIAL_CHECKS = [
category: 'continuity',
severityDefault: 'medium',
defaultEnabled: true,
- // Pairs each issue's comic with its prose section, so the manuscript sections
- // must be collected (the runner only pays that I/O when a needsManuscript check
- // is enabled).
- needsManuscript: true,
configSchema: z.object({
// Cap findings per issue so a long issue can't flood the review.
maxFindings: z.number().int().min(1).max(50).default(12),
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index 2035fba2f6..8c6c7cbc69 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -41,7 +41,7 @@ import {
canonCharacterStatesSummary,
canonCharacterTraitsSummary,
continuityLedgerSummary,
- proseByIssueNumber,
+ proseStageIssues,
renderComicForProseSync,
proseSyncPairs,
PROSE_SYNC_PROSE_CHAR_CAP,
@@ -3466,24 +3466,32 @@ describe('visual.appearance-continuity — LLM check (#1467)', () => {
});
describe('comic.prose-sync — LLM cross-media check (#1589)', () => {
- // An issue record whose comic content lives in the populated comicPages split.
- const comicIssue = (number, panels) => ({
+ // A hybrid issue record: a populated comicPages split AND a prose stage. Built the
+ // way production issues are (full `stages`), NOT via synthetic manuscript sections
+ // — so the prose half is read from the `prose` stage, exercising the real path.
+ const hybridIssue = (number, prose, panels, extraStages = {}) => ({
number,
- stages: { comicPages: { pages: [{ panels }] } },
+ stages: { prose: { output: prose }, comicPages: { pages: [{ panels }] }, ...extraStages },
});
- // A manuscript section as collectManuscriptSections emits it (one per issue).
- const section = (number, content) => ({ id: `i${number}`, number, title: '', stageId: 'manuscript', content });
+ // A comic-only issue (comic content, no prose stage).
+ const comicOnlyIssue = (number, panels) => ({ number, stages: { comicPages: { pages: [{ panels }] } } });
+ // A prose-only issue (prose stage, no comic content).
+ const proseOnlyIssue = (number, prose) => ({ number, stages: { prose: { output: prose } } });
+ const onePanel = (description) => [{ description, dialogue: [], caption: '', sfx: '' }];
describe('pure helpers', () => {
- it('proseByIssueNumber keys non-empty prose by issue number, skipping bad entries', () => {
- const map = proseByIssueNumber([
- section(3, 'Issue three prose.'),
- section(4, ' '), // blank → skipped
- { number: null, content: 'no number' }, // no number → skipped
- section(5, 'Issue five prose.'),
+ it('proseStageIssues reads the prose STAGE specifically, not comicScript — keyed/sorted by number', () => {
+ const rows = proseStageIssues([
+ // A hybrid issue with BOTH a comicScript stage AND a prose stage: the
+ // helper must pick the PROSE, never the comic script (the core bug guard).
+ { number: 5, stages: { comicScript: { output: 'COMIC SCRIPT — not prose' }, prose: { output: 'Issue five prose.' } } },
+ { number: 3, stages: { prose: { input: 'Issue three prose (input fallback).' } } },
+ { number: 9, stages: { prose: { output: ' ' } } }, // blank → skipped
+ { number: 7, stages: { comicScript: { output: 'comic only' } } }, // no prose → skipped
]);
- expect([...map.keys()].sort()).toEqual([3, 5]);
- expect(map.get(3)).toBe('Issue three prose.');
+ expect(rows.map((r) => r.number)).toEqual([3, 5]); // sorted, prose-bearing only
+ expect(rows.find((r) => r.number === 5).prose).toBe('Issue five prose.');
+ expect(rows.find((r) => r.number === 3).prose).toBe('Issue three prose (input fallback).');
});
it('renderComicForProseSync emits page/panel headers + shows/dialogue/caption/sfx, skipping empty panels', () => {
@@ -3502,50 +3510,65 @@ describe('comic.prose-sync — LLM cross-media check (#1589)', () => {
expect(out).not.toContain('Panel 2');
});
- it('proseSyncPairs joins only issues that have BOTH prose and comic, and caps prose length', () => {
+ it('proseSyncPairs joins only issues with BOTH prose and comic, caps prose, and uses the prose stage', () => {
const longProse = 'x'.repeat(PROSE_SYNC_PROSE_CHAR_CAP + 500);
const ctx = {
- sections: [section(3, longProse), section(9, 'prose but no comic')],
issues: [
- comicIssue(3, [{ description: 'a panel', dialogue: [], caption: '', sfx: '' }]),
- comicIssue(7, [{ description: 'comic but no prose', dialogue: [], caption: '', sfx: '' }]),
+ // Hybrid: prose stage + comic. Also carries a comicScript stage to prove
+ // the prose half comes from `prose`, not the comicScript precedence.
+ hybridIssue(3, longProse, onePanel('a panel'), { comicScript: { output: 'WRONG — comic script' } }),
+ comicOnlyIssue(7, onePanel('comic but no prose')),
+ proseOnlyIssue(9, 'prose but no comic'),
],
};
const pairs = proseSyncPairs(ctx);
expect(pairs.map((p) => p.number)).toEqual([3]); // only issue 3 has both
expect(pairs[0].prose).toHaveLength(PROSE_SYNC_PROSE_CHAR_CAP);
+ expect(pairs[0].prose.startsWith('x')).toBe(true); // the prose stage, not the comic script
expect(pairs[0].comic).toContain('Shows: a panel');
});
});
it('gates true only when an issue has both prose and comic content', () => {
const check = getCheck('comic.prose-sync');
- expect(check.gate({
- sections: [section(3, 'prose')],
- issues: [comicIssue(3, [{ description: 'panel', dialogue: [], caption: '', sfx: '' }])],
- })).toBe(true);
+ expect(check.gate({ issues: [hybridIssue(3, 'prose', onePanel('panel'))] })).toBe(true);
// Comic but no prose → nothing to cross-check.
- expect(check.gate({
- sections: [],
- issues: [comicIssue(3, [{ description: 'panel', dialogue: [], caption: '', sfx: '' }])],
- })).toBe(false);
- expect(check.gate({ sections: [], issues: [] })).toBe(false);
+ expect(check.gate({ issues: [comicOnlyIssue(3, onePanel('panel'))] })).toBe(false);
+ // Prose but no comic → nothing to cross-check.
+ expect(check.gate({ issues: [proseOnlyIssue(3, 'prose')] })).toBe(false);
+ expect(check.gate({ issues: [] })).toBe(false);
+ });
+
+ it('compares the PROSE stage (not the comic script) for a hybrid issue', async () => {
+ let seen = null;
+ await getCheck('comic.prose-sync').run({
+ issues: [
+ // A hybrid issue whose comicScript stage text differs from its prose stage —
+ // the check must hand the model the PROSE, never the comic script.
+ hybridIssue(3, 'Anna is stabbed and falls.', onePanel('Anna stands, unharmed'), { comicScript: { output: 'COMIC SCRIPT SOURCE — must not be sent' } }),
+ ],
+ config: {},
+ severityDefault: 'medium',
+ callStagedLLM: async (_stage, vars) => { seen = vars; return { content: { findings: [] } }; },
+ });
+ expect(seen.prose).toBe('Anna is stabbed and falls.');
+ expect(seen.prose).not.toContain('COMIC SCRIPT SOURCE');
+ expect(seen.comic).toContain('Shows: Anna stands, unharmed');
});
it('makes one model call per hybrid issue and forces the issue anchor on findings', async () => {
const seen = [];
const findings = await getCheck('comic.prose-sync').run({
- sections: [section(3, 'Anna is stabbed and falls.'), section(4, 'A quiet morning.')],
issues: [
- comicIssue(3, [{ description: 'Anna stands, unharmed', dialogue: [], caption: '', sfx: '' }]),
- comicIssue(4, [{ description: 'morning kitchen', dialogue: [], caption: '', sfx: '' }]),
+ hybridIssue(3, 'Anna is stabbed and falls.', onePanel('Anna stands, unharmed')),
+ hybridIssue(4, 'A quiet morning.', onePanel('morning kitchen')),
],
config: { maxFindings: 12, maxIssues: 40 },
severityDefault: 'medium',
callStagedLLM: async (_stage, vars) => {
seen.push(vars);
- // Model reports a mismatch only for the issue whose number it sees as 3,
- // and deliberately omits issueNumber to prove the check forces it.
+ // Model reports a mismatch only for issue 3, and deliberately omits
+ // issueNumber to prove the check forces it.
return vars.issueNumber === 3
? { content: { findings: [{ severity: 'medium', location: 'Issue 3 — unshown beat', problem: 'Prose stabs Anna; no panel shows it.', suggestion: 'Add a panel.', anchorQuote: 'Anna is stabbed' }] } }
: { content: { findings: [] } };
@@ -3563,11 +3586,10 @@ describe('comic.prose-sync — LLM cross-media check (#1589)', () => {
it('respects maxIssues (caps the number of model calls)', async () => {
let calls = 0;
await getCheck('comic.prose-sync').run({
- sections: [section(3, 'p3'), section(4, 'p4'), section(5, 'p5')],
issues: [
- comicIssue(3, [{ description: 'd3', dialogue: [], caption: '', sfx: '' }]),
- comicIssue(4, [{ description: 'd4', dialogue: [], caption: '', sfx: '' }]),
- comicIssue(5, [{ description: 'd5', dialogue: [], caption: '', sfx: '' }]),
+ hybridIssue(3, 'p3', onePanel('d3')),
+ hybridIssue(4, 'p4', onePanel('d4')),
+ hybridIssue(5, 'p5', onePanel('d5')),
],
config: { maxIssues: 2 },
severityDefault: 'medium',
@@ -3580,10 +3602,9 @@ describe('comic.prose-sync — LLM cross-media check (#1589)', () => {
let calls = 0;
const signal = { aborted: false };
await getCheck('comic.prose-sync').run({
- sections: [section(3, 'p3'), section(4, 'p4')],
issues: [
- comicIssue(3, [{ description: 'd3', dialogue: [], caption: '', sfx: '' }]),
- comicIssue(4, [{ description: 'd4', dialogue: [], caption: '', sfx: '' }]),
+ hybridIssue(3, 'p3', onePanel('d3')),
+ hybridIssue(4, 'p4', onePanel('d4')),
],
config: {},
severityDefault: 'medium',
@@ -3596,8 +3617,7 @@ describe('comic.prose-sync — LLM cross-media check (#1589)', () => {
it('returns no findings (and never calls the model) when no issue is hybrid', async () => {
let called = false;
const findings = await getCheck('comic.prose-sync').run({
- sections: [section(3, 'prose only')],
- issues: [], // no comic content anywhere
+ issues: [proseOnlyIssue(3, 'prose only')], // no comic content anywhere
config: {},
severityDefault: 'medium',
callStagedLLM: async () => { called = true; return { content: { findings: [] } }; },
diff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.js
index 6f70206b54..fb1a640fec 100644
--- a/server/services/pipeline/editorial/checkRunner.js
+++ b/server/services/pipeline/editorial/checkRunner.js
@@ -19,7 +19,7 @@ import { randomUUID, createHash } from 'crypto';
import { createSseRunner } from '../../../lib/sseUtils.js';
import { runStagedLLM, runInlineLLM, runStageScopedInlineLLM, resolveStageContext } from '../../../lib/stageRunner.js';
import { planManuscriptPass, fitContextToManuscriptFloor, estimateTokens, MANUSCRIPT_FLOOR_TOKENS } from '../../../lib/contextBudget.js';
-import { getEnabledChecks, getEnabledCheckRows, getAllChecks, EDITORIAL_SOURCES, comicLetteringIssues } from '../../../lib/editorial/index.js';
+import { getEnabledChecks, getEnabledCheckRows, getAllChecks, EDITORIAL_SOURCES, comicLetteringIssues, proseStageIssues } from '../../../lib/editorial/index.js';
import { getSettings } from '../../settings.js';
import { getSeries } from '../series.js';
import { listIssuesForSeries } from '../issues.js';
@@ -141,6 +141,14 @@ const SOURCE_RESOLVERS = {
// the verdict cannot have changed. Distinct from `comicScript.pacing` (which
// hashes the text the page-turn LLM reads).
'comicScript.layout': ({ comicLayoutContent }) => canonicalStringify(comicLayoutContent ?? null),
+ // Each issue's PROSE-stage text the comic↔prose-sync check compares against the
+ // comic (#1589). Its own token (NOT `manuscript`): the stitched manuscript picks
+ // comicScript over prose for a hybrid issue, so a `manuscript` fingerprint would
+ // track comic edits, not prose. `proseContent` is built off the SAME
+ // `proseStageIssues` projection the check reads (per-issue prose keyed by number),
+ // so a finding stales exactly when the prose it compared changes — and a comic-only
+ // edit doesn't stale it.
+ prose: ({ proseContent }) => canonicalStringify(proseContent ?? null),
};
// Flatten the storyboard scenes across every issue into the `{ issueNumber, scene }`
@@ -373,7 +381,8 @@ export async function runEditorialChecks(seriesId, options = {}) {
return sources.includes('storyboard.shots')
|| sources.includes('comicScript')
|| sources.includes('comicScript.pacing')
- || sources.includes('comicScript.layout');
+ || sources.includes('comicScript.layout')
+ || sources.includes('prose');
});
const [sections, canon, issues, outline, editorial, bible] = await Promise.all([
needsManuscript ? collectManuscriptSections(seriesId) : Promise.resolve([]),
@@ -414,10 +423,13 @@ export async function runEditorialChecks(seriesId, options = {}) {
const comicScripts = projectComicLetteringContent(comicIssues);
const comicPacingContent = projectComicPacingContent(comicIssues);
const comicLayoutContent = projectComicLayoutContent(comicIssues);
+ // The per-issue PROSE-stage content the comic↔prose-sync check compares against the
+ // comic (#1589) — built off the same already-loaded issues, keyed by issue number.
+ const proseContent = proseStageIssues(issues);
// Resolve every source token once — each finding's fingerprint reads from this
// so the editor flags it `stale` when the content that check actually read (its
// declared `sources`) drifts (#1345, #1387).
- const resolvedSources = resolveSources({ manuscript, canon, continuityBible, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts, comicPacingContent, comicLayoutContent });
+ const resolvedSources = resolveSources({ manuscript, canon, continuityBible, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts, comicPacingContent, comicLayoutContent, proseContent });
const baseCtx = {
seriesId,
series,
@@ -694,7 +706,10 @@ export async function getReviewWithStaleness(seriesId) {
const s = checkSources(checkFor(c.checkId));
return s.includes('comicScript') || s.includes('comicScript.pacing') || s.includes('comicScript.layout');
});
- const needsIssues = needsStoryboards || needsComicScript;
+ // The prose source (#1589) reads the per-issue prose stage off the same `issues`
+ // fetch, so it gates the issues load too — a prose-only check still loads issues.
+ const needsProse = evaluable.some((c) => checkSources(checkFor(c.checkId)).includes('prose'));
+ const needsIssues = needsStoryboards || needsComicScript || needsProse;
const series = await getSeries(seriesId);
const [sections, canon, outline, editorial, issues, bible] = await Promise.all([
needsManuscript ? collectManuscriptSections(seriesId) : Promise.resolve([]),
@@ -715,7 +730,8 @@ export async function getReviewWithStaleness(seriesId) {
const comicScripts = projectComicLetteringContent(comicIssues);
const comicPacingContent = projectComicPacingContent(comicIssues);
const comicLayoutContent = projectComicLayoutContent(comicIssues);
- const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, continuityBible, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts, comicPacingContent, comicLayoutContent });
+ const proseContent = proseStageIssues(issues);
+ const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, continuityBible, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts, comicPacingContent, comicLayoutContent, proseContent });
return {
...review,
comments: review.comments.map((c) => {