select_victim_slot

Function select_victim_slot 

Source
pub fn select_victim_slot(
    cache: &[(usize, SlotView)],
) -> Result<usize, VictimError>
Expand description

Task #27 pure victim-selection policy over the CACHE region only (the caller passes (slot_index, view) for slots [pinned, max_loras) — pinned startup adapters are never candidates, so the resident set and its position-based resolver can never desync). Tiers:

  1. FREE-FIRST: the first !filled (never-promoted) placeholder slot.
  2. LRU-IDLE: else the ref_count == 0 slot with the smallest last_used.
  3. POOL-FULL: else every cache slot is busy → Err(PoolFull) (retryable); a ref_count > 0 slot is NEVER returned.