Repository navigation
[WIP] Refactor duplicate code in filtered unified-server builders - #16930
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the changes include shared snapshot and identity helpers with tests covering isolation, filtering, empty registries, and identity edge cases.
No open issues 🎉
What changed in this PR
This PR removes duplicated tool-snapshot and identity logic from the agent- and delegation-filtered unified-server builders while preserving existing filtering behavior.
Changes:
- Added
UnifiedServer.snapshotTools()to safely copy registered tools under the read lock. - Added and reused shared
unifiedToolIdentity()logic. - Added unit tests for snapshots, isolation, empty registries, and identity edge cases.
| File | Description |
|---|---|
| internal/server/unified_lifecycle.go | Adds the shared locked tool-snapshot helper. |
| internal/server/unified_lifecycle_test.go | Tests snapshot contents, copy isolation, registration independence, and empty registries. |
| internal/server/agent_policy_enforce.go | Reuses the snapshot and identity helpers in both filtered unified-server builders. |
| internal/server/agent_policy_enforce_test.go | Tests unified tool identity behavior across prefix, mismatch, and empty-value cases. |
Review effort: Lite (adaptive)
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked; no destructive operations attempted.
|
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.