Repository navigation
fix(api): report the cache that requests actually use in /api/cache/stats - #10769
Merged
diegosouzapw merged 2 commits intoAug 20, 2026
Merged
diegosouzapw merged 2 commits into
diegosouzapw merged 2 commits into
Conversation
…tats /api/cache/stats read getPromptCache() — an LRU no request path writes to. It answered 0 hit / 0 miss with size 0 no matter how much traffic the semantic cache served, and the Health and Usage dashboards rendered that as fact. It now reports the semantic cache's in-memory entries. Same LRUCache shape, so the response keys and their types are unchanged and no dashboard code moves. DELETE clears the in-memory entries only: wiring it to clearCache() would turn a stats fix into a delete of persisted rows, which is a separate decision. Co-authored-by: Poid-ZA <Poid-ZA@users.noreply.github.com>
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…tats (diegosouzapw#10769) Merged via merge-train (release/v3.8.50, batch1 2026-08-20) — static gates (typecheck/file-size/complexity/cognitive/changelog) green on the combined tree; test:unit reds observed in the boarded run were verified pre-existing on the pure release tip (unrelated flake), not caused by this PR. Thanks for the contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/cache/statscallsgetPromptCache(), an in-memory LRU with no caller anywhere else in thecodebase. The cache actually wired into the request path is
semanticCache.ts(semantic_cachetable) — with 31 entries on a live instance, the endpoint still answered
0 hit / 0 miss, size 0,and both
/dashboard/healthand/dashboard/usagerendered that as fact.The route now reports the semantic cache's in-memory entries, using the same
LRUCache.getStats()shape, so no dashboard code changes.
DELETEclears the in-memory entries only — wiring it to thefull
clearCache()would also delete persisted rows, a separate decision from a stats-reportingfix.
Same fix @Poid-ZA already wrote and had accepted in principle in #9446 ("the change itself is
wanted!") before it was closed for an unrelated reason: that branch carried +12,055/-1,259 across
dozens of unrelated files from a stale base and conflicted broadly. This rebuilds just the
targeted change — two files — on a fresh branch.
Related Issues
Validation
node --test tests/unit/cache-stats-reports-semantic-cache.test.ts(3/3),npm run test:vitest(368/368)npm run lintrelease/v3.8.50Tests Added Or Updated
tests/unit/cache-stats-reports-semantic-cache.test.ts(new)Coverage Notes
Touches
src/app/api/cache/stats/route.tsandsrc/lib/semanticCache.ts. The new test covers theGET stats shape and the DELETE memory-clear path directly.
Reviewer Notes
DELETEis memory-only by design — see Summary.