From 78cac9f8cb562891c525f303fda5fe150417a88e Mon Sep 17 00:00:00 2001 From: Eddy Date: Mon, 6 Jul 2026 00:56:18 +0200 Subject: [PATCH] fix: report processed files after ingest byte cap --- src/__tests__/ingest-limits.test.ts | 2 ++ src/recon/code-ingest.ts | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/__tests__/ingest-limits.test.ts b/src/__tests__/ingest-limits.test.ts index 964316c..9167839 100644 --- a/src/__tests__/ingest-limits.test.ts +++ b/src/__tests__/ingest-limits.test.ts @@ -36,6 +36,8 @@ describe('ingest ceilings (bounded ingest, non-regressing)', () => { const dir = makeRepo(20); dirs.push(dir); const res = ingestRepository(cfg(dir, { maxTotalBytes: 50 })); // ~30 bytes/file → breaks after ~2 expect(res.stats.truncated).toBe(true); + expect(res.stats.files).toBeLessThan(20); + expect(res.stats.files).toBe(res.stats.blocks); // fixture has one block per processed file expect(res.stats.blocks).toBeGreaterThan(0); }); diff --git a/src/recon/code-ingest.ts b/src/recon/code-ingest.ts index ec8d394..7ebac16 100644 --- a/src/recon/code-ingest.ts +++ b/src/recon/code-ingest.ts @@ -753,6 +753,7 @@ export function ingestRepository(config: IngestConfig): IngestResult { let truncated = config.maxFiles !== undefined && files.length >= config.maxFiles; const allBlocks: CodeBlock[] = []; + let processedFiles = 0; for (const path of files) { let content: string; try { @@ -760,6 +761,7 @@ export function ingestRepository(config: IngestConfig): IngestResult { } catch { continue; } + processedFiles += 1; totalBytes += content.length; allBlocks.push(...parseFile(path, content)); if (maxTotalBytes !== undefined && totalBytes >= maxTotalBytes) { @@ -775,7 +777,7 @@ export function ingestRepository(config: IngestConfig): IngestResult { const reach = reachability(callGraph, entryPoints); const stats: IngestResult['stats'] = { - files: files.length, + files: processedFiles, blocks: allBlocks.length, exposed_externally: 0, exposed_internally: 0,