Skip to content

Refactor dead helpers and trivial guard wrappers; consolidate session ID utility#7279

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/refactor-semantic-function-analysis
Open

Refactor dead helpers and trivial guard wrappers; consolidate session ID utility#7279
Copilot wants to merge 3 commits into
mainfrom
copilot/refactor-semantic-function-analysis

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Static analysis flagged dead production helpers in logger, no-op wrapper indirection in guard, and a single-function micro-file in server. This PR removes unused code paths and trims indirection without changing runtime behavior.

  • Logger cleanup (dead production code)

    • Removed extractEssentialFields from internal/logger/rpc_helpers.go (unused in prod and tests after refactor).
    • Removed internal/logger/log_cleanup.go and moved its message-normalization helper into test-only scope (internal/logger/log_cleanup_test.go).
    • Updated internal/logger/rpc_helpers_test.go to match test-only helper naming and removed obsolete extractEssentialFields tests.
  • Guard policy validation (wrapper inlining)

    • Removed trivial pass-through wrappers in internal/guard/wasm_validate.go:
      • validateStringArray(...)
      • isValidAllowOnlyRepos(...)
    • Replaced call sites in internal/guard/wasm_payload.go with direct config package calls.
    • Updated guard tests to call canonical config validators directly.
  • Server utility consolidation

    • Moved truncateSessionID into internal/server/session.go.
    • Deleted redundant single-function file internal/server/session_util.go.
// before
if err := validateStringArray("trusted-bots", trustedBotsRaw, true); err != nil { ... }
if !isValidAllowOnlyRepos(reposRaw) { ... }

// after
if err := config.ValidateStringArrayField("trusted-bots", trustedBotsRaw, true); err != nil { ... }
if !config.IsValidAllowOnlyReposValue(reposRaw) { ... }

Copilot AI linked an issue Jun 9, 2026 that may be closed by this pull request
6 tasks
GitHub Advanced Security started work on behalf of lpcox June 9, 2026 15:27 View session
GitHub Advanced Security finished work on behalf of lpcox June 9, 2026 15:28
GitHub Advanced Security started work on behalf of lpcox June 9, 2026 15:42 View session
GitHub Advanced Security finished work on behalf of lpcox June 9, 2026 15:43
Copilot AI changed the title [WIP] Refactor semantic function clustering analysis for dead code and wrappers Refactor dead helpers and trivial guard wrappers; consolidate session ID utility Jun 9, 2026
Copilot finished work on behalf of lpcox June 9, 2026 15:43
Copilot AI requested a review from lpcox June 9, 2026 15:43
GitHub Advanced Security started work on behalf of lpcox June 9, 2026 15:45 View session
GitHub Advanced Security finished work on behalf of lpcox June 9, 2026 15:46
@lpcox lpcox marked this pull request as ready for review June 10, 2026 13:44
Copilot AI review requested due to automatic review settings June 10, 2026 13:45

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 removes unused helpers and trims trivial wrapper indirection, keeping behavior the same while reducing dead code and consolidating small utilities across logger, guard, and server.

Changes:

  • Consolidated truncateSessionID into internal/server/session.go and removed the redundant single-function file.
  • Removed dead/unused logger helper code (extractEssentialFields) and moved log cleanup normalization into test-only scope, updating tests accordingly.
  • Inlined trivial guard validation wrappers by calling canonical internal/config validators directly, updating call sites and tests.
Show a summary per file
File Description
internal/server/session.go Adds truncateSessionID implementation directly to the main session module and imports strutil.
internal/server/session_util.go Removes redundant file that only contained truncateSessionID.
internal/logger/rpc_helpers.go Deletes unused extractEssentialFields and drops now-unneeded encoding/json import.
internal/logger/rpc_helpers_test.go Updates tests/benchmarks to use the test-only error-message extractor and removes obsolete tests.
internal/logger/log_cleanup_test.go Renames the log cleanup helper into explicit test-only naming (testExtractErrorMessage).
internal/guard/wasm_validate.go Removes no-op wrapper functions around config validators.
internal/guard/wasm_validate_test.go Updates tests to call config.ValidateStringArrayField directly.
internal/guard/wasm_payload.go Replaces wrapper calls with direct config validator calls at payload-build time.
internal/guard/guard_test.go Updates repos validation test to call config.IsValidAllowOnlyReposValue directly.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 9/9 changed files
  • Comments generated: 0

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.

[refactor] Semantic Function Clustering Analysis: Dead Code and Trivial Wrappers

3 participants