← Model losses

Head-to-head comparison

openai / gpt-6-luna / low / low effort preferred over xai / grok-4.7-efficient / low / low 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 / low / low effort answer

The queue does not self-heal a `/complete` that waits for a slot while holding the job row lock. Under a completion storm the worker’s heartbeats cannot refresh the lease, the wait ends in 503, the retry is 410, and the row stays `running` until an external reaper.

**Failure state.** Job 42 is `running`, `attempt_count=1`, `leased_until` still in the future, worker heartbeats every 60s. Other `/complete` calls already hold every `WORKER_COMPLETE_MAX_CONCURRENT` slot (`worker_complete_slots.py` 65–83).

1. `complete_job` locks job 42 with `FOR UPDATE` and `_validate_claim` succeeds (`worker_queue.py` 7823–7936).
2. PDF-full, convert-only, mdb, and review-pack then call `_complete_with_tenant_slots` without releasing that lock (7987–8096). Only the Apple Vision branch rollbacks first (8016).
3. `acquire_complete_slots` waits up to `WORKER_COMPLETE_SLOT_WAIT_TIMEOUT_S` (65–93). Heartbeat for job 42 also takes `FOR UPDATE` (3761–3776) and blocks behind that wait, so `leased_until` is not extended (3779).
4. While the slot pool stays saturated, each Mac 5xx retry repeats steps 1–3 and keeps pinning the row for the whole wait. Heartbeats never land. The lease expires.
5. The in-flight wait then raises 503 (`worker_queue.py` 5980–6004). The retry calls `_validate_claim`, sees `leased_until <= now`, and gets 410 (2385–2397). The worker is specified to stop on 410.
6. Claim will not take the row: status is still `running`, and the same-worker check requires `leased_until > now` (3028–3043, 3119–3120). `/fail` and `/release` also 410 before any requeue (8544–8564, 8686).

Recovery is not in these three files. Comments point at `scheduler.py`’s lease reaper, which is outside this packet. Until that reaper runs, the job is stuck and the API key still counts the expired lease only after `leased_until` passes (3009–3015), so the stuck row itself does not hold the concurrency cap — it simply never returns to `pending`.

**Smallest safe change.** After the initial claim check in `complete_job`, snapshot the fields the branches need and `await db.rollback()` before `_complete_with_tenant_slots`, matching the Apple Vision path at 8016. Inside the slotted helper, re-lock the job and call `_validate_claim` before any mutation (AV persist already does this at 6419–6432). Do not clear the token on the 503 path.

Also make slot acquire cancellation-safe. The increment is inside `_wait_and_enter` (79–86), but the decrement runs only after `wait_for` returns and the context is yielded (92–109). A client disconnect or `wait_for` timeout that cancels the waiter after the increment never enters that `finally`, so `_global_in_flight` / `_muni_in_flight` stay high until process restart and later completes 503 forever. Roll the increment back on `CancelledError` before re-raising.

**Discarded.** Idempotent claim replay and `SKIP LOCKED` prevent a second lease of the same job when `Idempotency-Key` is present (3028–3056, 3162–3168). Graceful release’s `attempt_count - graceful_release_count` discount (8689–8703) does not apply to `/fail` (8164), so interruptions still burn the real-failure budget — real, but it terminal-fails rather than sticking a live lease. A 429-before-replay at `MAX_ACTIVE_LEASES_PER_API_KEY` (3009–3026 vs 3042–3056) can block stale-lease self-heal, but only at the cap.

**Missing.** `get_db` transaction lifetime, `WORKER_COMPLETE_SLOT_WAIT_TIMEOUT_S`, and the reaper are outside the packet. If the dependency did not hold the transaction open across the slot wait, heartbeats would not stall; the slot-leak bug would remain.

**Checks.** Saturate complete slots, start `/complete`, and assert a concurrent heartbeat commits without waiting out the slot timeout. Cancel a waiter after the counter increments and assert `in_flight_counts()` returns to baseline. After a 503, assert the job is still `running` with the same `claim_token_hash` and a future `leased_until`, and that the next `/complete` is not 410.

Primary judge's stated reason

Forced, weak preference for A because its bounded recovery claims are less likely to turn an unverified scheduling scenario or incomplete cancellation remedy into an asserted fix. B offers stronger actionable coverage of lock contention, making this a close tradeoff rather than an established material quality gap. An independent review could reasonably prefer B.

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_23efc143d8547b923aec8b5aaf584894468bc9dff11347834c0b5e375a1382ab. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.