Refactor config/logger structure for cohesion and consistent logging APIs#5566
Merged
Conversation
6 tasks
Copilot
AI
changed the title
[WIP] Refactor semantic function clustering analysis based on identified opportunities
Refactor config/logger structure for cohesion and consistent logging APIs
May 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors configuration and logger code to improve feature cohesion (tracing validation co-located with tracing config), reduce “nano-file” fragmentation, and standardize logger helper naming across the codebase while preserving backward compatibility.
Changes:
- Standardized logging helpers to canonical
Log*ToMarkdownandLog*ToServerAPIs and updated call sites/tests/docs accordingly (legacyLog*Md/Log*WithServerwrappers retained). - Consolidated configuration code by relocating tracing validation into
config_tracing.go, inlining guard-policy env var constants, and moving payload defaults/registration intoconfig_core.go. - Removed now-redundant nano-files (
config_payload.go,guard_policy_env.go,session_helpers.go) after inlining/moving their contents.
Show a summary per file
| File | Description |
|---|---|
| internal/server/tool_registry.go | Updates per-server logging calls to Log*ToServer during tool registration. |
| internal/server/http_helpers.go | Switches request rejection logging to LogErrorToMarkdown. |
| internal/server/guard_init.go | Updates DIFC/guard initialization logs to Log*ToServer. |
| internal/server/difc_log.go | Updates DIFC filtered-item logging to LogInfoToServer. |
| internal/mcp/errors.go | Standardizes backend connection error logging to Log*ToMarkdown / Log*ToServer. |
| internal/mcp/connection.go | Updates stderr/unified connection logs to canonical logger helpers. |
| internal/logger/startup.go | Moves startup helper to use LogInfoToMarkdown. |
| internal/logger/session_helpers.go | Removes file after moving SessionSuffix into common.go. |
| internal/logger/server_file_logger.go | Introduces Log*ToServer exports and keeps Log*WithServer wrappers for compatibility. |
| internal/logger/server_file_logger_test.go | Updates tests to use Log*ToServer. |
| internal/logger/README.md | Updates per-server logging examples to Log*ToServer. |
| internal/logger/markdown_logger.go | Introduces Log*ToMarkdown exports and keeps Log*Md wrappers for compatibility. |
| internal/logger/markdown_logger_test.go | Updates tests to use Log*ToMarkdown. |
| internal/logger/log_level_wrappers_test.go | Updates wrapper-coverage test mappings to new canonical names. |
| internal/logger/helper_functions_test.go | Updates helper-function tests to use canonical names. |
| internal/logger/doc.go | Updates package docs to list the canonical markdown/server helper APIs. |
| internal/logger/common.go | Updates logger API docs; adds SessionSuffix implementation here. |
| internal/launcher/log_helpers.go | Updates launcher logging to Log*ToServer while retaining session suffix usage. |
| internal/launcher/launcher.go | Updates launcher server logging to canonical Log*ToServer. |
| internal/config/validation.go | Removes tracing regex/validation implementation from validation module (moved). |
| internal/config/guard_policy_parse.go | Inlines guard-policy env var constants into this file. |
| internal/config/guard_policy_env.go | Removes file after inlining env var constants elsewhere. |
| internal/config/config_tracing.go | Adds regex helpers + validateOpenTelemetryConfig alongside tracing config. |
| internal/config/config_payload.go | Removes file after moving payload defaults/registration into config_core.go. |
| internal/config/config_core.go | Adds payload/log-related defaults/constants and registers payload defaults here. |
| internal/cmd/root.go | Updates startup/shutdown logging to Log*ToMarkdown. |
| AGENTS.md | Updates per-server logging example to LogInfoToServer. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 27/27 changed files
- Comments generated: 2
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 May 12, 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.
✨ Enhancement
This PR addresses the refactoring opportunities identified by semantic function clustering: tracing validation was split from tracing config, several nano-files added navigation overhead, and logger helper APIs used inconsistent naming conventions. The result is tighter feature locality and a more uniform logging surface.
Tracing validation co-located with tracing config
validateOpenTelemetryConfig(and its trace/span ID regex helpers) frominternal/config/validation.gotointernal/config/config_tracing.go.TracingConfigand its validation logic in one feature-focused file.Nano-file consolidation
internal/config/guard_policy_parse.goand removedinternal/config/guard_policy_env.go.internal/config/config_core.goand removedinternal/config/config_payload.go.SessionSuffixintointernal/logger/common.goand removedinternal/logger/session_helpers.go.Logger API naming standardization
Log*ToMarkdownLog*ToServerLog*MdandLog*WithServerwrappers for compatibility to avoid breaking existing external usage.Implementation approach: