test: distinguish status-card candidate and revision reads

Retain independent coalescing budgets for candidate reconstruction and required generation-revision reads. Preserve pass/search/deadline/quiet limits; the prior classifier counted both query shapes as reconstruction.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-31 12:58:32 -05:00
1 parent 6313bcb066
commit 0b65f490d9
1 file changed
+8 -4
@@ -352,15 +352,19 @@ const support = external ? { supported: true } : await getEmbeddedPostgresTestSu
await flush();
}
await flush();
// One eager reconciliation after idle and one bounded batched continuation;
// the producers themselves are not counted as background SQL.
const dueReads = () => select.mock.calls.filter(([fields]) => fields && "card" in fields && fields.card === statusCards).length;
// One eager reconciliation after idle and one bounded batched continuation.
// Each pass reads candidates once; evaluating its one changed card also
// reads that card's revision for generation CAS. Bound both query classes
// independently; the producers are not counted as background SQL.
const dueReads = () => select.mock.calls.filter(([fields]) => fields && "card" in fields && fields.card === statusCards && !("revision" in fields)).length;
const revisionReads = () => select.mock.calls.filter(([fields]) => fields && "card" in fields && fields.card === statusCards && "revision" in fields).length;
const nextReads = () => select.mock.calls.filter(([fields]) => fields && "at" in fields && fields.at === statusCards.nextEvalAt).length;
const elapsedMs = Date.now() - burstStarted;
const maximum = Math.ceil(elapsedMs / 1000) + 2;
console.info("status-card burst", { elapsedMs, maximum, runs: run.mock.calls.length, due: dueReads(), next: nextReads(), searches: searchedCompanies.length });
console.info("status-card burst", { elapsedMs, maximum, runs: run.mock.calls.length, due: dueReads(), revisions: revisionReads(), next: nextReads(), searches: searchedCompanies.length });
expect(run.mock.calls.length).toBeLessThanOrEqual(maximum);
expect(dueReads()).toBeLessThanOrEqual(maximum); expect(nextReads()).toBeLessThanOrEqual(maximum);
expect(revisionReads()).toBeLessThanOrEqual(maximum);
expect(searchedCompanies.length).toBeLessThanOrEqual(maximum);
expect(searchedCompanies.length).toBeGreaterThan(0);
expect(new Set(searchedCompanies)).toEqual(new Set([originalCompany]));