Draft
Refactor duplicated helper logic for session logging, rate-limit parsing, and routed server setup#8762
Conversation
6 tasks
Copilot
AI
changed the title
[WIP] Refactor code organization in semantic function clustering analysis
Refactor duplicated helper logic for session logging, rate-limit parsing, and routed server setup
Jul 6, 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.
This change addresses several small but recurring organization issues surfaced by the semantic clustering analysis: duplicated session-ID logging logic, split GitHub rate-limit parsing, a trivial logger alias, a misplaced tool-classification helper, and HTTP server factory functions split across files. The intent is to reduce duplication and make these helpers easier to find and evolve without changing behavior.
Session ID log formatting
util.FormatSessionIDForLogas the shared log-safe session ID formatter.serverandlauncherlogging paths to use the same truncation behavior, so launcher logs no longer emit full session IDs while server logs keep existing semantics.GitHub rate-limit parsing
internal/githubhttp/rate_limit.go.ParseRateLimitResetHeaderforX-RateLimit-ResetParseRateLimitResetFromTextfor MCP/tool error text such asrate reset in 42sHelper placement and indirection cleanup
truncateSanitizedwrapper and usedutil.Truncatedirectly at call sites.IsSingularReadToolfrominternal/difctointernal/mcp, which better matches its role as a tool-naming heuristic rather than DIFC logic.CreateHTTPServerForRoutedModeintointernal/server/http_server.goso HTTP server factory functions live together.Targeted test updates
IsSingularReadToolunderinternal/mcp.Example of the new shared session-ID formatting path: