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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: editorial check classifies unmodeled proper nouns as characters (#1412)
Adam Eivy92aaaf5067b0
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex b0c5525d23..6c2580c994 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## Added+- **[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). 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)- **[issue-1316] Editorial health score + revision-trend tracking — *manage* the draft, not just receive findings.** A new **Editorial Health** panel (Create → Editorial Checks, alongside the findings triage) turns the point-in-time manuscript-review findings into a metric you can steer by. A transparent, deterministic **health score** (0–100, per series with a per-issue drill-down) is computed from the OPEN findings weighted by severity — `100 − Σ weight(severity)` with published weights (high 12 / medium 5 / low 1), so it's never a black box; accepted (fixed) and dismissed (waived) findings cost nothing. A **revision-trend ledger** snapshots the open-finding counts (by severity + category) on each editorial-checks / completeness run — the run is the revision boundary — so the panel renders a **score sparkline** across revisions, the most-recent-revision **delta**, and per-category **regressions** (a category that got *worse* after an edit pass). A configurable **readiness gate** ("no open high findings" by default, or the stricter "no high or medium", or "none") is the convergence signal the UI shows as **Ready / Not ready** *and* that the **autopilot editorial loop** now reads as a final gate (`editorialHealthGate`): after both editorial passes seed their findings, autopilot pauses with the residual blockers if the manuscript isn't clean — catching a blocker the registry checks surface *after* the completeness loop converged. The trend ledger is install-local telemetry (`data/pipeline-editorial-health/{seriesId}.json`, not synced); the score/readiness are derived live from the synced review. Scoring is pure + unit-tested. (`server/services/pipeline/editorialScore.js`, `server/routes/pipeline/editorial.js`, `server/services/pipeline/{editorial/checkRunner,manuscriptCompletenessRunner,seriesAutopilot}.js`, `client/src/components/pipeline/editorial/EditorialHealthPanel.jsx`, `client/src/lib/editorialHealth.js`, Part of #1283, #1316)diff --git a/client/src/components/pipeline/manuscript/constants.js b/client/src/components/pipeline/manuscript/constants.jsindex e7dbd2751b..07aec3cf3f 100644--- a/client/src/components/pipeline/manuscript/constants.js+++ b/client/src/components/pipeline/manuscript/constants.js@@ -41,6 +41,9 @@ export const CATEGORY_LABEL = {// Theme-coherence findings (#1317): stated-but-undramatized / dropped / unpaid// themes and emergent-theme suggestions from the theme.coherence check.theme: 'Theme',+ // Casting findings (#1292/#1312/#1412): roster economy / throwaway names, cast+ // representation balance, and unmodeled proper nouns used as character names.+ casting: 'Casting',pacing: 'Pacing',continuity: 'Continuity',style: 'Style',diff --git a/data.reference/prompts/stage-config.json b/data.reference/prompts/stage-config.jsonindex 6a40ac80fb..edc88aff7f 100644--- a/data.reference/prompts/stage-config.json+++ b/data.reference/prompts/stage-config.json@@ -638,6 +638,13 @@"model": "default","returnsJson": true,"variables": []+ },+ "pipeline-editorial-unmodeled-names": {+ "name": "Pipeline — Editorial Check: Unmodeled proper nouns used as character names",+ "description": "Editorial check (#1412): the LLM-assisted half of roster economy (#1292). Surfaces capitalized proper nouns used as apparent CHARACTER names that are ABSENT from the story bible (canon.characters names + aliases), and classifies each (named person vs. place / organization / brand / honorific the deterministic roster.economy scan can't distinguish). Flags throwaway one-appearance unmodeled names, suggesting adding them to canon or leaving them unnamed. Reads the stitched manuscript plus the canon roster; treats an empty bible as every named proper noun being a candidate. Returns issue-anchored findings.",+ "model": "default",+ "returnsJson": true,+ "variables": []}}}diff --git a/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md b/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.mdnew file mode 100644index 0000000000..8851455aed--- /dev/null+++ b/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md@@ -0,0 +1,90 @@+# Pipeline — Editorial Check: Unmodeled proper nouns used as character names++You are a developmental editor doing a single focused pass for ONE concern:+**unmodeled character names** — capitalized proper nouns the prose uses as+apparent CHARACTER names that were never added to the story bible. Your job is to+surface them and CLASSIFY each one, because a deterministic name scan can't tell a+person from a place, an organization, a brand, or an honorific.++Flag only these (each is a distinct finding):++- **Unmodeled named character** — a proper noun used as a person's name (someone+ speaks, acts, is addressed, or is referred to as a character) that is NOT in the+ known-characters list below. Name them so the author can decide: add to canon, or+ leave unnamed.+- **Throwaway unmodeled name** — an unmodeled named character who appears only+ once (a named body the reader is told to remember but who never recurs and was+ never bibled). Suggest either adding them to canon if they are meant to matter, or+ recasting them as an unnamed description ("the bartender") so the reader isn't+ asked to track a name that goes nowhere.++Do NOT flag:++- Any name in the known-characters list, or one of its listed aliases (those are+ already modeled — that's the whole point of the list).+- A proper noun that is clearly NOT a person: a place (city, country, building,+ region), an organization/faction/company, a brand/product, a title or honorific+ used without a name ("the Captain", "your Majesty"), a deity/abstraction, or a+ day/month. These are the false positives a deterministic scan can't rule out — it+ is YOUR job to exclude them.+- A descriptive epithet that functions as an unnamed role ("the stranger", "the+ old woman") — that is already unnamed, which is the fix we'd suggest anyway.++{{#knownCharacters}}+## Known characters++```+{{knownCharacters}}+```+{{/knownCharacters}}+{{^knownCharacters}}+## Known characters++The story bible has no characters yet, so EVERY proper noun the prose uses as a+character name is unmodeled. Surface each named character you find (still excluding+places, organizations, brands, and bare honorifics).+{{/knownCharacters}}++## 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`.++```+{{manuscript}}+```++## Task++Scan the prose for capitalized proper nouns used as apparent character names,+drop every one that is already in the known-characters list (name or alias) or is+clearly a non-person (place / organization / brand / bare honorific), and report+what remains. For each finding set `location` to the classification + the name,+e.g. `Unmodeled character — "Marguerite"` or `Throwaway name — "Old Henrik" (1+appearance)`. Quote a short verbatim anchor (≤ 200 chars) at the name's first use.+Severity: a recurring unmodeled character who carries scenes is medium; a one-+appearance throwaway name is low. If every named character in the prose is already+modeled (or the only unmodeled proper nouns are places/orgs/brands/honorifics),+return an empty `findings` array. Do not invent names the prose doesn't use, and do+not flag a name just because it is rare — only because it is UNMODELED.++## 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 — classification + name (e.g. 'Unmodeled character — \"Marguerite\"' or 'Throwaway name — \"Old Henrik\" (1 appearance)')",+ "problem": "1–3 sentences naming the proper noun, why you classified it as a character (not a place/org/brand/honorific), and whether it recurs or appears only once",+ "suggestion": "1–3 sentences proposing how to resolve it (add to canon if it should matter, or recast as an unnamed description if it's a throwaway)",+ "anchorQuote": "short verbatim quote at the name's first use (≤ 200 chars)"+ }+ ]+}+```diff --git a/scripts/migrations/116-editorial-unmodeled-names-stage.js b/scripts/migrations/116-editorial-unmodeled-names-stage.jsnew file mode 100644index 0000000000..6d06a8660a--- /dev/null+++ b/scripts/migrations/116-editorial-unmodeled-names-stage.js@@ -0,0 +1,75 @@+/**+ * Seed the `pipeline-editorial-unmodeled-names` stage into existing installs (#1412).+ *+ * Mirrors `115-editorial-theme-coherence-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 unmodeled-names stage+ * unseeded and the `roster.unmodeled-names` 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-unmodeled-names.md';+const STAGE_KEY = 'pipeline-editorial-unmodeled-names';++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-unmodeled-names prompt: already present`);+ } else {+ const sampleExists = await access(samplePath, constants.F_OK).then(() => true, () => false);+ if (!sampleExists) {+ console.warn(`⚠️ pipeline-editorial-unmodeled-names: sample missing for ${FILENAME} — skipping copy`);+ } else {+ try {+ await copyFile(samplePath, dataPath);+ console.log(`✅ seeded ${FILENAME}`);+ } catch (err) {+ console.warn(`⚠️ pipeline-editorial-unmodeled-names: 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-unmodeled-names: 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-unmodeled-names stage-config: already present`);+ return;+ }+ if (!sample?.stages?.[STAGE_KEY]) {+ console.warn(`⚠️ pipeline-editorial-unmodeled-names: 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-unmodeled-names stage-config (${action}): 1 added`);+ } catch (err) {+ console.warn(`⚠️ pipeline-editorial-unmodeled-names: stage-config merge failed: ${err.message}`);+ }+ },+};diff --git a/scripts/migrations/116-editorial-unmodeled-names-stage.test.js b/scripts/migrations/116-editorial-unmodeled-names-stage.test.jsnew file mode 100644index 0000000000..d7f072db0d--- /dev/null+++ b/scripts/migrations/116-editorial-unmodeled-names-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 './116-editorial-unmodeled-names-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 115) — no MD5 bookkeeping, so the+// seed / no-clobber behavior is asserted directly.++const FILENAME = 'pipeline-editorial-unmodeled-names.md';+const STAGE_KEY = 'pipeline-editorial-unmodeled-names';+const BODY = '# Unmodeled proper nouns used as character names\n\nshipped body\n';++describe('migration 116 — seed editorial-unmodeled-names 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-116-'));+ 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.jsindex 54bf3855f1..93f5fd654d 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -336,6 +336,42 @@ export function declaredThemesSummary(themes) {return `Declared themes (authored on the story arc):\n${lines.join('\n')}`;}+// Stage name for the unmodeled-proper-nouns LLM check (#1412). Ships in+// data.reference/prompts/stages/ + stage-config.json (fresh installs via+// setup-data.js) and migrates to existing installs via migration 116 (boot runs+// migrations but NOT setup-data, so the migration is required). Reads the stitched+// manuscript plus the canon roster (names + aliases) and asks the model to surface+// capitalized proper nouns used as apparent CHARACTER names that are absent from+// canon — the LLM-assisted half of roster economy (#1292) the deterministic+// `roster.economy` scan deliberately leaves alone (it can't tell a person from a+// place/org/brand/honorific).+export const UNMODELED_NAMES_STAGE = 'pipeline-editorial-unmodeled-names';++// Render the canon roster's names + aliases (#1412) into a compact text block the+// unmodeled-names check passes alongside the manuscript, so the model knows which+// proper nouns are ALREADY modeled (and therefore must NOT be flagged) and only+// surfaces apparent character names absent from this list. Pure + deterministic so+// it's unit-testable and its token cost can be counted into the per-chunk overhead.+// Returns '' when no canon character has a usable name (the prompt's+// `{{#knownCharacters}}` section then renders nothing and EVERY named proper noun in+// the prose is a candidate — exactly right when the bible is empty). Reuses+// `characterNameTokens` so name + aliases render with the same trim/de-dup the+// deterministic matcher uses.+export function canonRosterNamesSummary(canon) {+ const chars = Array.isArray(canon?.characters) ? canon.characters : [];+ const lines = [];+ for (const c of chars) {+ // Require a real name — an alias-only row isn't a named character (mirrors+ // buildRosterAppearances, which skips nameless rows). characterNameTokens then+ // returns the trimmed name first, followed by de-duped aliases.+ if (!c || typeof c.name !== 'string' || !c.name.trim()) continue;+ const [name, ...aliases] = characterNameTokens(c);+ lines.push(aliases.length ? `- ${name} (also: ${aliases.join(', ')})` : `- ${name}`);+ }+ if (!lines.length) return '';+ return `Known characters (already in the story bible — do NOT flag these or their aliases):\n${lines.join('\n')}`;+}+// Render the authored reader-map cliffhangers (#1298) into a compact text block// the chapter-ending check passes alongside the manuscript so the model// reconciles its DETECTED endings against the issue-boundary tugs the writer@@ -1768,6 +1804,58 @@ export const EDITORIAL_CHECKS = [return findings;},},+ {+ // LLM-assisted companion to roster.economy (#1412, part of #1283). The+ // deterministic roster.economy scan only sees canon names/aliases; it can't+ // detect proper nouns used as apparent CHARACTER names that were never bibled+ // (the LLM-assist half #1292 called out). This check surfaces those — and+ // classifies them (is this token actually a named character, vs a place/org/+ // brand/honorific the deterministic scan can't tell apart).+ id: 'roster.unmodeled-names',+ sources: ['manuscript', 'canon'],+ label: 'Unmodeled proper nouns used as character names',+ description:+ 'LLM scan — surfaces capitalized proper nouns used as apparent CHARACTER names that are ABSENT from the story bible (canon.characters names + aliases), and classifies each (is this actually a named person, vs a place, organization, brand, or honorific the deterministic roster.economy scan can\'t distinguish). Flags throwaway one-appearance unmodeled names readers are asked to remember, suggesting either adding them to canon or leaving them unnamed. The LLM-assisted half of roster economy (#1292) that the deterministic check deliberately leaves alone.',+ scope: 'series',+ kind: 'llm',+ category: 'casting',+ 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 large unmodeled cast 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 large unmodeled cast can not flood the review.',+ },+ ],+ // Needs prose to scan. Unlike roster.economy this does NOT require a populated+ // canon — an EMPTY bible is the strongest case (every named proper noun is+ // unmodeled), and the prompt's {{^knownCharacters}} branch handles it.+ gate: (ctx) => (ctx.manuscript || '').trim().length > 0,+ run: (ctx) => {+ // The known-character roster is fixed per-call overhead (re-sent on each+ // chunk) — it's the exclusion list the model classifies against. Counted into+ // the per-chunk budget so the manuscript isn't squeezed past the window.+ const knownCharacters = canonRosterNamesSummary(ctx.canon);+ return runManuscriptLlmCheck(ctx, {+ stage: UNMODELED_NAMES_STAGE,+ category: 'casting',+ overheadTokens: EDITORIAL_PROMPT_OVERHEAD_TOKENS + estimateTokens(knownCharacters),+ buildVars: (manuscript) => ({ manuscript, knownCharacters }),+ });+ },+ },{id: 'comic.lettering-density',sources: ['comicScript'],diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex 9057b66b8b..ce451ec877 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -34,6 +34,7 @@ import {plotlineCoverageSummary,scenePovSummary,declaredThemesSummary,+ canonRosterNamesSummary,} from './checkRegistry.js';const NAMING = 'naming.dissimilar-names';@@ -47,6 +48,7 @@ const WHITE_ROOM = 'scene.white-room';const PLOT_STRUCTURE = 'plot.structure-momentum';const HEAD_HOPPING = 'pov.head-hopping';const THEME_COHERENCE = 'theme.coherence';+const UNMODELED_NAMES = 'roster.unmodeled-names';// A minimal valid stored custom-check definition.const customDef = (over = {}) => ({@@ -913,6 +915,96 @@ describe('declaredThemesSummary (#1317)', () => {});});+describe('roster.unmodeled-names — LLM check (#1412)', () => {+ const wholeCtx = (overrides = {}) => ({+ manuscript: '# Issue 1\n\nMarguerite drew her sword as the bells of Veridia rang.',+ config: { maxFindings: 12 },+ severityDefault: 'low',+ canon: { characters: [{ name: 'Robert', aliases: ['Bob'] }] },+ planManuscriptChunks: async () => ['# Issue 1\n\nMarguerite drew her sword.'],+ callStagedLLM: async () => ({ content: { findings: [] } }),+ ...overrides,+ });++ it('is registered as a series-scoped LLM casting check reading manuscript + canon', () => {+ const check = getCheck(UNMODELED_NAMES);+ expect(check.kind).toBe('llm');+ expect(check.scope).toBe('series');+ expect(check.category).toBe('casting');+ expect(check.sources).toEqual(['manuscript', 'canon']);+ expect(check.needsManuscript).toBe(true);+ });++ it('runs whenever there is prose — even with an EMPTY canon (every name is unmodeled)', () => {+ const check = getCheck(UNMODELED_NAMES);+ expect(check.gate({ manuscript: '' })).toBe(false);+ // Unlike roster.economy, it does NOT require a populated canon.+ expect(check.gate({ manuscript: '# Issue 1\n\nprose', canon: { characters: [] } })).toBeTruthy();+ expect(check.gate({ manuscript: '# Issue 1\n\nprose' })).toBeTruthy();+ });++ it('passes the manuscript + known-character roster to the model and forces the casting category', async () => {+ let seenVars = null;+ const ctx = wholeCtx({+ planManuscriptChunks: async (_stage, opts) => {+ // The known-character roster rides as fixed overhead.+ expect(opts.overheadTokens).toBeGreaterThan(0);+ return ['# Issue 1\n\nMarguerite drew her sword.'];+ },+ callStagedLLM: async (_stage, vars) => {+ seenVars = vars;+ return { content: { findings: [{ severity: 'medium', issueNumber: 1, location: 'Unmodeled character — "Marguerite"', problem: 'Named but not in canon' }] } };+ },+ });+ const findings = await getCheck(UNMODELED_NAMES).run(ctx);+ expect(seenVars.manuscript).toBe('# Issue 1\n\nMarguerite drew her sword.');+ expect(seenVars.knownCharacters).toContain('Robert');+ expect(seenVars.knownCharacters).toContain('Bob');+ expect(findings).toHaveLength(1);+ expect(findings[0].category).toBe('casting');+ expect(findings[0].location).toBe('Unmodeled character — "Marguerite"');+ });++ it('passes an empty roster var when the canon has no characters', async () => {+ let seenVars = null;+ const ctx = wholeCtx({+ canon: { characters: [] },+ callStagedLLM: async (_stage, vars) => { seenVars = vars; return { content: { findings: [] } }; },+ });+ await getCheck(UNMODELED_NAMES).run(ctx);+ expect(seenVars.knownCharacters).toBe('');+ });+});++describe('canonRosterNamesSummary (#1412)', () => {+ it('returns an empty string when there are no usable canon names', () => {+ expect(canonRosterNamesSummary(null)).toBe('');+ expect(canonRosterNamesSummary(undefined)).toBe('');+ expect(canonRosterNamesSummary({ characters: [] })).toBe('');+ expect(canonRosterNamesSummary({ characters: [{ name: ' ' }, { aliases: ['x'] }] })).toBe('');+ });++ it('renders one bullet per character with aliases appended', () => {+ const out = canonRosterNamesSummary({ characters: [+ { name: 'Robert', aliases: ['Bob', 'Bobby'] },+ { name: 'Alice' },+ ] });+ expect(out).toContain('do NOT flag these');+ expect(out).toContain('- Robert (also: Bob, Bobby)');+ expect(out).toContain('- Alice');+ });++ it('is type-guarded against hand-edited / older-peer rows and de-dups name vs alias', () => {+ const out = canonRosterNamesSummary({ characters: [+ 42,+ null,+ { name: ' Henrik ', aliases: ['Henrik', ' ', 7] },+ ] });+ // Name trimmed; the alias equal to the name is de-duped, blanks/non-strings dropped.+ expect(out.split('\n').filter((l) => l.startsWith('- '))).toEqual(['- Henrik']);+ });+});+describe('endings.cliffhanger — LLM check (#1298)', () => {const wholeCtx = (overrides = {}) => ({manuscript: '# Issue 1\n\nAnd so, with the war finally over, they all went home and rested.',