Skip to content

refactor: remove thin wrappers, move test helper to test file, consolidate formatDuration#17964

Merged
pelikhan merged 4 commits intomainfrom
copilot/refactor-semantic-function-clustering-99e7e7b5-7874-4c2d-8ccd-fd672c313b05
Feb 23, 2026
Merged

refactor: remove thin wrappers, move test helper to test file, consolidate formatDuration#17964
pelikhan merged 4 commits intomainfrom
copilot/refactor-semantic-function-clustering-99e7e7b5-7874-4c2d-8ccd-fd672c313b05

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

Three high-value, low-effort refactors identified in static analysis: 15 single-line boilerplate wrappers in content_extractor.go, a testing-importing helper in production code, and a duplicate formatDuration ignoring the existing timeutil package.

Finding 1 — Remove 14 thin wrappers from content_extractor.go

Eliminated 14 unexported one-liners (e.g. extractSafeOutputsFromContent, extractEngineFromContent, extractSkipRolesFromContent, etc.) that did nothing but relay to extractFrontmatterField or extractOnSectionField.

  • import_processor.go: callers now call extractFrontmatterField(content, "field-name", "default") directly
  • include_expander.go: function-value arguments replaced with closures
  • Test files updated to call extractFrontmatterField directly
  • ExtractPermissionsFromContent retained — it's exported and used by pkg/workflow

Finding 2 — Move assertEnvVarsInSteps out of production code

safe_outputs_env.go imported testing solely for this helper. Moved to a new safe_outputs_env_helpers_test.go with //go:build integration || !integration so it's available to both unit and integration test builds.

Finding 3 — Remove duplicate formatDuration in health_metrics.go

Replaced the local unexported copy with timeutil.FormatDuration, which already exists for this purpose and is used elsewhere in pkg/cli. Removed TestFormatDuration (was testing the now-deleted local function; timeutil has its own coverage).

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 --local x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git w/js/**/*.json' git pull.rebase x_amd64/vet 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 x_amd64/vet /usr/bin/git git conf�� user.email test@example.com /usr/bin/git (http block)
    • Triggering command: /usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet 1947�� -json GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolcache/go/1.25.0/xTest User (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 ry=1 -tests 4954287/b001/_pkg_.a (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha xterm-color sh /usr/bin/git echo $TEST_VAR x_amd64/vet /usr/bin/git git rev-�� runs/20260223-190800-17335/test-1124264615/.github/workflows git /usr/bin/git l 64/pkg/tool/linurev-parse /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha /tmp/go-build3571947930/b240/vet.cfg ache/go/1.25.0/xGO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet 3254850/b353/_pkgit GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /tmp�� g/cli go ache/node/24.13.0/x64/bin/node O1up/dJ7XGaEe8HMgit GO111MODULE 64/bin/go infocmp (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 --noprofile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha --show-toplevel ortcfg /usr/bin/git ripts/lint_errorinfocmp ripts/lint_error-1 ache/go/1.25.0/xxterm-color git rev-�� --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/link /usr/bin/git 4954287/b431/worgit -tests 4954287/b431/imp--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha .cfg GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet env .cfg GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuTest User (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 -bool -buildtags /home/REDACTED/work/node_modules/.bin/node -errorsas -ifaceassert -nilfunc node /opt�� prettier --write /bin/sh **/*.ts **/*.json --ignore-path /bin/sh (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha -unreachable=false /tmp/go-build3638810712/b354/vet.cfg ache/node/24.13.0/x64/bin/node d -n 10 (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha (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 json' --ignore-path ../../../.pr**/*.json (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --noprofile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel l /usr/bin/git (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 ire/doc.go ire/forward_requ-c=4 /node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha h ../../../.prettierignore --local x_amd64/vet user.name (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha h ../../../.pret.prettierignore g/workflow/mcp_config_shared_test.go x_amd64/vet g/workflow/sandbnode g/workflow/safe_/home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/.bin/pre�� g/workflow/netwo--write x_amd64/vet g/wo�� w/js/**/*.json' --ignore-path g/workflow/compi../../../.prettierignore x_amd64/vet g/workflow/step_/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/compile g/workflow/threa-o g/workflow/noop_/tmp/go-build1594954287/b420/_pkg_.a x_amd64/vet (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 -bool -buildtags ache/node/24.13.0/x64/bin/node -errorsas -ifaceassert -nilfunc node t-12�� sistency_GoAndJavaScript846201338/001/test-frontmatter-with-nestremote.origin.url --write 0/x64/bin/node **/*.ts **/*.json --ignore-path 0/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha --show-toplevel git /usr/bin/git /tmp/gh-aw-test-git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha ithub/workflows/agent-persona-explorer.md GOPROXY 0/x64/bin/node GOSUMDB GOWORK 64/bin/go fPolqxMEIvcmg/gRv3SRz3bsmph76Ltk1S/pZ37Atn67fBOzconfig -has�� ithub/workflows/auto-triage-issues.md go tartedAt,updatedAt,event,headBranch,headSha,displayTitle ck 'scripts/**/*git GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (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 -bool -buildtags /home/node_modules/.bin/node -errorsas -ifaceassert -nilfunc node /opt�� 4 --write /home/REDACTED/work/_temp/uv-python-dir/node **/*.ts **/*.json --ignore-path node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel x_amd64/vet /usr/bin/git git rev-�� --show-toplevel git 0/x64/bin/node --get remote.origin.urrev-parse /usr/bin/git 0/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha GOPATH GOPROXY /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linurev-parse /tmp�� GOMODCACHE go 760390/b363/vet.cfg ck 'scripts/**/*git GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linutest@example.com (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 (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/link /usr/bin/git /tmp/go-build159git -importcfg /usr/bin/git git rev-�� 0800-17335/test-1676379601/.github/workflows git /usr/bin/git testing.testBinagit -extld=gcc /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linuconfig 1947�� -json GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linurev-parse (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 8810712/b217/vet.cfg 0/x64/bin/node ignore (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 /opt/hostedtoolc--package-lock-only /usr/bin/git /tmp/go-build159git -trimpath /usr/bin/git git rev-�� OKEN }} git rgo/bin/bash --show-toplevel -dwarf=false /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_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 (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 /opt/hostedtoolc--package-lock-only 0/x64/bin/node -bool -buildtags /usr/bin/git git -has�� ithub/workflows/auto-triage-issues.md git nfig/composer/vendor/bin/bash /tmp/gh-aw-test-git rev-parse /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_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 (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/gh -bool -buildtags /usr/bin/git /usr/bin/gh api graphql -f ache/go/1.25.0/x64/pkg/tool/linux_amd64/asm -f owner=github -f ache/go/1.25.0/x64/pkg/tool/linux_amd64/asm (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linutest@example.com 1947�� 1202-39362/test-2574810437/.github/workflows GO111MODULE k/_temp/uv-python-dir/bash GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolcache/go/1.25.0/x.github/workflows/test.md (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 (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/compile /usr/bin/infocmp /tmp/go-build159git -trimpath /usr/bin/git infocmp -1 0800-17335/test-707458154/.github/workflows git ache/go/1.25.0/x64/pkg/tool/linux_amd64/cgo path.sh' ':/usr/git -goversion /usr/bin/git ache/go/1.25.0/x64/pkg/tool/linux_amd64/cgo (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ortcfg 1947�� 1202-39362/test-2574810437/.github/workflows GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/link (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 (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/compile /usr/bin/git /tmp/go-build159git -trimpath /usr/bin/git git rev-�� 0800-17335/test-707458154/.github/workflows git /usr/bin/git --get remote.origin.urrev-parse /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet 1947�� -json GO111MODULE ache/uv/0.10.4/x86_64/bash GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (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 (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/link /usr/bin/git /tmp/go-build159git -importcfg /usr/bin/git git rev-�� --show-toplevel git ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet path.sh' ':::' &git rev-parse /usr/bin/git ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linuTest User (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path ler_shared_cache**/*.ts ge_extraction_te**/*.json /prettier http.https://gitnode (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 (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 (http block)
  • https://api.github.com/repos/github/gh-aw/contents/.github/workflows/shared/reporting.md
    • Triggering command: /tmp/go-build575760390/b361/cli.test /tmp/go-build575760390/b361/cli.test -test.paniconexit0 -test.count=1 -test.timeout=2m0s -c npx prettier --cGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go sh -c "prettier" --check 'scripts/**/*GOINSECURE node 64/bin/go tierignore git 64/bin/go 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 js/**/*.json' --ignore-path ../../../.prettierignore ew@v1.1.1/spew/common.go x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha user.email test@example.com /usr/bin/git --noprofile .cfg tions/node_modul--show-toplevel git rev-�� --show-toplevel ache/go/1.25.0/x64/pkg/tool/linurev-parse /usr/bin/git '**/*.ts' '**/*.git 8810712/b052/vetrev-parse ache/go/1.25.0/x--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha k/gh-aw/gh-aw/pkGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK run-script/lib/n/tmp/go-build3571947930/b234/vet.cfg /opt/hostedtoolcache/go/1.25.0/xGO111MODULE -V=f�� /usr/bin/git node 64/bin/go /usr/bin/git git 64/bin/go go (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 js/**/*.json' ---s main 64/pkg/tool/linu-buildmode=exe (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha --show-toplevel 64/pkg/tool/linuremote.origin.url r,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,disp--show-toplevel --noprofile flow-ci-test-678rev-parse x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git '**/*.ts' '**/*.git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha 3254850/b385/embedcfg GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.0/xGO111MODULE -o /tmp/go-build2413254850/b353/_pkGOINSECURE -trimpath 64/bin/go -p main -lang=go1.25 go (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 (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion ons-test67776376git right_allowed_dorev-parse /usr/bin/git git rev-�� --show-toplevel git ache/node/24.13.0/x64/bin/node --get remote.origin.ur/tmp/fuzz-expr-2874985895.js /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet 1947�� -json GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/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 x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo /usr/bin/git (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo -nolocalimports -importcfg /tmp/go-build3518624140/b339/importcfg -pack /tmp/go-build3518624140/b339/_testmain.go rev-�� gh-aw/actions/setup/sh/sanitize_path.sh' '/usr/bin' && echo "$PATH" x_amd64/compile /usr/bin/git */*.ts' '**/*.js/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet 8810712/b055/vet-atomic .cfg git (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build1594954287/b381/cli.test /tmp/go-build1594954287/b381/cli.test -test.testlogfile=/tmp/go-build1594954287/b381/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true (http block)
    • Triggering command: /tmp/go-build3518624140/b361/cli.test /tmp/go-build3518624140/b361/cli.test -test.testlogfile=/tmp/go-build3518624140/b361/testlog.txt -test.paniconexit0 -test.timeout=10m0s rev-�� --show-toplevel 64/pkg/tool/linuremote.origin.url /usr/bin/git ../pkg/workflow/git .cfg n-dir/bash git rev-�� --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/git se 8810712/b012/vetrev-parse ache/go/1.25.0/x--show-toplevel git (http block)
    • Triggering command: /tmp/go-build575760390/b361/cli.test /tmp/go-build575760390/b361/cli.test -test.paniconexit0 -test.count=1 -test.timeout=2m0s -c npx prettier --cGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go sh -c "prettier" --check 'scripts/**/*GOINSECURE node 64/bin/go tierignore git 64/bin/go 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 ler_shared_cache**/*.ts ge_extraction_te**/*.json x_amd64/vet http.https://gitnode (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name che/go-build/28/2888c116b4dd41c7GOINSECURE GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcache/go/1.25.0/xGO111MODULE -o /tmp/go-build2413254850/b398/_pkGOINSECURE -trimpath 64/bin/go -p github.com/githu--norc -lang=go1.25 go (http block)
  • https://api.github.com/repos/test/repo
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch /tmp/go-build3571947930/b066/vet.cfg GOPROXY /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcv1.0.0 -uns�� /tmp/go-build3571947930/b209/vet.cfg erignore tartedAt,updatedAt,event,headBranch,headSha,displayTitle ions.md GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (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: 3 high-value refactoring opportunities</issue_title>
<issue_description>Analysis of 558 non-test Go files in pkg/ identified the following refactoring opportunities, ordered by impact.


Summary

Finding Location Impact Effort
15 single-line wrapper functions with identical structure pkg/parser/content_extractor.go High Low
Test helper function in production non-test file pkg/workflow/safe_outputs_env.go High Low
formatDuration duplicated across packages pkg/cli/health_metrics.go vs pkg/timeutil/format.go Medium Low
compiler_activation_jobs.go exceeds 1,000 lines pkg/workflow/compiler_activation_jobs.go Medium Medium
12 near-identical generateMaxWith*Config functions pkg/workflow/safe_outputs_config_generation_helpers.go Low Medium

Finding 1 — 15 identical thin wrappers in content_extractor.go

File: pkg/parser/content_extractor.go (286 lines)

Fifteen functions are 1-line wrappers that only differ in the field name and empty-value string they pass to a shared helper:

// All 13 of these are identical in structure:
func extractSafeOutputsFromContent(content string) (string, error) {
    return extractFrontmatterField(content, "safe-outputs", "{}")
}
func extractRuntimesFromContent(content string) (string, error) {
    return extractFrontmatterField(content, "runtimes", "{}")
}
func extractNetworkFromContent(content string) (string, error) {
    return extractFrontmatterField(content, "network", "{}")
}
// ... and 10 more: safe-inputs, mcp-servers, engine, permissions, secret-masking,
//     bots, plugins, labels, cache, features
// Plus 2 wrapping extractOnSectionField: skip-roles, skip-bots

The 3 non-trivial functions (extractToolsFromContent, extractStepsFromContent, extractServicesFromContent, extractPostStepsFromContent) have distinct logic and should stay.

Recommendation: Replace the 15 wrapper functions with a small registry map, eliminating ~80 lines of boilerplate while keeping the API surface identical via one generic exported function:

var frontmatterFieldExtractors = map[string]string{
    "safe-outputs":   "{}",
    "safe-inputs":    "{}",
    "mcp-servers":    "{}",
    // ... etc.
}

// All callers already use extractFrontmatterField indirectly.
// Callers inside import_processor.go can be updated to call
// extractFrontmatterField(content, "safe-outputs", "{}") directly.

Impact: Removes ~80 lines of boilerplate; makes adding new fields a one-line change in the registry rather than a new function.

Full list of redundant wrappers
Function Delegates to Field name Empty value
extractSafeOutputsFromContent extractFrontmatterField safe-outputs {}
extractSafeInputsFromContent extractFrontmatterField safe-inputs {}
extractMCPServersFromContent extractFrontmatterField mcp-servers {}
extractEngineFromContent extractFrontmatterField engine ""
extractRuntimesFromContent extractFrontmatterField runtimes {}
extractNetworkFromContent extractFrontmatterField network {}
ExtractPermissionsFromContent extractFrontmatterField permissions {}
extractSecretMaskingFromContent extractFrontmatterField secret-masking {}
extractBotsFromContent extractFrontmatterField bots []
extractPluginsFromContent extractFrontmatterField plugins []
extractLabelsFromContent extractFrontmatterField labels []
extractCacheFromContent extractFrontmatterField cache {}
extractFeaturesFromContent extractFrontmatterField features {}
extractSkipRolesFromContent extractOnSectionField skip-roles
extractSkipBotsFromContent extractOnSectionField skip-bots

Finding 2 — Test helper in production non-test file

File: pkg/workflow/safe_outputs_env.go:349

func assertEnvVarsInSteps(t *testing.T, steps []string, expectedEnvVars []string) {
    t.Helper()
    // ...
}

This function:

  • Imports the testing package into a production file with no build tag
  • Is unreachable from any external test package without importing production code
  • Bloats the compiled binary with test infrastructure

Recommendation: Move assertEnvVarsInSteps to a _test.go file in the same package (e.g., safe_outputs_env_test.go or an existing *_test.go file that uses it).


Finding 3 — formatDuration duplicated across packages

Production package: pkg/timeutil/format.go:10

// Exported, dedicated timeutil package
func FormatDuration(d time.Duration) string { ... }

CLI local copy: `pkg/cl...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…e, consolidate formatDuration"

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor semantic function clustering opportunities refactor: remove thin wrappers, move test helper to test file, consolidate formatDuration Feb 23, 2026
@pelikhan pelikhan marked this pull request as ready for review February 23, 2026 19:17
Copilot AI review requested due to automatic review settings February 23, 2026 19:17
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 refactors code to eliminate boilerplate and improve organization by removing thin wrapper functions, relocating a test helper, and consolidating duplicate duration formatting logic.

Changes:

  • Removed 14 one-line wrapper functions from content_extractor.go that simply delegated to extractFrontmatterField or extractOnSectionField
  • Moved assertEnvVarsInSteps test helper from production code (safe_outputs_env.go) to a new test-only file (safe_outputs_env_helpers_test.go)
  • Replaced duplicate formatDuration implementation in health_metrics.go with existing timeutil.FormatDuration

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/parser/content_extractor.go Removed 14 thin wrapper functions (extractSafeOutputsFromContent, extractEngineFromContent, etc.), kept ExtractPermissionsFromContent (exported)
pkg/parser/include_expander.go Updated to use inline closures calling extractFrontmatterField instead of removed wrapper functions
pkg/parser/import_processor.go Updated all callsites to call extractFrontmatterField and extractOnSectionField directly
pkg/parser/engine_includes_test.go Updated test to call extractFrontmatterField directly
pkg/parser/content_extractor_features_test.go Updated all tests to call extractFrontmatterField directly
pkg/workflow/safe_outputs_env.go Removed assertEnvVarsInSteps helper and testing import
pkg/workflow/safe_outputs_env_helpers_test.go New file containing the moved assertEnvVarsInSteps test helper
pkg/cli/health_metrics.go Replaced local formatDuration with timeutil.FormatDuration, added timeutil import
pkg/cli/health_metrics_test.go Removed TestFormatDuration (tested the now-deleted local function)

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

// Format display values
displayRate := fmt.Sprintf("%.0f%% (%d/%d)", successRate, successCount, totalRuns)
displayDur := formatDuration(avgDuration)
displayDur := timeutil.FormatDuration(avgDuration)
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The replacement of the local formatDuration with timeutil.FormatDuration changes the output format significantly. The original function formatted durations as "2m 30s" or "1h 15m" (integer values with multiple units), while timeutil.FormatDuration formats them as "2.5m" or "1.3h" (decimal values with a single unit). This will change the user-facing display format for health metrics. If this format change is intentional, it should be documented in the PR description. Otherwise, consider keeping the local formatDuration function or adding a new FormatDurationDetailed function to timeutil that preserves the multi-unit format.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,20 @@
//go:build integration || !integration
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build tag "//go:build integration || !integration" is a tautology that will always evaluate to true, making it equivalent to having no build tag at all. Since this helper is used in both safe_outputs_env_test.go (unit tests) and safe_outputs_env_integration_test.go (integration tests), the correct approach is to either remove the build tag entirely or use a simpler pattern. Looking at other test helper files in this package, safe_output_helpers_test.go uses "//go:build !integration" to exclude it from integration tests. Consider removing this build tag entirely since the helper needs to be available to both unit and integration tests.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit 87cc668 into main Feb 23, 2026
48 checks passed
@pelikhan pelikhan deleted the copilot/refactor-semantic-function-clustering-99e7e7b5-7874-4c2d-8ccd-fd672c313b05 branch February 23, 2026 19:30
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: 3 high-value refactoring opportunities

3 participants