Skip to content

fix: preserve bounded map updates#99

Merged
dialupdisaster merged 2 commits into
DEVtheOPS:mainfrom
fengjikui:codex/preserve-bounded-map-updates
Jul 16, 2026
Merged

fix: preserve bounded map updates#99
dialupdisaster merged 2 commits into
DEVtheOPS:mainfrom
fengjikui:codex/preserve-bounded-map-updates

Conversation

@fengjikui

Copy link
Copy Markdown
Contributor

Summary

  • update setBoundedMap so overwriting an existing key does not evict the oldest unrelated entry when the map is already at MAX_PENDING
  • add regression coverage for the at-capacity update case

Why

setBoundedMap is used for session/run/message bookkeeping as well as bounded pending state. Before this change, refreshing an existing key while the map was full still deleted the oldest entry first. That means an ordinary update to an existing session/run key could drop unrelated telemetry state even though no new entry was being added.

session.diff already had a local workaround for this class of issue; this makes the shared helper preserve existing-key updates consistently for every caller.

Validation

  • bun test tests/util.test.ts
  • bun run typecheck
  • bun run lint
  • bun test
  • bun run build
  • git diff --check

@dialupdisaster

Copy link
Copy Markdown
Contributor

The setBoundedMap fix and regression test look correct. Could you also update src/handlers/activity.ts as part of this PR? Its handleSessionDiff implementation still contains the local has/set workaround and a comment stating that setBoundedMap evicts an unrelated session when updating a full map. That comment becomes stale with this change, and the branch can now be replaced with:

setBoundedMap(ctx.sessionDiffTotals, sessionID, nextTotals)

This would make sessionDiffTotals use the corrected shared behavior as intended.

@fengjikui

Copy link
Copy Markdown
Contributor Author

Updated in f6de98e: handleSessionDiff now calls setBoundedMap(ctx.sessionDiffTotals, sessionID, nextTotals) directly, and the stale workaround comment/branch is removed.

Validation:

  • bun run lint
  • bun run check:jsdoc-coverage (84.21%)
  • bun run typecheck
  • bun test (303 passed, 0 failed)

@dialupdisaster
dialupdisaster merged commit a0a5577 into DEVtheOPS:main Jul 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants