Skip to content

refactor(redis): centralize miss and timestamp validation - #153

Merged
lan17 merged 1 commit into
mainfrom
codex/miss-invariant-cleanup
Sep 3, 2026
Merged

refactor(redis): centralize miss and timestamp validation#153
lan17 merged 1 commit into
mainfrom
codex/miss-invariant-cleanup

Conversation

@lan17

@lan17 lan17 commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

Small, behavior-preserving cleanup following the reviews on #146. Rebuilt on main after #146 collapsed the miss union, which already absorbed most of the original scope (one miss shape, one constructor, CACHE_MISS_REASONS driving the type, isValidRedisTimestampMs owning the timestamp envelope). What remains:

  • Move isCacheMissReason next to CACHE_MISS_REASONS in src/metrics.ts so the reason list has one owner; RedisCache imports it.
  • Use isValidRedisTimestampMs in frameAge instead of a hand-written copy of the safe-integer envelope.
  • Re-export CacheMissReason from dialcache/redis-protocol, where RedisReadMiss already lives; the packed consumer check asserts it is the root type.
  • Comment the internal RedisCacheMissReason disposition type so it is not mistaken for the metric reason.
  • Drop the README sentence duplicated between the network-shape and ACL paragraphs.
  • Unit tests pin the guard against prototype keys and non-strings, and the timestamp predicate against coercion.

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 typecheck
  • 658 unit tests with coverage thresholds
  • pnpm build and pnpm test:package

Base automatically changed from codex/issue-145-miss-reasons to main September 3, 2026 03:11
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.
@lan17
lan17 force-pushed the codex/miss-invariant-cleanup branch from 867c222 to 12f208b Compare September 3, 2026 03:19
@lan17
lan17 merged commit 0fded54 into main Sep 3, 2026
6 checks passed
@lan17
lan17 deleted the codex/miss-invariant-cleanup branch September 3, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant