Executive Summary
Analyzed all 155 non-test .go files under internal/ (~31,900 LOC). This repository has already undergone extensive prior refactoring passes (30+ closed [refactor] issues), and most previously-identified problems (response-writer duplication, DIFC tag-set consolidation, micro-file fragmentation) are already resolved. Common patterns like tagSet (shared by Label/Capabilities), BaseResponseWriter (shared by httputil/server), and validation error constructors are already well-factored.
One small remaining organizational nit was found.
Identified Issue
Near-empty "shared" file holding only a package-level logger
- File:
internal/config/validation_shared.go (5 lines total)
- Content:
package config
import "github.com/github/gh-aw-mcpg/internal/logger"
var logValidation = logger.ForFile()
- Issue: This file exists solely to declare
logValidation, which is then used across 7 other files in the package (agent_policy.go, expand.go, validation_errors.go, validation_gateway.go, validation_rules.go, validation_server.go, validation_tracing.go — 66 call sites total). Since logger.ForFile() derives its namespace from the calling file rather than where the logger variable is declared, all 66 call sites log under the config:validation_shared namespace regardless of which file actually emitted the message, which is misleading for DEBUG=config:* filtering and reduces the value of per-file debug namespacing described in this repo's logging conventions.
- Recommendation: Declare
logValidation in whichever validation file is now the primary/most-used call site (or keep one dedicated logger per file, consistent with the logger.ForFile() convention used elsewhere in the codebase, e.g. logValidationRules, logValidationServer), and remove the now-unnecessary validation_shared.go. This is a very small, low-risk cleanup — no behavior change, only logging namespace clarity and one fewer trivial file.
- Estimated Impact: Low — restores per-file DEBUG namespace accuracy for config validation logging; removes one near-empty file.
Analysis Metadata
- Total Go files analyzed: 155 (non-test, under
internal/)
- Prior open
[refactor] issues closed before this analysis: 0 (none were open)
- Significant duplicates found: None — prior consolidations (tagSet, BaseResponseWriter, validation error helpers) remain effective
- Outliers found: 1 (shared-logger file described above)
- Detection method: Manual semantic clustering via naming-pattern grep across packages (
util, logger, config, difc, sanitize, httputil, server, mcp, enclavegithub, githubhttp, envutil) plus targeted diff review of files with likely duplication (response writers, tag sets, error formatters)
- Analysis date: 2026-08-31
Generated by Semantic Function Refactoring · copilot · auto · 76.3 AIC · ⊞ 14.5K · ◷
Executive Summary
Analyzed all 155 non-test
.gofiles underinternal/(~31,900 LOC). This repository has already undergone extensive prior refactoring passes (30+ closed[refactor]issues), and most previously-identified problems (response-writer duplication, DIFC tag-set consolidation, micro-file fragmentation) are already resolved. Common patterns liketagSet(shared byLabel/Capabilities),BaseResponseWriter(shared byhttputil/server), and validation error constructors are already well-factored.One small remaining organizational nit was found.
Identified Issue
Near-empty "shared" file holding only a package-level logger
internal/config/validation_shared.go(5 lines total)logValidation, which is then used across 7 other files in the package (agent_policy.go,expand.go,validation_errors.go,validation_gateway.go,validation_rules.go,validation_server.go,validation_tracing.go— 66 call sites total). Sincelogger.ForFile()derives its namespace from the calling file rather than where the logger variable is declared, all 66 call sites log under theconfig:validation_sharednamespace regardless of which file actually emitted the message, which is misleading forDEBUG=config:*filtering and reduces the value of per-file debug namespacing described in this repo's logging conventions.logValidationin whichever validation file is now the primary/most-used call site (or keep one dedicated logger per file, consistent with thelogger.ForFile()convention used elsewhere in the codebase, e.g.logValidationRules,logValidationServer), and remove the now-unnecessaryvalidation_shared.go. This is a very small, low-risk cleanup — no behavior change, only logging namespace clarity and one fewer trivial file.Analysis Metadata
internal/)[refactor]issues closed before this analysis: 0 (none were open)util,logger,config,difc,sanitize,httputil,server,mcp,enclavegithub,githubhttp,envutil) plus targeted diff review of files with likely duplication (response writers, tag sets, error formatters)