test(insights): hold the health ledger still in the status parity harness

The batch golden lost a card's request about one run in eight. When the
batched call fails, every pending card falls back to its own call at once,
and each failure is recorded on the provider health ledger without being
awaited. Background work leaves a provider out from its third failure in a
row on, so a card that read the ledger after two of its siblings' writes
had landed was benched and never reached the model. Which card, if any,
was scheduling.

The stored notes were the same either way, so only the request list moved.
The parity harness now runs on a ledger that records and benches nothing;
the bench keeps its own tests.

Refs #1279
This commit is contained in:
Marc-André Bombeck committed 2026-10-24 23:06:00 +02:00
1 parent 3f17b40092
commit dbe05c958c
1 file changed
+20
@@ -73,6 +73,26 @@ vi.mock("@/lib/ai/provider", async (importOriginal) => ({
resolveProvider: async () => ({ type: "none" }),
}));
/**
* The provider health ledger stands still. When the batch call fails, every
* pending card falls back to its own call at once, and each failure is
* written to the ledger without being awaited. Background work leaves out a
* provider from its third failure in a row on (#1279), so whether a card
* still reaches the model depends on how many of its siblings' writes landed
* before it read the ledger: scheduling, not code. A ledger that records
* nothing and benches nothing keeps every arm's request list exact. The bench
* has its own tests (`provider-runner-background-bench.test.ts`, and
* `provider-pause.test.ts` for the pause it reads).
*/
vi.mock("@/lib/ai/provider-health-ledger", async (importOriginal) => ({
...(await importOriginal<typeof import("@/lib/ai/provider-health-ledger")>()),
postgresProviderHealthLedger: {
getSkipHints: async () => new Map(),
recordSuccess: async () => {},
recordFailure: async () => {},
},
}));
vi.mock(
"@/lib/jobs/insight-status-generate-shared",
async (importOriginal) => ({