TARGET PROJECT: queue — HANDOFF NOTE

Interface/algorithm contract:
- Implement evaluate(payload) -> {ready:[id], waiting:[{id,at}], dead:[id], cancelled:[id]}.
- Input: now (integer) and jobs with id, key, priority, created, attempt, last_code, cancelled, due, failed_at.
- Nonnegative integers; zero last_code means no failure. Do not mutate input.
- Deduplicate by dedup_key, keeping the last value and its actual original index.
- A retryable job has last_code in retryable_codes.
- A cancelled job goes to cancelled if cancel_wins, or if not retryable.
- Otherwise, dead if: now-created >= stale_after when stale_inclusive (otherwise >), attempt >= max_attempts, or nonzero nonretryable last_code.
- Otherwise, a retryable job's due becomes max(due, failed_at + min(base_delay * (2**max(0,attempt-1) if exponential else 1), delay_cap)); jobs without failure keep due.
- If due > now: waiting; else ready.
- Sort ready by priority descending iff priority_high_first (otherwise ascending), then created ascending iff fifo_ties (otherwise descending), then selected original index.
- Sort dead by id iff dead_order="id", else original index; waiting and cancelled always by selected original index.

Current choices (superseded and unrelated-project settings discarded):
{
  "base_delay": 100,
  "exponential": true,
  "max_attempts": 3,
  "retryable_codes": [429, 500],
  "cancel_wins": true,
  "dedup_key": "id",
  "fifo_ties": true,
  "priority_high_first": true,
  "dead_order": "id",
  "delay_cap": 150,
  "stale_after": 2000,
  "stale_inclusive": false
}

Exceptions/unresolved items: None recorded.