nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] BoundedMap.set doesn't update access order on overwrite

Open akramcodez opened this issue 3 months ago • 4 comments

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

  1. Instantiate a BoundedMap with a small max size.
  2. 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

akramcodez avatar Sep 02 '26 06:09 akramcodez

Picking this up - a fix will follow shortly.

awhite0030 avatar Sep 12 '26 00:09 awhite0030

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?

ScrappyAT avatar Oct 07 '26 10:10 ScrappyAT

Hi @addyCooks, can I take this? The earlier PRs went stale; I'll follow will-lamerton's review on #1153.

me-adityaraj8 avatar Oct 19 '26 13:10 me-adityaraj8

I'd like to work on this. The earlier PRs were closed without merging, and I'll follow the review notes from #1153.

KhadeerBasha1232 avatar Nov 28 '26 04:11 KhadeerBasha1232