openai / gpt-6-luna / low / low effort preferred over xai / grok-4.7-efficient / high / high effort · close win.
Primary judge: Sol 6.1, requested Low. Effective provider effort and internal attempts were not verified. A close win is still a scored preference; it does not establish a material defect.
Reviewed public evidence
Task goal
Review the worker-queue claim and completion lifecycle for stuck work, duplicate execution, or incorrect capacity accounting after retries and worker interruption. Trace an exact plausible failure state through the provided code, identify whether the queue recovers, and recommend the smallest safe change plus focused failure-injection checks.
openai / gpt-6-luna / low / low effort answer
**Assessment:** The shared claim/complete/fail/release paths mostly contain the expected recovery safeguards: fresh claims increment `attempt_count`, retryable failures clear lease state and requeue until the attempt cap, completion clears lease/token state, and late terminal callbacks cannot resurrect a completed job (claim: `worker_queue.py` lines 3233–3247; failure: 8145–8191; completion: 7713–7732; release: 8656–8678).
**Plausible stuck-work case:** A worker claims a job, then is interrupted without delivering `/fail` or `/release`. The job remains `running`; the per-API-key capacity query counts it while `leased_until > now` (lines 2993–3018). It is not immediately reclaimable because the pending selection requires `status == "pending"` (3110–3120). This is a temporary stall, not a permanent one: the claim path has same-worker stale-lease recovery after 150 seconds without heartbeat (3023–3079), and the packet’s endpoint documentation describes a lease reaper. However, the reaper implementation is outside this snapshot, so its timing and treatment of other workers’ abandoned leases cannot be verified here. Capacity accounting self-excludes the abandoned lease once it expires; the claim path’s API-key cap does not itself recover it.
**Smallest safe recommendation:** Verify that the out-of-packet reaper reliably changes *any* expired `running` job to `pending` (or terminal-failed at the retry ceiling), clears all lease fields, and does so atomically. If it does not, fix that transition rather than changing the active-lease count: counting only live leases is consistent with the stated cap, and counting expired leases would make abandoned work consume capacity indefinitely.
**Focused failure-injection checks:** Interrupt a worker after claim with no heartbeat or callback; assert recovery after the intended stale/expiry threshold, eventual reclaim by a different worker, and correct API-key active-lease counts before and after expiry. Also inject retryable `/fail`, graceful `/release`, attempt-ceiling exhaustion, and a lost `/complete` response followed by `/fail` or `/release`; assert retries preserve the claim-charged attempt count, terminal states stay terminal, and capacity is released. The complete-slot context manager uses `finally` to decrement counters on cancellation/exception (worker_complete_slots.py lines 65–110); test cancellation while holding a slot and timeout while waiting to detect accounting leaks.
**Alternatives / uncertainty:** Same-worker stale recovery is not a general reaper: another worker’s abandoned job is not selected while it remains `running`. The packet references a reaper but does not include its code, so it cannot establish whether that gap is actually covered. No defect in the supplied complete-slot counter’s normal exception/cancellation cleanup is evident.
xai / grok-4.7-efficient / high / high effort answer
The queue does not recover a job whose claim response is lost and whose worker keeps polling without a stable Idempotency-Key. The stale-lease self-heal requeues and re-claims that job in the same transaction with no retry ceiling, so the lease never expires and the attempt budget never trips.
**Conclusion.** The lost-response path documented at `worker_queue.py:142-156` becomes an unbounded reclaim loop. A claim can commit and still never deliver `claim_token`. The worker cannot heartbeat, complete, or release. The next `/claim` for that `worker_id` finds the live lease (`worker_queue.py:3028-3044`). Within 150 seconds it returns 409 (`worker_queue.py:3057-3067`). After 150 seconds the stale branch sets the row back to `pending` and clears the lease columns, but it does not read `attempt_count` and does not call `_max_attempts_for` or `_graceful_release_absolute_ceiling` (`worker_queue.py:3068-3086`). The same transaction then `SELECT … FOR UPDATE SKIP LOCKED` and re-claims that row: `attempt_count` increments and `leased_until` / `heartbeat_at` are refreshed (`worker_queue.py:3119-3167`, `3240-3248`). PostgreSQL does not skip a row this transaction already holds, and the pending update is invisible to other workers until commit, so the healed job is not offered to anyone else in between.
Each cycle also calls `record_claim_for_municipality` after commit (`worker_queue.py:3538-3551`) and keeps one API-key concurrency slot occupied (`leased_until > now` at `worker_queue.py:3009-3016`). `/fail` and `/release` both stop at a ceiling (`worker_queue.py:8164-8176`, `8684-8734`). `/release` even documents that a claim/release cycle with no charged failure must have an absolute ceiling or it loops forever (`worker_queue.py:8593-8604`). Stale reclaim is that same shape and has no ceiling. While this worker polls, the supplied code never terminal-fails the job and never lets the lease expire, so an expiry-based reaper cannot see it either.
A stable Idempotency-Key within 600 seconds does recover: replay rotates the token and does not increment `attempt_count` (`worker_queue.py:3046-3056`, `3217-3231`, `305-317`). Workers that omit the header are explicitly on the old path (`worker_queue.py:2941-2943`).
**Smallest safe change.** In the stale branch, before resetting the row to `pending`, if `attempt_count >= _graceful_release_absolute_ceiling(job.job_type)`, terminal-fail it with the same lease clear, footage-reuse restore, and media stamp `/release` already uses at the ceiling (`worker_queue.py:8726-8783`), audit, commit, and return `None`. Do not fall through into a new claim. Use the graceful absolute ceiling, not `_max_attempts_for` alone, so a few lost responses are not treated as real processing failures. No new column or response shape.
**Secondary capacity leak.** `acquire_complete_slots` increments `_global_in_flight` / `_muni_in_flight` inside the `asyncio.wait_for` task (`worker_complete_slots.py:78-88`) and decrements only after `wait_for` returns (`worker_complete_slots.py:99-109`). The timeout path raises and does not decrement (`worker_complete_slots.py:92-96`). If cancellation lands after the increment, during `Condition.__aexit__`, the slot stays taken and a cancelled lock release can wedge later acquires. Increment only after `wait_for` succeeds, and decrement in a `finally` that runs if and only if that increment happened.
**Discarded.** Idempotent `/complete`, `/fail`, and `/release` guards do stop completed-to-pending resurrection. `SKIP LOCKED` does stop two workers taking the same pending row. Claim-rate counts are not reversed on later release; that matches "successful claims," not a leak. The API-key cap is checked before replay/stale-heal (`worker_queue.py:2999-3026`), so a full cap delays self-heal, but the count itself drops when `leased_until` passes; that is delayed recovery, not the unbounded loop. Holding the job row lock across `/complete` storage I/O can stall heartbeats, but a finished or rolled-back request releases it.
**Missing.** `max_attempts_for` and the lease reaper live outside this packet (`app.constants.worker_job_types`, `scheduler.py`). If the worker stops polling, this code will not select a `running` row whose lease has already expired (`worker_queue.py:3119-3135`). Recovery then depends entirely on that reaper. Stale heal is also same-`worker_id` only; a restart that changes `worker_id` cannot clear the orphan here.
**Checks.** Drop the claim response and poll `/claim` with no Idempotency-Key: 409 until 150 seconds, then reclaim with `attempt_count` increased and `leased_until` refreshed; at the absolute ceiling the job must be `failed`, lease columns cleared, media not left `processing`, and a later claim must not re-lease it. Control: the same loss with a stable Idempotency-Key inside 600 seconds replays once, does not increment `attempt_count`, and does not terminal-fail. Separately, cancel `acquire_complete_slots` after a slot is taken and assert `in_flight_counts()` returns to zero.
Confidence: high on the stale-reclaim loop and that this code does not recover it while that worker polls. Medium on how often the complete-slot cancel window hits; the missing compensating decrement is structural.
Primary judge's stated reason
A receives a weak preference for avoiding an unsupported capacity-leak diagnosis and potentially unsafe corrective advice. This is not an established material quality gap: B's stronger stale-reclaim analysis is substantial counterevidence, and an independent review could reasonably favor that practical contribution.
This reason is the judge's assessment. No independent factual-defect finding is asserted by this record.
Battle wave: bc72a6bd-1168-4bad-b5a9-fbf90203e5d7. Pair: brp1_cab48e8589e98f3f52f4eecc480d9be748e970b8a8e76c376954074edf0c0c1a. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.