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: add narrative voice / tone consistency editorial check (#1586)

Adam Eivy5d188fcd0a66
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index a9401939b1..abce69c20f 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -59,6 +59,8 @@
- **[issue-1585] A new editorial check catches flat secondary characters — a recurring side character who appears scene after scene but is exactly the same at the end as at the start.** The existing `pov.justified` check asks whether each *POV* character earns their viewpoint, but nothing judged the *non-POV* cast — so a recurring side character (a partner, a foil, a co-worker who shows up across half the book) could stay completely static, draining the story's texture, without ever being flagged. The new **Secondary-character arcs** check (`character.secondary-arc`) tallies the recurring non-POV cast from the reverse-outline scene map — characters present across multiple scenes who never hold the viewpoint — and judges whether each shows meaningful change, flagging a *flat arc* (the same situation, attitude, and standing at the end as the start) or a *purposeless regression* (an arc that quietly undoes itself with nothing in the story making it meaningful). It reads the stitched manuscript with the recurring-cast roster and the canon roster, deliberately ignoring genuine walk-ons (a one- or two-scene bit player owes the reader no arc) and a deliberately-static foil whose constancy is the point. Because a flat arc is a whole-story claim, it carries each recurring secondary's established state forward between manuscript chunks and gates its verdict on the final part — so a character established early whose change lands in a chapter no longer in view isn't falsely flagged — and degrades to a whole-manuscript scan when no outline exists. A configurable **recurring threshold** (default 2 scenes) tunes how prominent a character must be before it's held to an arc. It's a default-on series check that surfaces in the existing editorial-review UI and Series Autopilot like every other check, marking a prominent recurring character left wholly flat medium-severity. (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-secondary-arc.md`, `scripts/migrations/133-editorial-secondary-arc-stage.js`)
+- **[issue-1586] A new editorial check catches narrator-voice whiplash — narration that's witty in issue 1, grim in issue 3, then witty again in issue 5.** The existing `dialogue.voice-distinctiveness` check guards each *character's* dialogue voice, but nothing watched the *narrator's* voice across a series — so the storytelling tone could lurch from issue to issue (a wry, ironic narrator turning flat and clinical, a spare hard-boiled voice going lush and lyrical) with no one flagging the inconsistency, even though voice consistency is part of the promise to the reader. The new **Narrative voice / tone consistency** check (`style.voice-consistency`) fingerprints each issue's narrative tone — diction, register, humor, emotional temperature, sentence rhythm — and flags two problems: a *cross-issue tonal shift* the story never earns, and *drift from the series style guide's intended voice* (the declared `tone` words) when one is set. It reads the stitched manuscript with the style guide's intended tone, deliberately ignoring a purposeful modulation the events justify (a grim chapter because the plot took a grim turn) and judging the narration only, not character dialogue. Because the comparison spans issues, it carries each issue's tone fingerprint forward between manuscript chunks, so a later issue's narration is judged against the voice the series established earlier; it degrades to a pure cross-issue consistency scan when no style guide tone is declared. It's a default-on series check that surfaces in the existing editorial-review UI and Series Autopilot like every other check, marking a sharp, unexplained whiplash medium-severity. (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-voice-consistency.md`, `scripts/migrations/134-editorial-voice-consistency-stage.js`)
+
## Series Autopilot
- **[issue-1510] Series Autopilot now catches whole-book continuity problems at the cheap beat stage, before it generates full scripts.** The autopilot reviewed continuity at two altitudes — the cross-volume synopsis pass (before beats exist) and the full-text editorial pass (after every issue's script is written, the most expensive stage) — leaving a gap in between. So structural defects spanning the whole book (a cliffhanger raised in one issue and never resolved, a finale that drifts onto a new subplot instead of landing the arc's intended ending, a promised through-line that never pays off, an event staged as the "first" in two different issues, a broken volume-to-volume hand-off) were only caught *after* all the scripts already existed — or not until a human read it. The autopilot now runs a **whole-manuscript beat-continuity pass over every issue's beat sheet, between beat generation and script generation**. Blocking findings are auto-resolved by rewriting just the affected issues' beats and re-checking (bounded, then it pauses for review with the residual findings), so the fix lands before any script is generated. The full-text editorial pass is unchanged and still catches what only the verbatim script can show (pacing, repeated/looping passages, dialogue craft). A new **Beat continuity rounds** control in the autopilot Options tunes how many auto-resolve rounds it attempts (0 skips the pass), saved as a per-install default like the existing Arc-verify and Editorial round knobs.
diff --git a/data.reference/prompts/stage-config.json b/data.reference/prompts/stage-config.json
index 2703ecc52d..04c47ea04e 100644
--- a/data.reference/prompts/stage-config.json
+++ b/data.reference/prompts/stage-config.json
@@ -660,6 +660,13 @@
"returnsJson": true,
"variables": []
},
+ "pipeline-editorial-voice-consistency": {
+ "name": "Pipeline — Editorial Check: Narrative voice / tone consistency",
+ "description": "Editorial check (#1586): the NARRATOR-voice sibling of voice-distinctiveness (which covers per-character dialogue). Fingerprints each issue's narrative tone (diction, register, humor, emotional temperature) and flags an unexplained tonal shift across issues (witty issue 1 → grim issue 3 → witty issue 5 = whiplash) plus drift from the style guide's intended voice. Does not flag a purposeful tonal modulation the story earns. Reads the stitched manuscript + the style guide's intended tone; rolls a per-issue tone fingerprint across chunks. Returns issue-anchored findings.",
+ "model": "default",
+ "returnsJson": true,
+ "variables": []
+ },
"pipeline-editorial-plot-structure": {
"name": "Pipeline — Editorial Check: Plot structure & momentum",
"description": "Editorial check (#1310): the macro pathologies editors flag at the manuscript/arc level — a passive protagonist, deus ex machina / convenient coincidence, idiot plot, flat or unclear stakes that never escalate, a sagging middle with no try-fail rhythm, and dropped subplots. Reads the stitched manuscript plus the reverse-outline scene map + plotline coverage (reconciling fizzled threads against tagged plotlines) and the authored reader-map hooks/payoffs; degrades to a whole-manuscript scan when no outline exists. Returns issue-anchored findings.",
diff --git a/data.reference/prompts/stages/pipeline-editorial-voice-consistency.md b/data.reference/prompts/stages/pipeline-editorial-voice-consistency.md
new file mode 100644
index 0000000000..9a89576b1a
--- /dev/null
+++ b/data.reference/prompts/stages/pipeline-editorial-voice-consistency.md
@@ -0,0 +1,99 @@
+# Pipeline — Editorial Check: Narrative voice / tone consistency
+
+You are a developmental editor doing a single focused pass for ONE concern:
+**the NARRATOR's voice** — whether the narration holds a consistent tone across
+the series, or whether it whiplashes from issue to issue. This is NOT about
+character dialogue (a separate check covers per-character voice). It is about the
+*narration itself*: the diction, register, humor, and emotional temperature of the
+storytelling voice. A series whose narration is witty in issue 1, grim in issue 3,
+then witty again in issue 5 reads as inconsistent — the reader was promised a
+voice, and it keeps changing under them.
+
+Judge two things:
+
+- **Cross-issue whiplash.** Fingerprint each issue's narrative tone, then flag an
+ issue whose narration shifts sharply from the voice the series established — a
+ wry, playful narrator that turns flat and clinical, or a spare, hard-boiled
+ voice that suddenly goes ornate and lyrical — *with nothing in the story making
+ the shift purposeful*. Name the concrete tell (e.g. "issue 1 narration is dry
+ and ironic; issue 3 narration is earnest and sentimental").
+- **Drift from intended voice.** When the style guide declares an intended tone
+ below, flag narration that contradicts it — a guide that asks for "spare,
+ deadpan" narration where an issue reads lush and emotive.
+
+A purposeful tonal modulation is NOT a finding. If the story *earns* a darker or
+lighter register — a grim issue because the plot took a grim turn, a tender close
+after a hard arc — that is craft, not drift. Flag only shifts the narration makes
+**without the story calling for them**. Do NOT flag:
+
+- a tonal change the events justify (a tragedy chapter reading heavier than a
+ setup chapter);
+- a single sentence or paragraph that varies for emphasis — voice consistency is
+ about an issue's *prevailing* narrative tone, not every line;
+- dialogue tone (characters may sound however they sound — that is judged
+ elsewhere); judge only the NARRATION between and around the dialogue.
+
+{{#intendedVoice}}
+## Intended narrative voice
+
+The series style guide declares an intended narrative tone. Measure each issue's
+narration against it — narration that contradicts the declared voice is a finding,
+not just narration that drifts from the other issues.
+
+```
+{{intendedVoice}}
+```
+{{/intendedVoice}}
+
+## Manuscript
+
+The manuscript is stitched from the drafted issues. Section headers attribute
+each chunk to an issue (e.g. `# Issue 3 — Title (prose)`). Use the issue number
+in each header to attribute every finding to its `issueNumber`. A "setup so far"
+digest above (when present) carries the narrative-tone fingerprint of issues in
+earlier parts no longer in the text below — judge a later issue's narration
+against those carried fingerprints, not only against what is visible here.
+
+```
+{{manuscript}}
+```
+
+## Task
+
+1. **Build a tone fingerprint** for each issue with enough narration to judge — a
+ one-line sketch of how the narration sounds (diction, register, humor,
+ emotional temperature, sentence rhythm).
+2. **Flag cross-issue whiplash.** When an issue's narration shifts sharply from
+ the established series voice with no story reason, emit one finding naming the
+ issues, the shift, and what the narration should hold to. Set `location` to the
+ issue + concern (e.g. `Issue 3 — tonal shift`). Quote a short verbatim line of
+ the off-tone narration as the `anchorQuote`.
+3. **Flag drift from the intended voice** (only when an intended voice is present
+ above): narration that contradicts the declared tone. Set `location` to the
+ issue + `voice drift` and quote the offending narration.
+
+Severity: a sharp, unexplained whiplash across a lead stretch of the series, or
+narration that flatly contradicts a declared voice, is medium; a milder wobble is
+low. If the narration holds a consistent voice (or every shift is one the story
+earns), return an empty `findings` array — do not invent drift where the voice is
+steady.
+
+## Output contract
+
+Return ONLY valid JSON matching this shape — no prose, no markdown fence, no
+commentary:
+
+```json
+{
+ "findings": [
+ {
+ "severity": "high|medium|low",
+ "issueNumber": 3,
+ "location": "string — issue + concern (e.g. 'Issue 3 — tonal shift' or 'Issue 3 — voice drift')",
+ "problem": "1–3 sentences naming the tonal shift or the drift from the intended voice, with the concrete tell (what the narration sounds like here vs the established / declared voice)",
+ "suggestion": "1–3 sentences proposing how to realign the narration with the series voice (or, if the shift should stay, what the story needs to do to earn it)",
+ "anchorQuote": "short verbatim quote of the off-tone NARRATION (≤ 200 chars)"
+ }
+ ]
+}
+```
diff --git a/scripts/migrations/134-editorial-voice-consistency-stage.js b/scripts/migrations/134-editorial-voice-consistency-stage.js
new file mode 100644
index 0000000000..62a4bf731f
--- /dev/null
+++ b/scripts/migrations/134-editorial-voice-consistency-stage.js
@@ -0,0 +1,75 @@
+/**
+ * Seed the `pipeline-editorial-voice-consistency` stage into existing installs (#1586).
+ *
+ * Mirrors `133-editorial-secondary-arc-stage.js`: copies the `.md` template from
+ * `data.reference/prompts/stages/` and merges the stage-config entry into
+ * `data/prompts/stage-config.json`. Boot runs migrations (server/index.js) but NOT
+ * `setup-data.js`, so an upgrade that pulls + `pm2 restart`s (rather than running
+ * `update.sh`) would otherwise leave the new voice-consistency stage unseeded and
+ * the `style.voice-consistency` editorial check would throw "Stage not found" the
+ * first time it runs.
+ */
+
+import { access, copyFile, mkdir, readFile, writeFile, constants } from 'fs/promises';
+import { dirname, join } from 'path';
+
+const FILENAME = 'pipeline-editorial-voice-consistency.md';
+const STAGE_KEY = 'pipeline-editorial-voice-consistency';
+
+export default {
+ async up({ rootDir }) {
+ const stagesDir = join(rootDir, 'data', 'prompts', 'stages');
+ await mkdir(stagesDir, { recursive: true });
+
+ const dataPath = join(stagesDir, FILENAME);
+ const samplePath = join(rootDir, 'data.reference', 'prompts', 'stages', FILENAME);
+
+ const exists = await access(dataPath, constants.F_OK).then(() => true, () => false);
+ if (exists) {
+ console.log(`📝 pipeline-editorial-voice-consistency prompt: already present`);
+ } else {
+ const sampleExists = await access(samplePath, constants.F_OK).then(() => true, () => false);
+ if (!sampleExists) {
+ console.warn(`⚠️ pipeline-editorial-voice-consistency: sample missing for ${FILENAME} — skipping copy`);
+ } else {
+ try {
+ await copyFile(samplePath, dataPath);
+ console.log(`✅ seeded ${FILENAME}`);
+ } catch (err) {
+ console.warn(`⚠️ pipeline-editorial-voice-consistency: copy failed for ${FILENAME}: ${err.message}`);
+ }
+ }
+ }
+
+ const installedConfigPath = join(rootDir, 'data', 'prompts', 'stage-config.json');
+ const sampleConfigPath = join(rootDir, 'data.reference', 'prompts', 'stage-config.json');
+ const sampleConfigExists = await access(sampleConfigPath, constants.F_OK).then(() => true, () => false);
+ if (!sampleConfigExists) {
+ console.warn('⚠️ pipeline-editorial-voice-consistency: data.reference stage-config.json missing — cannot resolve entry; skipping config write');
+ return;
+ }
+ try {
+ const sample = JSON.parse(await readFile(sampleConfigPath, 'utf8'));
+ const installedExists = await access(installedConfigPath, constants.F_OK).then(() => true, () => false);
+ const installed = installedExists
+ ? JSON.parse(await readFile(installedConfigPath, 'utf8'))
+ : { stages: {} };
+ installed.stages = installed.stages || {};
+ if (installed.stages[STAGE_KEY]) {
+ console.log(`📝 pipeline-editorial-voice-consistency stage-config: already present`);
+ return;
+ }
+ if (!sample?.stages?.[STAGE_KEY]) {
+ console.warn(`⚠️ pipeline-editorial-voice-consistency: sample stage-config missing ${STAGE_KEY} — skipping`);
+ return;
+ }
+ installed.stages[STAGE_KEY] = sample.stages[STAGE_KEY];
+ await mkdir(dirname(installedConfigPath), { recursive: true });
+ await writeFile(installedConfigPath, JSON.stringify(installed, null, 2) + '\n', 'utf8');
+ const action = installedExists ? 'merged' : 'created';
+ console.log(`📝 pipeline-editorial-voice-consistency stage-config (${action}): 1 added`);
+ } catch (err) {
+ console.warn(`⚠️ pipeline-editorial-voice-consistency: stage-config merge failed: ${err.message}`);
+ }
+ },
+};
diff --git a/scripts/migrations/134-editorial-voice-consistency-stage.test.js b/scripts/migrations/134-editorial-voice-consistency-stage.test.js
new file mode 100644
index 0000000000..e5687cd87d
--- /dev/null
+++ b/scripts/migrations/134-editorial-voice-consistency-stage.test.js
@@ -0,0 +1,86 @@
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import { mkdtempSync, rmSync, mkdirSync, writeFileSync, readFileSync, existsSync } from 'fs';
+import { tmpdir } from 'os';
+import { join, dirname } from 'path';
+import { fileURLToPath } from 'url';
+
+import migration from './134-editorial-voice-consistency-stage.js';
+
+// scripts/migrations/<this> → ../.. is the repo root (matches _testHelpers.js).
+const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '..', '..');
+
+// First-shipment seed migration (mirrors 133) — no MD5 bookkeeping, so the
+// seed / no-clobber behavior is asserted directly.
+
+const FILENAME = 'pipeline-editorial-voice-consistency.md';
+const STAGE_KEY = 'pipeline-editorial-voice-consistency';
+const BODY = '# Narrative voice / tone consistency\n\nshipped body\n';
+
+describe('migration 134 — seed editorial-voice-consistency stage', () => {
+ let rootDir;
+ let stagesDir;
+ let refStagesDir;
+ let installedConfigPath;
+
+ const seedReference = ({ withConfig = true } = {}) => {
+ writeFileSync(join(refStagesDir, FILENAME), BODY);
+ if (withConfig) {
+ const refConfigPath = join(rootDir, 'data.reference', 'prompts', 'stage-config.json');
+ writeFileSync(
+ refConfigPath,
+ JSON.stringify({ stages: { [STAGE_KEY]: { name: STAGE_KEY, description: 'desc', model: 'default', returnsJson: true, variables: [] } } }, null, 2) + '\n',
+ );
+ }
+ };
+
+ beforeEach(() => {
+ rootDir = mkdtempSync(join(tmpdir(), 'migration-134-'));
+ stagesDir = join(rootDir, 'data', 'prompts', 'stages');
+ refStagesDir = join(rootDir, 'data.reference', 'prompts', 'stages');
+ installedConfigPath = join(rootDir, 'data', 'prompts', 'stage-config.json');
+ mkdirSync(stagesDir, { recursive: true });
+ mkdirSync(refStagesDir, { recursive: true });
+ });
+
+ afterEach(() => {
+ rmSync(rootDir, { recursive: true, force: true });
+ });
+
+ it('seeds the .md template and merges the stage-config entry on a fresh install', async () => {
+ seedReference();
+ await expect(migration.up({ rootDir })).resolves.not.toThrow();
+ expect(readFileSync(join(stagesDir, FILENAME), 'utf8')).toBe(BODY);
+ const installed = JSON.parse(readFileSync(installedConfigPath, 'utf8'));
+ expect(installed.stages[STAGE_KEY]).toMatchObject({ returnsJson: true });
+ });
+
+ it('is idempotent and never clobbers a customized .md or an existing stage-config entry', async () => {
+ seedReference();
+ const customBody = '# CUSTOMIZED — do not overwrite\n';
+ writeFileSync(join(stagesDir, FILENAME), customBody);
+ writeFileSync(
+ installedConfigPath,
+ JSON.stringify({ stages: { [STAGE_KEY]: { name: 'user-tuned', model: 'custom' } } }, null, 2) + '\n',
+ );
+
+ await migration.up({ rootDir });
+
+ expect(readFileSync(join(stagesDir, FILENAME), 'utf8')).toBe(customBody);
+ const installed = JSON.parse(readFileSync(installedConfigPath, 'utf8'));
+ expect(installed.stages[STAGE_KEY]).toEqual({ name: 'user-tuned', model: 'custom' });
+ });
+
+ it('does not throw when the data.reference samples are missing', async () => {
+ await expect(migration.up({ rootDir })).resolves.not.toThrow();
+ expect(existsSync(join(stagesDir, FILENAME))).toBe(false);
+ });
+
+ it('matches the live shipped stage-config key + prompt file (drift catch)', () => {
+ const refConfig = JSON.parse(
+ readFileSync(join(repoRoot, 'data.reference', 'prompts', 'stage-config.json'), 'utf8'),
+ );
+ expect(refConfig.stages[STAGE_KEY], `stage-config missing ${STAGE_KEY}`).toBeTruthy();
+ expect(refConfig.stages[STAGE_KEY].returnsJson).toBe(true);
+ expect(existsSync(join(repoRoot, 'data.reference', 'prompts', 'stages', FILENAME))).toBe(true);
+ });
+});
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.js
index 438260520f..8d207eca4c 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -315,6 +315,13 @@ export const TELLING_EMOTION_STAGE = 'pipeline-editorial-telling-emotion';
export const ON_THE_NOSE_STAGE = 'pipeline-editorial-on-the-nose';
export const VOICE_DISTINCTIVENESS_STAGE = 'pipeline-editorial-voice-distinctiveness';
+// Stage name for the narrator voice / tone-consistency LLM check (#1586) — the
+// narration-level sibling of voice-distinctiveness (which covers per-CHARACTER
+// dialogue). Ships in data.reference/prompts/stages/ + stage-config.json (fresh
+// installs via setup-data.js) and migrates to existing installs via migration 134
+// (boot runs migrations but NOT setup-data, so the migration is required).
+export const VOICE_CONSISTENCY_STAGE = 'pipeline-editorial-voice-consistency';
+
// Render each canon character's authored voice fields into a compact text block
// the voice-distinctiveness LLM check passes alongside the manuscript, so the
// model can flag lines that contradict a character's recorded speechPattern /
@@ -343,6 +350,25 @@ export function characterVoiceProfiles(canon) {
return `Authored character voices (canon speechPattern / speechAccent):\n${lines.join('\n')}`;
}
+// Render the series style guide's INTENDED narrative voice — the authored `tone`
+// words (e.g. "witty", "grim", "lyrical") — into a compact block the narrator
+// voice-consistency check (#1586) passes alongside the manuscript, so the model
+// can measure each issue's narration against the declared intent, not just
+// against the other issues. Pure + deterministic so it's unit-testable and its
+// token cost counts into the per-chunk overhead. Type-guarded (styleGuide rides
+// peer sync, so a hand-edited / older-peer guide could carry a non-array `tone`
+// or non-string entries). Returns '' when the guide declares no tone (the
+// prompt's {{#intendedVoice}} section then renders nothing and the check degrades
+// to a pure cross-issue consistency scan).
+export function intendedVoiceSummary(styleGuide) {
+ const raw = Array.isArray(styleGuide?.tone) ? styleGuide.tone : [];
+ const tone = raw
+ .filter((t) => typeof t === 'string' && t.trim())
+ .map((t) => t.trim());
+ if (!tone.length) return '';
+ return `Style guide — intended narrative tone/voice: ${tone.join(', ')}.`;
+}
+
// Render each canon character's contradiction-relevant FACTS into a compact text
// block the timeline / canon-contradiction check (#1581) passes alongside the
// manuscript, so the model can reconcile the prose against the established bible:
@@ -5219,6 +5245,65 @@ export const EDITORIAL_CHECKS = [
});
},
},
+ {
+ id: 'style.voice-consistency',
+ sources: ['manuscript', 'series.styleGuide'],
+ label: 'Narrative voice / tone consistency (LLM)',
+ description:
+ "LLM scan — the NARRATOR-voice sibling of dialogue.voice-distinctiveness (which covers per-character dialogue, not the narration). Fingerprints each issue's narrative tone (diction, register, humor, emotional temperature) and flags an unexplained tonal shift ACROSS issues — narration witty in issue 1, grim in issue 3, witty again in issue 5 is tonal whiplash — plus drift from the series style guide's intended voice. Does NOT flag a purposeful tonal modulation the story earns (a darker chapter a grim turn calls for). Voice consistency is part of the promise to the reader; drift reads as inconsistency. Because the comparison spans issues, the per-issue tone fingerprint is carried forward across manuscript chunks so a later issue is judged against the tone the series established.",
+ scope: 'series',
+ kind: 'llm',
+ category: 'style',
+ // Tonal drift is a polish/texture concern, so a moderate wobble floors at
+ // 'low'; the prompt directs the model to mark a sharp, unexplained whiplash
+ // 'medium'.
+ severityDefault: 'low',
+ defaultEnabled: true,
+ // Reads the stitched manuscript corpus — so the runner only pays the
+ // section-collection I/O when a manuscript-consuming check is enabled.
+ needsManuscript: true,
+ configSchema: z.object({
+ // Cap findings per run so a long manuscript can't flood the review.
+ maxFindings: z.number().int().min(1).max(50).default(12),
+ }),
+ configFields: [
+ {
+ key: 'maxFindings',
+ label: 'Max findings per run',
+ type: 'number',
+ min: 1,
+ max: 50,
+ step: 1,
+ help: 'Cap findings so a long manuscript can not flood the review.',
+ },
+ ],
+ gate: (ctx) => (ctx.manuscript || '').trim().length > 0,
+ run: (ctx) => {
+ // The intended-voice block is fixed per-call overhead (re-sent on each chunk)
+ // and pure context: it lets the model measure each issue's narration against
+ // the declared tone, not just against the other issues. The check degrades
+ // gracefully — no style-guide tone ⇒ {{#intendedVoice}} renders nothing and
+ // the model still flags internal cross-issue whiplash.
+ const intendedVoice = intendedVoiceSummary(ctx.series?.styleGuide);
+ return runManuscriptLlmCheck(ctx, {
+ stage: VOICE_CONSISTENCY_STAGE,
+ category: 'style',
+ context: { intendedVoice },
+ buildVars: (manuscript, _meta, c) => ({ manuscript, intendedVoice: c.intendedVoice }),
+ // Narrator-voice consistency is a whole-series judgment: each issue's tone
+ // is spread across chunks, so a per-chunk view can't tell "the series
+ // shifted" from "this chunk only sampled one issue". Roll a per-issue tone
+ // fingerprint forward so a later chunk judges against the tone the series
+ // established (and the style guide's intent).
+ crossChunkSetup: true,
+ setupFocus:
+ "For each issue (use the `# Issue N` section headers), capture a compact fingerprint of the NARRATOR's "
+ + 'voice and tone — diction (plain vs ornate), register (formal vs casual), humor level (witty / wry / earnest / grim), '
+ + 'sentence rhythm, and emotional temperature. Carry these per-issue fingerprints forward so a later issue\'s '
+ + "narration can be judged against the tone the series established earlier and against the style guide's intended voice.",
+ });
+ },
+ },
{
id: 'prose.kill-your-darlings',
sources: ['manuscript'],
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index ba24e007cd..054c3af146 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -32,6 +32,7 @@ import {
authoredCliffhangerSummary,
sceneGroundingSummary,
characterVoiceProfiles,
+ intendedVoiceSummary,
plotlineCoverageSummary,
scenePovSummary,
secondaryCharacterPresenceSummary,
@@ -1549,6 +1550,88 @@ describe('character.secondary-arc — LLM check (#1585)', () => {
});
});
+describe('style.voice-consistency — LLM check (#1586)', () => {
+ const VOICE_CONSISTENCY = 'style.voice-consistency';
+ const wholeCtx = (overrides = {}) => ({
+ manuscript: '# Issue 1\n\nThe rain came down, wry and unhurried, as it always did in this town.',
+ config: { maxFindings: 12 },
+ severityDefault: 'low',
+ series: { styleGuide: { tone: ['wry', 'deadpan'] } },
+ planManuscriptChunks: async () => ['# Issue 1\n\nnarration'],
+ callStagedLLM: async () => ({ content: { findings: [] } }),
+ ...overrides,
+ });
+
+ it('is registered as a series-scoped LLM check reading manuscript + style guide', () => {
+ const check = getCheck(VOICE_CONSISTENCY);
+ expect(check.kind).toBe('llm');
+ expect(check.scope).toBe('series');
+ expect(check.category).toBe('style');
+ expect(check.severityDefault).toBe('low');
+ expect(check.sources).toEqual(['manuscript', 'series.styleGuide']);
+ expect(check.needsManuscript).toBe(true);
+ });
+
+ it('only runs when there is drafted prose to scan', () => {
+ const check = getCheck(VOICE_CONSISTENCY);
+ expect(check.gate({ manuscript: '' })).toBe(false);
+ expect(check.gate({ manuscript: '# Issue 1\n\nprose' })).toBeTruthy();
+ });
+
+ it('feeds the style guide intended voice alongside the manuscript and forces the style category', async () => {
+ let seenVars = null;
+ const ctx = wholeCtx({
+ planManuscriptChunks: async (_stage, opts) => {
+ expect(opts.context).toHaveProperty('intendedVoice');
+ expect(opts.fixedOverheadTokens).toBeGreaterThan(0);
+ return ['# Issue 1\n\nnarration'];
+ },
+ callStagedLLM: async (_stage, vars) => {
+ seenVars = vars;
+ return { content: { findings: [{ severity: 'medium', issueNumber: 3, location: 'Issue 3 — tonal shift', problem: 'narration turns earnest', anchorQuote: 'how he loved her' }] } };
+ },
+ });
+ const findings = await getCheck(VOICE_CONSISTENCY).run(ctx);
+ expect(seenVars.intendedVoice).toContain('wry');
+ expect(seenVars.intendedVoice).toContain('deadpan');
+ expect(findings).toHaveLength(1);
+ expect(findings[0].category).toBe('style');
+ expect(findings[0].location).toBe('Issue 3 — tonal shift');
+ });
+
+ it('still runs (cross-issue whiplash) when no style guide tone is declared', async () => {
+ let seenVars = null;
+ const ctx = wholeCtx({
+ series: undefined,
+ callStagedLLM: async (_stage, vars) => { seenVars = vars; return { content: { findings: [] } }; },
+ });
+ await getCheck(VOICE_CONSISTENCY).run(ctx);
+ expect(seenVars.intendedVoice).toBe('');
+ });
+});
+
+describe('intendedVoiceSummary helper (#1586)', () => {
+ it('renders the style guide tone words', () => {
+ const out = intendedVoiceSummary({ tone: ['wry', 'deadpan', 'noir'] });
+ expect(out).toContain('intended narrative tone/voice');
+ expect(out).toContain('wry, deadpan, noir');
+ });
+
+ it('returns "" when the guide declares no tone', () => {
+ expect(intendedVoiceSummary({ tone: [] })).toBe('');
+ expect(intendedVoiceSummary({})).toBe('');
+ expect(intendedVoiceSummary(null)).toBe('');
+ expect(intendedVoiceSummary(undefined)).toBe('');
+ });
+
+ it('tolerates a malformed tone field without throwing', () => {
+ expect(() => intendedVoiceSummary({ tone: 'not-an-array' })).not.toThrow();
+ expect(intendedVoiceSummary({ tone: 'not-an-array' })).toBe('');
+ expect(() => intendedVoiceSummary({ tone: [null, 42, ' ', 'wry'] })).not.toThrow();
+ expect(intendedVoiceSummary({ tone: [null, 42, ' ', 'wry'] })).toBe('Style guide — intended narrative tone/voice: wry.');
+ });
+});
+
describe('declaredThemesSummary (#1317)', () => {
it('returns an empty string when there are no themes', () => {
expect(declaredThemesSummary(null)).toBe('');