feat(mcp,agent): add retry jitter and cancellation smoke test#4609
Merged
Conversation
cc84ffa to
0a80e52
Compare
Add ±25% downward jitter to connect_retry_backoff() in zeph-mcp so concurrent MCP server restarts do not fire reconnect attempts in lock-step (thundering herd). Jitter range is [nominal*3/4, nominal], AWS full-jitter style. Requires rand workspace dependency. Add apply_response_cache_cleanup_spawns_without_panic test in the binary crate to verify the function does not panic when a CancellationToken is cancelled during setup. A NOTE comment documents that the inner detached cleanup loop cannot be directly awaited without exposing its JoinHandle; deeper coverage is deferred. Closes #4574 Closes #4587
0a80e52 to
53f92dc
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
connect_retry_backoff()inzeph-mcpto desynchronise concurrent MCP server restart retries (thundering herd prevention). Jitter range is[nominal*3/4, nominal](AWS full-jitter style).apply_response_cache_cleanup_spawns_without_panictest to verify the function does not panic when aCancellationTokenis cancelled during setup.Changes
crates/zeph-mcp/Cargo.toml: addrand.workspace = truecrates/zeph-mcp/src/manager.rs: apply jitter inconnect_retry_backoff(), update doc comment, update two tests to range assertionssrc/agent_setup.rs: add cancellation smoke test with NOTE comment explaining coverage limitationTest coverage limitation (#4587)
apply_response_cacheis a sync function that detaches an inner cleanup task viatokio::spawn. Without exposing the innerJoinHandle, a test cannot directly await the inner task's exit on cancellation. The added test verifies the function does not panic and returns promptly; deeper cancel-branch coverage requires a future API change to expose the handle.Test plan
cargo nextest run -p zeph-mcp -E 'test(connect_retry_backoff)'— 2/2 PASScargo nextest run -p zeph --features testing -E 'test(apply_response_cache_cleanup_spawns_without_panic)'— 1/1 PASScargo +nightly fmt --check— cleancargo clippy --workspace -- -D warnings— cleanRUSTFLAGS="-D warnings" cargo check --workspace --all-targets --features desktop,ide,server,chat,pdf,scheduler— cleanCloses #4574
Closes #4587