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

fix: gate objects.weight-proportionality verdict to the final manuscript part (#1624)

[._.]/ Adam Eivyf9f7a2d8b3de
diff --git a/data.reference/prompts/stages/pipeline-editorial-object-weight-proportionality.md b/data.reference/prompts/stages/pipeline-editorial-object-weight-proportionality.md
index 99f0138222..b8b2dea43a 100644
--- a/data.reference/prompts/stages/pipeline-editorial-object-weight-proportionality.md
+++ b/data.reference/prompts/stages/pipeline-editorial-object-weight-proportionality.md
@@ -43,6 +43,25 @@ The manuscript is stitched from the drafted issues. Each section begins with a
header like `# Issue 3 — Title (prose)`; use the issue number in that header to
attribute each finding to its `issueNumber`.
+{{#finalPart}}
+You are seeing the FINAL part of the manuscript, so the whole story is now in
+view and you may judge each object's overall weight against its overall
+prominence. The "setup so far" digest above carries each object's established
+backstory/significance and how prominent it has been, so an object that pays off
+here can be weighed against lineage planted pages earlier, and an object whose
+backstory loaded up early can be judged against how little (or much) the whole
+story actually used it.
+{{/finalPart}}
+{{^finalPart}}
+You are seeing an EARLIER part of a long manuscript reviewed in pieces. Do NOT
+yet flag an over- or under-weighted object — a later part may pay off an object
+that looks over-weighted now, or establish lineage for one that looks
+under-established. Note each object's prominence and the backstory/significance
+established so far (the "setup so far" digest carries this forward) but reserve
+every weight-proportionality verdict for the final part, and return an empty
+`findings` array for this part.
+{{/finalPart}}
+
```
{{manuscript}}
```
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.js
index 0998d59b7f..9c8c3c031a 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -5097,6 +5097,7 @@ export const EDITORIAL_CHECKS = [
kind: 'llm',
category: 'plot',
severityDefault: 'low',
+ 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,
@@ -5125,19 +5126,37 @@ export const EDITORIAL_CHECKS = [
stage: OBJECT_WEIGHT_STAGE,
category: 'plot',
context: { objects },
- buildVars: (manuscript, _meta, c) => ({ manuscript, objects: c.objects }),
+ // `finalPart` gates the whole-corpus verdict. Both directions of this check
+ // are whole-story claims: "over-weighted" needs the object's TOTAL prominence
+ // (a non-final chunk can't know a barely-used object pays off later), and
+ // "under-established" needs the object's TOTAL lineage (the backstory may sit
+ // in an earlier chunk, carried in the setup digest). runChunkedManuscriptCheck
+ // merges findings first-wins and never retracts, so an imbalance reported from
+ // a non-final chunk would persist even after a later chunk clears it — so a
+ // non-final chunk only carries setup forward and the verdict waits for the
+ // final part. A single-chunk run is its own final part and judges the whole text.
+ buildVars: (manuscript, meta, c) => ({
+ manuscript,
+ objects: c.objects,
+ finalPart: meta?.isFinal ? 'true' : '',
+ }),
// An object's backstory can be planted in an early chapter and its
// prominence (or payoff) land much later; the findings digest stops a
// later chunk re-flagging the same imbalance the prose only half-shows.
crossChunkDigest: true,
// …and a cleanly proportioned object produces no finding, so the findings
// digest alone can't carry it forward — roll a setup summary of each
- // object and the backstory/significance the prose has established so a
- // late payoff is weighed against the full lineage, not just its chunk.
+ // object and the backstory/significance the prose has established so the
+ // final part weighs a payoff against the full lineage, not just its chunk.
crossChunkSetup: true,
+ // #1667: the verdict is gated to the final part and weighs each object against
+ // its carried prominence/lineage snapshot, so guarantee the setup digest reaches
+ // the final chunk (trim its manuscript tail to fit) rather than letting a packed
+ // final chunk drop the snapshot and judge an object on its last chunk alone.
+ reserveSetupDigest: true,
setupFocus: 'Objects/items the story features, how prominent or decisive each one is, and the depth '
- + 'of backstory, lineage, or significance the prose or canon has established for it (so a later '
- + 'payoff is weighed against the full established weight, not just the current part).',
+ + 'of backstory, lineage, or significance the prose or canon has established for it (so the final '
+ + 'part weighs a payoff against the full established weight, not just the current part).',
});
},
},
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index 5b53d6489c..84de5862d3 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -3697,6 +3697,34 @@ describe('cross-chunk continuity digest (#1383)', () => {
expect(seen[1].endsWith('CHUNK_TWO')).toBe(true);
});
+ it('objects.weight-proportionality feeds the prior-chunk digest to later chunks and gates finalPart to the last chunk', async () => {
+ const seen = [];
+ const finalFlags = [];
+ await getCheck('objects.weight-proportionality').run({
+ config: { maxFindings: 12 },
+ severityDefault: 'low',
+ canon: {
+ objects: [{ id: 'o1', name: 'Locket', significance: 'an ancestral heirloom', attachments: [{ characterId: 'c1', emotion: 'reverence' }] }],
+ characters: [{ id: 'c1', name: 'Mara' }],
+ },
+ planManuscriptChunks: async () => ['CHUNK_ONE', 'CHUNK_TWO'],
+ callStagedLLM: async (_stage, vars) => {
+ seen.push(vars.manuscript);
+ finalFlags.push(vars.finalPart);
+ // Only the first chunk surfaces a finding, so the digest fed to chunk two carries it.
+ const findings = seen.length === 1
+ ? [{ severity: 'low', issueNumber: 1, problem: 'locket over-weighted', anchorQuote: 'the locket' }]
+ : [];
+ return { content: { findings } };
+ },
+ });
+ expect(seen[0]).toBe('CHUNK_ONE');
+ expect(seen[1]).toContain('EARLIER parts of this manuscript');
+ expect(seen[1].endsWith('CHUNK_TWO')).toBe(true);
+ // The whole-corpus verdict is gated: only the FINAL chunk is flagged finalPart.
+ expect(finalFlags).toEqual(['', 'true']);
+ });
+
it('prose.info-dumping stays per-chunk — no digest is prepended (its problems are localized)', async () => {
const { seen } = await runTwoChunks(INFODUMP, {
manuscript: 'CHUNK_ONE',
@@ -3810,6 +3838,21 @@ describe('cross-chunk clean-setup digest (#1403)', () => {
expect(seen[1].endsWith('CHUNK_TWO')).toBe(true);
});
+ it('objects.weight-proportionality rolls a setup summary forward keyed on object weight/prominence', async () => {
+ const { seen, setupPrompts } = await runTwoChunksWithSetup('objects.weight-proportionality', {
+ canon: {
+ objects: [{ id: 'o1', name: 'Locket', significance: 'an ancestral heirloom', attachments: [{ characterId: 'c1', emotion: 'reverence' }] }],
+ characters: [{ id: 'c1', name: 'Mara' }],
+ },
+ });
+ expect(seen[0]).toBe('CHUNK_ONE');
+ expect(setupPrompts).toHaveLength(1);
+ // The setup focus tracks each object's prominence + established lineage so the final part can weigh a late payoff.
+ expect(setupPrompts[0]).toMatch(/prominent or decisive/);
+ expect(seen[1]).toContain('Setup already established in EARLIER parts');
+ expect(seen[1].endsWith('CHUNK_TWO')).toBe(true);
+ });
+
it('runs the setup-summary on the check STAGE (so it follows the stage provider pin) with the dedicated source tag', async () => {
let source = null;
let stageSeen = null;