v3.2.2 - fix: spend-logger memory leak, CTE idempotency, and virtual key cache bounding
What's Changed
This release resolves a critical memory leak in file-based storage mode, introduces atomic and idempotent PostgreSQL spend log tracking via CTEs, bounds the virtual-key in-memory cache, and surfaces official per-model context windows.
Fixed
- Spend-logger memory leak in file-based storage mode: When running without PostgreSQL,
flushSpendLogs()returned early without draining the spend log queue, leading to unbounded heap memory accumulation.logSpend()now short-circuits and clearsqueuewhen PostgreSQL is not configured (#22 by @javargasm). - Atomic PostgreSQL spend log insert & daily aggregation via CTE: Combined
rotator_spend_logsinsert androtator_daily_spendupsert into a single atomic Common Table Expression query. Re-attempted inserts with existingrequest_idvalues produce 0 rows fromins_log, guaranteeing strict idempotency without double-counting on retries. On DB errors, only uncommitted logs are re-enqueued under a strict FIFO cap (MAX_QUEUE_CAP = 100) (#22 by @javargasm). - Virtual Key cache bounded: Added
KEY_CACHE_MAX = 500with 1-minute TTL and FIFO eviction tokeyCacheinsrc/virtual-keys.ts, preventing memory exhaustion from negative lookup caching and key scanning (#22 by @javargasm). /v1/modelsno longer reports the outdated 500K Claude context window.
Added
- Official per-model context windows surfaced across providers: Published upstream context windows for Claude (Opus 4.6 / Sonnet 4.6 → 1M, Opus 4.5 / Sonnet 4.5 → 200K), Google Gemini (3.1 Pro, 3 Pro, 3 Flash variants, 2.5 Pro/Flash → 1M each), and
gpt-oss-120b(131,072) viasrc/providers/google-antigravity/catalog.ts. /api/showlookup for Ollama model context windows: Dynamic context length lookup from Ollama.ModelSpec.contextWindow: Context window spec exposed across/v1/modelsendpoints.
Changed
- OpenAI Codex catalog updated to GPT-5.6 family official 1.05M window.
- OpenCode Zen catalog exposes per-model context helper.
- Claude Opus 4.6 / Sonnet 4.6 context window in
MODEL_CATALOGraised to 1M.
Full changelog: https://github.com/tuxevil/tuxevil-rotator/blob/main/CHANGELOG.md