Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
test(ingest): steadier IN-05 and one-file-batch scaling tests (#815)
Ian Hock249f4c6d3895
diff --git a/core-ingestion/src/__tests__/resolveEdges.batching.test.ts b/core-ingestion/src/__tests__/resolveEdges.batching.test.tsindex 31c2f43e..112bae37 100644--- a/core-ingestion/src/__tests__/resolveEdges.batching.test.ts+++ b/core-ingestion/src/__tests__/resolveEdges.batching.test.ts@@ -127,8 +127,8 @@ describe('resolveEdges scales with the repository', () => {it('doubling the files keeps the time well under quadratic', () => {// Best of seven on sizes large enough that one scheduler hiccup can't swing- // the ratio. Doubling measures ~2.2x locally but sits right at 3x on CI- // runners; quadratic would be ~4x, so 3.5x still catches it.+ // the ratio. Linear doubling is ~2x and quadratic ~4x; shared CI runners sit+ // well above linear, so the bound is 3.5x, which still catches quadratic.const time = (results: FileParseResult[]) => {const index = indexOf(results);return Math.min(...Array.from({ length: 7 }, () => {@@ -180,15 +180,25 @@ describe('resolveEdges against a summarized index', () => {}return { results, index: indexOf(results) };}- const time = ({ results, index }: ReturnType<typeof repo>) => Math.min(...[0, 1, 2].map(() => {+ // Best of seven samples, each resolving the batch REPEATS times. One+ // resolve of a one-file batch is so short that single resolves let one+ // scheduler hiccup swing the ratio past the old bound on CI runners+ // although the code was linear; several per sample lifts each sample+ // well above timer noise.+ const REPEATS = 5;+ const time = ({ results, index }: ReturnType<typeof repo>) => Math.min(...Array.from({ length: 7 }, () => {const t = performance.now();- resolveEdges([results[0]], undefined, index);+ for (let i = 0; i < REPEATS; i++) resolveEdges([results[0]], undefined, index);return performance.now() - t;}));const small = repo(3000);const large = repo(12000);- time(small); // warm up- // 4x the files: linear is ~4x, the old per-call de-dup was ~16x.- expect(time(large) / time(small)).toBeLessThan(8);- });+ time(small); // warm up both sizes+ time(large);+ // 4x the files: linear is ~4x (a little more, as the larger index costs a+ // little more per entry), the old per-call de-dup was ~16x. 10 leaves room+ // above linear for slow, noisy runners and still fails the quadratic+ // behaviour by a wide margin.+ expect(time(large) / time(small)).toBeLessThan(10);+ }, 60_000);});diff --git a/ix-cli/src/cli/__tests__/ingest-files.test.ts b/ix-cli/src/cli/__tests__/ingest-files.test.tsindex 3574ad79..c5703704 100644--- a/ix-cli/src/cli/__tests__/ingest-files.test.ts+++ b/ix-cli/src/cli/__tests__/ingest-files.test.ts@@ -1332,8 +1332,8 @@ describe("ingestFiles against a fake backend", () => {});describe("bulk requests bounded by size (IN-05)", () => {- // 1,100 files: three parse batches, so what the first batch learns has two- // more batches to hold for. The backend refuses a bulk over 300 ops.+ // More than one parse batch (500 files), so what the first batch learns has+ // a later batch to hold for. The backend refuses a bulk over 300 ops.const tooLarge = () => backend.requests.filter(r => r.path === "/v1/patches/bulk" && r.code === 413).length;const saved = process.env.IX_COMMIT_MAX_OPS;afterEach(() => {@@ -1341,8 +1341,14 @@ describe("ingestFiles against a fake backend", () => {else process.env.IX_COMMIT_MAX_OPS = saved;});- it("learns the size from the first 413 that suggests one, and is refused no more that run", async () => {- fixture(1100);+ // 560 files, two parse batches: 500, then 60. At 7 ops a file the second+ // batch is 420 ops, over the cap at the default bounds, so it is refused+ // too unless the run kept what the first batch learned. It used to be+ // 1,100 files (three batches), which timed out once on a slow Windows+ // runner; the second batch alone is what the assertion needs. The longer+ // timeout is a backstop for the fixture writes and parse there.+ it("learns the size from the first 413 that suggests one, and is refused no more that run", { timeout: 90_000 }, async () => {+ fixture(560);backend.maxBulkOps = 300;backend.suggestMaxPatches = true;@@ -1350,8 +1356,12 @@ describe("ingestFiles against a fake backend", () => {expect(tooLarge()).toBe(1);expect(summary.commitErrors).toBe(0);- expect(summary.patchesApplied).toBe(1100);+ expect(summary.patchesApplied).toBe(560);expect(backend.singleCount, "no per-file fallback").toBe(0);+ // Both batches were sent in bounded requests. Without the learned size,+ // the second batch goes out as one 60-patch request and is refused.+ const accepted = backend.requests.filter(r => r.path === "/v1/patches/bulk" && r.code !== 413);+ expect(Math.max(...accepted.map(r => r.patches))).toBeLessThanOrEqual(Math.floor(300 / 7));});it("halves by ops on a 413 that suggests nothing, and later batches start at the learned size", async () => {