← Model losses

Head-to-head comparison

openai / gpt-6.1-sol / low / low effort preferred over openai / gpt-6-luna / xhigh / xhigh effort · clear 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.1-sol / low / low effort answer

## Independent assessment

**The snapshot establishes retry-accounting and claim-admission defects. Completion interruption also exposes a plausible slot leak.** Analysis was direct and read-only.

### 1. Lost claim responses cannot recover at the API-key capacity limit — high confidence

Exact state:

1. A key already holds `MAX_ACTIVE_LEASES_PER_API_KEY - 1` live leases.
2. Worker W claims J with an idempotency key. The transaction commits, bringing the key to its limit, but the response is lost (`worker_queue.py:3529–3537`).
3. W retries the identical request.
4. The API-key count returns the limit and raises 429 **before** the same-worker lookup and idempotency replay (`2992–3014`, `3024–3046`).
5. W never obtains J’s token. The same ordering also prevents the 150-second stale-lease repair.

**Recovery:** other jobs completing can unblock replay; otherwise J must expire and depend on the external reaper. Expiry removes it from the capacity count, but `/claim` itself selects only pending rows (`3117–3121`), not expired running rows.

**Smallest safe change:** identify and authorize replay before applying fresh-claim capacity admission. Apply the cap only to operations that add a live lease. Serialize fresh admission per API-key principal: the current count-then-claim sequence is also racy across different workers, whose advisory locks differ (`2982–2986`).

### 2. Graceful interruption credits disappear on the next genuine failure — high confidence

Exact state, using a job type with retry cap C:

1. J undergoes C graceful claim/release cycles.
2. Raw `attempt_count = C`; `graceful_release_count = C`; each graceful release correctly requeues using the effective count (`8687–8702`).
3. The next claim increments raw attempts to C+1 (`3241`).
4. Its first genuine retryable failure invokes `_record_failure`, which compares **raw** attempts with C and terminal-fails J (`8158–8170`).

The default `reason="attempt_failed"` release likewise ignores accumulated graceful credits (`8703–8704`).

**Recovery:** none in these endpoints; J is terminal. This contradicts the stated graceful-interruption policy (`8625–8631`).

**Smallest safe change:** centralize effective-attempt calculation and use it consistently in failure and release decisions. Preserve the raw absolute ceiling as a separate backstop. Audit the external reaper for parity before shipping.

### 3. Cancellation can strand completion capacity — plausible, moderate confidence

`acquire_complete_slots` increments counters inside a child coroutine passed to `asyncio.wait_for` (`worker_complete_slots.py:74–84`). Its release `finally` starts only **after** that await returns (`95–106`).

A request cancellation racing with successful child admission can therefore leave:

```text
_global_in_flight = 1
_muni_in_flight[M] = 1
no live handler owning that reservation
```

If cancellation propagates before entering the release-protected region, no decrement or notification runs. Repetition can exhaust all slots; subsequent requests time out into 503 (`worker_queue.py:5976–5987`).

**Recovery:** no reconciliation exists in this module; process restart clears these process-local counters.

**Smallest safe change:** protect admission and execution with one outer `try/finally`, tracking whether admission occurred. Prefer same-task timeout-based waiting where supported, avoiding the child-task ownership handoff.

### Other material observations

- **Rate limiting is advisory, not a strict shared limit.** Municipality eligibility is checked before selection, but recorded only after commit (`worker_queue.py:3147–3155`, `3529–3537`). Concurrent claims can all pass the same snapshot. State is process-local (`worker_claim_rate.py:22–24`), so multiple API processes multiply the effective budget.
- **Completion waiters retain database locks**, except the AV branch. `/complete` locks J before waiting for slots (`7812–7821`, `8051–8079`); heartbeat also needs that lock (`3746–3753`). This can delay heartbeat during congestion. `now` is captured before the lock wait and slot wait, so several branches validate using an outdated clock.
- **Fresh same-worker claims without an idempotency header are not serialized.** Two requests can both observe no existing lease and select different pending rows using `SKIP LOCKED` (`2965–2986`, `3024–3028`, `3157–3165`). Whether a database constraint prevents this is outside the packet.
- Terminal completion/failure/release guards and lease clearing substantially reduce completed-job resurrection risk (`7827–7835`, `8525–8550`, `8651–8683`). They do not justify assuming every interruption path is safe.

## Focused failure-injection checks

1. **Capacity-bound lost response:** commit the last permitted claim, drop its response, retry the same key; require the same job, unchanged attempts, and no 429.
2. **Concurrent admission:** synchronize different workers immediately after the capacity count; require total live leases never exceed the key cap.
3. **Graceful-credit parity:** perform C graceful releases, then one genuine retryable failure; require requeue unless the raw absolute ceiling is reached. Repeat through default release and the reaper.
4. **Slot cancellation race:** cancel immediately after reservation but before context entry; require counters return to baseline and another waiter enters. Also cancel during waiting and handler execution.
5. **Completion congestion:** occupy all slots, start a non-AV completion, then heartbeat J. Measure lock blocking and test lease expiry during the wait.
6. **Rate-limit burst:** synchronize claims at the last available municipality budget unit, including multiple API processes; verify the intended strict or advisory behavior.

**Uncertainty:** the packet excludes database constraints, session cleanup, scheduler/reaper implementation, worker retry behavior, and configuration values. These determine eventual recovery and production impact; they do not remove the demonstrated graceful-accounting inconsistency or replay-before-cap ordering defect.

openai / gpt-6-luna / xhigh / xhigh effort answer

## Conclusion

**A lost `/claim` response can be unrecoverable by idempotent replay while the API-key lease cap is full.** The cap check runs before the code recognizes a replay, even though replay does not add a lease or increment `attempt_count`.

Example: with `MAX_ACTIVE_LEASES_PER_API_KEY=1`, a claim commits job J as running, but its response is lost. The worker retries with the same idempotency key. J itself makes the active count 1, so `/claim` returns 429 at `worker_queue.py:2993–3017`, before replay matching at `3022–3047`. The worker cannot recover J’s claim token that way; J remains running and occupies capacity until its lease expires.

After expiry, this snapshot does **not** itself recover J: the same-worker self-heal only examines a running job with a live lease (`3022–3086`), and fresh selection only selects `pending` jobs (`3105–3116`). Recovery therefore depends on the external lease reaper, whose implementation is outside this packet. Without it, the job remains unclaimable; with it, the job can eventually be requeued and claimed again, charging another attempt.

**Smallest safe change:** identify a valid same-worker idempotent replay before enforcing the active-lease cap, and exempt that replay from the cap. Apply the cap to fresh claims after stale-lease cleanup, so reclaiming a stale lease also stops counting the old running row. Keep the cap for genuinely new leases.

## Other capacity observations

- The municipality rate limit is not an atomic admission check. `/claim` reads blocked municipalities before selecting work (`worker_queue.py:3143–3158`) and records the successful claim only after commit (`3532–3540`). Those operations are separate from the locked check and append in `worker_claim_rate.py:48–80`. Two concurrent claims can both pass a limit of one before either records its claim; a process interruption after commit but before recording also loses that claim from the window. The in-memory state is additionally local to one process and resets on restart (`worker_claim_rate.py:17–30, 113–115`). Treat this as a **best-effort** limiter unless it is made atomic and shared; the packet does not establish the deployment’s process count.
- The API-key lease count is also a check-then-claim sequence (`worker_queue.py:2993–3017`); no per-key serialization is shown for distinct workers. Concurrent requests can both observe capacity before either commits. The optional advisory lock is keyed by `worker_id`, not API key (`2976–2990`), so it does not serialize those requests. If the cap must be strict, serialize or reserve capacity per API key.
- The completion-slot context manager appears to release counts on normal exit and exceptions, and maps wait timeout to 503 (`worker_complete_slots.py:64–112`; `worker_queue.py:5969–5998`). Its counters are process-local; the code describes them as process-wide, not cluster-wide. I found no demonstrated slot leak in this snapshot.

Normal completion retries are better protected: completion first returns terminal jobs idempotently (`worker_queue.py:7825–7920`), and failure/release paths clear lease state before requeueing or terminalizing (`8145–8192`, `8680–8720`). An interrupted worker without a successful release still requires the external reaper to move its expired `running` job back to `pending`.

## Focused checks

1. With cap 1, commit a claim and simulate losing its response; retry with the same worker and idempotency key. Verify replay succeeds, returns the same job, rotates the token, and does not increment `attempt_count`.
2. With an expired running lease, verify the claim endpoint alone does not make it claimable; then inject the reaper and verify it becomes pending and can be claimed.
3. Synchronize two same-municipality claims after the rate-limit read but before either records success; verify whether the configured limit can be exceeded. Also inject interruption between claim commit and rate recording.
4. Saturate completion slots; test waiter timeout/cancellation and exceptions inside the slot, asserting `in_flight_counts()` returns to zero.
5. Commit completion but drop the response; replay `/complete` and verify it returns the terminal result without re-ingesting or changing attempt accounting.

**Uncertainty:** the packet references a lease reaper but does not include it, and does not show worker handling of 429 or deployment topology. The recovery and operational impact of those paths depend on those external behaviors.

Primary judge's stated reason

B offers materially more actionable coverage of worker interruption: its recommendation addresses premature terminal failure after graceful restarts, not merely lost-token recovery. This supports a clear preference on substantive coverage, without treating its plausible cancellation risk as a proven leak or claiming any tests were executed.

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