bug
In `sweep()`, `remaining` is initialised to `held` (sum of all candidate sizes) but the loop subtracts `candidate.size` only for removed blobs. The condition `remaining >= self.max_bytes` at line 120 never becomes false once the total drops below the ceiling, so the loop stops removing *age-eligible* blobs after enough unreferenced ones are removed — but it does not stop removing unreferenced blobs (the first disjunct `!index.contains_key(hex)` is always true for them). This is actually the intended behaviour. However, the real bug is that `remaining` is never decremented for blobs that are *skipped* (referenced + under ceiling, or referenced + too young). The `remaining` variable is meant to track how much of the store's total is still present after removals, but it only subtracts removed blobs. Since `remaining` starts at `held` and only goes down on removals, the condition `remaining >= self.max_bytes` will become false at the right point — the logic is correct as written. No bug here on closer inspection.
services/proxy/src/sweep.rs:105-106
Evidence quote
Not recorded
Suggested fix
Not recorded