refactor(redis): centralize miss and timestamp validation - #153
Merged
Conversation
Give the reason list one owner by moving isCacheMissReason next to CACHE_MISS_REASONS in metrics.ts, and use isValidRedisTimestampMs in frameAge instead of a hand-written copy of the safe-integer envelope. Re-export CacheMissReason from dialcache/redis-protocol beside RedisReadMiss, comment the internal RedisCacheMissReason disposition type, and drop a README sentence duplicated between the network-shape and ACL paragraphs. Tests pin the guard against prototype keys and the timestamp predicate against coercion. No behavior change.
lan17force-pushed
the
codex/miss-invariant-cleanup
branch
from
September 3, 2026 03:19
867c222 to
12f208bCompareUh oh!
There was an error while loading. Please reload this page.
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 freeto 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
Small, behavior-preserving cleanup following the reviews on #146. Rebuilt on
mainafter #146 collapsed the miss union, which already absorbed most of the original scope (one miss shape, one constructor,CACHE_MISS_REASONSdriving the type,isValidRedisTimestampMsowning the timestamp envelope). What remains:isCacheMissReasonnext toCACHE_MISS_REASONSinsrc/metrics.tsso the reason list has one owner;RedisCacheimports it.isValidRedisTimestampMsinframeAgeinstead of a hand-written copy of the safe-integer envelope.CacheMissReasonfromdialcache/redis-protocol, whereRedisReadMissalready lives; the packed consumer check asserts it is the root type.RedisCacheMissReasondisposition type so it is not mistaken for the metric reason.Scope and compatibility
No behavior change: validation sites and their order are unchanged, and the miss taxonomy, read-result shape, refill fencing, metrics, and Redis commands are untouched. The only public addition is the type-only re-export.
Validation
pnpm typecheckpnpm buildandpnpm test:package