From 19eeab64e909e96b3a9640cefefef4bd174d7133 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 08:56:39 +0000 Subject: [PATCH] test(plugin-approvals): seed the #37808 stranded-scan cases in batches, not 1200 serial inserts The "older strand outside the newest window" case seeded 1201 rows with one engine insert each; that seeding was ~90% of the case's ~1 s locally and 5.8-13 s on loaded merge-queue runners, past the 5 s test default, so it ejected unrelated PRs from the queue. The rows now go through the engine's own array insert, 200 rows per batch (SQLite refuses a multi-row INSERT past its 500-term compound SELECT). Rows, order and every assertion are unchanged; the 600-row case additionally asserts all 601 rows are read. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgVv7fqmna3sqqbjzf2 --- .../src/stranded-request-inspection.test.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/plugins/plugin-approvals/src/stranded-request-inspection.test.ts b/packages/plugins/plugin-approvals/src/stranded-request-inspection.test.ts index f009f905114..ae29f1df256 100644 --- a/packages/plugins/plugin-approvals/src/stranded-request-inspection.test.ts +++ b/packages/plugins/plugin-approvals/src/stranded-request-inspection.test.ts @@ -795,8 +795,17 @@ describe('#37808 — past 500 decided requests, a new strand is still reported', svc.attachAutomation(surface(strandedRuns) as any); return svc; }; + // [#38223] Seeded in batches through the engine's own array insert, not one + // `insert` per row: 1200 serial single-row writes were ~90% of the slowest + // case's ~1 s locally and 5.8–13 s on loaded merge-queue runners, past the + // 5 s test default. The rows, their order and every assertion are unchanged; + // the batch is ≤ 200 rows because SQLite refuses a multi-row INSERT past its + // 500-term compound SELECT limit. + const SEED_BATCH = 200; const insertAll = async (rows: FakeRow[]) => { - for (const row of rows) await engine.insert('sys_approval_request', row, { context: { isSystem: true } } as any); + for (let i = 0; i < rows.length; i += SEED_BATCH) { + await engine.insert('sys_approval_request', rows.slice(i, i + SEED_BATCH), { context: { isSystem: true } } as any); + } }; // A fresh in-memory store per test: each one counts rows from zero. @@ -837,6 +846,8 @@ describe('#37808 — past 500 decided requests, a new strand is still reported', // The newest decision: its run is gone. await insertAll([decided(++seq, { flow_run_id: 'run_new_strand' })]); const out = await freshService(['run_new_strand']).inspectStrandedRequests(); + // Newest window (ids 102–601) plus the first walk page (ids 1–500): every one of the 601 seeded rows is read. + expect(out.scanned).toBe(601); expect(out.stranded.map(s => s.runId)).toEqual(['run_new_strand']); });