Skip to content

refactor: semantic function clustering — eliminate duplicates and relocate outlier functions#18258

Merged
pelikhan merged 2 commits intomainfrom
copilot/refactor-duplicate-detection
Feb 25, 2026
Merged

refactor: semantic function clustering — eliminate duplicates and relocate outlier functions#18258
pelikhan merged 2 commits intomainfrom
copilot/refactor-duplicate-detection

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

Six findings from a semantic function clustering analysis of 559 Go files across pkg/: one confirmed duplicate implementation and five functions placed in semantically incorrect files.

Changes

Duplicate eliminated

  • pkg/parser: Removed private removeDuplicates — replaced with sliceutil.Deduplicate[string] at the single call site in schema_suggestions.go

Outliers relocated

  • redact_secrets.gocompiler_yaml_helpers.go: (*Compiler).renderStepFromMap is a YAML serialization helper with no semantic relationship to secret redaction
  • github_tool_to_toolset.govalidation_helpers.go: formatList is a generic error message formatter, not toolset-specific logic
  • config_helpers.govalidation_helpers.go: validateTargetRepoSlug is a domain validator, not a config parser — now collocated with validateIntRange, ValidateRequired, etc.

Mixed-concern files split

  • console_types.go: Moved all 5 non-type functions (ToRelativePath, RenderTableAsJSON, FormatErrorWithSuggestions, renderTreeSimple, findWordEnd) to render.goconsole_types.go now contains only type/struct definitions
  • safe_output_builder.go: Extracted all Parse*Config functions and their associated types (SafeOutputTargetConfig, SafeOutputFilterConfig, CloseJobConfig, ListJobConfig, etc.) into new safe_output_parser.go, mirroring the existing safe_inputs_parser.go / safe_inputs_generator.go pattern; safe_output_builder.go retains only Build* functions

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw nonexistent-workinit --limit node /tmp�� /tmp/TestHashConsistency_GoAndJavaScript334725920/001/test-empty-frontmatter.md go r,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,disp--show-toplevel kUvS/ctF_2_fvCuPgit flow-12345 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw GO111MODULE 0/x64/bin/node git add /tmp/file-tracker-test1317735327/existing.md 0/x64/bin/node /usr/bin/git "prettier" --chegit GOPROXY e/git git (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha NzgP/Ll8JiAw7kBkXZcGgNzgP (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel go /usr/bin/git -json GO111MODULE ache/go/1.25.0/x--show-toplevel git rev-�� --show-toplevel go 0/x64/bin/node -json GO111MODULE m/_npx/b38865467--show-toplevel github.actor }} ${{ github.acto (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 5356-33737/test-2304311247/.github/workflows GO111MODULE .cfg GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha g_.a go 0/x64/bin/node -json GO111MODULE 64/bin/go git t-ha�� vaScript40492336test-logs/run-3 config /usr/bin/git remote.origin.urgit GO111MODULE 64/bin/go git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha agent-performance-analyzer.md .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha artifacts-summary.md .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha -unreachable=false /tmp/go-build1211350571/b092/vet.cfg 1350571/b351/vet.cfg (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha ithub/workflows/auto-triage-issues.md 1350571/b028/vet.cfg ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha -bool -buildtags /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -ato�� -bool -buildtags /opt/hostedtoolcache/node/24.13.0/x64/bin/node -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/node/24.13.0/x64/bin/node (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha archie.md .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha audit-workflows.md .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -bool -buildtags /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -uns�� tup/sh/sanitize_path.sh' ':::/usr/bin:/usr/local/bin' && echo "$PATH" /tmp/go-build1211350571/b223/vet.cfg /opt/hostedtoolcache/node/24.13.0/x64/bin/node (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha ai-moderator.md .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha ingutil.test GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env runs/20260225-045356-33737/test-4274889718/.github/workflows GO111MODULE g_.a l GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha ithub/workflows/archie.md config /usr/bin/git remote.origin.urgit GO111MODULE nch,headSha,disp--show-toplevel git rev-�� runs/20260225-050059-48473/test-test-logs/run-12345 go ache/node/24.13.0/x64/bin/node l GO111MODULE ache/go/1.25.0/x--show-toplevel git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha agent-persona-explorer.md .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha -json GO111MODULE /opt/hostedtoolcache/go/1.25.0/x-test.short=true GOINSECURE GOMOD GOMODCACHE go env runs/20260225-045356-33737/test-4274889718/.github/workflows GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go l GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha ithub/workflows/ai-moderator.md remote.origin.url /usr/bin/git */*.ts' '**/*.jsgit GO111MODULE ache/go/1.25.0/x--show-toplevel git rev-�� runs/20260225-050059-48473/test-4224436023/.github/workflows go /usr/bin/git -json GO111MODULE ache/go/1.25.0/x--show-toplevel git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE e_modules/.bin/node GOINSECURE GOMOD GOMODCACHE go m/_n�� -json GO111MODULE /opt/hostedtoolcache/go/1.25.0/x-nilfunc GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 go /opt/hostedtoolcache/node/24.13.0/x64/bin/node -json GO111MODULE 64/bin/go /opt/hostedtoolcache/node/24.13.rev-parse /tmp�� inputs.version go 64/pkg/tool/linux_amd64/vet -json GO111MODULE odules/npm/node_--show-toplevel 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go estl�� ty-test.md GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE h GOINSECURE GOMOD GOMODCACHE go env 97 GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go estl�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE x_amd64/cgo GOINSECURE GOMOD GOMODCACHE x_amd64/cgo env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env /ref/tags/v8 GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE es/.bin/node GOINSECURE GOMOD ode-gyp-bin/sh go m/_n�� 97 GO111MODULE /opt/hostedtoolcache/go/1.25.0/x-test.short=true GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE 0/x64/bin/node GOINSECURE GOMOD GOMODCACHE go t-ha�� ithub/workflows/artifacts-summar-errorsas GO111MODULE ache/node/24.13.0/x64/bin/node GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 go /usr/bin/git l GO111MODULE 64/bin/go git rev-�� --show-toplevel go 64/pkg/tool/linux_amd64/compile -json GO111MODULE es/.bin/node 64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE x_amd64/cgo GOINSECURE GOMOD GOMODCACHE x_amd64/cgo env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE in/node GOINSECURE GOMOD GOMODCACHE go m/_n�� 97 GO111MODULE /opt/hostedtoolcache/go/1.25.0/x-nilfunc GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE k/_temp/uv-python-dir/node GOINSECURE GOMOD GOMODCACHE go m/_n�� /ref/tags/v8 GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path GOSUMDB GOWORK 64/bin/go GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/xGO111MODULE env 2096183/b387/_pkGOINSECURE GO111MODULE 64/bin/go GOINSECURE b/gh-aw/pkg/consenv GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 GOMOD GOMODCACHE go env kUvS/ctF_2_fvCuPGOSUMDB GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE 2096183/b354/importcfg (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha -bool -buildtags 8745225/b433/vet.cfg -errorsas -ifaceassert -nilfunc node /tmp�� /tmp/TestHashStability_SameInputSameOutput3330027595/001/stability-test.md -tests cfg d --write 64/bin/go ache/node/24.13.0/x64/bin/node (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env ty-test.md GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha --show-toplevel node /usr/bin/git --write **/*.cjs 64/bin/go git -C 5751-47326/test-2661921112/.github/workflows config cfg remote.origin.urgit git 64/bin/go false (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion l GO111MODULE 64/bin/go /usr/bin/git remo�� -v go 64/pkg/tool/linux_amd64/vet -json GO111MODULE 64/bin/go 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/xGO111MODULE env 2096183/b394/_pkGOINSECURE GO111MODULE 64/bin/go GOINSECURE b/gh-aw/pkg/loggenv GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/xGO111MODULE env 2096183/b404/_pkGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go tags/v4 -buildtags run-script/lib/n-json node /opt�� prettier --write /node !../../../pkg/wonode --ignore-path ../../../.prettiprettier go (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build2015806930/b381/cli.test /tmp/go-build2015806930/b381/cli.test -test.testlogfile=/tmp/go-build2015806930/b381/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE go m/_n�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /tmp/go-build2278745225/b381/cli.test /tmp/go-build2278745225/b381/cli.test -test.testlogfile=/tmp/go-build2278745225/b381/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true -v go /usr/bin/git sh -c npx prettier --wGOINSECURE git 64/bin/go --show-toplevel go /usr/bin/git go (http block)
    • Triggering command: /tmp/go-build464754914/b381/cli.test /tmp/go-build464754914/b381/cli.test -test.testlogfile=/tmp/go-build464754914/b381/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE go env 1895547159/.github/workflows GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name GOSUMDB GOWORK 64/bin/go GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/xGO111MODULE env 2096183/b356/_pkGOINSECURE GO111MODULE 64/bin/go GOINSECURE b/gh-aw/pkg/mathenv GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name "prettier" --wriGOINSECURE /opt/hostedtoolcGOMOD 64/bin/go GOMODCACHE go /usr/bin/git node /opt�� prettier --write 64/bin/go !../../../pkg/wonode --ignore-path ../../../.pretti--check go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env 3707047020/.github/workflows GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[refactor] Semantic Function Clustering Analysis: Outliers and Duplicate Detection</issue_title>
<issue_description>### Overview

Semantic function clustering analysis of 559 non-test Go files across 18 packages in pkg/. Functions were inventoried by file, clustered by naming patterns and purpose, and cross-referenced to detect misplaced functions (outliers) and near-duplicate implementations.

Stats: ~7,500 functions cataloged across pkg/workflow (278 files), pkg/cli (190 files), pkg/parser (37 files), pkg/console (27 files), and 14 utility packages.


Critical Issues

Finding 1 — Duplicate deduplication logic in pkg/parser

File pkg/parser/schema_utilities.go
Function removeDuplicates(strings []string) []string (line ~37)
Duplicate of pkg/sliceutil/sliceutil.go:Deduplicate[T comparable]

The removeDuplicates function in the parser package is a private reimplementation of the already-available generic sliceutil.Deduplicate. The logic is nearly identical:

// pkg/parser/schema_utilities.go — private reimplementation
func removeDuplicates(strings []string) []string {
    seen := make(map[string]bool)
    var result []string
    for _, str := range strings {
        if !seen[str] {
            seen[str] = true
            result = append(result, str)
        }
    }
    return result
}

// pkg/sliceutil/sliceutil.go — canonical generic version
func Deduplicate[T comparable](slice []T) []T {
    seen := make(map[T]bool, len(slice))
    result := make([]T, 0, len(slice))
    for _, item := range slice {
        if !seen[item] {
            seen[item] = true
            result = append(result, item)
        }
    }
    return result
}

Recommendation: Replace removeDuplicates(x) call sites with sliceutil.Deduplicate(x) and delete the private function.


Outlier Functions (Functions in Wrong Files)

Finding 2 — YAML rendering method in redact_secrets.go

File pkg/workflow/redact_secrets.go
Function (*Compiler).renderStepFromMap(yaml, step, data, indent) (line 132)
Expected location pkg/workflow/compiler_yaml_helpers.go

renderStepFromMap renders a GitHub Actions YAML step from a map[string]any. It has no semantic relationship to secret redaction — it is a general YAML serialization helper. It is only called once, from generateCustomSecretMaskingStep in the same file, suggesting it was placed here as a convenience without considering file responsibility.

compiler_yaml_helpers.go already houses similar YAML construction helpers (e.g., ContainsCheckout). Moving renderStepFromMap there would collocate all step-rendering logic.

Recommendation: Move renderStepFromMap to pkg/workflow/compiler_yaml_helpers.go. Update the call site to reference it from there (same package — no import changes needed).


Finding 3 — Generic list formatter in github_tool_to_toolset.go

File pkg/workflow/github_tool_to_toolset.go
Function formatList(items []string) string (line 132)
Expected location pkg/workflow/validation_helpers.go or pkg/workflow/error_helpers.go

github_tool_to_toolset.go is responsible for validating GitHub tool names against permitted toolsets. It contains ValidateGitHubToolsAgainstToolsets and an init() that builds a lookup map — clearly a focused validation file.

formatList is a generic utility that joins items into a quoted, comma-separated string for error messages. It has no toolset-specific logic and could be useful across many validation error messages in the package.

Recommendation: Move formatList to pkg/workflow/validation_helpers.go (or error_helpers.go). The same-package move requires no import changes.


Finding 4 — Validation function in config_helpers.go

File pkg/workflow/config_helpers.go
Function validateTargetRepoSlug(targetRepoSlug string, log *logger.Logger) bool
Expected location pkg/workflow/validation_helpers.go

config_helpers.go documents itself as a file for parsing config values from map[string]any frontmatter. validateTargetRepoSlug performs domain validation (it rejects the wildcard "*" as an invalid repo slug) — this is a validation concern, not a parsing concern.

validation_helpers.go already houses validateIntRange, ValidateRequired, ValidateMaxLength, ValidateInList, etc. — exactly where this function belongs.

Recommendation: Move validateTargetRepoSlug to pkg/workflow/validation_helpers.go and update the single call site in config_helpers.go.


Mixed-Concern Files

Finding 5 — Utility and rendering functions in console_types.go

File pkg/console/console_types.go
Concern Non-t...

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…er issue analysis

- Finding 1: Replace private removeDuplicates in pkg/parser with sliceutil.Deduplicate
- Finding 2: Move renderStepFromMap from redact_secrets.go to compiler_yaml_helpers.go
- Finding 3: Move formatList from github_tool_to_toolset.go to validation_helpers.go
- Finding 4: Move validateTargetRepoSlug from config_helpers.go to validation_helpers.go
- Finding 5: Move non-type functions from console_types.go to render.go
- Finding 6: Extract Parse*Config functions from safe_output_builder.go into new safe_output_parser.go

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor duplicate detection logic in pkg/parser refactor: semantic function clustering — eliminate duplicates and relocate outlier functions Feb 25, 2026
@pelikhan pelikhan marked this pull request as ready for review February 25, 2026 05:12
Copilot AI review requested due to automatic review settings February 25, 2026 05:12
Copy link
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 performs a semantic refactoring of the codebase based on clustering analysis of 559 Go files, eliminating duplicate implementations and relocating functions to semantically appropriate files for improved maintainability.

Changes:

  • Eliminated duplicate removeDuplicates function in favor of existing generic sliceutil.Deduplicate
  • Relocated 3 outlier functions to semantically correct files based on their purpose
  • Split 2 mixed-concern files by extracting non-type functions and parser logic into dedicated files

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/parser/schema_utilities.go Removed duplicate removeDuplicates function
pkg/parser/schema_suggestions.go Updated to use sliceutil.Deduplicate instead of local duplicate
pkg/workflow/redact_secrets.go Removed renderStepFromMap (moved to yaml helpers) and unused slices import
pkg/workflow/compiler_yaml_helpers.go Added renderStepFromMap YAML serialization helper and slices import
pkg/workflow/github_tool_to_toolset.go Removed formatList (moved to validation helpers)
pkg/workflow/config_helpers.go Removed validateTargetRepoSlug (moved to validation helpers)
pkg/workflow/validation_helpers.go Added formatList and validateTargetRepoSlug validation helpers
pkg/console/console_types.go Removed non-type functions and their imports (moved to render.go)
pkg/console/render.go Added utility functions ToRelativePath, RenderTableAsJSON, FormatErrorWithSuggestions, renderTreeSimple, and findWordEnd
pkg/workflow/safe_output_builder.go Removed parser-related types and functions, kept only builder functions
pkg/workflow/safe_output_parser.go New file containing extracted parser types and functions from safe_output_builder.go

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

@pelikhan pelikhan merged commit b144774 into main Feb 25, 2026
110 checks passed
@pelikhan pelikhan deleted the copilot/refactor-duplicate-detection branch February 25, 2026 05:16
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 Duplicate Detection

3 participants