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): author problem/suggestion deterministically so LLM text can't contradict the recurrence verdict (#1412)

Adam Eivy3d81ed51ea2e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index f961f60c6d..df797db346 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). The LLM does only the judgment it alone can — surface a name and confirm it's a *person* — while a **deterministic post-pass counts each surfaced name's appearances across the whole manuscript** to apply the one-appearance-throwaway vs recurring label, 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-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/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md b/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md
index 75712a3e4b..9fad21bf5d 100644
--- a/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md
+++ b/data.reference/prompts/stages/pipeline-editorial-unmodeled-names.md
@@ -86,9 +86,9 @@ commentary:
{
"severity": "high|medium|low",
"issueNumber": 3,
- "location": "string — always 'Unmodeled character — \"Name\"' (e.g. 'Unmodeled character — \"Marguerite\"'); the deterministic post-pass relabels throwaway vs recurring",
- "problem": "1–2 sentences naming the proper noun and why you classified it as a character (not a place/org/brand/honorific). Do NOT state how often it appears — a deterministic pass counts that across the whole manuscript and appends the recurrence sentence.",
- "suggestion": "1 sentence: it is unmodeled, so the author should either add it to the story bible or leave it unnamed. Do NOT decide which based on frequency — the post-pass appends a frequency-specific recommendation.",
+ "location": "string — always 'Unmodeled character — \"Name\"' (e.g. 'Unmodeled character — \"Marguerite\"'); a deterministic post-pass rewrites the throwaway-vs-recurring label",
+ "problem": "1–2 sentences naming the proper noun and why you classified it as a character (not a place/org/brand/honorific). REQUIRED. A deterministic post-pass authors the final user-visible problem/suggestion (it owns the frequency narrative), so just justify the person classification here — don't worry about wording or how often the name appears.",
+ "suggestion": "1 short sentence (the post-pass replaces it) — e.g. 'add to the bible or leave unnamed'.",
"anchorQuote": "short verbatim quote at the name's first use (≤ 200 chars)"
}
]
diff --git a/server/lib/editorial/README.md b/server/lib/editorial/README.md
index b588c91c0b..0ed639471c 100644
--- a/server/lib/editorial/README.md
+++ b/server/lib/editorial/README.md
@@ -35,11 +35,15 @@ problems are localized).
`roster.unmodeled-names` also shows the LLM/deterministic split that keeps a
chunked judgment correct: the model does ONLY what it alone can — surface a proper
noun used as a character name and confirm it's a person (not a place/org/brand/
-honorific) — and a deterministic post-pass in `run()` counts each surfaced name's
-distinct-issue appearances across the WHOLE `ctx.sections` corpus to apply the
-one-appearance-throwaway vs recurring label + final severity. Recurrence is a
-whole-corpus count the model can't make per-chunk (a name in issues 1 and 12 looks
-like a one-off to whichever chunk sees it), so it never asks the model for it.
+honorific). A deterministic post-pass in `run()` then counts each surfaced name's
+distinct-issue appearances across the WHOLE `ctx.sections` corpus and **authors the
+final `location` / `problem` / `suggestion` / severity itself** from that count
+(keeping only the model's `anchorQuote` + `issueNumber`). It does NOT append to the
+model's free text — owning the frequency narrative outright means a stray model
+claim ("appears only once") can't contradict the deterministic verdict. Recurrence
+is a whole-corpus count the model can't make per-chunk (a name in issues 1 and 12
+looks like a one-off to whichever chunk sees it), so it never trusts the model for
+it; a surfaced name the matcher can't find in any section is dropped, not reported.
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 c3fd7f0a91..1f2e53d02a 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -1861,23 +1861,26 @@ export const EDITORIAL_CHECKS = [
crossChunkDigest: true,
buildVars: (manuscript) => ({ manuscript, knownCharacters }),
});
- // Deterministic whole-corpus recurrence pass. The model is told NOT to judge
- // frequency (it can't, per-chunk); it just surfaces the name in `location`
- // ("Unmodeled character — \"Marguerite\"") and explains the person-vs-non-person
- // call in `problem`. Here we count the name's distinct-issue appearances across
- // ALL sections (not just the chunk the LLM saw) so the throwaway/recurring
- // verdict is correct regardless of chunking, rewrite the location label + final
- // severity, AND append the frequency sentence to problem/suggestion so the
- // user-visible text can't disagree with the label. Findings surfacing the same
- // name from different chunks collapse to one. A name the matcher can't find in
- // the prose (a stray/garbled LLM token) is left as the model classified it
- // rather than fabricating a "0 appearances" throwaway.
+ // Deterministic whole-corpus recurrence pass. The model's job is the judgment
+ // it alone can make — is this surfaced proper noun a PERSON (vs a place/org/
+ // brand/honorific)? — expressed by whether it emits the finding at all and by
+ // the name it quotes in `location`. It is NOT trusted for frequency: that's a
+ // whole-corpus count it can't make per-chunk (a name in issues 1 and 12 looks
+ // like a one-off to whichever chunk sees it). So we OWN `problem`/`suggestion`
+ // here — composing them from the deterministic count rather than appending to
+ // (and risking contradiction with) the model's free text — and keep only the
+ // model's `anchorQuote` + `issueNumber` (facts it's authoritative on). We count
+ // the name's distinct-issue appearances across ALL sections, set the location
+ // label + severity, and collapse the same name surfaced from different chunks.
+ // A name the matcher can't find in the prose (a stray/garbled LLM token) is
+ // dropped rather than reported as a "0 appearances" phantom.
const sections = Array.isArray(ctx.sections) ? ctx.sections : [];
const seenNames = new Set();
const out = [];
- const append = (text, extra) => (text ? `${text} ${extra}` : extra);
for (const f of findings) {
const name = (String(f.location || '').match(/"([^"]+)"/) || [])[1];
+ // No quoted name to verify against the prose — keep the model's finding as-is
+ // rather than guessing (it may be a general roster note, not a single name).
if (!name) { out.push(f); continue; }
const key = normalizeName(name);
if (key && seenNames.has(key)) continue; // same unmodeled name from another chunk
@@ -1887,21 +1890,25 @@ export const EDITORIAL_CHECKS = [
? new Set(sections.filter((s) => matcher.test(s.content || '')).map((s) => s.number))
: new Set();
const count = issues.size;
- if (count === 0) { out.push(f); continue; }
+ // The model surfaced a name the matcher can't locate in any section (a garbled
+ // token, or a form the whole-token matcher won't match) — drop it rather than
+ // emit a finding the editor can't anchor.
+ if (count === 0) continue;
+ const base = { category: 'casting', anchorQuote: f.anchorQuote || '', issueNumber: f.issueNumber ?? null };
out.push(count === 1
? {
- ...f,
+ ...base,
severity: 'low',
location: `Throwaway name — "${name}" (1 appearance)`,
- problem: append(f.problem, `It appears in only one issue — a named body the reader is told to remember but who never recurs and was never bibled.`),
- suggestion: append(f.suggestion, `Add "${name}" to canon only if they are meant to recur; otherwise recast them as an unnamed description so the reader isn't asked to track a name that goes nowhere.`),
+ problem: `"${name}" is used as a character name but is not in the story bible, and appears in only one issue — a named body the reader is told to remember but who never recurs and was never bibled.`,
+ suggestion: `Add "${name}" to canon only if they are meant to recur; otherwise recast them as an unnamed description (e.g. "the bartender") so the reader isn't asked to track a name that goes nowhere.`,
}
: {
- ...f,
+ ...base,
severity: 'medium',
location: `Unmodeled character — "${name}" (${count} issues)`,
- problem: append(f.problem, `They recur across ${count} issues but are not in the story bible.`),
- suggestion: append(f.suggestion, `A recurring character should be modeled — add "${name}" to canon.`),
+ problem: `"${name}" is used as a character name across ${count} issues but is not in the story bible.`,
+ suggestion: `A recurring character should be modeled — add "${name}" to canon.`,
});
}
return out;
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index 9862fa7773..f10a4cfea2 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -990,7 +990,8 @@ describe('roster.unmodeled-names — LLM check (#1412)', () => {
expect(findings).toHaveLength(1);
expect(findings[0].location).toBe('Throwaway name — "Old Henrik" (1 appearance)');
expect(findings[0].severity).toBe('low');
- // The frequency sentence is appended so the visible text matches the label.
+ // problem/suggestion are authored deterministically (not the LLM's free text),
+ // so the frequency narrative can never contradict the label.
expect(findings[0].problem).toContain('only one issue');
expect(findings[0].suggestion).toContain('recast them as an unnamed description');
});
@@ -1010,10 +1011,33 @@ describe('roster.unmodeled-names — LLM check (#1412)', () => {
expect(findings).toHaveLength(1);
expect(findings[0].location).toBe('Unmodeled character — "Marguerite" (2 issues)');
expect(findings[0].severity).toBe('medium');
- expect(findings[0].problem).toContain('recur across 2 issues');
+ expect(findings[0].problem).toContain('across 2 issues');
expect(findings[0].suggestion).toContain('add "Marguerite" to canon');
});
+ it('authors problem/suggestion deterministically — a contradicting LLM frequency claim cannot survive', async () => {
+ // The model (wrongly) calls a recurring name a one-off in its free text. Because
+ // the post-pass OWNS problem/suggestion (it doesn't append to the model's text),
+ // the recurring verdict + count win and the false "appears only once" never shows.
+ const ctx = wholeCtx({
+ sections: [
+ { number: 1, content: 'Marguerite drew her sword.' },
+ { number: 2, content: 'Marguerite returned to the war room.' },
+ ],
+ callStagedLLM: async () => ({ content: { findings: [{
+ severity: 'low', issueNumber: 1, location: 'Unmodeled character — "Marguerite"',
+ problem: 'Marguerite appears only once and should be cut.',
+ suggestion: 'Recast Marguerite as an unnamed description.',
+ }] } }),
+ });
+ const findings = await getCheck(UNMODELED_NAMES).run(ctx);
+ expect(findings).toHaveLength(1);
+ expect(findings[0].location).toBe('Unmodeled character — "Marguerite" (2 issues)');
+ expect(findings[0].problem).not.toContain('only once');
+ expect(findings[0].problem).toContain('across 2 issues');
+ expect(findings[0].suggestion).not.toContain('unnamed description');
+ });
+
it('collapses the same surfaced name reported from two different chunks into one finding', async () => {
const ctx = wholeCtx({
sections: [
@@ -1028,7 +1052,7 @@ describe('roster.unmodeled-names — LLM check (#1412)', () => {
expect(findings[0].location).toBe('Unmodeled character — "Marguerite" (2 issues)');
});
- it('leaves a finding untouched when its name cannot be parsed or is absent from the prose', async () => {
+ it('keeps a quote-less finding as-is but drops a quoted name absent from the prose', async () => {
const ctx = wholeCtx({
sections: [{ number: 1, content: 'Nothing matching here.' }],
callStagedLLM: async () => ({ content: { findings: [
@@ -1037,11 +1061,9 @@ describe('roster.unmodeled-names — LLM check (#1412)', () => {
] } }),
});
const findings = await getCheck(UNMODELED_NAMES).run(ctx);
- // Neither is rewritten: the first has no quoted name; the second matches 0 sections.
- expect(findings.map((f) => f.location)).toEqual([
- 'General note (no quoted name)',
- 'Unmodeled character — "Ghostname"',
- ]);
+ // The quote-less note is kept untouched (can't verify a name); the quoted
+ // "Ghostname" matches 0 sections, so it's dropped rather than reported.
+ expect(findings.map((f) => f.location)).toEqual(['General note (no quoted name)']);
});
});