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
fix(#1584): gate under-reaction findings to the final part so a later payoff can't be falsely flagged
[._.]/ Adam Eivy0e5f55671ab7
diff --git a/data.reference/prompts/stages/pipeline-editorial-reaction-proportionality.md b/data.reference/prompts/stages/pipeline-editorial-reaction-proportionality.mdindex fcbf0b8934..2d77849782 100644--- a/data.reference/prompts/stages/pipeline-editorial-reaction-proportionality.md+++ b/data.reference/prompts/stages/pipeline-editorial-reaction-proportionality.md@@ -50,13 +50,28 @@ right `issueNumber`.The manuscript is stitched from the drafted issues. Section headers attributeeach 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).+in each header to attribute every finding to its `issueNumber`.++{{#finalPart}}+This is the FINAL part of the manuscript — the whole story is now in view, so an+**under-reaction** ("a high-magnitude event is never processed afterward") can now+be judged: a payoff would have appeared by now if it were coming. **The event may+have appeared in an EARLIER part, not in the text below.** The "setup so far"+digest above carries forward every high-magnitude event still AWAITING a+proportionate reaction (the affected character, its issue, and its magnitude) —+flag each such event that the whole story never pays off, attributing the finding+to the issue where the reaction SHOULD have landed. Also report any over-reaction+in the text below.+{{/finalPart}}+{{^finalPart}}+This is NOT the final part of the manuscript. Do NOT report any **under-reaction**+finding here — a later part may still process the event, and a premature+"never processed" claim cannot be retracted. High-magnitude events that have not+yet drawn a proportionate reaction are carried forward in the "setup so far"+digest and judged once the final part is in view. In this part report ONLY+**over-reactions** (a reaction wildly out of proportion to its trigger is fully+visible in the text that contains it).+{{/finalPart}}```{{manuscript}}@@ -65,7 +80,8 @@ landed (the event's issue, or a later issue that pointedly ignores it).## TaskIdentify events whose emotional weight and the on-page reaction are out of-balance. For each genuine finding:+balance — subject to the part gate above (under-reactions only in the final part;+over-reactions in any part). 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).diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex 43c68beeae..f5b69782bd 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -3553,16 +3553,26 @@ export const EDITORIAL_CHECKS = [stage: REACTION_PROPORTIONALITY_STAGE,category: 'emotion',context: { sceneMap },- buildVars: (manuscript, _meta, c) => ({ manuscript, sceneMap: c.sceneMap }),+ // `finalPart` gates ONLY the under-reaction verdict. "A high-magnitude+ // event is never processed afterward" is a whole-story claim — a non-final+ // chunk can't know whether a LATER chunk pays the event off, and+ // runChunkedManuscriptCheck merges findings first-wins and never retracts,+ // so an under-reaction reported early would persist even after a later+ // payoff clears it (a false positive). Over-reactions stay local — a+ // disproportionate reaction is fully visible in the chunk that contains it.+ // A single-chunk run is its own final part and judges the whole text.+ buildVars: (manuscript, meta, c) => ({+ manuscript,+ sceneMap: c.sceneMap,+ finalPart: meta?.isFinal ? 'true' : '',+ }),// 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.+ // reaction so the FINAL chunk can flag the unprocessed trauma even when it+ // happened pages earlier.crossChunkDigest: true,crossChunkSetup: true,setupFocus: 'List the high-magnitude emotional events seen so far (a death, trauma, betrayal, 'diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex 7cccabd325..5ec4dd3d7d 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -1346,15 +1346,23 @@ describe('emotion.reaction-proportionality — LLM check (#1584)', () => {expect(seenVars.sceneMap).toBe('');});- it('does not gate on a final part — every chunk can report a proportionality finding', async () => {- const seen = [];+ it('marks a single-chunk run as the final part so the under-reaction verdict is enabled', async () => {+ let seenVars = null;const ctx = wholeCtx({- planManuscriptChunks: async () => ['# Issue 1\n\np1', '# Issue 2\n\np2'],- callStagedLLM: async (_stage, vars) => { seen.push(vars); return { content: { findings: [] } }; },+ callStagedLLM: async (_stage, vars) => { seenVars = 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);+ expect(seenVars.finalPart).toBe('true');+ });++ it('flags only the LAST part as final across a chunked manuscript (under-reaction gate)', 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(REACTION_PROPORTIONALITY).run(ctx);+ expect(finals).toEqual(['', '', 'true']);});});