brainy/tests/unit/utils
David Snelling 8e7b52bda9 fix: correct cache eviction formula to prioritize high-value items
Fixed inverted eviction scoring formula in UnifiedCache that was causing
metadata (cheap to rebuild) to be retained while HNSW vectors (expensive,
frequently accessed) were evicted. This was causing OOM crashes during
large Excel imports with relationship extraction.

Changes:
- evictLowestValue(): Changed accessScore / rebuildCost to accessScore * rebuildCost
- evictForSize(): Changed accessScore / rebuildCost to accessScore * rebuildCost
- evictType(): Changed accessScore / rebuildCost to accessScore * rebuildCost

With the corrected formula, items with higher access counts AND higher
rebuild costs get higher scores and are protected from eviction.

Test coverage: Added comprehensive eviction scoring tests

Fixes: Type metadata hogging 99.7% of cache with only 3.7% access rate
2025-10-13 11:21:19 -07:00
..
mutex.test.ts feat: add distributed architecture with sharding and coordination 2025-09-22 15:45:35 -07:00
paramValidation.test.ts fix: resolve 10 test failures across clustering, metadata, and deletion 2025-10-09 16:33:08 -07:00
unifiedCache-eviction.test.ts fix: correct cache eviction formula to prioritize high-value items 2025-10-13 11:21:19 -07:00