HANDOFF: target project queue

Scope
Only queue requirements are authoritative. Ignore all archived records for other projects. Updates 1–5 have been applied; superseded values are discarded. No future updates or questions are available.

CURRENT configuration
{
  "max_attempts": 4,
  "base_delay": 200,
  "exponential": false,
  "retryable_codes": [408, 503],
  "cancel_wins": false,
  "priority_high_first": false,
  "fifo_ties": false,
  "dedup_key": "key",
  "stale_after": 1000,
  "stale_inclusive": true,
  "delay_cap": 400,
  "dead_order": "input"
}

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

Input contains integer now and jobs with:
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 input.

Processing contract, using CURRENT choices
1. Deduplicate jobs by key, retaining the last job for each key together with that job’s actual original input index. Do not retain the first occurrence’s index.
2. A job is retryable iff last_code is 408 or 503.
3. First classify a cancelled job as cancelled only if it is not retryable, because cancel_wins is false.
   Exception: a cancelled retryable job continues through normal dead/waiting/ready processing.
4. Otherwise classify as dead if any condition holds:
   - now - created >= 1000 (inclusive stale boundary);
   - attempt >= 4;
   - last_code is nonzero and not retryable.
5. For surviving retryable jobs, effective due is:
   max(original due, failed_at + 200).
   This follows min(base_delay, delay_cap) = min(200, 400), with exponential disabled; attempt does not affect delay.
   Jobs without failure retain their original due.
6. If effective due > now, classify as waiting with {id, at: effective due}; otherwise classify as ready. Equality with now is ready.

Output ordering
- ready: priority ascending, then created descending, then selected original index ascending.
- dead: selected original index ascending (not id).
- waiting: selected original index ascending (not due time).
- cancelled: selected original index ascending.
- ready, dead and cancelled contain IDs only.

Precedence and boundary reminders
- Deduplication occurs before classification.
- Eligible cancellation takes precedence over dead checks.
- Dead checks take precedence over retry scheduling.
- Cancellation does not automatically win for retryable failures.
- Staleness is inclusive; attempt limit is inclusive.
- Backoff must never reduce original due.
- Preserve selected original indices for every output ordering.

Unresolved items
No explicitly identified unresolved requirements remain in the supplied record. Implementation language, validation/error behavior for invalid or missing fields, and tests have not been specified. Do not infer them from unrelated archives.