refactor: move collaborator_permission to proxy, add strutil.RandomBytes#6687
Merged
Conversation
5 tasks
…RandomBytes - Move internal/httputil/collaborator_permission.go to internal/proxy/collaborator_permission.go - Updated package name from 'httputil' to 'proxy' - Updated logger namespace from 'httputil:collaborator_permission' to 'proxy:collaborator_permission' - Move unit tests to internal/proxy/collaborator_permission_helpers_test.go - Remove old httputil/collaborator_permission.go and its test file - Update proxy/proxy.go to call ParseCollaboratorPermissionArgs and FetchCollaboratorPermission without httputil prefix (now in the same package) - Update server/unified.go to import proxy and use proxy.ParseCollaboratorPermissionArgs and proxy.FetchCollaboratorPermission - Add strutil.RandomBytes(n int) ([]byte, error) as a shared crypto/rand primitive - Refactor strutil.randomHexFromReader to delegate to randomBytesFromReader - Add tests for randomBytesFromReader and RandomBytes in strutil/random_hex_test.go - Update tracing/provider.go to use strutil.RandomBytes instead of crypto/rand.Read directly, removing the direct crypto/rand import from the tracing package
Copilot
AI
changed the title
[WIP] Refactor semantic function clustering analysis based on opportunities
refactor: move collaborator_permission to proxy, add strutil.RandomBytes
May 29, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors ownership boundaries by moving collaborator-permission REST helpers from generic HTTP utilities into the proxy package, and extracts reusable random byte generation into strutil.
Changes:
- Relocated collaborator-permission helper code/tests into
internal/proxyand updated call sites in proxy/server code. - Added
strutil.RandomBytesand refactoredRandomHexinternals to share the byte-generation primitive. - Updated tracing span ID generation to use the shared
strutil.RandomByteshelper.
Show a summary per file
| File | Description |
|---|---|
internal/proxy/collaborator_permission.go |
Moves collaborator-permission helper implementation into the proxy package and updates logger namespace. |
internal/proxy/collaborator_permission_helpers_test.go |
Relocates helper tests into the proxy package and avoids test-name collision. |
internal/proxy/proxy.go |
Updates proxy caller to use same-package collaborator-permission helpers. |
internal/server/unified.go |
Updates server caller to use exported proxy collaborator-permission helpers. |
internal/strutil/random_hex.go |
Adds reusable random byte generation and delegates random hex generation through it. |
internal/strutil/random_hex_test.go |
Adds coverage for RandomBytes and its testable reader-backed helper. |
internal/tracing/provider.go |
Replaces direct crypto/rand span ID generation with strutil.RandomBytes. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/7 changed files
- Comments generated: 0
This was referenced May 29, 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.
Addresses two of three refactoring opportunities identified by semantic function clustering analysis: a domain-specific file misplaced in a generic utility package, and a duplicated
crypto/randusage pattern that can share a common primitive.Move
httputil/collaborator_permission.go→proxy/ParseCollaboratorPermissionArgs,LogAndWrapCollaboratorPermission, andFetchCollaboratorPermissionare GitHub REST API helpers for a specific MCP tool — not generic HTTP utilities. Moving them tointernal/proxy/aligns package responsibility with actual content.internal/proxy/collaborator_permission.go— moved file, updated package/logger namespace (proxy:collaborator_permission)internal/proxy/collaborator_permission_helpers_test.go— unit tests relocated from httputilinternal/proxy/proxy.go— callers now use unqualified names (same package)internal/server/unified.go— updated to importproxyand callproxy.ParseCollaboratorPermissionArgs/proxy.FetchCollaboratorPermissioninternal/httputil/collaborator_permission{,_test}.go— deletedAdd
strutil.RandomBytesas sharedcrypto/randprimitiveinternal/tracing/provider.gocalledcrypto/rand.Readdirectly whileinternal/strutilalready owns random generation. AddedRandomBytes(n int) ([]byte, error)and its testable corerandomBytesFromReader, then refactoredrandomHexFromReaderto delegate to it:Deferred
server/difc_log.go(Priority 3) is left in place — moving tointernal/difc/is only warranted if other packages need those DIFC log helpers, which is not currently the case.