Conversation
dc0a8b9 to
918c4c2
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses review feedback on the vmcp/session package by extracting common interfaces, factoring out concurrency logic, and adding test coverage for HTTP round trippers. The changes improve code organization and testability without altering functionality.
Changes:
- Extract shared MCP operation methods into a new
types.Callerinterface to eliminate duplication betweenbackend.SessionandMultiSession - Factor in-flight request tracking into a new
AdmissionQueueinterface with comprehensive unit tests, removing synchronization noise from the session struct - Add unit tests for HTTP round trippers (
httpRoundTripperFunc,authRoundTripper,identityRoundTripper) covering request cloning, auth error propagation, and identity context handling
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/vmcp/session/types/session.go | New Caller interface defining common MCP protocol operations shared by backend and multi-session types |
| pkg/vmcp/session/session.go | Updated MultiSession to embed sessiontypes.Caller, removing duplicate method declarations |
| pkg/vmcp/session/internal/backend/session.go | Updated Session to embed sessiontypes.Caller, removing duplicate method declarations |
| pkg/vmcp/session/admission.go | New AdmissionQueue interface and implementation for managing concurrent request admission and graceful shutdown |
| pkg/vmcp/session/admission_test.go | Comprehensive unit tests for admission queue covering concurrency, idempotency, and drain semantics |
| pkg/vmcp/session/default_session.go | Refactored to use AdmissionQueue, removing mutex/waitgroup fields and lock operations from snapshot methods |
| pkg/vmcp/session/default_session_test.go | Updated test fixtures to initialize the new queue field |
| pkg/vmcp/session/factory.go | Updated factory to initialize the admission queue when creating sessions |
| pkg/vmcp/session/internal/backend/roundtripper_test.go | New unit tests for HTTP round trippers validating request cloning, auth handling, and identity propagation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
918c4c2 to
cfd2970
Compare
Extract the shared MCP operation methods (CallTool, ReadResource, GetPrompt, Close) from backend.Session and MultiSession into a new types.Caller interface in pkg/vmcp/session/types, eliminating duplication between the two interfaces. This is a first step toward the future consolidation of the two session types. Factor the in-flight request tracking logic (sync.RWMutex, sync.WaitGroup, closed bool) out of defaultMultiSession into a new AdmissionQueue interface with a concrete admissionQueue implementation. This makes the concurrency contract independently testable and removes synchronization noise from the session struct. Snapshot methods (Tools, Resources, Prompts, BackendSessions) no longer need locks since those fields are immutable after construction. Add unit tests for the HTTP round trippers (httpRoundTripperFunc, authRoundTripper, identityRoundTripper) in the internal/backend package, covering request cloning, auth error propagation, and identity context propagation.
cfd2970 to
dee5c2c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3905 +/- ##
==========================================
+ Coverage 67.18% 67.21% +0.02%
==========================================
Files 448 449 +1
Lines 45218 45220 +2
==========================================
+ Hits 30380 30393 +13
+ Misses 12469 12459 -10
+ Partials 2369 2368 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Extract the shared MCP operation methods (CallTool, ReadResource, GetPrompt, Close) from backend.Session and MultiSession into a new types.Caller interface in pkg/vmcp/session/types, eliminating duplication between the two interfaces. This is a first step toward the future consolidation of the two session types.
Factor the in-flight request tracking logic (sync.RWMutex, sync.WaitGroup, closed bool) out of defaultMultiSession into a new AdmissionQueue interface with a concrete admissionQueue implementation. This makes the concurrency contract independently testable and removes synchronization noise from the session struct. Snapshot methods (Tools, Resources, Prompts, BackendSessions) no longer need locks since those fields are immutable after construction.
Add unit tests for the HTTP round trippers (httpRoundTripperFunc, authRoundTripper, identityRoundTripper) in the internal/backend package, covering request cloning, auth error propagation, and identity context propagation.