refactor: semantic function clustering — consolidate rate-limit utils, httputil, and logger helpers#7532
Merged
Conversation
…lpers, reorganize logger helpers
Copilot
AI
changed the title
[WIP] Refactor semantic function clustering analysis
refactor: semantic function clustering — consolidate rate-limit utils, httputil, and logger helpers
Jun 14, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors and re-clusters a handful of HTTP/rate-limit and logging helper functions so they live alongside their closest semantic companions (and removes a now-redundant helper file), improving discoverability and reuse across internal packages.
Changes:
- Promotes and moves the rate-limit
ComputeRetryAfterhelper fromproxyintointernal/httputil/github_http.go, updating proxy call sites and tests. - Consolidates logger initialization warning helpers into
internal/logger/global_helpers.go, leavinginternal/logger/init.goas orchestration-only. - Deletes
internal/httputil/endpoint_helpers.goand merges its two small response helpers intointernal/httputil/httputil.go, keeping behavior intact.
Show a summary per file
| File | Description |
|---|---|
| internal/server/rate_limit.go | Adds cross-reference comments between header-based and text-based rate-limit reset parsing. |
| internal/proxy/rate_limit_test.go | Updates tests to use the new exported httputil.ComputeRetryAfter. |
| internal/proxy/handler.go | Switches proxy retry-after injection to call httputil.ComputeRetryAfter and drops the local helper. |
| internal/logger/init.go | Removes private helpers/imports so the file only orchestrates public logger init. |
| internal/logger/global_helpers.go | Centralizes initWithWarning / logFallbackWarnings helpers in a shared logger helper file. |
| internal/httputil/httputil.go | Merges health/reflect endpoint helpers into the main httputil file. |
| internal/httputil/github_http.go | Adds exported ComputeRetryAfter colocated with GitHub rate-limit header parsing. |
| internal/httputil/endpoint_helpers.go | Deleted; functionality moved into internal/httputil/httputil.go. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 8/8 changed files
- Comments generated: 0
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.
Automated semantic analysis identified several functions in wrong files or packages. Implements all actionable items from the clustering report.
Changes
httputil.ComputeRetryAfter(new export) — movedcomputeRetryAfterfromproxy/handler.gotohttputil/github_http.go, exported, and co-located with its companionParseRateLimitResetHeader. Caller inproxy/handler.goupdated;timeimport dropped.logger/global_helpers.go— absorbedinitWithWarningandlogFallbackWarningsfromlogger/init.go, which now only contains the publicInitGatewayLoggers/InitProxyLoggersorchestration API. Removesinit.go'simport "log".httputil/endpoint_helpers.godeleted —WriteSimpleHealthResponseandWriteReflectResponsemerged intohttputil/httputil.go. File had only 2 functions wrappingWriteJSONResponse.Cross-reference comments —
ParseRateLimitResetHeaderandparseRateLimitResetFromTextnow point at each other; both parse rate-limit reset timing but from different sources (HTTP header vs. MCP tool result text).Skipped:
mcpresult→mcpconsolidationWould create a circular import:
mcp→difc→mcpresult→mcp. Left as-is.