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

refactor([issue-1312]): reuse ctx.manuscript for dialogue-share scan

Adam Eivyf3a59c058b07
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.js
index ad6335fd4e..8c8278101e 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -1897,10 +1897,9 @@ export const EDITORIAL_CHECKS = [
findings.push({ severity, category: 'casting', location, problem, suggestion, anchorQuote, issueNumber });
// --- 1) Dialogue share ------------------------------------------------
- // Longest-token-first owners so a beat naming two characters credits the
- // more specific match first (mirrors characterMatcher's intent).
- const sections = Array.isArray(ctx.sections) ? ctx.sections : [];
- const manuscript = sections.map((s) => (typeof s?.content === 'string' ? s.content : '')).join('\n\n');
+ // The runner injects the canonical stitched corpus as ctx.manuscript
+ // (needsManuscript) — reuse it rather than re-stitching ctx.sections.
+ const manuscript = typeof ctx.manuscript === 'string' ? ctx.manuscript : '';
if (maxDialogueShare < 1 && manuscript.trim()) {
const owners = identities
.filter((id) => id.matcher)
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index b26d40071c..91cdd0af64 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -3076,7 +3076,15 @@ describe('cast.representation-balance — deterministic check (#1312)', () => {
const REP = 'cast.representation-balance';
const sec = (number, content) => ({ number, content });
const runRep = (canon, { sections = [], reverseOutline = [], config = {} } = {}) =>
- getCheck(REP).run({ canon, sections, reverseOutline, config, severityDefault: 'low' });
+ getCheck(REP).run({
+ canon,
+ sections,
+ // The runner injects the stitched corpus as ctx.manuscript; mirror it here.
+ manuscript: sections.map((s) => s.content || '').join('\n\n'),
+ reverseOutline,
+ config,
+ severityDefault: 'low',
+ });
const dialogue = (findings) => findings.find((f) => f.location === 'Series dialogue');
const bechdel = (findings) => findings.find((f) => /Bechdel/.test(f.problem));
const screenTime = (findings) => findings.find((f) => /strongly skewed cast/.test(f.problem));