refactor: fix package placement and consolidate micro-files per semantic clustering analysis by Copilot · Pull Request #7483 · github/gh-aw-mcpg · GitHub
Skip to content

refactor: fix package placement and consolidate micro-files per semantic clustering analysis#7483

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

refactor: fix package placement and consolidate micro-files per semantic clustering analysis#7483
lpcox merged 2 commits into
mainfrom
copilot/refactor-semantic-function-clustering

Conversation

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Three structural issues identified by semantic function clustering analysis: a cross-cutting security utility buried under the wrong parent, a sub-package with no consumers outside its parent, and two navigation-overhead micro-files.

Changes

  • internal/logger/sanitizeinternal/sanitize: The sanitize package (secret redaction, token truncation, URL sanitization) is consumed by 14+ files across auth, envutil, launcher, mcp, and server — not by logger. Promotes it to a first-class top-level utility package; updates all 18 import sites.

  • internal/config/rules → inlined into internal/config: The rules sub-package had zero consumers outside config. Moves all validation types (ValidationError, PortRange, TimeoutPositive, etc.) into config/validation_rules.go; removes the now-redundant type ValidationError = rules.ValidationError alias.

  • Merge tracing/holder.go (14 lines) into tracing/provider.go: CachedTracer and its method now live next to GetCachedOrGlobal which they delegate to.

  • Merge proxy/metadata.go (13 lines) into proxy/handler.go: metadataPassthrough map and helper co-located with their sole call site.

GitHub Advanced Security started work on behalf of lpcox June 13, 2026 14:23 View session
GitHub Advanced Security finished work on behalf of lpcox June 13, 2026 14:24
…idation

- Move internal/logger/sanitize → internal/sanitize (cross-cutting security utility)
- Merge internal/config/rules into internal/config package (exclusive sub-package)
- Merge tracing/holder.go into tracing/provider.go (micro-file)
- Merge proxy/metadata.go into proxy/handler.go (micro-file)

Closes #7445
Copilot AI changed the title [WIP] Refactor semantic function clustering analysis for package placement refactor: fix package placement and consolidate micro-files per semantic clustering analysis Jun 13, 2026
Copilot finished work on behalf of lpcox June 13, 2026 14:34
Copilot AI requested a review from lpcox June 13, 2026 14:34
GitHub Advanced Security started work on behalf of lpcox June 13, 2026 14:44 View session
GitHub Advanced Security finished work on behalf of lpcox June 13, 2026 14:45
@lpcox lpcox marked this pull request as ready for review June 13, 2026 15:48
Copilot AI review requested due to automatic review settings June 13, 2026 15:48

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 package structure to better reflect actual usage: promoting shared sanitization utilities to a top-level helper package, inlining config validation “rules” into internal/config, and merging two micro-files into their primary implementation files to reduce navigation overhead.

Changes:

  • Move internal/logger/sanitize to internal/sanitize and update import sites across the codebase.
  • Inline internal/config/rules into internal/config by moving validation types/helpers into validation_rules.go and updating call sites.
  • Merge tracing/holder.go into tracing/provider.go and proxy/metadata.go into proxy/handler.go.
Show a summary per file
File Description
internal/tracing/provider.go Inlines CachedTracer next to GetCachedOrGlobal.
internal/tracing/holder.go Removes now-redundant micro-file after inlining.
internal/server/tool_registry.go Updates sanitize import to internal/sanitize.
internal/server/tool_registry_test.go Updates sanitize import to internal/sanitize.
internal/server/middleware.go Updates sanitize import to internal/sanitize.
internal/server/http_helpers.go Updates sanitize import to internal/sanitize.
internal/sanitize/sanitize.go Introduces promoted sanitize utilities as a first-class internal package.
internal/sanitize/sanitize_test.go Adds/relocates tests for sanitization behaviors.
internal/proxy/metadata.go Removes now-redundant micro-file after inlining.
internal/proxy/handler.go Inlines metadata passthrough map/helper into sole call-site file.
internal/mcp/http_transport.go Updates sanitize import to internal/sanitize.
internal/mcp/connection.go Updates sanitize import to internal/sanitize.
internal/logger/rpc_helpers.go Updates sanitize import to internal/sanitize.
internal/logger/markdown_logger.go Updates sanitize import to internal/sanitize.
internal/logger/jsonl_logger.go Updates sanitize import to internal/sanitize.
internal/logger/jsonl_logger_test.go Updates sanitize import to internal/sanitize.
internal/launcher/log_helpers.go Updates sanitize import to internal/sanitize.
internal/launcher/launcher.go Updates sanitize import to internal/sanitize.
internal/launcher/launcher_test.go Updates sanitize import to internal/sanitize.
internal/envutil/github.go Updates sanitize import to internal/sanitize.
internal/envutil/envutil.go Updates sanitize import to internal/sanitize.
internal/envutil/envfile.go Updates sanitize import to internal/sanitize.
internal/config/validation.go Replaces rules.* calls with in-package validation helpers.
internal/config/validation_tracing.go Replaces rules.* calls with in-package validation helpers.
internal/config/validation_schema.go Replaces rules.* calls with in-package validation helpers.
internal/config/validation_rules.go Moves validation rule helpers into package config.
internal/config/validation_rules_test.go Updates tests to package config.
internal/config/expand.go Replaces rules.UndefinedVariable with in-package helper.
internal/config/config_stdin_test.go Updates ValidationError typing and related assertions.
internal/config/config_env.go Updates env parsing helper signature to use *ValidationError.
internal/config/config_core.go Replaces rules.PositiveInteger with in-package helper.
internal/auth/header.go Updates sanitize import to internal/sanitize.
internal/auth/header_test.go Updates sanitize import to internal/sanitize.

Copilot's findings

Tip

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

  • Files reviewed: 31/33 changed files
  • Comments generated: 0

@lpcox lpcox merged commit d766e8a into main Jun 13, 2026
40 checks passed
@lpcox lpcox deleted the copilot/refactor-semantic-function-clustering branch June 13, 2026 15:57
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