Conversation
… state to proper packages Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
lpcox
March 15, 2026 23:43
View session
5 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors DIFC/guard-policy domain logic out of transport/CLI layers into the config and difc packages, reducing semantic clustering in server and mcp while keeping behavior/call-sites consistent.
Changes:
- Moved server guard-policy parsing helpers into
internal/config(ParseServerGuardPolicy,ParsePolicyMap) and updatedUnifiedServer+ tests to call them. - Moved AllowOnly policy factory into
internal/config(BuildAllowOnlyPolicy) and updated CLI override resolution + tests accordingly. - Moved DIFC sink server ID global state into
internal/difc(SetSinkServerIDs,IsSinkServerID), updatedmcplogging enrichment and CLI wiring.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/server/unified.go | Delegates server guard-policy parsing to config.ParseServerGuardPolicy; removes local parsing helpers. |
| internal/server/guard_policy_parsing_test.go | Updates tests to call config.ParseServerGuardPolicy. |
| internal/config/guard_policy.go | Adds exported parsing helpers and BuildAllowOnlyPolicy factory. |
| internal/cmd/root.go | Wires sink server IDs via difc.SetSinkServerIDs; builds AllowOnly policy via config.BuildAllowOnlyPolicy. |
| internal/cmd/flags_difc.go | Removes CLI-local buildAllowOnlyPolicy helper. |
| internal/cmd/flags_difc_test.go | Updates tests to call config.BuildAllowOnlyPolicy. |
| internal/mcp/connection.go | Delegates sink-server check to difc.IsSinkServerID for tag snapshot enrichment. |
| internal/mcp/connection_test.go | Updates sink-server ID tests to use difc API. |
| internal/mcp/sdk_method_dispatch_test.go | Updates tests to configure sink-server IDs via difc.SetSinkServerIDs. |
| internal/difc/sink_server_ids.go | Introduces concurrency-safe global sink server ID set and lookup helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This was referenced Mar 16, 2026
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
Addresses the three most impactful semantic function clustering refactoring opportunities identified in the issue.
Changes
1. Guard-policy parsing moved to
configpackageparseServerGuardPolicyandparsePolicyMapmoved frominternal/server/unified.go→internal/config/guard_policy.go, exported asParseServerGuardPolicy/ParsePolicyMapGuardPolicystructure and should live alongside the type definitions, not in the transport/server layerinternal/server/unified.gonow delegates toconfig.ParseServerGuardPolicy2.
BuildAllowOnlyPolicyfactory moved toconfigpackagebuildAllowOnlyPolicymoved frominternal/cmd/flags_difc.go→internal/config/guard_policy.go, exported asBuildAllowOnlyPolicyinternal/cmd/root.gonow delegates toconfig.BuildAllowOnlyPolicy3. DIFC sink server ID state moved to
difcpackagedifcSinkServerIDsglobal state,SetDIFCSinkServerIDs, andisDIFCSinkServerIDremoved frominternal/mcp/connection.gointernal/difc/sink_server_ids.goexportsSetSinkServerIDsandIsSinkServerIDmcp) should not own security policy state — it now importsdifcand delegates todifc.IsSinkServerIDinternal/cmd/root.gonow callsdifc.SetSinkServerIDsdirectlyTesting
All existing tests pass (
make agent-finished). Call sites updated throughout.Closes #[issue-number]