Repository navigation
fix(core): reject future feature-flag cache timestamps - #234
Merged
Merged
Conversation
The cache freshness check subtracted fetched_at from the current time, which overflows (and panics in debug builds) when the cached timestamp is in the future, for example after a clock rollback or an edited cache file. Pass now explicitly to the private validity check and use checked_sub so a future timestamp is treated as stale. The public API and the stale-cache fallback on API errors are unchanged. Coven-Harness: Claude Code / claude-opus-5-5
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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
The remote feature-flag cache no longer overflows when its stored
fetched_atis in the future; such a cache is treated as stale.Context
crates/core/src/feature_flags.rs(cache validity only).FeatureFlagManagerAPI, the 10 s HTTP timeout, and the stale-cache fallback on API errors are unchanged. No network request or user cache was touched.Changes
now - fetched_at. A future timestamp, from a clock rollback or file contents, overflowed, which is a panic in debug builds (reproduced with the extracted expression atu64::MAX).nowexplicitly and useschecked_sub, so a future timestamp is never fresh (+1 net production line).u64::MAX, a future timestamp and zero TTL.Validation
cargo test --locked -p claurst-core --lib feature_flags: 4 passed, 0 failed.cargo fmt --all -- --check,cargo check --workspace --locked,cargo clippy --workspace --all-targets --locked -- -D warnings: pass on this branch (current main).git diff --check: clean.cargo test --workspace: hosted Rust CI. Source: 669 core tests passed; integration assembly 2,078 passed.PR Readiness