Skip to content

Refactor helper ownership across cmd/server and document logger sink topology#5496

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

Refactor helper ownership across cmd/server and document logger sink topology#5496
lpcox merged 2 commits into
mainfrom
copilot/refactor-semantic-function-clustering

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

✨ Enhancement

The semantic clustering pass flagged cohesion outliers: WASM cache helpers in logging flags, a tracing config helper in root.go, and ambiguous local helper naming in DIFC logging, plus missing docs around parallel logger sink APIs. This PR realigns helper placement to file responsibility and clarifies the logger API contract.

What does this improve?
Stronger package/file cohesion in internal/cmd and internal/server, plus clearer internal/logger API intent for multi-sink logging.

Why is this valuable?
It reduces maintenance friction (finding/changing logic in the expected file) and lowers misuse risk where logger sink APIs could be interpreted as alternatives rather than parallel outputs.

Implementation approach:

  • WASM cache ownership (internal/cmd)

    • Moved defaultWasmCacheDir and resolveWasmCacheDir from flags_logging.go to wasm_cache.go, colocated with configureWasmCompilationCache.
  • Tracing ownership (internal/cmd)

    • Moved ensureTracingConfig from root.go to tracing.go so tracing setup helpers live together.
  • Logger API contract documentation (internal/logger)

    • Added package-level docs (doc.go) explicitly describing the three parallel global sink families:
      • unified file/stdout (LogInfo/...)
      • markdown (LogInfoMd/...)
      • per-server (LogInfoWithServer/...)
  • DIFC helper naming clarity (internal/server)

    • Renamed local helper getStringFieldgetFilteredItemStringField in difc_log.go and updated corresponding helper tests.
// before
entry.HTMLURL = getStringField(m, "html_url", "htmlUrl")

// after
entry.HTMLURL = getFilteredItemStringField(m, "html_url", "htmlUrl")

Copilot AI changed the title [WIP] Refactor outliers and improve structure in function analysis Refactor helper ownership across cmd/server and document logger sink topology May 12, 2026
Copilot finished work on behalf of lpcox May 12, 2026 00:14
Copilot AI requested a review from lpcox May 12, 2026 00:14
@lpcox lpcox marked this pull request as ready for review May 12, 2026 00:19
Copilot AI review requested due to automatic review settings May 12, 2026 00:19
@lpcox lpcox merged commit 93a0095 into main May 12, 2026
28 checks passed
@lpcox lpcox deleted the copilot/refactor-semantic-function-clustering branch May 12, 2026 00:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 helper function ownership in internal/cmd and internal/server to better align helpers with their feature responsibilities, and adds package-level documentation clarifying internal/logger’s multi-sink logging APIs.

Changes:

  • Moved WASM cache directory helpers from flags_logging.go to wasm_cache.go alongside cache configuration logic.
  • Moved ensureTracingConfig from root.go into tracing.go to keep tracing helpers together.
  • Renamed DIFC filtered-item helper getStringFieldgetFilteredItemStringField (and updated tests), and added internal/logger package docs.
Show a summary per file
File Description
internal/server/difc_log.go Renames the DIFC filtered-item string helper to a more specific name and updates call sites.
internal/server/difc_log_helpers_test.go Updates helper test naming and references to match the renamed helper.
internal/logger/doc.go Adds package-level documentation describing logger sink API families.
internal/cmd/wasm_cache.go Co-locates WASM cache dir resolution helpers with cache configuration.
internal/cmd/tracing.go Co-locates ensureTracingConfig with other tracing helpers.
internal/cmd/root.go Removes the tracing helper from root command file after relocation.
internal/cmd/flags_logging.go Removes moved WASM cache dir helper implementations from logging flags file.

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: 1

Comment thread internal/logger/doc.go
Comment on lines +3 to +10
// The package exposes three parallel global sink APIs:
// - LogInfo / LogWarn / LogError / LogDebug for unified file/stdout logs
// - LogInfoMd / LogWarnMd / LogErrorMd / LogDebugMd for markdown preview logs
// - LogInfoWithServer / LogWarnWithServer / LogErrorWithServer / LogDebugWithServer
// for per-server logs
//
// These APIs target different sinks and can be used together when a message should
// appear in multiple outputs.
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: Outliers and Structural Improvements

3 participants