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: add emotional-beat / reaction-proportionality editorial check (#1584)
[._.]/ Adam Eivybdf9f9e4d1d4
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 76f3917a8a..b0bffe88cc 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -55,6 +55,8 @@- **[issue-1583] A new editorial check catches a weak climax — a protagonist who is rescued at the payoff scene, or a climax that wins the plot but never lands the story's emotional/thematic core.** Nothing checked that the climax is the protagonist's *hardest, most active* moment: a finale where an ally swoops in to resolve the conflict, the antagonist conveniently self-destructs, or a coincidence settles things — or a climax that lands the action but leaves the theme the story has been building unanswered — could ship unflagged, even though a passive climax is story-breaking for the reader who invested in the whole arc. The new **Climax / resolution power** check (`arc.climax-agency`) identifies the climax scene and judges two things: *agency* (does the protagonist drive the resolution through a hard, costly choice, vs. being a spectator at their own climax) and *resolution power* (does the climax resolve the core problem and land the emotional/thematic argument, not just the surface plot). It reconciles the prose against the authored reader-map payoffs (what the reader was promised) and the declared themes, using the reverse-outline scene map to locate the climax, and gates its verdict on the final manuscript part — the climax can only be judged once the whole story is in view — degrading to a whole-manuscript scan when no reader-map, themes, or outline exists. It's a default-on series check that surfaces in the existing editorial-review UI and Series Autopilot like every other check, marking a fully passive climax high-severity; it complements `plot.structure-momentum` (which flags a passive protagonist arc-wide) by focusing the lens on the single payoff scene. (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-climax-agency.md`, `scripts/migrations/131-editorial-climax-agency-stage.js`)+- **[issue-1584] A new editorial check catches emotional beats that don't match the stakes — a trauma the story never processes, or a minor setback that triggers wildly outsized grief.** Nothing checked that reactions track event magnitude: a character could lose their brother in issue 2, the prose moves on, and the wound is never touched again — or a small disappointment could trigger a chapter of despair the story hasn't earned — and either way the emotional authenticity collapses without being flagged. The new **Emotional beat proportionality** check (`emotion.reaction-proportionality`) reads the stitched manuscript with the reverse-outline scene map to weigh each event's magnitude and flags two mismatches: an *under-reaction* (a high-magnitude event — death, trauma, betrayal, major loss or win — that draws no on-page reaction and is never processed in later issues) and an *over-reaction* (a minor setback triggering grief, rage, or despair out of all proportion). Because an unprocessed event in an early issue can stay unaddressed many issues later, the check carries every high-magnitude event still awaiting a proportionate reaction forward between manuscript chunks, so a trauma introduced early and then ignored is flagged against the later issue that should have paid it off; it degrades to a whole-manuscript scan when no outline exists, and respects characterization the story has established (a deliberately stoic or numb character isn't flagged for measured restraint). It's a default-on series check that surfaces in the existing editorial-review UI and Series Autopilot like every other check, marking a major trauma left wholly unprocessed high-severity. (`server/lib/editorial/checkRegistry.js`, `data.reference/prompts/stages/pipeline-editorial-reaction-proportionality.md`, `scripts/migrations/132-editorial-reaction-proportionality-stage.js`)+## Series Autopilot- **[issue-1510] Series Autopilot now catches whole-book continuity problems at the cheap beat stage, before it generates full scripts.** The autopilot reviewed continuity at two altitudes — the cross-volume synopsis pass (before beats exist) and the full-text editorial pass (after every issue's script is written, the most expensive stage) — leaving a gap in between. So structural defects spanning the whole book (a cliffhanger raised in one issue and never resolved, a finale that drifts onto a new subplot instead of landing the arc's intended ending, a promised through-line that never pays off, an event staged as the "first" in two different issues, a broken volume-to-volume hand-off) were only caught *after* all the scripts already existed — or not until a human read it. The autopilot now runs a **whole-manuscript beat-continuity pass over every issue's beat sheet, between beat generation and script generation**. Blocking findings are auto-resolved by rewriting just the affected issues' beats and re-checking (bounded, then it pauses for review with the residual findings), so the fix lands before any script is generated. The full-text editorial pass is unchanged and still catches what only the verbatim script can show (pacing, repeated/looping passages, dialogue craft). A new **Beat continuity rounds** control in the autopilot Options tunes how many auto-resolve rounds it attempts (0 skips the pass), saved as a per-install default like the existing Arc-verify and Editorial round knobs.diff --git a/data.reference/prompts/stage-config.json b/data.reference/prompts/stage-config.jsonindex f3d8de9a43..5f759c7fb7 100644--- a/data.reference/prompts/stage-config.json+++ b/data.reference/prompts/stage-config.json@@ -681,6 +681,13 @@"returnsJson": true,"variables": []},+ "pipeline-editorial-reaction-proportionality": {+ "name": "Pipeline — Editorial Check: Emotional beat proportionality (reactions vs event magnitude)",+ "description": "Editorial check (#1584): whether each character's emotional reactions are PROPORTIONATE to the magnitude of the events that befall them. Flags an under-reaction (a high-magnitude event — trauma, death, betrayal, major loss/win — that draws no on-page reaction and is never processed in later issues) and an over-reaction (a minor setback triggering grief/rage/despair out of all proportion). Uses the reverse-outline scene map to weigh event magnitude and attribute findings to the right issue, and carries unprocessed high-magnitude events across manuscript parts so a later part can flag a trauma introduced early and left unaddressed; degrades to a whole-manuscript scan when no outline exists. Returns issue-anchored findings.",+ "model": "default",+ "returnsJson": true,+ "variables": []+ },"pipeline-editorial-theme-coherence": {"name": "Pipeline — Editorial Check: Theme coherence / thematic throughline","description": "Editorial check (#1317): whether the manuscript actually DELIVERS its declared themes (series.arc.themes), not just states them. Builds a per-theme setup/complication/payoff coverage map, flags a theme that is stated but never dramatized or dropped after the opening, detects a strong EMERGENT theme not in the arc, and checks that the climax lands the thematic argument. Reads the stitched manuscript plus the authored arc themes and the reverse-outline scene map; degrades to a whole-manuscript scan when no outline or no themes exist. Returns issue-anchored findings.",diff --git a/data.reference/prompts/stages/pipeline-editorial-reaction-proportionality.md b/data.reference/prompts/stages/pipeline-editorial-reaction-proportionality.mdnew file mode 100644index 0000000000..fcbf0b8934--- /dev/null+++ b/data.reference/prompts/stages/pipeline-editorial-reaction-proportionality.md@@ -0,0 +1,104 @@+# Pipeline — Editorial Check: Emotional beat proportionality (reactions vs event magnitude)++You are a developmental editor doing a single focused pass for ONE concern:+**do the emotional beats match the magnitude of what happens?** A story earns the+reader's investment when reactions track stakes. It breaks when they don't — in+either direction:++1. **Under-reaction** — a high-magnitude event (a death, a trauma, a betrayal, a+ major loss or a hard-won victory) draws little or no on-page emotional+ reaction, and is never processed afterward. The classic failure: a character+ is traumatized in issue 2, the prose moves on, and the wound is never touched+ again — the reader feels the event didn't matter.+2. **Over-reaction** — a minor setback or low-stakes event triggers grief, rage,+ or despair out of all proportion, with nothing established to justify the+ intensity (no prior wound, no accumulated pressure the moment is paying off).++Your job is to flag the genuine mismatches — NOT to police every feeling. Find+the events whose emotional weight and the on-page reaction are clearly out of+balance, and attribute each to the issue where the imbalance lands.++A genuine finding is one of:++- **unprocessed high-magnitude event** — something major happens to a character+ and the prose never shows a proportionate reaction, in the moment OR in the+ issues that follow. (A deliberately delayed reaction that the story DOES+ eventually pay off is NOT a finding — only an event left wholly unaddressed is.)+- **disproportionate reaction** — a character's grief/rage/despair vastly exceeds+ what the triggering event and the established context warrant.++Do NOT flag: a measured reaction that fits a character the story has established+as stoic or numb (when that restraint is itself the characterization, not a gap);+a reaction the story deliberately defers and later pays off; genre-appropriate+restraint (a hardened soldier who grieves quietly); an intense reaction the story+has clearly earned through accumulated pressure or a revealed prior wound.++{{#sceneMap}}+## Scene segmentation++The reverse outline below segments the manuscript into scenes in story order+(with the recorded setting, POV character, and characters present). Use it to+weigh each event's MAGNITUDE in context and to attribute your finding to the+right `issueNumber`.++```+{{sceneMap}}+```+{{/sceneMap}}++## 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`. A high-magnitude+event may appear in an EARLIER part than the one where you flag its missing+reaction — the "setup so far" digest above carries forward every event still+awaiting a proportionate reaction (the affected character, its issue, and its+magnitude), so you can flag a trauma introduced early and then left unprocessed.+Attribute an under-reaction finding to the issue where the reaction SHOULD have+landed (the event's issue, or a later issue that pointedly ignores it).++```+{{manuscript}}+```++## Task++Identify events whose emotional weight and the on-page reaction are out of+balance. For each genuine finding:++1. Name the event (issue + a short description) and its magnitude (why it is high-+ or low-stakes for the affected character).+2. State which mismatch it is — an unprocessed high-magnitude event (what reaction+ the story never shows) or a disproportionate reaction (why the intensity+ exceeds what is warranted).+3. Quote a short verbatim anchor (≤ 200 chars) at the event or the (mis-)reaction.+4. Set the `location` to the affected character + the mismatch kind — one of+ `under-reaction`, `over-reaction` — e.g. `Issue 4 — Mara — under-reaction` or+ `Issue 2 — Jonah — over-reaction`.++Severity: a major trauma (death, assault, betrayal) left WHOLLY unprocessed across+the whole story is high; a notable event under-weighted, or a clearly outsized+reaction, is medium; a small proportionality wobble is low. If every reaction+fits its event's stakes (or fits the character the story has established), return+an empty `findings` array — do not invent an imbalance where the beats land.++## Output contract++Return ONLY valid JSON matching this shape — no prose, no markdown fence, no+commentary:++```json+{+ "findings": [+ {+ "severity": "high|medium|low",+ "issueNumber": 4,+ "location": "string — affected character + mismatch kind (e.g. 'Issue 4 — Mara — under-reaction' or 'Issue 2 — Jonah — over-reaction')",+ "problem": "1–3 sentences naming the event, its magnitude, and why the reaction is out of proportion (too little / never processed, or too much)",+ "suggestion": "1–3 sentences proposing a proportionate beat — what reaction the event warrants and where to place it, or how to dial an outsized reaction back or earn it",+ "anchorQuote": "short verbatim quote at the event or the (mis-)reaction (≤ 200 chars)"+ }+ ]+}+```diff --git a/scripts/migrations/132-editorial-reaction-proportionality-stage.js b/scripts/migrations/132-editorial-reaction-proportionality-stage.jsnew file mode 100644index 0000000000..efb47809b1--- /dev/null+++ b/scripts/migrations/132-editorial-reaction-proportionality-stage.js@@ -0,0 +1,75 @@+/**+ * Seed the `pipeline-editorial-reaction-proportionality` stage into existing installs (#1584).+ *+ * Mirrors `131-editorial-climax-agency-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 reaction-proportionality+ * stage unseeded and the `emotion.reaction-proportionality` 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-reaction-proportionality.md';+const STAGE_KEY = 'pipeline-editorial-reaction-proportionality';++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-reaction-proportionality prompt: already present`);+ } else {+ const sampleExists = await access(samplePath, constants.F_OK).then(() => true, () => false);+ if (!sampleExists) {+ console.warn(`⚠️ pipeline-editorial-reaction-proportionality: sample missing for ${FILENAME} — skipping copy`);+ } else {+ try {+ await copyFile(samplePath, dataPath);+ console.log(`✅ seeded ${FILENAME}`);+ } catch (err) {+ console.warn(`⚠️ pipeline-editorial-reaction-proportionality: 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-reaction-proportionality: 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-reaction-proportionality stage-config: already present`);+ return;+ }+ if (!sample?.stages?.[STAGE_KEY]) {+ console.warn(`⚠️ pipeline-editorial-reaction-proportionality: 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-reaction-proportionality stage-config (${action}): 1 added`);+ } catch (err) {+ console.warn(`⚠️ pipeline-editorial-reaction-proportionality: stage-config merge failed: ${err.message}`);+ }+ },+};diff --git a/scripts/migrations/132-editorial-reaction-proportionality-stage.test.js b/scripts/migrations/132-editorial-reaction-proportionality-stage.test.jsnew file mode 100644index 0000000000..f359448fc6--- /dev/null+++ b/scripts/migrations/132-editorial-reaction-proportionality-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 './132-editorial-reaction-proportionality-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 131) — no MD5 bookkeeping, so the+// seed / no-clobber behavior is asserted directly.++const FILENAME = 'pipeline-editorial-reaction-proportionality.md';+const STAGE_KEY = 'pipeline-editorial-reaction-proportionality';+const BODY = '# Emotional beat proportionality\n\nshipped body\n';++describe('migration 132 — seed editorial-reaction-proportionality 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-132-'));+ 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 39e017e0b1..43c68beeae 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -598,6 +598,21 @@ export function declaredThemesSummary(themes) {// themes, or outline exist.export const CLIMAX_AGENCY_STAGE = 'pipeline-editorial-climax-agency';+// Stage name for the emotional-beat / reaction-proportionality LLM check (#1584).+// Ships in data.reference/prompts/stages/ + stage-config.json (fresh installs via+// setup-data.js) and migrates to existing installs via migration 132 (boot runs+// migrations but NOT setup-data, so the migration is required). Reads the stitched+// manuscript plus the reverse-outline scene map and judges whether each character's+// emotional reactions are PROPORTIONATE to the magnitude of the events that befall+// them: a high-magnitude event (trauma, death, betrayal, a major loss or win) that+// draws no on-page reaction and is never processed afterward (under-reaction), or a+// minor setback that triggers grief/rage out of all proportion (over-reaction).+// Because an unprocessed event in an early issue can stay unaddressed many issues+// later, the run carries high-magnitude events still awaiting a proportionate+// reaction across chunks (`crossChunkSetup`) so a later part can flag the missing+// payoff; degrades to a prose-only scan when no outline exists.+export const REACTION_PROPORTIONALITY_STAGE = 'pipeline-editorial-reaction-proportionality';+// 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@@ -3493,6 +3508,73 @@ export const EDITORIAL_CHECKS = [});},},+ {+ id: 'emotion.reaction-proportionality',+ sources: ['manuscript', 'reverseOutline'],+ label: 'Emotional beat proportionality (reactions vs event magnitude)',+ description:+ 'LLM scan for emotional beats that do not track the magnitude of what happens: a high-magnitude event (trauma, a death, a betrayal, a major loss or win) that draws no on-page reaction and is never processed in later issues (under-reaction), or a minor setback that triggers grief, rage, or despair out of all proportion (over-reaction). Uses the reverse-outline scene map to weigh each event and attribute findings to the right issue; degrades to a whole-manuscript scan when no outline exists. Because an unprocessed event can stay unaddressed many issues later, an event flagged in an early part is carried forward so a later part can flag the missing reaction.',+ scope: 'series',+ kind: 'llm',+ category: 'emotion',+ // Fallback severity when the model omits one — 'medium' to match the sibling+ // characterization/arc LLM checks. The prompt directs the model to mark a major+ // trauma left wholly unprocessed 'high' per finding, so a genuinely jarring+ // emotional gap still surfaces as high.+ severityDefault: 'medium',+ 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 long manuscript 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 long manuscript can not flood the review.',+ },+ ],+ gate: (ctx) => (ctx.manuscript || '').trim().length > 0,+ run: (ctx) => {+ // The scene map is fixed per-call overhead (re-sent on each chunk) and pure+ // context: it records each scene's events so the model can weigh an event's+ // MAGNITUDE and attribute a finding to the right issue. The check degrades+ // gracefully — no outline ⇒ {{#sceneMap}} renders nothing and the model+ // weighs each event from the prose's own description.+ const sceneMap = sceneGroundingSummary(ctx.reverseOutline);+ return runManuscriptLlmCheck(ctx, {+ stage: REACTION_PROPORTIONALITY_STAGE,+ category: 'emotion',+ context: { sceneMap },+ buildVars: (manuscript, _meta, c) => ({ manuscript, sceneMap: c.sceneMap }),+ // A reaction is proportionate (or not) only relative to the event that+ // triggered it — and the event and its (missing) processing can be issues+ // apart. The findings digest keeps prior findings in view so a later chunk+ // doesn't re-flag the same gap, and the clean-setup digest rolls forward+ // every high-magnitude event that has NOT yet drawn a proportionate+ // reaction so a later chunk can flag the unprocessed trauma even when it+ // happened pages earlier. Unlike the climax check there is no final-part+ // gate: an over-reaction is visible in its own chunk, and an under-reaction+ // is flaggable as soon as enough subsequent text has passed with no payoff.+ crossChunkDigest: true,+ crossChunkSetup: true,+ setupFocus: 'List the high-magnitude emotional events seen so far (a death, trauma, betrayal, '+ + 'a major loss or hard-won victory) and, for each, whether the affected character has yet shown '+ + 'a proportionate on-page reaction or processed it. CRUCIALLY: carry forward every event that is '+ + 'still AWAITING a proportionate reaction — record which character it befell, which issue it '+ + 'occurred in, and a short note on its magnitude — and drop it only once the prose has paid it '+ + 'off with a fitting reaction. This lets a later part flag a trauma that is introduced early and '+ + 'then left unprocessed many issues later.',+ });+ },+ },{id: 'relationships.reciprocity',sources: ['canon'],diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex b4bda4ec8f..7cccabd325 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -56,6 +56,7 @@ const UNMODELED_NAMES = 'roster.unmodeled-names';const TIMELINE_CONTRADICTION = 'continuity.timeline-contradiction';const CHARACTER_CONSISTENCY = 'character.consistency';const CLIMAX_AGENCY = 'arc.climax-agency';+const REACTION_PROPORTIONALITY = 'emotion.reaction-proportionality';// A minimal valid stored custom-check definition.const customDef = (over = {}) => ({@@ -1286,6 +1287,77 @@ describe('arc.climax-agency — LLM check (#1583)', () => {});});+describe('emotion.reaction-proportionality — LLM check (#1584)', () => {+ const wholeCtx = (overrides = {}) => ({+ manuscript: '# Issue 1\n\nThe bomb killed her brother. She made breakfast.',+ config: { maxFindings: 12 },+ severityDefault: 'medium',+ reverseOutline: [{ sequence: 0, issueNumber: 1, heading: 'The blast', setting: 'the kitchen', charactersPresent: ['Mara'] }],+ planManuscriptChunks: async () => ['# Issue 1\n\nThe bomb killed her brother. She made breakfast.'],+ callStagedLLM: async () => ({ content: { findings: [] } }),+ ...overrides,+ });++ it('is registered as a series-scoped LLM check reading manuscript + outline with category emotion', () => {+ const check = getCheck(REACTION_PROPORTIONALITY);+ expect(check.kind).toBe('llm');+ expect(check.scope).toBe('series');+ expect(check.category).toBe('emotion');+ expect(check.severityDefault).toBe('medium');+ expect(check.sources).toEqual(['manuscript', 'reverseOutline']);+ expect(check.needsManuscript).toBe(true);+ });++ it('only runs when there is drafted prose to scan', () => {+ const check = getCheck(REACTION_PROPORTIONALITY);+ expect(check.gate({ manuscript: '' })).toBe(false);+ expect(check.gate({ manuscript: '# Issue 1\n\nprose' })).toBeTruthy();+ });++ it('passes the manuscript + scene map to the model and forces the emotion category', async () => {+ let seenVars = null;+ const ctx = wholeCtx({+ planManuscriptChunks: async (_stage, opts) => {+ // The scene map rides as trimmable context with a non-zero overhead.+ expect(opts.context).toHaveProperty('sceneMap');+ expect(opts.fixedOverheadTokens).toBeGreaterThan(0);+ return ['# Issue 1\n\nThe bomb killed her brother. She made breakfast.'];+ },+ callStagedLLM: async (_stage, vars) => {+ seenVars = vars;+ return { content: { findings: [{ severity: 'high', issueNumber: 1, location: 'Issue 1 — Mara — under-reaction', problem: 'Her brother dies and she shows no reaction' }] } };+ },+ });+ const findings = await getCheck(REACTION_PROPORTIONALITY).run(ctx);+ expect(seenVars.manuscript).toBe('# Issue 1\n\nThe bomb killed her brother. She made breakfast.');+ expect(seenVars.sceneMap).toContain('Issue 1: The blast');+ expect(findings).toHaveLength(1);+ expect(findings[0].category).toBe('emotion');+ expect(findings[0].location).toBe('Issue 1 — Mara — under-reaction');+ });++ it('passes an empty scene map when the series has no reverse outline', async () => {+ let seenVars = null;+ const ctx = wholeCtx({+ reverseOutline: undefined,+ callStagedLLM: async (_stage, vars) => { seenVars = vars; return { content: { findings: [] } }; },+ });+ await getCheck(REACTION_PROPORTIONALITY).run(ctx);+ expect(seenVars.sceneMap).toBe('');+ });++ it('does not gate on a final part — every chunk can report a proportionality finding', async () => {+ const seen = [];+ const ctx = wholeCtx({+ planManuscriptChunks: async () => ['# Issue 1\n\np1', '# Issue 2\n\np2'],+ callStagedLLM: async (_stage, vars) => { seen.push(vars); return { content: { findings: [] } }; },+ });+ await getCheck(REACTION_PROPORTIONALITY).run(ctx);+ // Unlike the climax check, no chunk receives a finalPart gate var.+ expect(seen.every((v) => !('finalPart' in v))).toBe(true);+ });+});+describe('declaredThemesSummary (#1317)', () => {it('returns an empty string when there are no themes', () => {expect(declaredThemesSummary(null)).toBe('');