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

address review (codex): gate Chekhov 'planted, never fired' to the final manuscript part

Adam Eivy8d7b404aeef1
diff --git a/data.reference/prompts/stages/pipeline-editorial-chekhov.md b/data.reference/prompts/stages/pipeline-editorial-chekhov.md
index 6e1e0ee28b..f30535fd8f 100644
--- a/data.reference/prompts/stages/pipeline-editorial-chekhov.md
+++ b/data.reference/prompts/stages/pipeline-editorial-chekhov.md
@@ -22,15 +22,33 @@ the threat lands, the skill is used at a decisive moment.
## What to flag
+Two failure modes:
+
+- **Fired, never planted** — "the antidote appears in Issue 7 with no prior
+ setup"; "she suddenly picks a lock she was never shown able to pick." A payoff
+ that lands unearned because nothing set it up. Judge this in **every** part:
+ the digest of setups established in earlier parts (above, when present) tells
+ you what was already planted, so a payoff whose setup appears nowhere — not in
+ this part and not in that digest — is unearned.
- **Planted, never fired** — "the locked drawer introduced in Issue 2 is never
opened"; "Issue 1 makes a point of Mara's fear of water, but she never faces
it." A setup the reader is primed to expect a payoff for, that the manuscript
- drops.
-- **Fired, never planted** — "the antidote appears in Issue 7 with no prior
- setup"; "she suddenly picks a lock she was never shown able to pick." A payoff
- that lands unearned because nothing set it up.
-- **Secret never spilled / fear never confronted / promise never resolved** —
- specific sub-cases of *planted, never fired* worth naming as such.
+ drops. Sub-cases worth naming as such: **secret never spilled**, **fear never
+ confronted**, **promise never resolved**.
+
+{{#finalPart}}
+This is the **final part** of the manuscript, so you can now judge *planted,
+never fired*: read the setups established in earlier parts (the digest above,
+when present) together with this part, and report any planted element you can
+confirm is **never paid off anywhere**.
+{{/finalPart}}
+{{^finalPart}}
+**You are reading the manuscript in PARTS and have not yet seen the later
+parts.** A setup introduced here may be paid off in a part you have not seen
+yet — so do **NOT** report *planted, never fired* in this part. Report only
+*fired, never planted* here. The setups you see in this part are carried forward
+and judged for payoff once the final part is in view.
+{{/finalPart}}
Do NOT flag: a deliberately unresolved thread the story clearly intends to carry
into a later installment; incidental scenery that is plainly not presented as
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.js
index 774090ce49..94123a34eb 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -479,7 +479,13 @@ async function runChunkedManuscriptCheck(ctx, { chunks, category, max, callChunk
// coverage and the findings digest both win over the setup digest if budget is tight.
if (setup && setup.length <= usableChars - text.length) text = `${setup}${text}`;
}
- const content = await callChunk(text);
+ // `isFinal` lets a check distinguish the last part of a chunked manuscript
+ // from earlier ones (#1299): a whole-corpus judgment like "this setup is
+ // never paid off" can only be made once the final part is in view, so the
+ // Chekhov check defers its "planted, never fired" findings to it. A
+ // single-chunk run is its own final part, so the common (provider-fits-the-
+ // book) case judges against the whole text. Existing checks ignore the arg.
+ const content = await callChunk(text, { isFinal: i === chunks.length - 1 });
for (const f of mapLlmFindings(content?.findings, {
severityDefault: ctx.severityDefault,
category,
@@ -510,8 +516,10 @@ async function runChunkedManuscriptCheck(ctx, { chunks, category, max, callChunk
// Shared body for a manuscript-consuming LLM check. Plans the manuscript into
// provider-sized chunks for `stage` (via the runner-injected
// `ctx.planManuscriptChunks`), runs the model on each chunk, and merges the
-// findings first-wins (capped at the check's `maxFindings`). `buildVars(chunk)`
-// returns the stage vars — only the manuscript var changes per chunk. These
+// findings first-wins (capped at the check's `maxFindings`). `buildVars(chunk, meta)`
+// returns the stage vars — only the manuscript var changes per chunk; `meta.isFinal`
+// is true on the last (or only) chunk so a check can gate whole-corpus judgments to
+// it (the Chekhov "planted, never fired" pass). Existing checks ignore `meta`. These
// checks are all manuscript-scoped, so findings keep a model-supplied issue
// number (`withIssueNumber: true`).
//
@@ -546,8 +554,8 @@ async function runManuscriptLlmCheck(ctx, { stage, category, overheadTokens = 0,
max,
crossChunkDigest,
summarizeChunk,
- callChunk: async (manuscript) => {
- const { content } = await ctx.callStagedLLM(stage, buildVars(manuscript), { returnsJson: true, source: stage });
+ callChunk: async (manuscript, meta) => {
+ const { content } = await ctx.callStagedLLM(stage, buildVars(manuscript, meta), { returnsJson: true, source: stage });
return content;
},
});
@@ -1752,7 +1760,12 @@ export const EDITORIAL_CHECKS = [
stage: CHEKHOV_STAGE,
category: 'continuity',
overheadTokens: EDITORIAL_PROMPT_OVERHEAD_TOKENS + estimateTokens(authoredSetups),
- buildVars: (manuscript) => ({ manuscript, authoredSetups }),
+ // `finalPart` gates the whole-corpus "planted, never fired" judgment to the
+ // last part of a chunked manuscript (#1299) — an earlier part can't know a
+ // setup pays off later, so it would false-flag. A single-chunk run is its own
+ // final part. "fired, never planted" stays enabled on every part (the carried
+ // setup digest tells a later part what was already planted).
+ buildVars: (manuscript, meta) => ({ manuscript, authoredSetups, finalPart: meta?.isFinal ? 'true' : '' }),
// A setup planted in chapter 2 and paid off (or NOT) in chapter 9 spans
// chunks — the cross-chunk digest keeps prior findings in view so a later
// chunk doesn't re-flag, and the clean-setup digest rolls forward which
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index 0a1cf2af47..fd690cbe6d 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -390,6 +390,26 @@ describe('chekhov.setups-payoffs — LLM check (#1299)', () => {
await getCheck(CHEKHOV).run(ctx);
expect(seenVars.authoredSetups).toBe('');
});
+
+ it('marks a single-chunk run as the final part so whole-corpus "never fired" judgments are enabled', async () => {
+ let seenVars = null;
+ const ctx = wholeCtx({
+ callStagedLLM: async (_stage, vars) => { seenVars = vars; return { content: { findings: [] } }; },
+ });
+ await getCheck(CHEKHOV).run(ctx);
+ expect(seenVars.finalPart).toBe('true');
+ });
+
+ it('flags only the LAST part as final across a chunked manuscript (#1299)', async () => {
+ const finals = [];
+ const ctx = wholeCtx({
+ planManuscriptChunks: async () => ['# Issue 1\n\npart one', '# Issue 2\n\npart two', '# Issue 3\n\npart three'],
+ callStagedLLM: async (_stage, vars) => { finals.push(vars.finalPart); return { content: { findings: [] } }; },
+ });
+ await getCheck(CHEKHOV).run(ctx);
+ // Earlier parts can't know a setup pays off later → not final; only the last is.
+ expect(finals).toEqual(['', '', 'true']);
+ });
});
describe('authoredSetupPayoffSummary (#1299)', () => {