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): split comic-pacing staleness token; surface text in page-turn digest

Adam Eivyccb471809067
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.js
index 9c814525a0..0f1e6970bd 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -111,13 +111,19 @@ const SEVERITIES = CHECK_SEVERITIES;
// (`stages.comicPages.pages[]`) when present, else the
// generated `stages.comicScript.output`. The
// lettering-density check (#1313) counts per-panel/per-page
-// word + balloon load over it; the comic-pacing checks
-// (#1314) read the same parsed page/panel structure for
-// splash usage, panel rhythm, and page-turn beat placement.
-// Both read it via the shared `comicLetteringIssues(ctx.issues)`
-// projection (`[{ number, pages }]`). The runner fingerprints
-// the lettering-relevant fields so a finding goes stale when
-// the comic text (not the prose manuscript) is edited.
+// word + balloon load over it (caption/dialogue/SFX only).
+// Both comic-source checks read the same parsed pages via
+// `comicLetteringIssues(ctx.issues)` (`[{ number, pages }]`);
+// the runner fingerprints ONLY the lettering fields for this
+// token, so a visual-description edit doesn't stale a
+// lettering finding.
+// - 'comicScript.pacing' — the same parsed comic pages, but for the comic-PACING
+// checks (#1314: panel rhythm + page-turn beats). Distinct
+// token from 'comicScript' because the page-turn check ALSO
+// reads each panel's visual `description` — so its fingerprint
+// must move on a description edit while the lettering token's
+// stays put (and vice-versa). Same `ctx.issues` source, no
+// extra I/O.
export const EDITORIAL_SOURCES = Object.freeze([
'manuscript',
'canon',
@@ -131,6 +137,7 @@ export const EDITORIAL_SOURCES = Object.freeze([
'series.characterArcs',
'storyboard.shots',
'comicScript',
+ 'comicScript.pacing',
]);
// Default per-run finding cap for user-defined checks (#1346) — mirrors the
@@ -4502,7 +4509,7 @@ export const EDITORIAL_CHECKS = [
},
{
id: 'comic.panel-rhythm',
- sources: ['comicScript'],
+ sources: ['comicScript.pacing'],
label: 'Comic panel rhythm & splash usage',
description:
'Deterministic scan of each issue\'s parsed comic-page layout for reading-rhythm problems: splash-page overuse (too high a share of full-page splashes), back-to-back splashes that blow the page budget, overcrowded pages that cram too many beats, and monotonous grids (the same multi-panel count repeated page after page). Reads the parsed comic script (page → panel breakdown), not the prose manuscript.',
@@ -4581,7 +4588,7 @@ export const EDITORIAL_CHECKS = [
},
{
id: 'comic.page-turn-beats',
- sources: ['comicScript', 'series.arc.readerMap'],
+ sources: ['comicScript.pacing', 'series.arc.readerMap'],
label: 'Comic page-turn beat placement (LLM)',
description:
'LLM scan of each issue\'s comic-page layout for reveals and cliffhangers placed where the reader can see them early. On a two-page spread both pages are visible at once, so a surprise on a page the reader has already been looking at is spoiled before they reach it — a big reveal should land on the first page after a page turn (the start of the next spread). Reconciles the placement against the authored reader-map reveals/cliffhangers and suggests which panel to move.',
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index 4cb50f49f0..a9b9949fe2 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -3278,12 +3278,12 @@ describe('comic-pacing bundle (#1314)', () => {
const issue = (number, counts) => ({ number, stages: { comicPages: { pages: counts.map(page) } } });
describe('comic.panel-rhythm — deterministic', () => {
- it('is registered as an issue-scoped deterministic pacing check over comicScript', () => {
+ it('is registered as an issue-scoped deterministic pacing check over comicScript.pacing', () => {
const check = getCheck(PANEL_RHYTHM);
expect(check.kind).toBe('deterministic');
expect(check.scope).toBe('issue');
expect(check.category).toBe('pacing');
- expect(check.sources).toEqual(['comicScript']);
+ expect(check.sources).toEqual(['comicScript.pacing']);
});
it('only runs when at least one issue has comic content', () => {
@@ -3321,12 +3321,12 @@ describe('comic-pacing bundle (#1314)', () => {
});
describe('comic.page-turn-beats — LLM', () => {
- it('is registered as an issue-scoped LLM pacing check reading comicScript + reader-map', () => {
+ it('is registered as an issue-scoped LLM pacing check reading comicScript.pacing + reader-map', () => {
const check = getCheck(PAGE_TURN);
expect(check.kind).toBe('llm');
expect(check.scope).toBe('issue');
expect(check.category).toBe('pacing');
- expect(check.sources).toEqual(['comicScript', 'series.arc.readerMap']);
+ expect(check.sources).toEqual(['comicScript.pacing', 'series.arc.readerMap']);
});
it('passes each issue page layout + authored reveals to the model and attributes findings to the issue', async () => {
diff --git a/server/lib/editorial/comicPacing.js b/server/lib/editorial/comicPacing.js
index 255f5843d6..945e2b58a2 100644
--- a/server/lib/editorial/comicPacing.js
+++ b/server/lib/editorial/comicPacing.js
@@ -42,21 +42,36 @@ export function comicSpreadLayout(pageCount) {
return layout;
}
+// Collapse whitespace and truncate a text field to `max` chars for the digest.
+const clip = (s, max) => {
+ const t = typeof s === 'string' ? s.trim().replace(/\s+/g, ' ') : '';
+ return t.length > max ? `${t.slice(0, max)}…` : t;
+};
+
// A compact, type-guarded one-line digest of a panel's content for the page-turn
-// LLM context — its description (truncated), plus a hint of caption/dialogue/SFX
-// load so the model can reason about where a beat actually lands on the page.
+// LLM context — its description (truncated) PLUS truncated snippets of the
+// caption / dialogue / SFX text. The text matters because a reveal or cliffhanger
+// is often delivered in a caption or a line of dialogue rather than the visual
+// description; a presence-only marker ("caption", "1 dialogue") would hide the
+// actual beat from the model, so the snippets are included (not just counts).
function panelDigest(panel) {
if (!panel || typeof panel !== 'object') return '';
- const desc = typeof panel.description === 'string' ? panel.description.trim().replace(/\s+/g, ' ') : '';
- const head = desc ? desc.slice(0, 160) : '(no description)';
+ const desc = clip(panel.description, 160);
+ const head = desc || '(no description)';
const extras = [];
- const caption = typeof panel.caption === 'string' ? panel.caption.trim() : '';
- if (caption) extras.push('caption');
+ const caption = clip(panel.caption, 80);
+ if (caption) extras.push(`caption: "${caption}"`);
const dialogue = Array.isArray(panel.dialogue) ? panel.dialogue : [];
- if (dialogue.length) extras.push(`${dialogue.length} dialogue`);
- const sfx = typeof panel.sfx === 'string' ? panel.sfx.trim() : '';
- if (sfx) extras.push('sfx');
- return extras.length ? `${head} [${extras.join(', ')}]` : head;
+ for (const d of dialogue) {
+ // Parsed dialogue is `{ character, line }`; tolerate a bare string too.
+ const speaker = typeof d?.character === 'string' ? d.character.trim() : '';
+ const line = clip(typeof d === 'string' ? d : d?.line, 80);
+ if (!line) continue;
+ extras.push(speaker ? `${speaker}: "${line}"` : `dialogue: "${line}"`);
+ }
+ const sfx = clip(panel.sfx, 40);
+ if (sfx) extras.push(`sfx: ${sfx}`);
+ return extras.length ? `${head} [${extras.join('; ')}]` : head;
}
// Per-page summary used by both the deterministic rhythm analysis and the
diff --git a/server/lib/editorial/comicPacing.test.js b/server/lib/editorial/comicPacing.test.js
index eb477f1e8e..353024b965 100644
--- a/server/lib/editorial/comicPacing.test.js
+++ b/server/lib/editorial/comicPacing.test.js
@@ -49,13 +49,23 @@ describe('summarizeComicPages', () => {
expect(summary[1].panels).toHaveLength(3);
});
- it('folds caption/dialogue/sfx hints into the panel digest', () => {
- const pages = [{ panels: [{ description: 'A long beat', caption: 'cap', dialogue: [{ character: 'X', line: 'hi' }], sfx: 'BOOM' }] }];
+ it('folds caption/dialogue/sfx TEXT (not just presence) into the panel digest', () => {
+ const pages = [{ panels: [{ description: 'A long beat', caption: 'Later that night', dialogue: [{ character: 'JANE', line: 'It was you' }], sfx: 'BOOM' }] }];
const [pg] = summarizeComicPages(pages);
expect(pg.panels[0]).toContain('A long beat');
- expect(pg.panels[0]).toContain('caption');
- expect(pg.panels[0]).toContain('1 dialogue');
- expect(pg.panels[0]).toContain('sfx');
+ // The actual text is surfaced — a reveal delivered in a caption/line must be
+ // visible to the page-turn LLM, not hidden behind a count marker.
+ expect(pg.panels[0]).toContain('caption: "Later that night"');
+ expect(pg.panels[0]).toContain('JANE: "It was you"');
+ expect(pg.panels[0]).toContain('sfx: BOOM');
+ });
+
+ it('truncates long text fields and tolerates a bare-string dialogue entry', () => {
+ const longLine = 'word '.repeat(40).trim(); // 199 chars
+ const pages = [{ panels: [{ description: 'd', caption: '', dialogue: ['a bare line'], sfx: '' }, { description: 'e', caption: longLine, dialogue: [], sfx: '' }] }];
+ const [pg] = summarizeComicPages(pages);
+ expect(pg.panels[0]).toContain('dialogue: "a bare line"'); // no speaker → generic label
+ expect(pg.panels[1]).toContain('…'); // caption clipped at 80 chars
});
it('tolerates a non-array input', () => {
diff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.js
index 3d55440e8f..5361575ec7 100644
--- a/server/services/pipeline/editorial/checkRunner.js
+++ b/server/services/pipeline/editorial/checkRunner.js
@@ -105,6 +105,11 @@ const SOURCE_RESOLVERS = {
// text it read changes (and an unrelated image render — `panel.imageJobId` — does
// NOT stale it, since only the lettering fields are projected).
comicScript: ({ comicScripts }) => canonicalStringify(comicScripts ?? null),
+ // The comic-pacing checks' content (#1314) — its own token so a visual
+ // `description` edit stales a page-turn finding without staling a lettering
+ // finding (which doesn't read `description`), and vice-versa. Same page-grouped
+ // shape as the lettering projection plus `description`.
+ 'comicScript.pacing': ({ comicPacingContent }) => canonicalStringify(comicPacingContent ?? null),
};
// Flatten the storyboard scenes across every issue into the `{ issueNumber, scene }`
@@ -147,18 +152,36 @@ function projectStoryboardContinuity(storyboardScenes) {
}));
}
-// Project the loaded issues down to the comic content the `comicScript`-source
-// checks analyze, via the registry's shared `comicLetteringIssues` (so the
-// fingerprint can't drift from what the checks read). The `comicScript` token is
-// shared: the lettering check (#1313) reads caption/dialogue/SFX, and the
-// page-turn check (#1314) additionally reads each panel's `description`. The
-// fingerprint must cover the UNION of fields any comic check reads off the token,
-// so it includes `description` too — otherwise a description-only edit would leave
-// a page-turn finding falsely fresh. (It also stays stable across image renders —
-// `panel.imageJobId` etc. are never projected.) PAGE GROUPING is preserved (not
-// flattened): the checks report per-page totals/locations and panel-count rhythm,
-// so moving panels between pages must change the hash even when text is identical.
+// Project the loaded issues down to the lettering-relevant comic content the check
+// analyzes, via the registry's shared `comicLetteringIssues` (so the fingerprint
+// can't drift from what `run` reads). Keeps ONLY caption/dialogue/SFX — the fields
+// `panelLetteringMetrics` consumes — so the hash is stable across image renders and
+// description edits that don't change lettering. PAGE GROUPING is preserved (not
+// flattened): the check reports per-page totals and page/panel locations, so moving
+// panels between pages must change the hash even when the lettering text is identical.
function projectComicLetteringContent(issues) {
+ return comicLetteringIssues(issues).map(({ number, pages }) => ({
+ number,
+ pages: pages.map((p) => ({
+ panels: (Array.isArray(p?.panels) ? p.panels : []).map((panel) => ({
+ caption: typeof panel?.caption === 'string' ? panel.caption : '',
+ dialogue: Array.isArray(panel?.dialogue) ? panel.dialogue : [],
+ sfx: typeof panel?.sfx === 'string' ? panel.sfx : '',
+ })),
+ })),
+ }));
+}
+
+// Project the loaded issues down to the content the comic-PACING checks (#1314)
+// analyze — its own source token (`comicScript.pacing`) distinct from the
+// lettering token (`comicScript`) so the two checks' fingerprints don't bleed:
+// editing a panel's visual `description` must stale a page-turn finding (the
+// page-turn LLM digest reads the description) WITHOUT staling a lettering finding
+// (which never reads it), and vice-versa. This projection therefore additionally
+// includes `description` on top of caption/dialogue/SFX. PAGE GROUPING is preserved
+// so the panel-rhythm check's per-page counts/splash signals stale when panels move
+// between pages. Render/status fields (`panel.imageJobId`) are never projected.
+function projectComicPacingContent(issues) {
return comicLetteringIssues(issues).map(({ number, pages }) => ({
number,
pages: pages.map((p) => ({
@@ -311,14 +334,16 @@ export async function runEditorialChecks(seriesId, options = {}) {
// series (canceled/early-stopped batch) doesn't flag a not-yet-analyzed POV
// holder as arc-less (#1295). Folded into the editorialArcs fingerprint below.
const editorialArcsComplete = editorialCoverageComplete(editorial);
- // The comic lettering content the check (#1313) reads — derived from the
- // already-loaded issues (no extra I/O), so a finding stales when an issue's comic
- // pages / script are edited.
+ // The comic content the comic checks read — derived from the already-loaded
+ // issues (no extra I/O). Two projections, one per source token: lettering (#1313,
+ // caption/dialogue/SFX) and pacing (#1314, + visual `description`), so a
+ // description edit stales a pacing finding without staling a lettering one.
const comicScripts = projectComicLetteringContent(issues);
+ const comicPacingContent = projectComicPacingContent(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, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts });
+ const resolvedSources = resolveSources({ manuscript, canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts, comicPacingContent });
const baseCtx = {
seriesId,
series,
@@ -491,10 +516,14 @@ export async function getReviewWithStaleness(seriesId) {
});
const needsEditorialArcs = evaluable.some((c) => checkSources(checkFor(c.checkId)).includes('editorialArcs'));
// Issues are fetched here only when a storyboard-shots (#1315) OR comic-script
- // (#1313/#1314) finding needs re-fingerprinting — both derive from the issue
- // records, so a single gated fetch serves both. Mirrors the other per-source I/O gates.
+ // (#1313 lettering / #1314 pacing) finding needs re-fingerprinting — all derive
+ // from the issue records, so a single gated fetch serves them. Mirrors the other
+ // per-source I/O gates.
const needsStoryboards = evaluable.some((c) => checkSources(checkFor(c.checkId)).includes('storyboard.shots'));
- const needsComicScript = evaluable.some((c) => checkSources(checkFor(c.checkId)).includes('comicScript'));
+ const needsComicScript = evaluable.some((c) => {
+ const s = checkSources(checkFor(c.checkId));
+ return s.includes('comicScript') || s.includes('comicScript.pacing');
+ });
const needsIssues = needsStoryboards || needsComicScript;
const series = await getSeries(seriesId);
const [sections, canon, outline, editorial, issues] = await Promise.all([
@@ -511,7 +540,8 @@ export async function getReviewWithStaleness(seriesId) {
const editorialArcsComplete = editorialCoverageComplete(editorial);
const storyboardScenes = collectStoryboardScenes(issues);
const comicScripts = projectComicLetteringContent(issues);
- const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts });
+ const comicPacingContent = projectComicPacingContent(issues);
+ const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts, comicPacingContent });
return {
...review,
comments: review.comments.map((c) => {
diff --git a/server/services/pipeline/editorial/checkRunner.test.js b/server/services/pipeline/editorial/checkRunner.test.js
index 5ba2263645..ef605968f5 100644
--- a/server/services/pipeline/editorial/checkRunner.test.js
+++ b/server/services/pipeline/editorial/checkRunner.test.js
@@ -500,35 +500,41 @@ describe('getReviewWithStaleness (#1345)', () => {
expect(review.comments.find((c) => c.checkId === 'visual.shot-continuity').stale).toBe(false);
});
- it('stales a comic.page-turn-beats finding when a panel description changes (#1314 projection)', async () => {
- // The comicScript fingerprint is shared by the lettering (#1313) and page-turn
- // (#1314) checks. page-turn reads each panel's `description` (lettering does
- // not), so the projection must include `description` — else a description-only
- // edit leaves a page-turn finding falsely fresh.
+ it('a panel description edit stales the page-turn finding but NOT the lettering finding (#1314 vs #1313 source split)', async () => {
+ // The pacing checks (#1314) read each panel's visual `description`; the
+ // lettering check (#1313) reads only caption/dialogue/SFX. They use SEPARATE
+ // source tokens (`comicScript.pacing` vs `comicScript`) so a description-only
+ // edit stales a page-turn finding (it read the description) WITHOUT staling a
+ // lettering finding (it didn't) — and vice-versa. This pins both halves.
const comicIssue = (desc) => [{
id: 'i1', seriesId: 's1', number: 1,
stages: { comicPages: { pages: [
- { panels: [{ description: desc, caption: '', dialogue: [], sfx: '' }] },
+ // A 30-word caption so the lettering check fires an over-stuffed-balloon finding too.
+ { panels: [{ description: desc, caption: 'word '.repeat(30).trim(), dialogue: [], sfx: '' }] },
{ panels: [{ description: 'b1', caption: '', dialogue: [], sfx: '' }, { description: 'b2', caption: '', dialogue: [], sfx: '' }] },
] } },
}];
issuesState = comicIssue('a reveal on the wrong page');
- // The page-turn check is the only LLM check we want firing here; the shared
- // runStagedLLM mock returns a finding for whatever stage it's called with.
- const onlyPageTurn = {
+ // Enable ONLY the two comic checks; the shared runStagedLLM mock returns a
+ // finding for the page-turn stage call.
+ const comicChecksOnly = {
pipelineEditorialChecks: {
checks: Object.fromEntries(
- listChecks().filter((c) => c.id !== 'comic.page-turn-beats').map((c) => [c.id, { enabled: false }]),
+ listChecks()
+ .filter((c) => c.id !== 'comic.page-turn-beats' && c.id !== 'comic.lettering-density')
+ .map((c) => [c.id, { enabled: false }]),
),
},
};
- const { findings } = await runEditorialChecks('s1', { settings: onlyPageTurn });
+ const { findings } = await runEditorialChecks('s1', { settings: comicChecksOnly });
reviewState = { comments: findings.map((f) => ({ ...f, status: 'open' })) };
expect(reviewState.comments.find((c) => c.checkId === 'comic.page-turn-beats')).toBeTruthy();
- // Only a panel description changed — panel counts/lettering identical.
+ expect(reviewState.comments.find((c) => c.checkId === 'comic.lettering-density')).toBeTruthy();
+ // Only a panel description changed — panel counts + all lettering text identical.
issuesState = comicIssue('a reveal moved to a reveal-safe page');
const review = await getReviewWithStaleness('s1');
expect(review.comments.find((c) => c.checkId === 'comic.page-turn-beats').stale).toBe(true);
+ expect(review.comments.find((c) => c.checkId === 'comic.lettering-density').stale).toBe(false);
});
it('keeps a scene finding fresh when the manuscript changes (reverseOutline-only source)', async () => {