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 cliffhanger beats in page-turn context; parse comic scripts once

Adam Eivy1ea97b37bae1
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 4f30278045..a388617590 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,7 +2,7 @@
## Added
-- **[issue-1314] Editorial checks for comic pacing — splash usage, panel rhythm, and page-turn beat placement.** Two new checks (Create → Editorial Checks) read each issue's parsed comic script (page → panel breakdown), not the prose manuscript. **Comic panel rhythm & splash usage** is deterministic: it flags **splash overuse** (too high a share of full-page splashes), **back-to-back splash runs** (consecutive full-page splashes that read as a slideshow and burn the page budget), **overcrowded pages** (too many panels cramped onto one page), and **grid monotony** (the same multi-panel count repeated page after page) — all threshold-configurable (max panels/page, splash-overuse ratio, monotony run length). **Comic page-turn beat placement** is LLM-judged: because a printed comic is read in two-page spreads, a reveal or cliffhanger on a page the reader has already been looking at across the open spread is spoiled before they reach it — a big reveal should land on the *first page after a page turn*. It reads each issue's recto/verso spread layout and flags reveals exposed early, reconciling against the authored reader-map reveals/cliffhangers and suggesting which panel to move. The runner parses each issue's stored comic script into pages only when a comic-pacing check is enabled (no extra I/O otherwise), and fingerprints the parsed layout for finding staleness so a comic-script edit re-stales the findings while a prose-only edit doesn't. The pure scanners live in `server/lib/editorial/comicPacing.js` (no new deps); the page-turn stage prompt (`pipeline-editorial-comic-page-turn`) migrates for existing installs (117). (`server/lib/editorial/{comicPacing,checkRegistry}.js`, `server/services/pipeline/editorial/checkRunner.js`, `scripts/migrations/117-editorial-comic-page-turn-stage.js`, #1314)
+- **[issue-1314] Editorial checks for comic pacing — splash usage, panel rhythm, and page-turn beat placement.** Two new checks (Create → Editorial Checks) read each issue's parsed comic script (page → panel breakdown), not the prose manuscript. **Comic panel rhythm & splash usage** is deterministic: it flags **splash overuse** (too high a share of full-page splashes), **back-to-back splash runs** (consecutive full-page splashes that read as a slideshow and burn the page budget), **overcrowded pages** (too many panels cramped onto one page), and **grid monotony** (the same multi-panel count repeated page after page) — all threshold-configurable (max panels/page, splash-overuse ratio, monotony run length). **Comic page-turn beat placement** is LLM-judged: because a printed comic is read in two-page spreads, a reveal or cliffhanger on a page the reader has already been looking at across the open spread is spoiled before they reach it — a big reveal should land on the *first page after a page turn*. It reads each issue's recto/verso spread layout (including the caption/dialogue/SFX text of each panel, so a reveal delivered in a line — not just the art — is visible to the model) and flags reveals exposed early, reconciling against the authored reader-map reveals/cliffhangers and suggesting which panel to move. Both checks reuse the parsed comic pages the lettering check (#1313) already derives from each issue (no extra parse), and each declares a precise staleness source so findings only re-stale when the content that check actually read changes: panel-rhythm reads per-page panel **counts** (`comicScript.layout`), so a text-only edit that leaves the layout intact never stales it; page-turn additionally reads each panel's visual **description** + text (`comicScript.pacing`), so a description edit re-stales it without touching a lettering finding (and vice-versa). The pure scanners live in `server/lib/editorial/comicPacing.js` (no new deps); the page-turn stage prompt (`pipeline-editorial-comic-page-turn`) migrates for existing installs (117). (`server/lib/editorial/{comicPacing,checkRegistry}.js`, `server/services/pipeline/editorial/checkRunner.js`, `scripts/migrations/117-editorial-comic-page-turn-stage.js`, #1314)
- **[issue-1408] LoRA training quality-of-life: vision-assisted reference-sheet slicing, caption with Claude/Codex CLI providers, and a richer training queue.** Three improvements to building character LoRAs (Create → LoRA Training). **(1) Smarter sheet slicing** — "Slice reference sheet" now offers *Auto-detect figures with a vision model*, which asks a vision model to draw a tight box around each figure on the turnaround and crops those instead of a rigid grid; it falls back to the columns×rows grid automatically when no vision model is installed or detection finds nothing, so you still get crops to prune either way. **(2) Caption with a CLI model** — the caption-model picker now also lists vision-capable CLI providers (Codex / Claude Code), so you can auto-caption a dataset with `codex` or `claude` (vision) rather than only a local LM Studio / Ollama vision model. **(3) Training queue at a glance** — the new Training queue on the LoRA Training page shows each run's loss curve (a sparkline over its checkpoints) and sample thumbnails right in the row, so you can watch a run learn — and spot a divergence — without opening it. (Part of #1227, #1408)
- **[issue-1412] Editorial check classifies unmodeled proper nouns used as character names — the LLM-assisted half of roster economy.** A new **Unmodeled proper nouns used as character names** LLM check (Create → Editorial Checks) closes the gap the deterministic **roster economy** check (#1292) deliberately left open: that scan only sees canon names + aliases, so a proper noun used as an *apparent* character name that was never added to the story bible is invisible to it. This check surfaces those — and **classifies** each one, because a keyword scan can't tell a person from a place, organization, brand, or honorific. It reads the stitched manuscript plus your canon roster (names + aliases) as an exclusion list, flags capitalized proper nouns used as character names that are **absent from canon**, and calls out **throwaway one-appearance names** the reader is told to remember but who never recur — suggesting either adding them to canon or recasting them as an unnamed description. Unlike roster economy it runs even on an **empty bible** (then every named proper noun is a candidate). The LLM does only the judgment it alone can — surface a name and confirm it's a *person* — while a **deterministic pass counts each surfaced name's appearances across the whole manuscript and authors the verdict** (one-appearance throwaway vs recurring), so a long book reviewed in chunks never mislabels a name that appears in chapters 1 and 12 as a throwaway (and the same name surfaced from two chunks collapses to one finding). Findings render as `Casting` notes anchored to the issue + a verbatim quote. Ships a new stage prompt (`pipeline-editorial-unmodeled-names`) that migrates for existing installs (116). (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md`, `scripts/migrations/116-editorial-unmodeled-names-stage.js`, Part of #1283, #1412)
- **[issue-1317] Editorial check flags theme-coherence problems — themes stated but never dramatized, dropped after the opening, or unpaid at the climax (plus emergent-theme detection).** A new **Theme coherence / thematic throughline** LLM check (Create → Editorial Checks) asks whether the manuscript actually *delivers* the themes the story arc declares (`series.arc.themes`), not just names them. For each declared theme it builds a setup → complication → payoff coverage map and flags a theme that is **stated but never dramatized** through a character's choices or the central conflict, a theme that is **dropped** after the opening, and a climax that **resolves the plot but never lands the thematic argument** the setup promised. It also detects a strong **emergent theme** the story is really telling that isn't in the declared list — offering to add it (or reconciling it when the story drifts into a competing argument). It reads your reverse-outline scene segmentation as context so it can attribute a theme's setup/payoff to a scene + issue, and **degrades gracefully** — no authored themes ⇒ it works from the prose alone to surface emergent themes; no outline ⇒ it scans the whole manuscript. Whole-arc judgments (a dropped theme, an unpaid climax) are deferred until it has seen the final chunk, and cross-chunk findings + clean-setup digests keep a long book reviewed in pieces from false-flagging a theme whose payoff lands later. Findings render as `Theme` notes anchored to the issue + a verbatim quote. Ships a new stage prompt (`pipeline-editorial-theme-coherence`) that migrates for existing installs (115). (`server/lib/editorial/checkRegistry.js`, `server/services/pipeline/editorial/checkRunner.js`, `data.reference/prompts/stages/pipeline-editorial-theme-coherence.md`, `scripts/migrations/115-editorial-theme-coherence-stage.js`, Part of #1283, #1317)
diff --git a/server/lib/editorial/comicPacing.js b/server/lib/editorial/comicPacing.js
index 177d39128a..d331ca581b 100644
--- a/server/lib/editorial/comicPacing.js
+++ b/server/lib/editorial/comicPacing.js
@@ -202,23 +202,29 @@ export function comicPageTurnSummary(pages, issueNumber = null) {
return `${header}\n${lines.join('\n')}`;
}
-// Render the authored reader-map REVEALS (beats with kind 'reveal') and
-// CLIFFHANGERS into a compact text block the page-turn-beats check passes
-// alongside the script, so the model reconciles WHICH beats are big reveals that
-// need a protected page-turn against what the writer logged. Pure + deterministic
-// (mirrors authoredCliffhangerSummary / authoredSetupPayoffSummary in the
-// registry). Returns '' when nothing reveal-like is authored.
+// Render the authored reader-map REVEALS and CLIFFHANGERS into a compact text
+// block the page-turn-beats check passes alongside the script, so the model
+// reconciles WHICH beats are big reveals/cliffhangers that need a protected
+// page-turn against what the writer logged. Both the timeline beats with kind
+// 'reveal' OR 'cliffhanger' (`readerMap.beats`) AND the separate issue-boundary
+// cliffhanger list (`readerMap.cliffhangers`) are surfaced — a cliffhanger stored
+// as a beat must not be dropped. Pure + deterministic (mirrors
+// authoredCliffhangerSummary / authoredSetupPayoffSummary in the registry).
+// Returns '' when nothing reveal-like is authored.
+const REVEAL_BEAT_KINDS = new Set(['reveal', 'cliffhanger']);
export function authoredRevealSummary(readerMap) {
const beats = Array.isArray(readerMap?.beats) ? readerMap.beats : [];
const cliffs = Array.isArray(readerMap?.cliffhangers) ? readerMap.cliffhangers : [];
const revealLines = beats
- .filter((b) => b?.kind === 'reveal')
+ .filter((b) => REVEAL_BEAT_KINDS.has(b?.kind))
.map((b) => {
// fenceSafe (not bare trim): the note is embedded in a ``` block in the prompt.
const note = fenceSafe(b?.note);
if (!note) return '';
+ // Tag a cliffhanger beat so the model can tell it from a mid-issue reveal.
+ const tag = b?.kind === 'cliffhanger' ? ' [cliffhanger]' : '';
const pos = Number.isFinite(b?.atArcPosition) ? ` (arc position ${b.atArcPosition})` : '';
- return `- ${note}${pos}`;
+ return `- ${note}${tag}${pos}`;
})
.filter(Boolean);
const cliffLines = cliffs
diff --git a/server/lib/editorial/comicPacing.test.js b/server/lib/editorial/comicPacing.test.js
index f6fa578d03..395bc88dd9 100644
--- a/server/lib/editorial/comicPacing.test.js
+++ b/server/lib/editorial/comicPacing.test.js
@@ -164,6 +164,22 @@ describe('authoredRevealSummary', () => {
expect(authoredRevealSummary({ beats: [{ kind: 'hook', note: 'q' }] })).toBe('');
});
+ it('includes cliffhanger BEATS (kind=cliffhanger), not just reveal beats and the cliffhangers list', () => {
+ // READER_MAP_BEAT_KINDS allows a cliffhanger to be stored as a timeline beat;
+ // the page-turn check handles reveals AND cliffhangers, so it must not drop it.
+ const out = authoredRevealSummary({
+ beats: [
+ { kind: 'reveal', note: 'the mole is exposed', atArcPosition: 4 },
+ { kind: 'cliffhanger', note: 'the bridge collapses', atArcPosition: 8 },
+ { kind: 'emotional', note: 'a quiet goodbye' },
+ ],
+ cliffhangers: [],
+ });
+ expect(out).toContain('the mole is exposed (arc position 4)');
+ expect(out).toContain('the bridge collapses [cliffhanger] (arc position 8)');
+ expect(out).not.toContain('a quiet goodbye'); // emotional beats aren't page-turn-relevant
+ });
+
it('neutralizes markdown fence delimiters in reveal/cliffhanger notes (prompt-fence safety)', () => {
// The summary is embedded in a ``` fenced block in the page-turn prompt, so a
// note containing backticks must not be able to close the fence early.
diff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.js
index c294e68476..1c1d5eff6b 100644
--- a/server/services/pipeline/editorial/checkRunner.js
+++ b/server/services/pipeline/editorial/checkRunner.js
@@ -159,15 +159,19 @@ function projectStoryboardContinuity(storyboardScenes) {
}));
}
-// 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 }) => ({
+// The three comic projections below all derive from the SAME parsed page list
+// (`comicLetteringIssues(issues)` → `[{ number, pages }]`), so the caller parses
+// the comic scripts ONCE (`comicIssuesFor(issues)`) and passes the rows in —
+// rather than each projection re-parsing every issue's script. They take the
+// already-parsed `comicIssues` rows, not raw `issues`.
+
+// Lettering token (`comicScript`, #1313): 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: the check reports per-page totals/locations, so moving panels between
+// pages must change the hash even when the lettering text is identical.
+function projectComicLetteringContent(comicIssues) {
+ return comicIssues.map(({ number, pages }) => ({
number,
pages: pages.map((p) => ({
panels: (Array.isArray(p?.panels) ? p.panels : []).map((panel) => ({
@@ -179,17 +183,14 @@ function projectComicLetteringContent(issues) {
}));
}
-// 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 }) => ({
+// Page-turn token (`comicScript.pacing`, #1314): distinct from the lettering token
+// so the two checks' fingerprints don't bleed — editing a panel's visual
+// `description` must stale a page-turn finding (the LLM digest reads it) WITHOUT
+// staling a lettering finding (which never reads it), and vice-versa. So this adds
+// `description` on top of caption/dialogue/SFX. PAGE GROUPING preserved; render/
+// status fields (`panel.imageJobId`) are never projected.
+function projectComicPacingContent(comicIssues) {
+ return comicIssues.map(({ number, pages }) => ({
number,
pages: pages.map((p) => ({
panels: (Array.isArray(p?.panels) ? p.panels : []).map((panel) => ({
@@ -202,14 +203,15 @@ function projectComicPacingContent(issues) {
}));
}
-// Project the loaded issues down to LAYOUT ONLY — the per-page panel COUNT — for
-// the panel-rhythm check (#1314), which reads nothing but counts (`analyzePanelRhythm`).
-// Fingerprinting only the count means a text-only edit (reword a caption/description
-// without changing how many panels a page has) does NOT stale a rhythm finding,
-// while adding/removing/moving a panel does. Per-page array order is preserved so a
-// reordering that changes the run structure (splash runs, monotony) re-hashes.
-function projectComicLayoutContent(issues) {
- return comicLetteringIssues(issues).map(({ number, pages }) => ({
+// Layout token (`comicScript.layout`, #1314): LAYOUT ONLY — the per-page panel
+// COUNT — for the panel-rhythm check, which reads nothing but counts
+// (`analyzePanelRhythm`). Fingerprinting only the count means a text-only edit
+// (reword a caption/description without changing how many panels a page has) does
+// NOT stale a rhythm finding, while adding/removing/moving a panel does. Per-page
+// array order is preserved so a reordering that changes the run structure (splash
+// runs, monotony) re-hashes.
+function projectComicLayoutContent(comicIssues) {
+ return comicIssues.map(({ number, pages }) => ({
number,
panelCounts: pages.map((p) => (Array.isArray(p?.panels) ? p.panels.length : 0)),
}));
@@ -355,12 +357,15 @@ export async function runEditorialChecks(seriesId, options = {}) {
// holder as arc-less (#1295). Folded into the editorialArcs fingerprint below.
const editorialArcsComplete = editorialCoverageComplete(editorial);
// 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);
- const comicLayoutContent = projectComicLayoutContent(issues);
+ // issues (no extra I/O). Parse each issue's comic script ONCE, then build all
+ // three per-token projections from the shared rows: lettering (#1313,
+ // caption/dialogue/SFX), pacing (#1314, + visual `description`), and layout
+ // (#1314, panel counts only) — so a description edit stales a pacing finding
+ // without staling a lettering one, and a text-only edit never stales a rhythm one.
+ const comicIssues = comicLetteringIssues(issues);
+ const comicScripts = projectComicLetteringContent(comicIssues);
+ const comicPacingContent = projectComicPacingContent(comicIssues);
+ const comicLayoutContent = projectComicLayoutContent(comicIssues);
// 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).
@@ -560,9 +565,10 @@ export async function getReviewWithStaleness(seriesId) {
const editorialArcs = projectEditorialArcs(editorial);
const editorialArcsComplete = editorialCoverageComplete(editorial);
const storyboardScenes = collectStoryboardScenes(issues);
- const comicScripts = projectComicLetteringContent(issues);
- const comicPacingContent = projectComicPacingContent(issues);
- const comicLayoutContent = projectComicLayoutContent(issues);
+ const comicIssues = comicLetteringIssues(issues);
+ const comicScripts = projectComicLetteringContent(comicIssues);
+ const comicPacingContent = projectComicPacingContent(comicIssues);
+ const comicLayoutContent = projectComicLayoutContent(comicIssues);
const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, series, reverseOutline, reverseOutlinePlotlines, editorialArcs, editorialArcsComplete, storyboardScenes, comicScripts, comicPacingContent, comicLayoutContent });
return {
...review,