fix: address PR 15 review gaps — verify_invariants, validation, dead code - #20
Merged
Conversation
…code Fixes identified by domain expert review of PR 15 (memory optimizations): 1. Add CommandExecutor::verify_invariants() (TigerStyle) - Invariant 1: every expiration key exists in data - Invariant 2: no expired keys remain after eviction - Invariant 3: no empty collections in data Called after both eviction methods in debug builds. 2. Add validate() bounds for ConnectionPoolConfig (Rust Style) - max_connections must be > 0 - buffer_pool_size must be > 0 3. Remove dead key_count field from CommandExecutor Initialized to 0, never updated, never read. Had #[allow(dead_code)]. 4. Use Vec::with_capacity() in eviction (TigerStyle) Pre-allocate expired_keys vec at 25% of expirations map size. 5. Add ConnectionPoolConfig test coverage (Rust Style) - Default values asserted - TOML parsing with and without [connection_pool] section - Validation error tests for zero values Verified: 9 executor DST tests pass (verify_invariants fires on every eviction across 100+ seeds × 1000+ ops), 8 perf_config tests pass, 0 clippy warnings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Fixes 5 gaps identified by domain expert review of PR #15 (memory optimizations).
CommandExecutor::verify_invariants()— New TigerStyle method checking 3 invariants: orphaned expirations, stale expired keys, empty collections. Called after every eviction in debug builds.ConnectionPoolConfigvalidation —max_connections > 0andbuffer_pool_size > 0bounds added toPerformanceConfig::validate()key_countfield — Was initialized to 0, never updated, never read, had#[allow(dead_code)]Vec::with_capacity()— Pre-allocate expired_keys vec in both eviction methodsWhat verify_invariants() catches
This closes the gap where a bug like "LPOP forgets to clean up empty list" would only be caught if LLEN happened to be called on that exact key later. Now it's caught immediately after every eviction cycle.
Test plan
cargo clippy --release -p redis-sim -- -D warnings— 0 warnings🤖 Generated with Claude Code