Skip to content

Refactor config/logger structure for cohesion and consistent logging APIs#5566

Merged
lpcox merged 4 commits into
mainfrom
copilot/refactor-semantic-function-clustering
May 12, 2026
Merged

Refactor config/logger structure for cohesion and consistent logging APIs#5566
lpcox merged 4 commits into
mainfrom
copilot/refactor-semantic-function-clustering

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

✨ 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

    • Moved validateOpenTelemetryConfig (and its trace/span ID regex helpers) from internal/config/validation.go to internal/config/config_tracing.go.
    • Keeps TracingConfig and its validation logic in one feature-focused file.
  • Nano-file consolidation

    • Inlined guard policy env var constants into internal/config/guard_policy_parse.go and removed internal/config/guard_policy_env.go.
    • Moved payload-related defaults and registration into internal/config/config_core.go and removed internal/config/config_payload.go.
    • Moved SessionSuffix into internal/logger/common.go and removed internal/logger/session_helpers.go.
  • Logger API naming standardization

    • Introduced canonical helper names:
      • Log*ToMarkdown
      • Log*ToServer
    • Updated call sites to use canonical names.
    • Kept Log*Md and Log*WithServer wrappers for compatibility to avoid breaking existing external usage.

Implementation approach:

// Canonical names
logger.LogInfoToMarkdown("startup", "Gateway started")
logger.LogWarnToServer("github", "backend", "Connection timeout")

// Compatibility wrappers remain valid
logger.LogInfoMd("startup", "Gateway started")
logger.LogWarnWithServer("github", "backend", "Connection timeout")

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
Copilot finished work on behalf of lpcox May 12, 2026 22:58
Copilot AI requested a review from lpcox May 12, 2026 22:58
@lpcox lpcox marked this pull request as ready for review May 12, 2026 23:14
Copilot AI review requested due to automatic review settings May 12, 2026 23:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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*ToMarkdown and Log*ToServer APIs and updated call sites/tests/docs accordingly (legacy Log*Md / Log*WithServer wrappers retained).
  • Consolidated configuration code by relocating tracing validation into config_tracing.go, inlining guard-policy env var constants, and moving payload defaults/registration into config_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

Comment thread AGENTS.md Outdated
Comment thread internal/config/config_tracing.go Outdated
lpcox and others added 2 commits May 12, 2026 16:22
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>
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.

[refactor] Semantic Function Clustering Analysis: Refactoring Opportunities

3 participants