QVAC-17783 fix: scope kv-cache invalidation to deleted key on RPC delete-cache#1740
Merged
maxim-smotrov merged 3 commits intoApr 24, 2026
Merged
Conversation
… key instead of wiping all entries
NamelsKing
approved these changes
Apr 24, 2026
opaninakuffo
approved these changes
Apr 24, 2026
Contributor
Author
|
/review |
Contributor
Tier-based Approval Status |
simon-iribarren
approved these changes
Apr 24, 2026
simon-iribarren
left a comment
Contributor
There was a problem hiding this comment.
Approving as team member — lead (NamelsKing) and opaninakuffo already signed off.
The bug and fix are both well-characterized:
handleDeleteCachewas wiping the entirecachedMessageCountsmap on single-key deletes; now scoped to the removed path.clearCacheRegistrywas substring-matching on the composite key (modelId:configHash:cacheKey) and could false-positive across entries; now parses and exact-matches.clearCachedMessageCountsmatches on exact key orprefix + path.sep, avoiding the unrelated-prefix-collision class of bugs.{ all: true }branch now also resets the registry, closing a gap the old code had.deleteCachereturning the removed path + switching torm({ recursive: true, force: true })is the right shape — idempotent on missing dirs and errors surface through the handler's existing structured-error wrapper.
Small diff (+54/-49, 3 files), tightly scoped to the invalidation path. Ship it.
Proletter
pushed a commit
that referenced
this pull request
May 24, 2026
… key instead of wiping all entries (#1740)
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.
🎯 What problem does this PR solve?
delete-cacheRPC (removeCache({ kvCacheKey, modelId })) wiped the entire in-memorycachedMessageCountsmap, not just entries for the deleted target. Unrelated caches lost their cached message counts and were forced to reprocess history on the next completion.📝 How does it solve it?
handleDeleteCachenow scopes both invalidations to the actually-removed target:clearCachedMessageCounts(removedPath)— only entries under the deleted directoryclearCacheRegistry({ cacheKey, modelId })— only matchingmodelId:configHash:cacheKeyentries{ all: true }branch now also resets the registry (it wasn't being cleared before).deleteCachenow returns the removed path so the handler can pass it to the message-count cleaner, and usesrm({ recursive: true, force: true })so a missing dir is not an error. Errors propagate to the handler's existing structured-error wrapper instead of being silently logged.clearCacheRegistryrewritten to parse the composite key (modelId:configHash:cacheKey) and exact-match oncacheKeyand/ormodelIdinstead of substring matching.clearCachedMessageCountsmatches by exact key orprefix + path.sepso a deleted directory invalidates only its own entries, not unrelated keys sharing a string prefix.🧪 How was it tested?
delete-cacheRPC with{ kvCacheKey, modelId }and verified that:initializedCachesno longer retains entries for the deleted target{ all: true }still wipes everything end-to-end.