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): bound info-dumping prompt to avoid context overflow

[._.]/ Adam Eivy5d2270fcdab0
diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.js
index bb6f61c9f4..4321840272 100644
--- a/server/lib/editorial/checkRegistry.js
+++ b/server/lib/editorial/checkRegistry.js
@@ -116,12 +116,22 @@ export const EDITORIAL_CHECKS = [
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),
+ // Bound the prompt so a long series can't overflow a small/local
+ // provider's context window (which would reject/clip the call and yield
+ // zero findings). This is a single-call safeguard — full per-provider
+ // context-window chunking (à la completenessPass) is tracked separately.
+ maxManuscriptChars: z.number().int().min(2000).max(200_000).default(48_000),
}),
gate: (ctx) => (ctx.manuscript || '').trim().length > 0,
run: async (ctx) => {
+ const cap = ctx.config?.maxManuscriptChars ?? 48_000;
+ const full = ctx.manuscript || '';
+ const manuscript = full.length > cap
+ ? `${full.slice(0, cap)}\n\n[manuscript truncated to the first ${cap} characters for this check]`
+ : full;
const { content } = await ctx.callStagedLLM(
INFO_DUMPING_STAGE,
- { manuscript: ctx.manuscript },
+ { manuscript },
{ returnsJson: true, source: INFO_DUMPING_STAGE },
);
const raw = Array.isArray(content?.findings) ? content.findings : [];
diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.js
index 0288efc0eb..4369fdbafd 100644
--- a/server/lib/editorial/checkRegistry.test.js
+++ b/server/lib/editorial/checkRegistry.test.js
@@ -113,6 +113,49 @@ describe('editorial check registry — config + state resolution', () => {
});
});
+describe('prose.info-dumping — LLM check', () => {
+ it('caps the manuscript sent to the model so a long corpus cannot overflow context', async () => {
+ let sent = null;
+ const ctx = {
+ manuscript: 'x'.repeat(100_000),
+ config: { maxManuscriptChars: 10_000, maxFindings: 12 },
+ severityDefault: 'medium',
+ callStagedLLM: async (_stage, vars) => { sent = vars.manuscript; return { content: { findings: [] } }; },
+ };
+ await getCheck(INFODUMP).run(ctx);
+ expect(sent.length).toBeLessThan(11_000); // 10k cap + a short truncation note
+ expect(sent).toContain('truncated');
+ });
+
+ it('passes a short manuscript through untruncated and shapes findings', async () => {
+ const ctx = {
+ manuscript: 'As you know, Bob, the kingdom fell.',
+ config: { maxManuscriptChars: 48_000, maxFindings: 12 },
+ severityDefault: 'medium',
+ callStagedLLM: async (_stage, vars) => {
+ expect(vars.manuscript).not.toContain('truncated');
+ return { content: { findings: [{ severity: 'high', issueNumber: 1, problem: 'dump', anchorQuote: 'As you know', suggestion: 'cut' }] } };
+ },
+ };
+ const findings = await getCheck(INFODUMP).run(ctx);
+ expect(findings).toHaveLength(1);
+ expect(findings[0].category).toBe('exposition');
+ expect(findings[0].issueNumber).toBe(1);
+ });
+
+ it('respects maxFindings', async () => {
+ const many = Array.from({ length: 30 }, (_, i) => ({ severity: 'low', problem: `p${i}`, anchorQuote: `a${i}` }));
+ const ctx = {
+ manuscript: 'short',
+ config: { maxManuscriptChars: 48_000, maxFindings: 5 },
+ severityDefault: 'medium',
+ callStagedLLM: async () => ({ content: { findings: many } }),
+ };
+ const findings = await getCheck(INFODUMP).run(ctx);
+ expect(findings).toHaveLength(5);
+ });
+});
+
describe('naming.dissimilar-names — deterministic check', () => {
const run = (characters, config = { minSharedSignals: 2 }) =>
getCheck(NAMING).run({ canon: { characters }, config, severityDefault: 'low' });