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(#1583): feed only payoffs to climax check + forbid non-final climax verdicts
[._.]/ Adam Eivy69d8e0c9675f
diff --git a/data.reference/prompts/stages/pipeline-editorial-climax-agency.md b/data.reference/prompts/stages/pipeline-editorial-climax-agency.mdindex ec65aa4f27..96b3a21c35 100644--- a/data.reference/prompts/stages/pipeline-editorial-climax-agency.md+++ b/data.reference/prompts/stages/pipeline-editorial-climax-agency.md@@ -81,11 +81,13 @@ This is the FINAL part of the manuscript — the whole story is now in view, soclimax can be identified and judged. Make your climax verdict here.{{/finalPart}}{{^finalPart}}-This is NOT the final part of the manuscript — the climax has likely not arrived-yet. Do NOT flag a climax verdict in this part; an earlier scene that looks like-a turning point may be set up to be eclipsed by the real climax later. Return an-empty `findings` array unless you can already see a clearly-completed climax in-this chunk.+This is NOT the final part of the manuscript. The climax is a SINGLE whole-story+event that can only be identified once the entire story is in view — and an+earlier high-stakes scene (a mid-story battle, a per-issue turning point, a false+victory) is NOT the climax, no matter how complete it looks in isolation. Do NOT+report any climax finding in this part — return an empty `findings` array. The+central problem and the protagonist's pattern of agency are carried forward and+judged once the final part is in view.{{/finalPart}}```diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex c2033b9c34..8910b48f23 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -217,21 +217,25 @@ export const ENDINGS_CLIFFHANGER_STAGE = 'pipeline-editorial-endings-cliffhanger// logged. Pure + deterministic so it's unit-testable and so its token cost can be// counted into the per-chunk overhead. Returns '' when nothing is authored (the// prompt's `{{#authoredSetups}}` section then renders nothing).+// Render one reader-map entry (hook or payoff) to a `- text (arc position N)` line.+// Shared by authoredSetupPayoffSummary + authoredPayoffsSummary. Returns '' for an+// entry with no usable label/note so callers can `.filter(Boolean)`.+function renderReaderMapEntryLine(e) {+ const label = typeof e?.label === 'string' ? e.label.trim() : '';+ const note = typeof e?.note === 'string' ? e.note.trim() : '';+ const text = label && note ? `${label} — ${note}` : (label || note);+ if (!text) return '';+ // A coarse expected-location hint so the model can reason about WHERE an+ // authored hook should have paid off (reconciliation signal, #1299).+ const pos = Number.isFinite(e?.atArcPosition) ? ` (arc position ${e.atArcPosition})` : '';+ return `- ${text}${pos}`;+}+export function authoredSetupPayoffSummary(readerMap) {const hooks = Array.isArray(readerMap?.hooks) ? readerMap.hooks : [];const payoffs = Array.isArray(readerMap?.payoffs) ? readerMap.payoffs : [];- const line = (e) => {- const label = typeof e?.label === 'string' ? e.label.trim() : '';- const note = typeof e?.note === 'string' ? e.note.trim() : '';- const text = label && note ? `${label} — ${note}` : (label || note);- if (!text) return '';- // A coarse expected-location hint so the model can reason about WHERE an- // authored hook should have paid off (reconciliation signal, #1299).- const pos = Number.isFinite(e?.atArcPosition) ? ` (arc position ${e.atArcPosition})` : '';- return `- ${text}${pos}`;- };- const hookLines = hooks.map(line).filter(Boolean);- const payoffLines = payoffs.map(line).filter(Boolean);+ const hookLines = hooks.map(renderReaderMapEntryLine).filter(Boolean);+ const payoffLines = payoffs.map(renderReaderMapEntryLine).filter(Boolean);if (!hookLines.length && !payoffLines.length) return '';const parts = [];if (hookLines.length) parts.push(`Authored hooks (questions the writer planted):\n${hookLines.join('\n')}`);@@ -239,6 +243,23 @@ export function authoredSetupPayoffSummary(readerMap) {return parts.join('\n\n');}+// Render ONLY the authored reader-map payoffs (#1583) — the resolutions the writer+// LOGGED that the reader was promised. The climax / resolution-power check passes+// this (NOT authoredSetupPayoffSummary, which also bundles hooks) so the prompt's+// "payoffs the climax should deliver" framing stays accurate: a hook is a question+// the writer planted, not a climax obligation, so feeding hooks here would risk the+// model flagging an ordinary unanswered hook as a missing climax resolution. Pure ++// deterministic so it's unit-testable and its token cost can be counted into the+// per-chunk overhead. Returns '' when no payoff is authored (the prompt's+// `{{#authoredPayoffs}}` section then renders nothing and the check reasons from the+// prose + themes alone).+export function authoredPayoffsSummary(readerMap) {+ const payoffs = Array.isArray(readerMap?.payoffs) ? readerMap.payoffs : [];+ const payoffLines = payoffs.map(renderReaderMapEntryLine).filter(Boolean);+ if (!payoffLines.length) return '';+ return `Authored payoffs (resolutions the writer logged — what the reader was promised):\n${payoffLines.join('\n')}`;+}+// Stage name for the cliché / dead-metaphor / overwriting LLM check (#1308).// Ships in data.reference/prompts/stages/ + stage-config.json (fresh installs// via setup-data.js) and migrates to existing installs via migration 101 (boot@@ -3419,7 +3440,7 @@ export const EDITORIAL_CHECKS = [// gracefully — no reader map ⇒ {{#authoredPayoffs}} renders nothing; no// themes ⇒ {{#declaredThemes}} renders nothing; no outline ⇒ {{#sceneMap}}// renders nothing and the model reasons from the prose's own shape.- const authoredPayoffs = authoredSetupPayoffSummary(ctx.series?.arc?.readerMap);+ const authoredPayoffs = authoredPayoffsSummary(ctx.series?.arc?.readerMap);const declaredThemes = declaredThemesSummary(ctx.series?.arc?.themes);const sceneMap = sceneGroundingSummary(ctx.reverseOutline);return runManuscriptLlmCheck(ctx, {diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex b7fa397a22..b4bda4ec8f 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -28,6 +28,7 @@ import {EDITORIAL_SETUP_DIGEST_CHARS,EDITORIAL_SETUP_DIGEST_SOURCE,authoredSetupPayoffSummary,+ authoredPayoffsSummary,authoredCliffhangerSummary,sceneGroundingSummary,characterVoiceProfiles,@@ -699,6 +700,34 @@ describe('authoredSetupPayoffSummary (#1299)', () => {});});+describe('authoredPayoffsSummary (#1583)', () => {+ it('returns an empty string when there are no authored payoffs', () => {+ expect(authoredPayoffsSummary(null)).toBe('');+ expect(authoredPayoffsSummary({})).toBe('');+ expect(authoredPayoffsSummary({ payoffs: [] })).toBe('');+ // Hooks alone do NOT produce a payoffs block — a hook is not a climax obligation.+ expect(authoredPayoffsSummary({ hooks: [{ label: 'Who killed the duke?' }] })).toBe('');+ });++ it('renders ONLY the payoffs (never the hooks), with an arc-position hint when present', () => {+ const out = authoredPayoffsSummary({+ hooks: [{ label: 'Who killed the duke?' }],+ payoffs: [{ label: 'The butler confesses', note: 'Issue 8', atArcPosition: 9 }, { label: 'The heir returns' }],+ });+ expect(out).toContain('Authored payoffs');+ expect(out).toContain('- The butler confesses — Issue 8 (arc position 9)');+ expect(out).toContain('- The heir returns');+ // The hook must never leak into the payoffs block.+ expect(out).not.toContain('Who killed the duke?');+ expect(out).not.toContain('Authored hooks');+ });++ it('drops entries with neither label nor note and falls back to note-only', () => {+ const out = authoredPayoffsSummary({ payoffs: [{ atArcPosition: 3 }, { note: 'a quiet reckoning' }] });+ expect(out).toContain('- a quiet reckoning');+ });+});+describe('plot.structure-momentum — LLM check (#1310)', () => {const wholeCtx = (overrides = {}) => ({manuscript: '# Issue 1\n\nThings happened to her, and then more things happened.',@@ -1168,7 +1197,10 @@ describe('arc.climax-agency — LLM check (#1583)', () => {severityDefault: 'medium',series: { arc: {themes: ['earning forgiveness'],- readerMap: { payoffs: [{ label: 'the debt is repaid', note: 'by the protagonist' }] },+ readerMap: {+ hooks: [{ label: 'who burned the village?' }],+ payoffs: [{ label: 'the debt is repaid', note: 'by the protagonist' }],+ },} },reverseOutline: [{ sequence: 0, issueNumber: 1, heading: 'The siege', setting: 'the gate', charactersPresent: ['Hero'] }],planManuscriptChunks: async () => ['# Issue 1\n\nThe hero waited as the cavalry arrived.'],@@ -1211,6 +1243,9 @@ describe('arc.climax-agency — LLM check (#1583)', () => {const findings = await getCheck(CLIMAX_AGENCY).run(ctx);expect(seenVars.manuscript).toBe('# Issue 1\n\nThe hero waited as the cavalry arrived and won the day.');expect(seenVars.authoredPayoffs).toContain('the debt is repaid');+ // Only PAYOFFS feed the climax check — a planted hook is not a climax+ // obligation, so it must NOT appear in the authoredPayoffs block (#1583).+ expect(seenVars.authoredPayoffs).not.toContain('who burned the village?');expect(seenVars.declaredThemes).toContain('earning forgiveness');expect(seenVars.sceneMap).toContain('Issue 1: The siege');expect(findings).toHaveLength(1);