Skip to content

refactor: semantic function clustering — consolidate rate-limit utils, httputil, and logger helpers#7532

Merged
lpcox merged 2 commits into
mainfrom
copilot/refactor-semantic-function-clustering
Jun 14, 2026
Merged

refactor: semantic function clustering — consolidate rate-limit utils, httputil, and logger helpers#7532
lpcox merged 2 commits into
mainfrom
copilot/refactor-semantic-function-clustering

Conversation

Copilot AI commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Automated semantic analysis identified several functions in wrong files or packages. Implements all actionable items from the clustering report.

Changes

  • httputil.ComputeRetryAfter (new export) — moved computeRetryAfter from proxy/handler.go to httputil/github_http.go, exported, and co-located with its companion ParseRateLimitResetHeader. Caller in proxy/handler.go updated; time import dropped.

  • logger/global_helpers.go — absorbed initWithWarning and logFallbackWarnings from logger/init.go, which now only contains the public InitGatewayLoggers/InitProxyLoggers orchestration API. Removes init.go's import "log".

  • httputil/endpoint_helpers.go deletedWriteSimpleHealthResponse and WriteReflectResponse merged into httputil/httputil.go. File had only 2 functions wrapping WriteJSONResponse.

  • Cross-reference commentsParseRateLimitResetHeader and parseRateLimitResetFromText now point at each other; both parse rate-limit reset timing but from different sources (HTTP header vs. MCP tool result text).

Skipped: mcpresultmcp consolidation

Would create a circular import: mcpdifcmcpresultmcp. Left as-is.

GitHub Advanced Security started work on behalf of lpcox June 14, 2026 17:21 View session
GitHub Advanced Security finished work on behalf of lpcox June 14, 2026 17:23
GitHub Advanced Security started work on behalf of lpcox June 14, 2026 17:28 View session
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
Copilot finished work on behalf of lpcox June 14, 2026 17:28
Copilot AI requested a review from lpcox June 14, 2026 17:28
GitHub Advanced Security finished work on behalf of lpcox June 14, 2026 17:30
@lpcox lpcox marked this pull request as ready for review June 14, 2026 17:34
Copilot AI review requested due to automatic review settings June 14, 2026 17:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 ComputeRetryAfter helper from proxy into internal/httputil/github_http.go, updating proxy call sites and tests.
  • Consolidates logger initialization warning helpers into internal/logger/global_helpers.go, leaving internal/logger/init.go as orchestration-only.
  • Deletes internal/httputil/endpoint_helpers.go and merges its two small response helpers into internal/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

@lpcox lpcox merged commit 885d445 into main Jun 14, 2026
40 checks passed
@lpcox lpcox deleted the copilot/refactor-semantic-function-clustering branch June 14, 2026 17:45
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.

3 participants