-
Notifications
You must be signed in to change notification settings - Fork 7
TerminalHistory: inconsistent eviction policy between setMaxSize() and add() #115
Copy link
Copy link
Open
Description
Summary
TerminalHistory.add() has an asymmetric capacity eviction policy compared to setMaxSize():
setMaxSize(Integer)— when trimming an oversized list, removes from the front (remove(0), oldest-first / FIFO).add()— when the list is already at capacity (size == maxSize), appends the new entry then immediately removes from the back (removeLast()), silently discarding the newest command (LIFO-on-add).
This asymmetry is counterintuitive: users who set a max size would reasonably expect that older entries are evicted to make room for newer ones, consistent with how setMaxSize() itself trims the list.
Suggested Fix
In add(), replace the removeLast() call with a removeFirst() (or remove(0)) before appending the new entry, so that capacity eviction is consistently FIFO (oldest entry discarded). Update the add() JavaDoc to explicitly document the eviction policy and reference setMaxSize(Integer).
References
- Identified in PR chore: add CLAUDE.md #114 review: chore: add CLAUDE.md #114 (comment)
- Requested by @javier-godoy
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels