HANDOFF: target project queue

Scope
Only queue requirements are authoritative. Ignore all archived records for other projects. Updates 1–5 have been applied below; superseded values are discarded. No later update or question is available.

CURRENT configuration
{
  "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
evaluate(payload) returns:
{ready: [id], waiting: [{id, at}], dead: [id], cancelled: [id]}

Input: now (integer), jobs with fields 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 the payload or jobs.

Algorithm, in order
1. Deduplicate by id, retaining the LAST job value for each id and its actual original input index. All later processing uses only these selected jobs.
2. A job is retryable iff last_code is in [429, 500].
3. Cancellation precedes all dead/retry/due checks. Since cancel_wins is true, every selected job marked cancelled goes to cancelled, including retryable, stale, or exhausted jobs.
4. Otherwise, put the 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. For a surviving retryable job, compute effective due:
   max(due, failed_at + min(100 * 2**max(0, attempt - 1), 150)).
   Jobs without failure keep their original due.
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: selected original index ascending, NOT by due.
- cancelled: selected original index ascending.
Deduplication must not substitute the first occurrence’s index for the retained last occurrence’s index.

Boundary details
- Attempts 0 and 1 have retry delay 100; attempt 2 has delay capped at 150.
- Attempt 3 or greater is dead before retry delay calculation, unless cancelled.
- Retry scheduling never reduces an existing due.
- Nonretryable nonzero failures are dead regardless of due, unless cancelled.
- Age exactly 2000 does not alone make a job dead.

Unresolved / continuation
No explicitly unresolved requirement items are recorded. Implementation and tests are not supplied in this handoff. Preserve the fixed interface and algorithm contract. Future queue updates replace only their named keys and leave all other current choices unchanged; do not infer future changes.