From 1204058e94650ccc14f6c051c29d46cd5d6672d5 Mon Sep 17 00:00:00 2001 From: JSONbored <49853598+JSONbored@users.noreply.github.com> Date: Tue, 7 Jul 2026 04:08:41 -0700 Subject: [PATCH] test(queue): assert repair-attempt recording at execution time, not dispatch The #orb-retry-storm regression test checked the repair_attempt audit count immediately after the sweep dispatched the job, without ever processing it -- passing only under the OLD (buggy) dispatch-time recording the fix in #3998/#4023 deliberately replaced. Process the fanned-out agent-regate-pr job before asserting the count, matching the actual execution-time design: a queued-but-not-yet-run job must not count against REGATE_REPAIR_MAX_ATTEMPTS_PER_SHA. --- test/unit/queue.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/unit/queue.test.ts b/test/unit/queue.test.ts index 8e895a2ad9..88df190ef4 100644 --- a/test/unit/queue.test.ts +++ b/test/unit/queue.test.ts @@ -6920,6 +6920,11 @@ describe("queue processors", () => { const fanned = sent.filter((job): job is Extract => job.type === "agent-regate-pr"); expect(fanned.map((job) => job.deliveryId)).toContain("regate-repair:owner/agent-repo#2"); + // #orb-retry-storm: the attempt is recorded at EXECUTION time (after rate-limit admission), not at + // dispatch time -- a queued-but-not-yet-run job must not count against the cap. Process the fanned-out + // job (simulating the queue consumer picking it up) before checking the recorded count. + const repairJob = fanned.find((job) => job.deliveryId === "regate-repair:owner/agent-repo#2"); + await processJob(env, repairJob!); const attemptsAfterFirst = await env.DB.prepare("select count(*) as n from audit_events where event_type = ? and target_key = ?") .bind("agent.sweep.regate.repair_attempt", targetKey) .first<{ n: number }>();