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): gate throwaway/recurrence judgment to final chunk + cross-chunk digest (#1412)

Adam Eivyb32a5d7f6fc7
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 6c2580c994..76f0493d04 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,7 +2,7 @@
## 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-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). Because whether an unmodeled name recurs is a whole-story judgment, the "throwaway / one-appearance" classification is deferred until the final chunk and a cross-chunk digest carries surfaced names forward — so a long book reviewed in pieces never mislabels a name that appears in chapters 1 and 12 as a one-appearance throwaway. 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/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md b/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md
index 8851455aed..c64ec5affc 100644
--- a/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md
+++ b/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md
@@ -55,19 +55,38 @@ in each header to attribute every finding to its `issueNumber`.
{{manuscript}}
```
+{{#finalPart}}
+You are seeing the FINAL part of the manuscript, so you may now judge RECURRENCE
+across the whole story: an unmodeled name that appears in only one place is a
+one-appearance throwaway, while one that recurs across parts is a recurring
+unmodeled character. The "already recorded" digest above lists unmodeled names
+earlier parts already surfaced — do NOT repeat those; instead use them to decide
+recurrence (a name flagged earlier that also appears here recurs, so report it as
+recurring rather than a throwaway).
+{{/finalPart}}
+{{^finalPart}}
+You are seeing an EARLIER part of a long manuscript reviewed in pieces, so you
+CANNOT yet judge whether a name is a one-appearance throwaway — it may recur in a
+later part you haven't seen. Surface each unmodeled name you find here WITHOUT the
+throwaway/recurrence classification (use `Unmodeled character — "Name"`); a later
+part reconciles recurrence. The "already recorded" digest above lists unmodeled
+names earlier parts already surfaced — do NOT repeat those.
+{{/finalPart}}
+
## 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.
+e.g. `Unmodeled character — "Marguerite"` or (only when you can see the whole
+manuscript) `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
diff --git a/server/lib/editorial/README.md b/server/lib/editorial/README.md
index 4b34992aea..19b68df866 100644
--- a/server/lib/editorial/README.md
+++ b/server/lib/editorial/README.md
@@ -26,9 +26,12 @@ template change). The digest body is capped (`EDITORIAL_PRIOR_DIGEST_CHARS`) and
`usableChars` budget, and the digest is prepended only when it fits the chunk's
spare room — so it never displaces manuscript text or overflows the provider
window (a chunk packed to the budget just runs without a digest).
-`style.conformance` (tense/POV established earlier) and
-`objects.unmotivated-interaction` (setup/payoff across chapters) opt in;
-`prose.info-dumping` stays per-chunk (its problems are localized).
+`style.conformance` (tense/POV established earlier),
+`objects.unmotivated-interaction` (setup/payoff across chapters), and
+`roster.unmodeled-names` (an unmodeled name's recurrence is whole-corpus, so a
+later part doesn't re-flag a name an earlier part surfaced and the throwaway/
+recurring judgment is gated to the final part) opt in; `prose.info-dumping` stays
+per-chunk (its problems are localized).
The findings digest carries prior *problems* forward but not clean prior *setup*
— a payoff in a later chunk can be mis-flagged "missing setup" when the earlier
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.js
index 93f5fd654d..792f0380bb 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -1852,7 +1852,16 @@ export const EDITORIAL_CHECKS = [
stage: UNMODELED_NAMES_STAGE,
category: 'casting',
overheadTokens: EDITORIAL_PROMPT_OVERHEAD_TOKENS + estimateTokens(knownCharacters),
- buildVars: (manuscript) => ({ manuscript, knownCharacters }),
+ // The recurrence judgment (one-appearance throwaway vs recurring) is a
+ // WHOLE-corpus call, so on a chunked manuscript an earlier part must NOT
+ // declare a name a throwaway — it may recur in a later part it hasn't seen.
+ // `finalPart` gates that judgment to the last chunk (mirrors chekhov /
+ // endings), and `crossChunkDigest` carries each part's surfaced names
+ // forward so the final part can confirm recurrence and the same unmodeled
+ // name isn't re-flagged across parts. A single-chunk run is its own final
+ // part, so the common (provider-fits-the-book) case judges the whole text.
+ crossChunkDigest: true,
+ buildVars: (manuscript, meta) => ({ manuscript, knownCharacters, finalPart: meta?.isFinal ? 'true' : '' }),
});
},
},
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index ce451ec877..eb736c77e2 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -974,6 +974,25 @@ describe('roster.unmodeled-names — LLM check (#1412)', () => {
await getCheck(UNMODELED_NAMES).run(ctx);
expect(seenVars.knownCharacters).toBe('');
});
+
+ it('marks a single-chunk run as the final part so the recurrence judgment is enabled', async () => {
+ let seenVars = null;
+ const ctx = wholeCtx({
+ callStagedLLM: async (_stage, vars) => { seenVars = vars; return { content: { findings: [] } }; },
+ });
+ await getCheck(UNMODELED_NAMES).run(ctx);
+ expect(seenVars.finalPart).toBe('true');
+ });
+
+ it('flags only the LAST part as final across a chunked manuscript (recurrence is whole-corpus)', async () => {
+ const finals = [];
+ const ctx = wholeCtx({
+ planManuscriptChunks: async () => ['# Issue 1\n\np1', '# Issue 2\n\np2', '# Issue 3\n\np3'],
+ callStagedLLM: async (_stage, vars) => { finals.push(vars.finalPart); return { content: { findings: [] } }; },
+ });
+ await getCheck(UNMODELED_NAMES).run(ctx);
+ expect(finals).toEqual(['', '', 'true']);
+ });
});
describe('canonRosterNamesSummary (#1412)', () => {