Skip to content

refactor: move outlier functions to semantically correct files/packages#7394

Merged
lpcox merged 2 commits into
mainfrom
copilot/refactor-semantic-function-clustering-analysis
Jun 12, 2026
Merged

refactor: move outlier functions to semantically correct files/packages#7394
lpcox merged 2 commits into
mainfrom
copilot/refactor-semantic-function-clustering-analysis

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Four functions lived in files that didn't match their purpose. This moves each to its natural home with no logic changes.

Changes

  • strutil/json_clone.go (new) — extracts DeepCloneJSON from strutil.go; JSON deep-clone has nothing to do with string utilities
  • mcp/helpers.go (new) — extracts marshalToResponse, unmarshalParams, and callParamMethod from pagination.go; these are general-purpose MCP helpers consumed by connection_methods.go, not pagination-specific code
  • server/middleware.go — moves withResponseLogging from http_helpers.go; it's an http.Handler decorator and belongs alongside WithOTELTracing, authMiddleware, WithSDKLogging, etc.
  • mcpresult/mcpresult.go (new, replaces content_items.go + text_content.go) — consolidates two tiny single-function files into one; NormalizeContentItems and ExtractTextContent form a single logical unit

Finding 5 (AgentTagsSnapshot in mcp/connection_logging.go) is left as-is pending circular import analysis.

GitHub Advanced Security started work on behalf of lpcox June 11, 2026 22:47 View session
GitHub Advanced Security finished work on behalf of lpcox June 11, 2026 22:49
GitHub Advanced Security started work on behalf of lpcox June 11, 2026 22:53 View session
Copilot AI changed the title [WIP] Refactor JSON utility in string utility package refactor: move outlier functions to semantically correct files/packages Jun 11, 2026
Copilot finished work on behalf of lpcox June 11, 2026 22:53
Copilot AI requested a review from lpcox June 11, 2026 22:53
GitHub Advanced Security finished work on behalf of lpcox June 11, 2026 22:54
@lpcox lpcox marked this pull request as ready for review June 12, 2026 13:42
Copilot AI review requested due to automatic review settings June 12, 2026 13:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors internal helpers by relocating a handful of “outlier” functions into files that better match their responsibilities, without changing behavior. The goal is to improve code organization and discoverability across strutil, mcp, server, and mcpresult.

Changes:

  • Moved DeepCloneJSON out of strutil.go into a dedicated json_clone.go.
  • Extracted MCP JSON-RPC helper functions from pagination.go into a new helpers.go, leaving pagination focused on paging logic.
  • Consolidated MCP result parsing helpers (NormalizeContentItems, ExtractTextContent) into a single mcpresult.go, removing the prior tiny single-purpose files.
Show a summary per file
File Description
internal/strutil/strutil.go Removes DeepCloneJSON from the general string-utility file.
internal/strutil/json_clone.go Adds DeepCloneJSON in a semantically focused file within strutil.
internal/mcp/pagination.go Removes non-pagination MCP helpers; keeps pagination primitives and list helpers.
internal/mcp/helpers.go Adds shared MCP helper functions for response marshalling and param unmarshalling.
internal/server/http_helpers.go Removes withResponseLogging from HTTP helpers (keeps request-body logging utilities).
internal/server/middleware.go Adds withResponseLogging alongside other HTTP middleware/wrappers.
internal/mcpresult/mcpresult.go Hosts both NormalizeContentItems and ExtractTextContent in one cohesive file.
internal/mcpresult/content_items.go Removed as part of consolidating MCP result helpers.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 8/8 changed files
  • Comments generated: 0

@lpcox lpcox merged commit 84b576f into main Jun 12, 2026
40 checks passed
@lpcox lpcox deleted the copilot/refactor-semantic-function-clustering-analysis branch June 12, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants