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: per-check declared source dependencies for editorial-check staleness (#1387)
Adam Eivyadc699caf9bb
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 0c23122ba6..04270ac82b 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -59,6 +59,8 @@## Changed+- **[issue-1387] Editorial-check "stale" badges are now scoped to exactly what each check reads, so a single edit no longer marks unrelated findings stale.** A finding's stale badge tells you the manuscript/canon/series content the check analyzed has drifted since it ran. That signal used to be derived from a coarse two-bucket heuristic (manuscript-vs-canon) that folded the *style guide* and the *arc ticking clock* into shared buckets — so editing the ticking clock marked **every** canon-only finding stale (naming, object-attachment, …), and editing the style guide marked **every** manuscript finding stale (even the info-dumping check, which never reads the style guide). Each check now declares the exact inputs it reads (`sources`, a subset of `manuscript` / `canon` / `series.styleGuide` / `series.arc.tickingClock`) and the runner fingerprints precisely those — so editing the ticking clock stales only the ticking-clock-hygiene finding, editing the style guide stales only the style checks, and a future check that reads a new series field can't silently stay falsely "fresh" (a fail-fast guard requires every check to declare a non-empty, known source set, and a `manuscript` source to pair with `needsManuscript`). Staleness is still derived per-read and never stored or synced. (`server/lib/editorial/checkRegistry.js`, `server/services/pipeline/editorial/checkRunner.js`, #1387)+- **[issue-1348] Your reverse outline now travels with the series across federated machines.** The scene-by-scene Reverse Outline is stored alongside the series, and until now it stayed put — regenerating it on one machine left your other synced machines (and anyone you share a bucket with) showing a stale or empty outline. It now rides the same cross-install sync as the series itself: regenerate it on one peer and the newest outline propagates everywhere, last-writer-wins by generation time. Older installs that don't yet understand outlines simply skip it (the series and its issues still sync fine) and pick it up automatically once they update. (#1348)- **[issue-1340] LLM editorial checks now review your whole manuscript, even on a small-context model.** The info-dumping, unmotivated-object-interaction, and style-conformance checks used to send the manuscript to the model in a single call, capped at a fixed length so it couldn't overflow a small or local provider's context window — which meant later issues in a long series were silently skipped. Each check now chunks the manuscript to fit whatever provider it runs on (the same context-window planning the completeness pass already uses) and merges the findings across chunks, so the entire series gets reviewed regardless of model size. Frontier models that can hold the whole book still run it in one pass. The per-run "max findings" cap is unchanged. (#1340)diff --git a/server/lib/editorial/README.md b/server/lib/editorial/README.mdindex 980643011c..2d81a3b838 100644--- a/server/lib/editorial/README.md+++ b/server/lib/editorial/README.md@@ -23,6 +23,15 @@ Before adding an editorial rule, check whether an existing registry entry coversit. To add a new built-in check, append an entry to `EDITORIAL_CHECKS` in`checkRegistry.js` (the fail-fast guards enforce shape, enum, and unique-id).+Declare every input the check's `run(ctx)` reads in its `sources` array (a+non-empty subset of `EDITORIAL_SOURCES`: `manuscript`, `canon`,+`series.styleGuide`, `series.arc.tickingClock`). The staleness runner+fingerprints exactly those sources, so a finding goes stale only when content the+check actually analyzed drifts — declare too few and a finding stays falsely+fresh; a `manuscript` source must pair with `needsManuscript: true`. When a new+check reads a `ctx.series` field that isn't yet a token, add the token to+`EDITORIAL_SOURCES` and a matching resolver in the runner's `SOURCE_RESOLVERS`.+## User-defined checks (#1346)Users author their own LLM checks (name + prompt + scope) from the Editorial@@ -40,5 +49,5 @@ runner-injected `ctx.callInlineLLM` (an inline-prompt sibling of| Module | Purpose ||---|---|-| `checkRegistry.js` | `EDITORIAL_CHECKS` array + fail-fast guards + lookup/state helpers (`getCheck`, `getCheckById`, `getAllChecks`, `listChecks`, `resolveCheckState`, `getEnabledChecks`, `resolveCheckConfig`). User-defined-check helpers (`buildCustomCheck`, `buildCustomCheckPrompt`, `readCustomCheckDefs`, `isCustomCheckId`, `isValidCustomCheckDef`). Ships two reference checks: `naming.dissimilar-names` (deterministic) and `prose.info-dumping` (LLM). |+| `checkRegistry.js` | `EDITORIAL_CHECKS` array + `EDITORIAL_SOURCES` (the per-check `sources` vocabulary the staleness runner fingerprints, #1387) + fail-fast guards + lookup/state helpers (`getCheck`, `getCheckById`, `getAllChecks`, `listChecks`, `resolveCheckState`, `getEnabledChecks`, `resolveCheckConfig`). User-defined-check helpers (`buildCustomCheck`, `buildCustomCheckPrompt`, `readCustomCheckDefs`, `isCustomCheckId`, `isValidCustomCheckDef`). Ships two reference checks: `naming.dissimilar-names` (deterministic) and `prose.info-dumping` (LLM). || `index.js` | Barrel re-export of the above. |diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex bb08555ffa..e7b176ea64 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -32,6 +32,24 @@ export const CHECK_KINDS = Object.freeze(['deterministic', 'llm']);export const CHECK_SEVERITIES = Object.freeze(['high', 'medium', 'low']);const SEVERITIES = CHECK_SEVERITIES;+// The inputs a check can read, declared per-check via `sources` (#1387). The+// staleness runner (server/services/pipeline/editorial/checkRunner.js) fingerprints+// EXACTLY a check's declared sources, so a finding only goes stale when content+// the check actually analyzed drifts — editing the style guide no longer marks a+// naming finding stale, and editing the ticking clock no longer marks every+// canon-only finding stale. Every token here must have a matching resolver in the+// runner's `SOURCE_RESOLVERS` (a load-time guard there fails fast if they drift).+// - 'manuscript' — the stitched manuscript corpus (implies needsManuscript)+// - 'canon' — the universe/series canon (characters, relationships, objects)+// - 'series.styleGuide' — the series style guide (tense/POV/rating/reading level)+// - 'series.arc.tickingClock' — the series arc's ticking clock+export const EDITORIAL_SOURCES = Object.freeze([+ 'manuscript',+ 'canon',+ 'series.styleGuide',+ 'series.arc.tickingClock',+]);+// Default per-run finding cap for user-defined checks (#1346) — mirrors the// built-in LLM checks' `maxFindings` default so a long manuscript can't flood// the review. Defined up here so the custom-check prompt builder and config@@ -407,6 +425,7 @@ const hasConformanceFields = (sg) => styleGuideExpectations(sg).length > 0;export const EDITORIAL_CHECKS = [{id: 'naming.dissimilar-names',+ sources: ['canon'],label: 'Character name dissimilarity',description:'Flags pairs of character names a reader could confuse — sharing a first letter, length, vowel pattern, opening, or ending.',@@ -457,6 +476,7 @@ export const EDITORIAL_CHECKS = [},{id: 'relationships.reciprocity',+ sources: ['canon'],label: 'Relationship reciprocity',description:'Flags one-sided structured relationship links — character A links to B, but B has no link back to A.',@@ -495,6 +515,7 @@ export const EDITORIAL_CHECKS = [},{id: 'relationships.dangling-target',+ sources: ['canon'],label: 'Relationship dangling target',description:'Flags structured relationship links that point at a character id no longer present in the canon (deleted or renamed away).',@@ -525,6 +546,7 @@ export const EDITORIAL_CHECKS = [},{id: 'relationships.opposition-reversal',+ sources: ['canon'],label: 'Opposition role-reversal payoff',description:'Advisory — surfaces every tagged opposing-force pair (hunter/prey, winner/loser…) so you can confirm whether the reader ever sees the roles reverse, or deliberately not.',@@ -566,6 +588,7 @@ export const EDITORIAL_CHECKS = [},{id: 'arc.ticking-clock-hygiene',+ sources: ['series.arc.tickingClock'],label: 'Ticking-clock hygiene',description:'Advisory — checks the series ticking clock/countdown is fully specified: named, with stakes, a plant→due span, and reminder beats so the reader does not forget it through the long middle.',@@ -659,6 +682,7 @@ export const EDITORIAL_CHECKS = [},{id: 'objects.unattached-significant',+ sources: ['canon'],label: 'Unattached significant object',description:'Flags objects with written significance but no character attachment — the object clearly matters to the story, yet nobody in the cast is on record caring about it.',@@ -696,6 +720,7 @@ export const EDITORIAL_CHECKS = [},{id: 'objects.unmotivated-interaction',+ sources: ['manuscript', 'canon'],label: 'Unmotivated object interaction',description:'LLM scan — flags moments where a character interacts meaningfully with an object the prose (and the canon attachments) have given them no reason to care about.',@@ -734,6 +759,7 @@ export const EDITORIAL_CHECKS = [},{id: 'objects.backstory-consistency',+ sources: ['canon'],label: 'Attachment backstory consistency',description:"LLM check — flags object attachments whose origin story contradicts the attached character's established background.",@@ -784,6 +810,7 @@ export const EDITORIAL_CHECKS = [},{id: 'prose.info-dumping',+ sources: ['manuscript'],label: 'Info-dumping / "as you know, Bob" exposition',description:'Flags passages that dump backstory or world rules through unnatural exposition — characters telling each other what they both already know.',@@ -820,6 +847,7 @@ export const EDITORIAL_CHECKS = [},{id: 'style.reading-level',+ sources: ['manuscript', 'series.styleGuide'],label: 'Reading-level conformance',description:"Measures the drafted manuscript's reading grade level (Flesch–Kincaid) and flags it when it drifts beyond a tolerance from the series style guide's target reading level.",@@ -875,6 +903,7 @@ export const EDITORIAL_CHECKS = [},{id: 'style.conformance',+ sources: ['manuscript', 'series.styleGuide'],label: 'Style-guide conformance (tense / POV / rating)',description:"LLM scan — flags passages where the prose drifts from the series style guide's tense, point-of-view person, or content rating (profanity/violence/sexual content beyond the configured ceiling).",@@ -945,6 +974,22 @@ export function assertValidChecks(checks) {if (!check.configSchema || typeof check.configSchema.safeParse !== 'function') {throw new Error(`checkRegistry: ${check.id} is missing a Zod configSchema`);}+ // `sources` declares the inputs the check reads so the runner can fingerprint+ // exactly those for staleness (#1387). Required + non-empty + known tokens.+ // A 'manuscript' source implies `needsManuscript` (the runner gates the+ // corpus-collection I/O on that flag) — keeping the two consistent prevents a+ // check that fingerprints the manuscript but never triggers its collection.+ if (!Array.isArray(check.sources) || check.sources.length === 0) {+ throw new Error(`checkRegistry: ${check.id} must declare a non-empty sources array (one of ${EDITORIAL_SOURCES.join(', ')})`);+ }+ for (const source of check.sources) {+ if (!EDITORIAL_SOURCES.includes(source)) {+ throw new Error(`checkRegistry: ${check.id} declares unknown source "${source}" (must be one of ${EDITORIAL_SOURCES.join(', ')})`);+ }+ }+ if (check.sources.includes('manuscript') && !check.needsManuscript) {+ throw new Error(`checkRegistry: ${check.id} reads the 'manuscript' source but is not marked needsManuscript`);+ }// configFields is optional, but when present each entry must be a renderable// descriptor (key + label + known type) so the UI never has to guess a// field's control. The Zod configSchema remains the validation authority —@@ -1112,6 +1157,9 @@ export function buildCustomCheck(def) {severityDefault: def.severityDefault,defaultEnabled: true,needsManuscript: true,+ // Custom checks read only the stitched manuscript (the inline prompt is fed+ // the corpus, nothing else), so their findings stale on a prose edit alone (#1387).+ sources: ['manuscript'],isCustom: true,prompt: instructions,configSchema: customCheckConfigSchema,diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex 463cf48f21..73483fa1a0 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';import { z } from 'zod';import {EDITORIAL_CHECKS,+ EDITORIAL_SOURCES,CHECK_SCOPES,CHECK_KINDS,getCheck,@@ -45,6 +46,15 @@ describe('editorial check registry — shape invariants', () => {expect(['high', 'medium', 'low'], `${check.id} severity`).toContain(check.severityDefault);expect(typeof check.run, `${check.id} run`).toBe('function');expect(typeof check.configSchema?.safeParse, `${check.id} configSchema`).toBe('function');+ // Every check declares a non-empty source set drawn from EDITORIAL_SOURCES,+ // and a manuscript source pairs with needsManuscript (#1387).+ expect(Array.isArray(check.sources) && check.sources.length, `${check.id} sources`).toBeTruthy();+ for (const source of check.sources) {+ expect(EDITORIAL_SOURCES, `${check.id} source "${source}"`).toContain(source);+ }+ if (check.sources.includes('manuscript')) {+ expect(check.needsManuscript, `${check.id} manuscript source ⇒ needsManuscript`).toBe(true);+ }}});@@ -64,7 +74,8 @@ describe('editorial check registry — shape invariants', () => {describe('editorial check registry — fail-fast guards', () => {const valid = {id: 'x.ok', label: 'ok', scope: 'series', kind: 'deterministic',- category: 'naming', severityDefault: 'low', configSchema: z.object({}), run: () => [],+ category: 'naming', severityDefault: 'low', sources: ['canon'],+ configSchema: z.object({}), run: () => [],};it('accepts a valid set', () => {@@ -111,6 +122,21 @@ describe('editorial check registry — fail-fast guards', () => {expect(() => assertValidChecks([{ ...valid, configFields: [{ label: 'x', type: 'number' }] }])).toThrow(/malformed configField/);expect(() => assertValidChecks([{ ...valid, configFields: [{ key: 'k', label: 'x', type: 'galaxy' }] }])).toThrow(/malformed configField/);});++ it('throws on a missing or empty sources array (#1387)', () => {+ expect(() => assertValidChecks([{ ...valid, sources: undefined }])).toThrow(/non-empty sources array/);+ expect(() => assertValidChecks([{ ...valid, sources: [] }])).toThrow(/non-empty sources array/);+ });++ it('throws on an unknown source token (#1387)', () => {+ expect(() => assertValidChecks([{ ...valid, sources: ['series.readerMap'] }])).toThrow(/unknown source/);+ });++ it('throws when a manuscript source is not paired with needsManuscript (#1387)', () => {+ expect(() => assertValidChecks([{ ...valid, sources: ['manuscript'] }])).toThrow(/not marked needsManuscript/);+ // Pairing them is accepted.+ expect(() => assertValidChecks([{ ...valid, sources: ['manuscript'], needsManuscript: true }])).not.toThrow();+ });});describe('editorial check registry — config + state resolution', () => {diff --git a/server/services/pipeline/editorial/checkRunner.js b/server/services/pipeline/editorial/checkRunner.jsindex 0455227ff5..b6650d8ac2 100644--- a/server/services/pipeline/editorial/checkRunner.js+++ b/server/services/pipeline/editorial/checkRunner.js@@ -19,7 +19,7 @@ import { randomUUID, createHash } from 'crypto';import { createSseRunner } from '../../../lib/sseUtils.js';import { runStagedLLM, runInlineLLM, resolveStageContext } from '../../../lib/stageRunner.js';import { planManuscriptPass } from '../../../lib/contextBudget.js';-import { getEnabledChecks, getEnabledCheckRows, getAllChecks } from '../../../lib/editorial/index.js';+import { getEnabledChecks, getEnabledCheckRows, getAllChecks, EDITORIAL_SOURCES } from '../../../lib/editorial/index.js';import { getSettings } from '../../settings.js';import { getSeries } from '../series.js';import { listIssues } from '../issues.js';@@ -28,42 +28,68 @@ import { collectManuscriptSections, sectionsCorpus, manuscriptSectionHeader } frimport { seedReviewFromFindings, getReview } from '../manuscriptReview.js';import { canonicalStringify } from '../../../lib/objects.js';-// Source-content fingerprinting for finding staleness (#1345). Each finding is-// stamped with a hash of the exact content its check analyzed; the manuscript+// Source-content fingerprinting for finding staleness (#1345, #1387). Each finding+// is stamped with a hash of the exact content its check analyzed; the manuscript// editor / triage view flags a finding `stale` once that content drifts.//-// Two segments cover the inputs the checks actually read: a manuscript-consuming-// check (`needsManuscript`) hashes the stitched corpus + canon + style guide; a-// canon-only check hashes canon + the arc's ticking clock — so a canon-only-// finding (naming, object-attachment, ticking-clock) doesn't go stale on a pure-// prose edit, and a manuscript finding doesn't go stale on a ticking-clock edit.-// `canonicalStringify` (key-sorted) keeps the hash stable across machines so a-// synced finding isn't falsely flagged stale after an import re-orders keys.+// Per-check declared sources (#1387): a check declares the inputs its run() reads+// via `check.sources` (a subset of EDITORIAL_SOURCES), and we fingerprint EXACTLY+// those — so a naming finding (sources: ['canon']) doesn't go stale on a prose or+// style-guide edit, and editing the ticking clock stales only the+// arc.ticking-clock-hygiene finding (sources: ['series.arc.tickingClock']) instead+// of every canon-only finding. This replaces the prior two-segment heuristic+// (manuscript-vs-canon) that over-flagged because it folded the style guide ++// ticking clock into shared segments.//-// NOTE: the input set is derived from `needsManuscript` + a fixed series field-// set, NOT a per-check source declaration — so editing the style guide or ticking-// clock marks ALL findings in that segment stale, not only the checks that read-// it. That over-flag is the deliberate SAFE direction (never under-flag): a check-// added later that reads `styleGuide` still auto-stales, whereas a per-check-// allow-list would silently false-fresh it. Precise-and-safe scoping via declared-// per-check sources is tracked in #1387. NUL separates the segments so they can't-// run together ambiguously.+// `SOURCE_RESOLVERS` maps each declared token to the exact content hashed.+// `canonicalStringify` (key-sorted) keeps the hash stable across machines so a+// synced finding isn't falsely flagged stale after an import re-orders keys. A+// load-time guard asserts every EDITORIAL_SOURCES token has a resolver here — a+// token with no resolver would silently contribute nothing (false-fresh).const HASH_SEP = '\u0000';const sha256 = (text) => createHash('sha256').update(text || '').digest('hex');-function computeSourceHashes(manuscript, canon, series) {- const canonStr = canonicalStringify(canon ?? null);- const styleGuide = canonicalStringify(series?.styleGuide ?? null);- const tickingClock = canonicalStringify(series?.arc?.tickingClock ?? null);- return {- // Manuscript checks (style.reading-level / style.conformance + the prose/object- // LLM checks) read the corpus + canon + style guide.- withManuscript: sha256([manuscript || '', canonStr, styleGuide].join(HASH_SEP)),- // Canon-only checks read canon; arc.ticking-clock-hygiene also reads the arc's- // ticking clock (folded in here since it's the only non-canon input they consult).- canonOnly: sha256([canonStr, tickingClock].join(HASH_SEP)),- };+const SOURCE_RESOLVERS = {+ manuscript: ({ manuscript }) => manuscript || '',+ canon: ({ canon }) => canonicalStringify(canon ?? null),+ 'series.styleGuide': ({ series }) => canonicalStringify(series?.styleGuide ?? null),+ 'series.arc.tickingClock': ({ series }) => canonicalStringify(series?.arc?.tickingClock ?? null),+};+for (const token of EDITORIAL_SOURCES) {+ if (typeof SOURCE_RESOLVERS[token] !== 'function') {+ throw new Error(`checkRunner: editorial source "${token}" has no fingerprint resolver — keep SOURCE_RESOLVERS in sync with EDITORIAL_SOURCES`);+ }+}++// A check's declared sources, falling back to the legacy needsManuscript heuristic+// for any check synthesized before the declaration existed (e.g. an older custom+// check). Unknown tokens are dropped so a typo can't corrupt the hash.+function checkSources(check) {+ const declared = Array.isArray(check?.sources) && check.sources.length+ ? check.sources+ : (check?.needsManuscript ? ['manuscript', 'canon'] : ['canon']);+ return declared.filter((token) => SOURCE_RESOLVERS[token]);+}++// Resolve every source token's content ONCE for a given inputs object+// (`{ manuscript, canon, series }`), so fingerprinting many checks/comments doesn't+// re-stringify the canon per call. Returns a token→string map the fingerprint reads.+function resolveSources(inputs) {+ const resolved = {};+ for (const token of EDITORIAL_SOURCES) resolved[token] = SOURCE_RESOLVERS[token](inputs);+ return resolved;+}++// Fingerprint exactly the inputs a check reads, from a pre-resolved token→content+// map (see `resolveSources`). Tokens are de-duped and sorted so the hash is+// independent of declaration order; each segment is prefixed with its token so two+// source sets can't collide on equal content. NUL joins segments (it can't appear+// in the JSON the resolvers emit) so they can't run together ambiguously.+function fingerprintForCheck(check, resolved) {+ const segments = [...new Set(checkSources(check))]+ .sort()+ .map((token) => `${token}=${resolved[token]}`);+ return sha256(segments.join(HASH_SEP));}-const hashForCheck = (hashes, needsManuscript) => (needsManuscript ? hashes.withManuscript : hashes.canonOnly);// Output room reserved for an editorial check's findings JSON. Sized for the// editorial output (a bounded findings list — far smaller than the completeness@@ -107,9 +133,10 @@ export async function runEditorialChecks(seriesId, options = {}) {listIssues({ seriesId }).catch(() => []),]);const manuscript = sectionsCorpus(sections);- // Fingerprint the analyzed content once per run — stamped onto every finding- // below so the editor can flag it `stale` when the manuscript/canon/series-meta drifts (#1345).- const sourceHashes = computeSourceHashes(manuscript, canon, series);+ // 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).+ const resolvedSources = resolveSources({ manuscript, canon, series });const baseCtx = {seriesId,series,@@ -177,7 +204,7 @@ export async function runEditorialChecks(seriesId, options = {}) {continue;}const raw = (await check.run(ctx)) || [];- const sourceContentHash = hashForCheck(sourceHashes, !!check.needsManuscript);+ const sourceContentHash = fingerprintForCheck(check, resolvedSources);const stamped = raw.map((f) => ({ ...f, checkId: check.id, sourceContentHash }));findings.push(...stamped);perCheck.push({ checkId: check.id, count: stamped.length });@@ -242,19 +269,22 @@ export async function getReviewWithStaleness(seriesId) {// still-registered check — a pure completeness review pays no extra I/O.const evaluable = review.comments.filter((c) => c.checkId && c.sourceContentHash && checkFor(c.checkId));if (!evaluable.length) return review;- const needsManuscript = evaluable.some((c) => checkFor(c.checkId).needsManuscript);+ // Only pay the manuscript-collection I/O when an evaluable check declares it as+ // a source (mirrors the run path's gate, now source-derived rather than the bare+ // needsManuscript flag so it stays correct as the source vocabulary grows).+ const needsManuscript = evaluable.some((c) => checkSources(checkFor(c.checkId)).includes('manuscript'));const series = await getSeries(seriesId);const [sections, canon] = await Promise.all([needsManuscript ? collectManuscriptSections(seriesId) : Promise.resolve([]),getSeriesCanon(series),]);- const sourceHashes = computeSourceHashes(sectionsCorpus(sections), canon, series);+ const resolvedSources = resolveSources({ manuscript: sectionsCorpus(sections), canon, series });return {...review,comments: review.comments.map((c) => {const check = c.checkId && c.sourceContentHash ? checkFor(c.checkId) : null;if (!check) return c;- const current = hashForCheck(sourceHashes, !!check.needsManuscript);+ const current = fingerprintForCheck(check, resolvedSources);return { ...c, stale: c.sourceContentHash !== current };}),};diff --git a/server/services/pipeline/editorial/checkRunner.test.js b/server/services/pipeline/editorial/checkRunner.test.jsindex ba2b13cec0..eb88994224 100644--- a/server/services/pipeline/editorial/checkRunner.test.js+++ b/server/services/pipeline/editorial/checkRunner.test.js@@ -275,23 +275,31 @@ describe('getReviewWithStaleness (#1345)', () => {expect(naming.stale).toBe(true);});- it('stales a manuscript-check finding (not a canon-only one) when the series style guide changes', async () => {- getSeries.mockResolvedValueOnce({ id: 's1', universeId: 'u1', styleGuide: { readingLevel: 8 } });+ it('stales only the style-guide-reading checks when the series style guide changes (#1387 precision)', async () => {+ // style.conformance declares 'series.styleGuide'; prose.info-dumping is+ // manuscript-only and naming is canon-only — so editing the style guide must+ // stale ONLY the style check, not every manuscript-consuming finding (the+ // pre-#1387 heuristic over-flagged info-dumping here).+ getSeries.mockResolvedValueOnce({ id: 's1', universeId: 'u1', styleGuide: { tense: 'past' } });await seedReviewFromRun();- getSeries.mockResolvedValueOnce({ id: 's1', universeId: 'u1', styleGuide: { readingLevel: 12 } });+ getSeries.mockResolvedValueOnce({ id: 's1', universeId: 'u1', styleGuide: { tense: 'present' } });const review = await getReviewWithStaleness('s1');- expect(review.comments.find((c) => c.checkId === 'prose.info-dumping').stale).toBe(true);- // styleGuide is in the manuscript segment only → a canon-only finding stays fresh.+ expect(review.comments.find((c) => c.checkId === 'style.conformance').stale).toBe(true);+ expect(review.comments.find((c) => c.checkId === 'prose.info-dumping').stale).toBe(false);expect(review.comments.find((c) => c.checkId === 'naming.dissimilar-names').stale).toBe(false);});- it('stales a canon-only finding (not a manuscript one) when the arc ticking clock changes', async () => {- getSeries.mockResolvedValueOnce({ id: 's1', universeId: 'u1', arc: { tickingClock: { name: 'storm' } } });+ it('stales only the ticking-clock check when the arc ticking clock changes (#1387 precision)', async () => {+ // arc.ticking-clock-hygiene declares 'series.arc.tickingClock'; naming is+ // canon-only and info-dumping manuscript-only — so editing the ticking clock+ // must stale ONLY the ticking-clock finding (the pre-#1387 heuristic folded the+ // clock into the shared canon segment and over-flagged naming/object findings).+ getSeries.mockResolvedValueOnce({ id: 's1', universeId: 'u1', arc: { tickingClock: { enabled: true } } });await seedReviewFromRun();- getSeries.mockResolvedValueOnce({ id: 's1', universeId: 'u1', arc: { tickingClock: { name: 'eclipse' } } });+ getSeries.mockResolvedValueOnce({ id: 's1', universeId: 'u1', arc: { tickingClock: { enabled: true, label: 'eclipse' } } });const review = await getReviewWithStaleness('s1');- // tickingClock is in the canon segment only → the manuscript finding stays fresh.- expect(review.comments.find((c) => c.checkId === 'naming.dissimilar-names').stale).toBe(true);+ expect(review.comments.find((c) => c.checkId === 'arc.ticking-clock-hygiene').stale).toBe(true);+ expect(review.comments.find((c) => c.checkId === 'naming.dissimilar-names').stale).toBe(false);expect(review.comments.find((c) => c.checkId === 'prose.info-dumping').stale).toBe(false);});