TARGET PROJECT: queue — HANDOFF NOTE

Fixed contract (authoritative):
Implement evaluate(payload) -> {ready:[id], waiting:[{id,at}], dead:[id], cancelled:[id]}.
Input: now (integer); jobs each with id, key, priority, created, attempt, last_code, cancelled, due, failed_at. All integers nonnegative; last_code 0 means no failure. Do not mutate input.
- Deduplicate by field named by dedup_key, keeping the last occurrence value and its actual original index.
- Retryable: last_code is in retryable_codes.
- Cancelled jobs: go to cancelled if cancel_wins is true OR if not retryable. This check precedes dead classification.
- Otherwise dead if: (now-created >= stale_after when stale_inclusive, else now-created > stale_after), OR attempt >= max_attempts, OR last_code is nonzero and non-retryable.
- Otherwise, for retryable jobs, effective due = max(due, failed_at + min(base_delay*(2**max(0,attempt-1) if exponential else 1), delay_cap)). Jobs without failure keep their due.
- If effective due > now: waiting (with id and at=effective due); else ready.
- Ready sort: priority descending if priority_high_first else ascending; then created ascending if fifo_ties else descending; then selected original index.
- Dead sort: by id if dead_order="id", else by selected original index. Waiting and cancelled: always by selected original index.

CURRENT choices for queue (all resolved, superseding earlier updates; discard all archived/other-project settings):
{
  "base_delay": 200,
  "exponential": false,
  "max_attempts": 4,
  "retryable_codes": [408, 503],
  "cancel_wins": false,
  "priority_high_first": false,
  "fifo_ties": false,
  "dedup_key": "key",
  "dead_order": "input",
  "delay_cap": 400,
  "stale_after": 1000,
  "stale_inclusive": true
}

Exceptions/unresolved: None recorded. No keys remain unset in the updates received.