szn

Bug 410 — BufferList.delete’s swapRemove breaks the newest-at-0 / oldest-at-last positional contract that get(null) and evictOldestIfFull depend on

410. BufferList.delete’s swapRemove breaks the newest-at-0 / oldest-at-last positional contract that get(null) and evictOldestIfFull depend on

Severity: MEDIUM Status: ✅ RESOLVED

The list maintains recency by position: pushes insert(..., 0, ...) (newest at index 0), get(null) reads items[0], evictOldestIfFull drops items[len-1]. delete uses swapRemove(i) (:67), which moves the last (oldest) entry into the deleted slot:

Also generateName returns name_buf[0..0] — an empty name — after 10 000 collisions (:93), which then aliases with any other empty-name lookup/delete.

Fix: orderedRemove (O(n) over ≤50 entries, trivial); return an error from generateName on exhaustion.