[Bug] BoundedMap.set doesn't update access order on overwrite
Description
When set(k, v) is called for an existing key, it writes a fresh entry but does NOT bump the existing entry's accessOrder. A frequently-overwritten key can sit at the oldest position and be incorrectly evicted.
Environment
- OS: Any
- Node version: v22.20.0
- Nanocoder version: 1.30.0
- Provider: N/A
- Model: N/A
Steps to Reproduce
- Instantiate a
BoundedMapwith a small max size. - Continually overwrite the same key while inserting new unique keys.
Expected Behavior
The frequently overwritten key should have its access order updated and be safe from eviction.
Actual Behavior
It retains its old order and gets evicted prematurely.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder
Picking this up - a fix will follow shortly.
Hi, I'd like to work on this issue. I can update the overwrite behavior so the access order is refreshed and add/adjust tests to cover the eviction case. Is it okay if I take this?
Hi @addyCooks, can I take this? The earlier PRs went stale; I'll follow will-lamerton's review on #1153.
I'd like to work on this. The earlier PRs were closed without merging, and I'll follow the review notes from #1153.