HANDOFF: target project queue

Scope
Only queue requirements are authoritative. All archive-* records are unrelated and excluded. Apply future queue updates only to the keys they explicitly replace; retain other current choices. No future update or later question is available yet.

Current configuration (resolved through Update 5)
{
  "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
}

Fixed interface
Implement evaluate(payload) returning:
{ready: [id], waiting: [{id, at}], dead: [id], cancelled: [id]}

Input: now integer and jobs containing id, key, priority, created, attempt, last_code, cancelled, due, failed_at. Numeric inputs are nonnegative integers. last_code = 0 means no failure. Do not mutate input.

Algorithm and precedence
1. Deduplicate by id, keeping the LAST job value for each id and that occurrence's actual original input index. Do this before classification.
2. A job is retryable when last_code is in [429, 500].
3. Cancellation precedes dead/retry/due checks. With current cancel_wins = true, every selected cancelled job goes to cancelled, including retryable, stale, or exhausted jobs.
   Fixed general rule: a cancelled job goes to cancelled if cancel_wins OR it is not retryable.
4. Otherwise, put a job in dead if ANY condition holds:
   - now - created > 2000 (strict; equality is not stale);
   - attempt >= 3;
   - last_code is nonzero and not retryable.
5. Otherwise, for a retryable job, compute effective due:
   max(original due,
       failed_at + min(100 * 2**max(0, attempt - 1), 150)).
   Jobs without failure keep their original due.
   Under current limits, surviving retryable jobs have attempts 0, 1, or 2: delay is 100 for 0/1 and 150 for 2.
6. If effective due > now, put {id, at: effective due} in waiting; otherwise put id in ready. Equality with now is ready.

Ordering
- ready: priority descending, then created ascending, then selected original index ascending.
- dead: id ascending.
- waiting and cancelled: selected original index ascending, NOT due/id order.
- Deduplication must not substitute the first occurrence's index or a compacted index.

Status / unresolved items
All configuration keys referenced by the contract now have explicit queue values; no unresolved configuration choices are recorded. Implementation and validation remain to be done. Preserve the fixed contract and current settings unless a future authoritative queue update replaces specific keys.