Skip to content

refactor(pkg/cli): semantic function clustering — consolidate scattered utilities#29952

Merged
pelikhan merged 4 commits intomainfrom
copilot/refactor-semantic-function-clustering-another-one
May 3, 2026
Merged

refactor(pkg/cli): semantic function clustering — consolidate scattered utilities#29952
pelikhan merged 4 commits intomainfrom
copilot/refactor-semantic-function-clustering-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 3, 2026

Addresses four medium-severity cohesion findings in pkg/cli where utility functions were placed near their first use rather than with semantically related functions.

Changes

Finding 1 — Audit format functions → audit_math_helpers.go

Moved formatVolumeChange, formatPercentagePointChange, formatCountChange out of audit_diff.go into the existing audit_math_helpers.go, which was created for exactly this purpose.

Finding 2 — Compile batch operations split into focused files

  • New compile_external_tools.go: all external tool runners (RunActionlintOnFiles, RunZizmorOnFiles, RunPoutineOnDirectory, RunRunnerGuardOnDirectory, runBatchLockFileTool, runBatchDirectoryTool) — these are workflow analysis tools, not compilation logic
  • compile_post_processing.go: absorbs purge functions (purgeOrphanedLockFiles, purgeInvalidFiles) from compile_batch_operations.go, and display/cache functions (displayScheduleWarnings, displaySafeUpdateWarnings, pruneStaleActionCacheEntries) from compile_pipeline.go
  • compile_batch_operations.go is now a stub with redirect comments

Finding 3 — Log file discovery → logs_utils.go

Moved findAgentOutputFile and findAgentLogFile from logs_parsing_core.go (which should be parsing-only) into logs_utils.go alongside getAgenticWorkflowNames. Removed now-unused strings, constants, and fileutil imports from logs_parsing_core.go.

Finding 4 — Path utilities → helpers.go

Moved getRepositoryRelativePath and getAbsoluteWorkflowDir out of compile_file_operations.go into helpers.go, co-locating them with the existing getParentDir. None of these functions depend on compilation logic.

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 gh repo view --json owner,name --jq .owner.login + "/" + .name in/node (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 se_entity_helperrev-parse ex_engine.go ex_engine_test.go ache�� ex_logs_test.go ex_mcp.go .cfg ex_total_tokens_git lect_packages_teinit r mand_precision_test.go (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 (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name (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, .object.type] | @tsv --show-toplevel sh /usr/bin/git runs/20260503-15git (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, .object.type] | @tsv --get remote.origin.url /usr/bin/git se 2287174/b015/vetrev-parse ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel ache/go/1.25.8/x--jq /usr/bin/git se 2287174/b143/vetrev-parse h 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, .object.type] | @tsv --show-toplevel node /usr/bin/git /tmp/TestHashCongit (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv ithub-script/git/ref/tags/v9 git bject.type] | @tsv /tmp/gh-aw-test-git l e/git git rev-�� /ref/tags/v9 e/git sv /tmp/compile-allinfocmp config /usr/bin/git gh (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, .object.type] | @tsv prettier --write e/git **/*.ts **/*.json --ignore-path e/git /opt�� run format:pkg-json .cfg =receive (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel /bin/sh (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq [.object.sha, .object.type] | @tsv --show-toplevel infocmp /usr/bin/git xterm-color /opt/hostedtoolcrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/infocmp --show-toplevel 64/pkg/tool/linurev-parse /usr/bin/git infocmp (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv t0 (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv /tmp/gh-aw-test-runs/20260503-153747-16543/test-1586075819/.github/workflows rev-parse /usr/bin/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv -test.paniconexit0 -test.v=true /usr/bin/git -test.timeout=10git -test.run=^Test -test.short=true--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linu-extld=gcc /usr/bin/infocmp 431257/001 431257/002/work 64/pkg/tool/linu--show-toplevel infocmp (http block)
  • https://api.github.com/repos/actions/download-artifact/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/download-artifact/git/ref/tags/v8 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE $name) { hasDiscussionsEnabled } } GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/download-artifact/git/ref/tags/v8 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE repository(owner: $owner, name:-f GOINSECURE GOMOD GOMODCACHE go (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, .object.type] | @tsv /ref/tags/v9 64/pkg/tool/linux_amd64/compile sv g_.a /home/REDACTED/worapi /usr/bin/git infocmp -1 xterm-color git /usr/bin/git wcQDCtpJ8 64/pkg/tool/linu-1 e/git git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv ath ../../../.pr**/*.json (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9 --jq [.object.sha, .object.type] | @tsv INVALID,NEW -j DROP (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v9.0.0
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv -c=4 -nolocalimports -importcfg /tmp/go-build3582015038/b408/importcfg -pack /home/REDACTED/go/pkg/mod/github.com/aymanbagabas/go-udiff@v0.4.1/diff.go /home/REDACTED/go/pkg/mod/github.com/aymanbagabas/go-udiff@v0.4.1/export.go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq [.object.sha, .object.type] | @tsv ath ../../../.pr**/*.json (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, .object.type] | @tsv xterm-color ache/go/1.25.8/x64/pkg/tool/linuorigin /usr/bin/git 2015038/b415/_pkgit (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, .object.type] | @tsv --get remote.origin.url /usr/bin/git Gitmaster_branchgit Gitmaster_branchrev-parse 64/pkg/tool/linu--show-toplevel git add test.txt 64/pkg/tool/linuconfig /usr/bin/git 346 credential.usernrev-parse .cfg git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel x_amd64/vet /usr/bin/git CommaSeparatedCogh -test.timeout=10api ache/go/1.25.8/x/repos/actions/github-script/git/ref/tags/v9 git rev-�� --show-toplevel ache/go/1.25.8/x-buildtags /usr/bin/git UflV/KROAB2Zhyucgit **/*.cjs 1/x64/bin/node git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/infocmp /tmp/gh-aw-test-git remote om/testowner/tes--show-toplevel infocmp -1 xterm-color /tmp/go-build3582015038/b450/styles.test /usr/bin/git -test.paniconexiinfocmp -test.v=true /usr/bin/git git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv 3747-16543/test-2966005242 show bject.type] | @tsv (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv k/gh-aw/gh-aw/pkg/testutil/spec_test.go l epo.git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv /tmp/gh-aw-test-runs/20260503-153747-16543/test-882282340 rev-parse /usr/bin/git -p .cfg 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linuremote.origin.url /usr/bin/git th .prettierignogit --local nch,headSha,disp--show-toplevel git (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv /tmp/TestCompileUpdateDiscussionFieldEnforcement3172559297/001 remote /usr/bin/git on' --ignore-patgit .cfg 64/pkg/tool/linu--show-toplevel git remo�� (http block)
  • https://api.github.com/repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq [.object.sha, .object.type] | @tsv azure-vmextensioGOINSECURE --property 64/bin/go -json GO111MODULE 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/astral-sh/setup-uv/git/ref/tags/eac588ad8def6316056a12d4907a9d4d84ff7a3b --jq [.object.sha, .object.type] | @tsv GOMODCACHE go 64/bin/go -json GO111MODULE 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/aws-actions/configure-aws-credentials/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/aws-actions/configure-aws-credentials/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv ithub-script/git/ref/tags/v9 /tmp/go-build3582015038/b435/rep--jq bject.type] | @tsv -test.paniconexigit -test.v=true /usr/bin/infocmp--show-toplevel git rev-�� --show-toplevel infocmp /usr/bin/git xterm-color x_amd64/vet /opt/hostedtoolcstatus git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/aws-actions/configure-aws-credentials/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv --show-toplevel gh /usr/bin/git v1.0.0 --jq /usr/bin/infocmpuser.name git rev-�� --show-toplevel infocmp /usr/bin/gh xterm-color x_amd64/vet /opt/hostedtoolc--show-toplevel gh (http block)
  • https://api.github.com/repos/azure/login/git/ref/tags/v2
    • Triggering command: /usr/bin/gh gh api /repos/azure/login/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile /usr/bin/git /tmp/go-build358git -trimpath om/testorg/testr--show-toplevel git rev-�� --show-toplevel git /usr/bin/git --show-toplevel -dwarf=false /usr/bin/git git (http block)
  • https://api.github.com/repos/docker/login-action/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/docker/login-action/git/ref/tags/v3 --jq [.object.sha, .object.type] | @tsv --show-toplevel gh /usr/bin/git /repos/actions/ggit --jq /usr/bin/infocmp--show-toplevel git rev-�� /ref/tags/v9 infocmp sv xterm-color x_amd64/vet /opt/hostedtoolcxterm-color git (http block)
  • https://api.github.com/repos/docker/metadata-action/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/docker/metadata-action/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env def6316056a12d49-f GO111MODULE ache/go/1.25.8/x-f GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/docker/metadata-action/git/ref/tags/v6 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE r: $owner, name: $name) { hasDiscussionsEnabled } } GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/docker/setup-buildx-action/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/docker/setup-buildx-action/git/ref/tags/v4 --jq [.object.sha, .object.type] | @tsv -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .default_branch ithub/workflows GO111MODULE ache/go/1.25.8/x-f GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE r: $owner, name: $name) { hasDiscussionsEnabled } } GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq [.object.sha, .object.type] | @tsv /repos/actions/github-script/git/ref/tags/v9 --jq /usr/bin/git Onlymin-integritinfocmp /tmp/go-build233-1 2015038/b408=> git rev-�� --show-toplevel sh /usr/bin/infocmp ithub-script/gitinfocmp (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq [.object.sha, .object.type] | @tsv --show-toplevel 3Zv3h0y/rLzSlIqW-q /usr/bin/gh get .cfg sh gh api /repos/actions/github-script/git/ref/tags/v9.0.0 --jq /usr/bin/git ../pkg/workflow/git .cfg x_amd64/compile git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv /home/REDACTED/work/gh-aw/gh-aw/.github/workflows/agent-persona-explorer.md 64/pkg/tool/linumy-default /usr/bin/git get .cfg odules/npm/node_--show-toplevel git -C /tmp/shared-actions-test3077246891 rev-parse .cfg ../pkg/workflow/git .cfg x_amd64/compile e/git-remote-https (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-26 (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-04-03 (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --limit 100 --created >=2026-02-02 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 --merged=d750034e92c7bbda4c0ab830d8e949b058fb505c 64/pkg/tool/linux_amd64/compile nore onpins (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name !.git 64/pkg/tool/linux_amd64/vet ignore defaultAgentStdiremote /home/REDACTED/worremove 64/pkg/tool/linuremote1 -uns�� rite '**/*.cjs' '**/*.ts' '**/*.json' --ignore-path ../../../.pr**/*.json /tmp/go-build2332287174/b164/vet.cfg m/_npx/b388654678d519d9/node_modules/.bin/node (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1234567890
    • Triggering command: /usr/bin/gh gh api repos/{owner}/{repo}/actions/runs/1234567890 --jq {databaseId: .id, number: .run_number, url: .html_url, status: .status, conclusion: .conclusion, workflowName: .name, workflowPath: .path, createdAt: .created_at, startedAt: .run_started_at, updatedAt: .updated_at, event: .event, headBranch: .head_branch, re --log-level=e!../../../pkg/workflow/js/**/*.json (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name security 64/pkg/tool/linux_amd64/link ignore (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 blob k/gh-aw/gh-aw/actions/node_modules/.bin/sh nore (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 2287174/b061/vet.cfg 64/pkg/tool/linux_amd64/compile nore (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 til_test.go ache/node/24.14.1/x64/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin/sh nore --format=format:rev-parse --end-of-options--show-toplevel /opt/hostedtoolcache/go/1.25.8/x/tmp/go-build3582015038/b114/vet.cfg -uns�� 01/test2.md /tmp/go-build2332287174/b084/vet.cfg .cfg (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 log 64/pkg/tool/linux_amd64/link nore tdrain --end-of-options--show-toplevel N_/MhA652aEkSuR8NKQxPfr/feDwSjXStImIOC-NY5wN -uns�� outil.test /tmp/go-build2332287174/b067/vet.cfg ortcfg.link (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path (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-build3582015038/b404/cli.test /tmp/go-build3582015038/b404/cli.test -test.testlogfile=/tmp/go-build3582015038/b404/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git /tmp/TestGuardPobasename l /usr/bin/git git rev-�� --show-toplevel git /usr/bin/gh --show-toplevel 64/pkg/tool/linuapi /usr/bin/git gh (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, .object.type] | @tsv te 'scripts/**/*.js' --ignore-pago1.25.8 -buildtags sh -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.8/x/tmp/go-build3582015038/b466/_testmain.go -ato�� test.go ir_test.go 2015038/b413/constants.test -errorsas -ifaceassert -nilfunc 2015038/b413/constants.test (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq [.object.sha, .object.type] | @tsv get .cfg 64/pkg/tool/linux_amd64/vet credential.userngit (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv get .cfg 64/pkg/tool/linux_amd64/vet credential.userngit (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq [.object.sha, .object.type] | @tsv get --local d56dde992ac1e029-lang=go1.25 credential.usernnode (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq [.object.sha, .object.type] | @tsv get --local 64/pkg/tool/linux_amd64/vet credential.userngit (http block)
  • https://api.github.com/repos/google-github-actions/auth/git/ref/tags/v2
    • Triggering command: /usr/bin/gh gh api /repos/google-github-actions/auth/git/ref/tags/v2 --jq [.object.sha, .object.type] | @tsv --show-toplevel git /usr/bin/git --show-toplevel x_amd64/vet /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linuremote.origin.url /usr/bin/git /tmp/go-build358git -trimpath /opt/hostedtoolc--show-toplevel git (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, .object.type] | @tsv efaultBranchFromLsRemoteWithRealGitmain_branch66-s efaultBranchFromLsRemoteWithRealGitmain_branch66-w /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linu-buildmode=exe -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linurev-parse -ato�� te '../../../**/*.json' '!../../../pkg/workflow/js/**/*.json' ---errorsas -buildtags ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile -errorsas -ifaceassert -nilfunc ache/go/1.25.8/x64/pkg/tool/linumyorg (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)
  • 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 ame (http block)
    • Triggering command: /usr/bin/gh gh workflow list --repo owner/repo --json name,path,state k (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 (http block)
  • https://api.github.com/repos/test/repo
    • Triggering command: /usr/bin/gh gh api /repos/test/repo --jq .default_branch 1621522809/.github/workflows /tmp/go-build2332287174/b124/vet.cfg k/gh-aw/gh-aw/node_modules/.bin/sh (http block)

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

- Move formatVolumeChange, formatPercentagePointChange, formatCountChange
  from audit_diff.go to audit_math_helpers.go (Finding 1)
- Create compile_external_tools.go with external tool runners moved from
  compile_batch_operations.go (Finding 2a)
- Move purgeOrphanedLockFiles, purgeInvalidFiles from compile_batch_operations.go
  to compile_post_processing.go (Finding 2b)
- Move displayScheduleWarnings, displaySafeUpdateWarnings, pruneStaleActionCacheEntries
  from compile_pipeline.go to compile_post_processing.go (Finding 2c)
- Move findAgentOutputFile, findAgentLogFile from logs_parsing_core.go
  to logs_utils.go (Finding 3)
- Move getRepositoryRelativePath, getAbsoluteWorkflowDir from
  compile_file_operations.go to helpers.go (Finding 4)

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/0c2d3a48-7102-4ff2-80fe-91d71349bb5a

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor format utility functions in pkg/cli refactor(pkg/cli): semantic function clustering — consolidate scattered utilities May 3, 2026
Copilot AI requested a review from gh-aw-bot May 3, 2026 15:43
@pelikhan pelikhan marked this pull request as ready for review May 3, 2026 16:01
Copilot AI review requested due to automatic review settings May 3, 2026 16:01
@github-actions github-actions Bot mentioned this pull request May 3, 2026
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

Refactors pkg/cli to improve cohesion by relocating utility functions into files that better match their domain (audit formatting helpers, log discovery utilities, compile post-processing, and external tool runners).

Changes:

  • Moved log discovery helpers (findAgentLogFile, findAgentOutputFile) into logs_utils.go and removed related imports/logic from logs_parsing_core.go.
  • Split compile-related batch/post-processing responsibilities into compile_external_tools.go and expanded compile_post_processing.go, leaving compile_batch_operations.go as a stub.
  • Centralized misc helpers (repo-relative path + absolute workflow dir) into helpers.go, and moved audit diff formatting helpers into audit_math_helpers.go.
Show a summary per file
File Description
pkg/cli/logs_utils.go Adds agent log/output discovery helpers alongside other logs utilities.
pkg/cli/logs_parsing_core.go Removes moved log-discovery code and trims imports.
pkg/cli/helpers.go Gains repo/path helper functions previously in compile file ops.
pkg/cli/compile_post_processing.go Consolidates purge/warnings/cache post-processing helpers.
pkg/cli/compile_pipeline.go Removes inlined warning/cache helpers now housed in post-processing.
pkg/cli/compile_file_operations.go Removes repo/path helpers moved to helpers.go.
pkg/cli/compile_external_tools.go Introduces a focused home for external tool runner wrappers/utilities.
pkg/cli/compile_batch_operations.go Reduced to stub comments pointing to new file locations.
pkg/cli/audit_math_helpers.go Adds formatting helpers moved from audit diff.
pkg/cli/audit_diff.go Removes formatting helpers/imports after relocation.

Copilot's findings

Tip

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

  • Files reviewed: 10/10 changed files
  • Comments generated: 2

Comment thread pkg/cli/logs_utils.go
Comment on lines +159 to +169
// Check for flattened location (after flattening)
// The engine's log path is absolute (e.g., /tmp/gh-aw/sandbox/agent/logs/)
// After flattening, it's at logDir/sandbox/agent/logs/
// Strip /tmp/gh-aw/ prefix to get the relative path
const tmpGhAwPrefix = "/tmp/gh-aw/"
if after, ok := strings.CutPrefix(logFileForParsing, tmpGhAwPrefix); ok {
relPath := after
flattenedDir := filepath.Join(logDir, relPath)
logsUtilsLog.Printf("Checking flattened location for logs: %s", flattenedDir)
if fileutil.DirExists(flattenedDir) {
// Prefer events.jsonl (structured Copilot session format) over debug .log files.
Comment on lines 14 to 18
"errors"
"fmt"
"os"
"path/filepath"
"strings"

…g/cli

Generated by the Design Decision Gate workflow to document the decision
to reorganize pkg/cli by semantic cohesion rather than point-of-first-use.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

Commit pushed: 3283228

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (511 new lines in pkg/) but does not have a linked Architecture Decision Record (ADR).

AI has analyzed the PR diff and generated a draft ADR to help you get started:

📄 Draft ADR: docs/adr/29952-semantic-function-clustering-pkg-cli.md

What to do next

  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI could not infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-29952: Semantic Function Clustering in pkg/cli

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say ‘I’ll deal with this later.’ Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.


📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 0042-use-postgresql.md for PR #42).

🔒 This PR cannot merge until an ADR is linked in the PR body.

References: §25283930938

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · ● 156.3K ·

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented May 3, 2026

@copilot review all comments

- Update logs_parsing_core.go header comment to reflect current scope
  (removed stale references to locating agent log files)
- Fix findAgentLogFile to handle engine log paths that point to a file
  (not just a directory) after /tmp/gh-aw/ prefix stripping:
  case 1: direct file match at flattened path
  case 2: directory walk for events.jsonl/.log files (existing)
  case 3: fallback search by base filename across logDir

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/22826460-76f1-4160-aca0-1ce3e88914cf

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 3, 2026

@copilot review all comments

Both reviewer comments addressed in e18e319:

  1. logs_parsing_core.go header: Updated to reflect the current scope — aw_info.json parsing and engine extraction only (removed stale references to locating log files).

  2. findAgentLogFile file-path case: The flattened-location check now handles three cases:

    • Case 1: the flattened path is a direct file (e.g. logDir/pi-streaming.jsonl) — returned immediately
    • Case 2: the flattened path is a directory — existing walk for events.jsonl/.log files (unchanged)
    • Case 3: new fallback that searches logDir recursively for a file matching filepath.Base(logFileForParsing), covering unusual artifact layouts

Copilot AI requested a review from pelikhan May 3, 2026 16:15
@pelikhan pelikhan merged commit cce19bc into main May 3, 2026
@pelikhan pelikhan deleted the copilot/refactor-semantic-function-clustering-another-one branch May 3, 2026 16:36
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: pkg/cli Refactoring Opportunities

4 participants