refactor(mcp-server): add injectable clock for session expiry#131
Merged
Conversation
bug-ops
enabled auto-merge (squash)
July 9, 2026 15:12
Replace direct Utc::now() calls in PendingGeneration with a Clock trait (SystemClock in production, TestClock in tests), threaded through StateManager and GeneratorService via Arc<dyn Clock>. Tests now inject a fake clock to exercise the 30-minute TTL boundary precisely instead of rewinding expires_at after construction. Also files follow-up issues for three previously untracked TODO markers (#124, #125, #126) and updates the comments to reference them. Closes #121
bug-ops
force-pushed
the
mcp-server-session-expiry-has
branch
from
July 9, 2026 15:14
1396318 to
004380f
Compare
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
Clocktrait (SystemClockin production,TestClockin tests) incrates/mcp-server/src/clock.rs, replacing directUtc::now()calls inPendingGeneration::new/is_expired.Arc<dyn Clock>throughStateManagerandGeneratorServicevia newwith_clockconstructors, so tests can inject a fake "now" instead of rewindingexpires_atpost-construction.StateManager/GeneratorServiceactually consult the injected clock rather than a hardcodedSystemClock.crates/mcp-skill/src/parser.rsandcrates/mcp-cli/src/main.rs, and updates the comments to reference them (TODO(#N): ...) without resolving the underlying concerns.This is a behavior-preserving refactor:
SystemClock::now()is a pure passthrough toUtc::now(), and production expiry semantics are unchanged.Closes #121
Test plan
cargo +nightly fmt --checkcargo +stable clippy --all-targets --all-features --workspace -- -D warningscargo nextest run --all-features --workspace --no-fail-fast(664/664 passed)cargo test --doc --all-features --workspace(182/182 passed)