fix: report processed files after ingest byte cap

This commit is contained in:
Eddy committed 2026-07-06 00:56:18 +02:00
1 parent a5667374bf
commit 78cac9f8cb
2 files changed
+5 -1

No files matched your search

+2
View File
@@ -36,6 +36,8 @@ describe('ingest ceilings (bounded ingest, non-regressing)', () => {
const dir = makeRepo(20); dirs.push(dir); const dir = makeRepo(20); dirs.push(dir);
const res = ingestRepository(cfg(dir, { maxTotalBytes: 50 })); // ~30 bytes/file → breaks after ~2 const res = ingestRepository(cfg(dir, { maxTotalBytes: 50 })); // ~30 bytes/file → breaks after ~2
expect(res.stats.truncated).toBe(true); 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); expect(res.stats.blocks).toBeGreaterThan(0);
}); });
+3 -1
View File
@@ -753,6 +753,7 @@ export function ingestRepository(config: IngestConfig): IngestResult {
let truncated = config.maxFiles !== undefined && files.length >= config.maxFiles; let truncated = config.maxFiles !== undefined && files.length >= config.maxFiles;
const allBlocks: CodeBlock[] = []; const allBlocks: CodeBlock[] = [];
let processedFiles = 0;
for (const path of files) { for (const path of files) {
let content: string; let content: string;
try { try {
@@ -760,6 +761,7 @@ export function ingestRepository(config: IngestConfig): IngestResult {
} catch { } catch {
continue; continue;
} }
processedFiles += 1;
totalBytes += content.length; totalBytes += content.length;
allBlocks.push(...parseFile(path, content)); allBlocks.push(...parseFile(path, content));
if (maxTotalBytes !== undefined && totalBytes >= maxTotalBytes) { if (maxTotalBytes !== undefined && totalBytes >= maxTotalBytes) {
@@ -775,7 +777,7 @@ export function ingestRepository(config: IngestConfig): IngestResult {
const reach = reachability(callGraph, entryPoints); const reach = reachability(callGraph, entryPoints);
const stats: IngestResult['stats'] = { const stats: IngestResult['stats'] = {
files: files.length, files: processedFiles,
blocks: allBlocks.length, blocks: allBlocks.length,
exposed_externally: 0, exposed_externally: 0,
exposed_internally: 0, exposed_internally: 0,