refactor: extract eviction engine into eviction.py (rag.py 303→109 lines)

- Move all eviction logic (evict_batch, maybe_evict, EVICTION_LOG,
  get_collection_count/stats, get_rag_operational_stats) into eviction.py
- Move QDRANT_URL, RAG_COLLECTION into config.py to break circular dep
- rag.py re-exports eviction symbols for backward compatibility
- Router imports updated to use eviction module directly
- All 130 tests pass
This commit is contained in:
gramps
2026-07-06 08:00:26 -07:00
parent 8072fb3dd0
commit bb16cd6927
7 changed files with 227 additions and 210 deletions
+4 -3
View File
@@ -7,6 +7,7 @@ import httpx
from fastapi.testclient import TestClient
import app
import config
import db
import rag
from security import SESSIONS, PIN_ATTEMPTS, RATE_EVENTS
@@ -257,13 +258,13 @@ def test_maybe_evict_at_high_water(monkeypatch):
def test_maybe_evict_zero_config_disabled(monkeypatch):
"""RAG_MAX_VECTORS <= 0 should disable eviction."""
orig = rag.RAG_MAX_VECTORS
orig = config.RAG_MAX_VECTORS
try:
rag.RAG_MAX_VECTORS = 0
config.RAG_MAX_VECTORS = 0
evicted = asyncio.run(rag.maybe_evict())
assert evicted == 0
finally:
rag.RAG_MAX_VECTORS = orig
config.RAG_MAX_VECTORS = orig
# ---------- get_rag_operational_stats ----------