Refactor env int parsing and clarify logger sink intent#6019
Merged
Conversation
4 tasks
Copilot
AI
changed the title
[WIP] Refactor semantic function clustering analysis
Refactor env int parsing and clarify logger sink intent
May 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors integer environment-variable parsing to centralize raw parsing semantics in envutil, and clarifies the intent/destination of logger sinks via improved godoc and documentation notes.
Changes:
- Added
envutil.GetEnvIntRaw(envKey) (int, bool, error)and refactoredGetEnvInt+config.parseAndValidateIntEnvto reuse it. - Clarified logger godoc/agent guidance to distinguish unsuffixed
Log*(unified file sink) from destination-specificLog*ToMarkdown/Log*ToServer. - Added tests covering
GetEnvIntRawbehavior and a discoverability note for a generic DIFC JSON extraction helper.
Show a summary per file
| File | Description |
|---|---|
| internal/server/difc_log.go | Adds a note clarifying the generic nature of getFilteredItemStringField for future extraction. |
| internal/logger/file_logger.go | Updates exported Log* godoc to clarify it targets the unified file sink. |
| internal/envutil/envutil.go | Introduces GetEnvIntRaw and refactors GetEnvInt to delegate parsing. |
| internal/envutil/envutil_test.go | Adds unit tests for the new GetEnvIntRaw helper. |
| internal/config/config_env.go | Refactors int env parsing/validation to delegate parsing to envutil.GetEnvIntRaw. |
| AGENTS.md | Adds usage guidance distinguishing unified vs destination-specific logging helpers. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 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 19, 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.
The semantic clustering review found three refactor opportunities: ambiguous logger sink naming, duplicated int env parsing logic, and a generic JSON extraction helper hidden in DIFC logging code. This PR takes the low-risk path: consolidate parsing behavior and improve discoverability/intent via docs and comments without API churn.
Env parsing consolidation
envutil.GetEnvIntRaw(envKey) (int, bool, error)to centralize raw integer env parsing (present/not-present/parse-error semantics).config.parseAndValidateIntEnvto delegate parsing toGetEnvIntRaw, keeping domain validation inconfig.GetEnvIntto reuseGetEnvIntRawinternally, removing duplicate parse logic.Logger sink clarity (no rename)
LogInfo/LogWarn/LogError/LogDebugthat unsuffixed functions target the unified file sink (mcp-gateway.log).AGENTS.mdto direct destination-specific usage towardLog*ToMarkdown/Log*ToServer.DIFC helper discoverability
getFilteredItemStringFieldininternal/server/difc_log.goindicating it is intentionally generic and a candidate for future extraction if reuse grows.Focused coverage update
GetEnvIntRawbehavior ininternal/envutil/envutil_test.go.