Skip to content

refactor: eliminate duplicate git root detection and typeutil alias wrappers#25283

Merged
pelikhan merged 2 commits intomainfrom
copilot/refactor-semantic-function-clustering
Apr 8, 2026
Merged

refactor: eliminate duplicate git root detection and typeutil alias wrappers#25283
pelikhan merged 2 commits intomainfrom
copilot/refactor-semantic-function-clustering

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Three semantic duplication issues identified by automated analysis: a manual .git-walking implementation duplicating existing git utilities, five one-liner typeutil aliases in map_helpers.go creating unnecessary indirection, and near-identical bool extraction functions across package boundaries.

Issue 1: DependencyGraph.findGitRoot()findGitRootForPath()

Removed the manual filesystem-walking implementation in dependency_graph.go in favor of findGitRootForPath() (already in pkg/cli/git.go), which uses git -C dir rev-parse --show-toplevel. The g.workflowsDir fallback is preserved via error handling. The old implementation was also incorrect for git worktrees.

Issue 2: Remove 5 alias wrappers from map_helpers.go

Migrated all internal callers directly to typeutil.* and deleted the wrappers:

Removed alias Direct call
parseIntValue typeutil.ParseIntValue
safeUint64ToInt typeutil.SafeUint64ToInt
safeUintToInt typeutil.SafeUintToInt
ConvertToInt typeutil.ConvertToInt
ConvertToFloat typeutil.ConvertToFloat

Affected files: claude_logs.go, metrics.go, mcp_scripts_parser.go, frontmatter_extraction_metadata.go, publish_artifacts.go, safe_outputs_config.go, publish_assets.go. Test files updated accordingly.

Issue 3: Add typeutil.ParseBool() and consolidate bool extractors

Added ParseBool(m map[string]any, key string) bool to pkg/typeutil/convert.go — handles nil maps, absent keys, and non-bool values. Both parseBoolFromFrontmatter (parser) and ParseBoolFromConfig (workflow) now delegate to it:

// pkg/typeutil/convert.go
func ParseBool(m map[string]any, key string) bool {
    if m == nil { return false }
    if v, ok := m[key]; ok {
        b, _ := v.(bool)
        return b
    }
    return false
}

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 -buildtags /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel -tests /usr/bin/git 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 git /usr/bin/git git init�� /usr/bin/git git /usr/bin/git --show-toplevel git /usr/bin/git 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 git 1/x64/bin/node git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git 1/x64/bin/node git (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 -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name --show-toplevel git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel 64/pkg/tool/linuunpack-objects /usr/bin/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 --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git -json GO111MODULE ache/go/1.25.8/x--show-toplevel git conf�� user.name Test User /usr/bin/git 3648648183/.githgit 0770569/b076/vetrev-parse .cfg git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --get l /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel 1/x64/bin/node /usr/bin/git git rev-�� it/ref/tags/v4 git 1/x64/bin/node --show-toplevel git /usr/bin/du 1/x64/bin/node (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 ts.result test@example.com /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile latted/flatted.ggit GO111MODULE x_amd64/vet /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile -o /tmp/go-build3730784642/b457/_pkg_.a -trimpath /opt/hostedtoolcache/node/24.14.1/x64/bin/node -p github.com/githurev-parse -lang=go1.25 node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha --show-toplevel git /usr/bin/git 1535524626/001' 1535524626/001' /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha --show-toplevel git ache/node/24.14.1/x64/bin/node --show-toplevel git-receive-packrev-parse /usr/bin/git git _inc�� --show-toplevel git ptables --show-toplevel git /usr/bin/git git (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 .cfg x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json .cfg 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /usr/bin/git J-vPE9CJQ 0770569/b203/vetrev-parse 1/x64/bin/node git rev-�� --show-toplevel ache/go/1.25.8/xmyorg /usr/bin/git vaScript30341471git stmain.go ache/go/1.25.8/x--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel -extld=gcc t git rev-�� --show-toplevel git /usr/bin/git --show-toplevel x_amd64/vet /usr/bin/git git (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 --show-toplevel 64/pkg/tool/linuremote.origin.url /usr/bin/git -json GO111MODULE 64/pkg/tool/linu--show-toplevel git conf�� --get remote.origin.url /usr/bin/git 1644675514/.githgit GO111MODULE .cfg git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git -json GO111MODULE 64/pkg/tool/linu--show-toplevel git remo�� GOMODCACHE 64/pkg/tool/linux_amd64/vet /usr/bin/git -json GO111MODULE 64/bin/bash git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel node /usr/bin/git /tmp/TestHashCongit go /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git /tmp/TestGuardPogit rev-parse /usr/bin/git 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 -json GOCACHE 64/bin/go tierignore go 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha led-with-body-content.md GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha 1 GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE 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 --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git LsRemoteWithRealgit LsRemoteWithRealrev-parse x_amd64/compile git conf�� --get remote.origin.url /usr/bin/git -json GO111MODULE .cfg git (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 ub/workflows git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha -t security /usr/bin/git OUTPUT -d 168.63.129.16 git rev-�� --show-toplevel 53 /opt/hostedtoolcache/node/24.14.1/x64/bin/node ACCEPT git /usr/bin/git node (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 --show-toplevel 64/pkg/tool/linuremote.origin.url /usr/bin/git -json .cfg 64/pkg/tool/linu--show-toplevel git remo�� remove origin /usr/bin/git md GO111MODULE x_amd64/link git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel git e/git ub/workflows git /usr/bin/git e/git rev-�� --show-toplevel git /usr/bin/git 01 git /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha command -v debian-sa1 > /dev/null && debian-sa1 1 1 git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git 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 --show-toplevel go ache/node/24.14.1/x64/bin/node -json GO111MODULE 64/bin/go git t-20�� k/gh-aw/gh-aw/.github/workflows/api-consumption-report.md config /usr/bin/git remote.origin.urgit GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel node /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha --show-toplevel git 1/x64/bin/node --show-toplevel git /opt/hostedtoolcgithub.token git cjs --show-toplevel /opt/hostedtoolcache/node/24.14.1/x64/bin/node ache/node/24.14.1/x64/bin/node github.prop.prop/opt/hostedtoolcache/node/24.14.1/x64/bin/node git /usr/bin/git git (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 --show-toplevel 64/pkg/tool/linuTest User /usr/bin/git -json .cfg 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git -json .cfg 64/pkg/tool/linu--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha --show-toplevel git /usr/bin/git ub/workflows git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git 895614/001 git /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha /usr/bin/git git /usr/bin/git --show-toplevel git /usr/bin/infocmp--show-toplevel git rev-�� --show-toplevel infocmp /usr/bin/git xterm-color git /usr/bin/git git (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 -bool -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git -C /tmp/gh-aw-test-runs/20260408-121224-63477/test-1053468571/.github/workflows remote /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel git ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel git /opt/hostedtoolcache/node/24.14.1/x64/bin/node --show-toplevel nly /usr/bin/git node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha 3784/001/stability-test.md git 1/x64/bin/bash --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git ache/node/24.14.1/x64/bin/node --show-toplevel infocmp /usr/bin/infocmp--show-toplevel 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 -m initial commit /usr/bin/git -json GO111MODULE 64/bin/go git -C /tmp/gh-aw-test-runs/20260408-121224-63477/test-1053468571/.github/workflows rev-parse /opt/hostedtoolcache/node/24.14.1/x64/bin/node -json GO111MODULE 64/bin/go node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha 1424-69562/test-1700131384 git /usr/bin/git --show-toplevel node /usr/bin/git git rev-�� heckout/git/ref/tags/v5 git /opt/hostedtoolcache/node/24.14.1/x64/bin/node --show-toplevel git /usr/bin/git node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha --show-toplevel gh 86_64/bash /repos/github/ghgit --jq /usr/bin/git git rev-�� --show-toplevel git ache/node/24.14.1/x64/bin/node --show-toplevel git /usr/bin/git git (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 -buildtags /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -ato�� -bool -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 -buildtags (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name FeyQDZieFZeq /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git (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 /tmp/go-build3890770569/b183/vet.cfg /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -json set 64/bin/go 0784642/b399/importcfg -ato�� 568088680 -buildtags /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 /tmp/go-build3890770569/b206/vet.cfg 0784642/b408/vet.cfg -json GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.8/xremote2 -ato�� licyMinIntegrityOnlymin-integrity_with_repos_array_c610960456/001 -buildtags ache/node/24.14.1/x64/bin/node -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� kflows/test-expires.lock.yml git ache/node/24.14.1/x64/bin/node --show-toplevel git /home/REDACTED/.lo--show-toplevel git (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 /tmp/go-build3890770569/b182/vet.cfg /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linu-test.short=true =receive GO111MODULE 64/bin/go (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 /tmp/go-build3890770569/b199/vet.cfg 0784642/b406/_pkg_.a =receive GO111MODULE 64/bin/go (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name git /usr/bin/git --show-toplevel /opt/hostedtoolcrev-parse e/git git rev-�� --show-toplevel e/git /usr/bin/git --show-toplevel git /opt/hostedtoolc--show-toplevel git (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 /tmp/go-build3890770569/b219/vet.cfg /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -json GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -ato�� licyBlockedUsersCommaSeparatedCompiledOutput4057218715/001 -buildtags ache/node/24.14.1/x64/bin/node l -ifaceassert -nilfunc git (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 -buildtags /home/REDACTED/go/bin/bash -errorsas -ifaceassert -nilfunc bash --no�� --noprofile -tests /usr/lib/git-core/git-upload-pack "prettier" --chegit GOPROXY 64/bin/go git-upload-pack (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name git /usr/bin/git --show-toplevel git /usr/bin/infocmp--show-toplevel git -C /tmp/gh-aw-test-runs/20260408-121424-69562/test-1935328610/.github/workflows remote /usr/bin/git xterm-color git /usr/bin/git git (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 -buildtags /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -ato�� licyBlockedUsersCommaSeparatedCompiledOutput4057218715/001 -buildtags 0784642/b431/vet.cfg -errorsas -ifaceassert -nilfunc git (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 -buildtags /tmp/go-build3890770569/b398/typeutil.test -errorsas -ifaceassert -nilfunc /tmp/go-build3890770569/b398/typeutil.test -tes�� -test.paniconexit0 l (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name git /usr/bin/git --show-toplevel git /usr/bin/infocmp--show-toplevel git rev-�� --show-toplevel infocmp /usr/bin/git ]*:[[:space:]]*"git git /usr/bin/git git (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 /tmp/go-build3890770569/b226/vet.cfg 0784642/b435=> -json GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -ato�� licyBlockedUsersCommaSeparatedCompiledOutput4057218715/001 -buildtags (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 -buildtags ache/go/1.25.8/x64/pkg/tool/linux_amd64/link -errorsas -ifaceassert -nilfunc ache/go/1.25.8/x64/pkg/tool/linux_amd64/link --no�� 0784642/b452/workflow.test -tests 1/x64/bin/node "prettier" --che/usr/bin/git GOPROXY 64/bin/go 1/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name (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 -buildtags 0784642/b435/importcfg.link -errorsas -ifaceassert -nilfunc 8IwtLslUObn8g/hV8dBAPheVNXq858eZBB/DhPXKBUjWYAJ47sC7-S6/7aa0EhL8IwtLslUObn8g -ato�� ry=1 -buildtags 0784642/b435/_pkg_.a -errorsas -ifaceassert -nilfunc infocmp (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git rev-�� --show-toplevel -tests 1/x64/bin/node "prettier" --chegit GOPROXY 64/bin/go 1/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name 7GEvC2xYQ2wY 1/x64/bin/node --show-toplevel git /usr/bin/gh 1/x64/bin/node t-38�� k/gh-aw/gh-aw/.github/workflows/agent-persona-explorer.md gh /usr/bin/git /repos/actions/ggit --jq /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path -c=4 -nolocalimports -importcfg /tmp/go-build3730784642/b411/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/fileutil/fileutil.go /home/REDACTED/work/gh-aw/gh-aw/pkg/fileutil/tar.go env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (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 x_amd64/vet env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (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 GOWORK 64/bin/go e/git -uns�� 3 /tmp/go-build3890770569/b205/vet.cfg 0784642/b403/_pkg_.a -json GO111MODULE 64/bin/go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet (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 --show-toplevel tutil.test /usr/bin/git -json GO111MODULE .cfg git rev-�� --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile /usr/bin/git 0784642/b411/_pkgit /tmp/go-build389rev-parse 0784642/b411=> git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel git p/bin/bash git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git e/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git (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 y-frontmatter.md GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE x_amd64/link GOINSECURE GOMOD GOMODCACHE WKKjjpb/pnOHWmOW0VPsKVyXPZlC (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha --show-toplevel nly /usr/bin/git xterm-color x_amd64/vet /usr/bin/git git rev-�� --show-toplevel git e/git --show-toplevel x_amd64/vet /usr/bin/git e/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha 2aace9e8f9961e9129b37a38..HEAD ache/node/24.14.1/x64/bin/node /usr/bin/git ub.actor }} git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git (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 -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha ub/workflows git /usr/bin/git --show-toplevel ache/go/1.25.8/x-C e/git-remote-htt/tmp/gh-aw-test-runs/20260408-121424-69562/test-350674049 git itbr�� --show-toplevel e/git-remote-https /usr/bin/git om/owner/repo.gigit ache/go/1.25.8/xrev-parse /usr/bin/git git (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 -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE IJoBJLv/YoLpUfOG-test.v=true env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha ub/workflows git /usr/bin/git --show-toplevel ache/go/1.25.8/xrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel ache/go/1.25.8/xrev-parse /usr/bin/git git (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 -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE vL9a24R/kExe3dXfrev-parse env Gitbranch_with_hyphen408551104/001' Gitbranch_with_hyphen408551104/001' x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha repo3903691295/001 --jq /usr/bin/git --show-toplevel tutil.test /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel ache/go/1.25.8/x-C /usr/bin/git 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 -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE k1K6e8V/fbV2ig0Crev-parse env 62/001 GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha --show-toplevel infocmp /usr/bin/git xterm-color x_amd64/vet /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel x_amd64/vet /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git user.name (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 -errorsas -ifaceassert -nilfunc git init�� k/gh-aw/gh-aw/.github/workflows --initial-branch=main ache/node/24.14.1/x64/bin/node log.showsignaturgit log 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git (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 go env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo /usr/bin/git --show-toplevel x_amd64/compile /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git test.txt 64/pkg/tool/linucommit /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo /usr/bin/git --show-toplevel x_amd64/vet /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --oneline -1 /usr/bin/git git (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build3730784642/b397/cli.test /tmp/go-build3730784642/b397/cli.test -test.testlogfile=/tmp/go-build3730784642/b397/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true tierignore **/*.cjs 64/bin/go 96T_MkWd-kcE env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /tmp/go-build3373318536/b377/cli.test /tmp/go-build3373318536/b377/cli.test -test.testlogfile=/tmp/go-build3373318536/b377/testlog.txt -test.paniconexit0 -test.timeout=10m0s rev-�� --show-toplevel git /usr/bin/git --show-toplevel (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 08750633/001' 08750633/001' 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name --show-toplevel git /usr/bin/gh --show-toplevel x_amd64/vet /usr/bin/git gh api /repos/actions/github-script/git/ref/tags/v8 7924ac4edf32d241201ba772..HEAD /opt/hostedtoolcache/node/24.14.1/x64/bin/npm --show-toplevel x_amd64/link /usr/bin/git -type d -name bin 2>/dev/null | tr '\n' ':')$PATH"; [ -n "$GOROOT" ] && export (http block)

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

- Issue 1: Replace DependencyGraph.findGitRoot() with findGitRootForPath()
  in pkg/cli/dependency_graph.go, removing the manual filesystem-walking
  implementation in favor of the existing git-command-based utility

- Issue 2: Remove 5 alias wrappers from pkg/workflow/map_helpers.go;
  migrate all internal callers (claude_logs.go, mcp_scripts_parser.go,
  frontmatter_extraction_metadata.go, publish_artifacts.go,
  safe_outputs_config.go, publish_assets.go, metrics.go) to use
  typeutil.* directly; update test files accordingly

- Issue 3: Add typeutil.ParseBool() to pkg/typeutil/convert.go;
  update parseBoolFromFrontmatter and ParseBoolFromConfig to delegate to it"

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/283402d8-43b1-4753-8c0b-cfcca2e2a476

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor semantic function clustering analysis findings refactor: eliminate duplicate git root detection and typeutil alias wrappers Apr 8, 2026
Copilot AI requested a review from pelikhan April 8, 2026 12:20
@pelikhan pelikhan marked this pull request as ready for review April 8, 2026 12:21
Copilot AI review requested due to automatic review settings April 8, 2026 12:21
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 git-root detection and type conversion helpers to reduce semantic duplication across packages, while centralizing boolean extraction in pkg/typeutil.

Changes:

  • Replaced DependencyGraph’s manual .git walking with the existing findGitRootForPath() (git rev-parse) approach.
  • Removed pkg/workflow’s typeutil alias wrappers and migrated call sites/tests to use pkg/typeutil directly.
  • Added typeutil.ParseBool() and updated frontmatter/config bool extractors to delegate to it.
Show a summary per file
File Description
pkg/cli/dependency_graph.go Uses findGitRootForPath() when building an import cache for include resolution.
pkg/cli/logs_parsing_test.go Switches tests to call typeutil.ConvertToInt/ConvertToFloat directly.
pkg/parser/frontmatter_hash.go Delegates frontmatter bool extraction to typeutil.ParseBool.
pkg/typeutil/convert.go Adds ParseBool() helper and documents it alongside other conversions.
pkg/workflow/claude_logs.go Replaces workflow conversion wrappers with typeutil conversions.
pkg/workflow/config_helpers.go Refactors ParseBoolFromConfig to use typeutil.ParseBool.
pkg/workflow/frontmatter_extraction_metadata.go Replaces safe uint→int wrappers with typeutil safe conversions.
pkg/workflow/map_helpers.go Removes typeutil alias wrappers; keeps only map helper utilities.
pkg/workflow/map_helpers_test.go Updates tests to use typeutil conversions directly.
pkg/workflow/mcp_scripts_parser.go Replaces safe uint64→int wrapper with typeutil.SafeUint64ToInt.
pkg/workflow/metrics.go Uses typeutil.ConvertToInt/ConvertToFloat for JSON metric extraction.
pkg/workflow/metrics_test.go Updates tests to use typeutil conversions directly.
pkg/workflow/publish_artifacts.go Uses typeutil.ParseIntValue for numeric config parsing.
pkg/workflow/publish_assets.go Uses typeutil.ParseIntValue for numeric config parsing.
pkg/workflow/safe_outputs_config.go Uses typeutil.ParseIntValue for numeric config parsing.
pkg/workflow/type_conversion_test.go Updates conversion tests to target typeutil directly.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (1)

pkg/cli/dependency_graph.go:255

  • resolveImportPath now runs findGitRootForPath(...) (which shells out to git) on every call. Since this method is invoked per-import during graph building, this can introduce significant overhead and repeated logging. Consider caching the git root once on the DependencyGraph (e.g., compute lazily with a sync.Once or during NewDependencyGraph/BuildGraph) and reusing it for all resolutions.
	// If that fails, try resolving with parser's cache-aware resolution
	// Note: We create a minimal cache here just for resolution
	gitRoot, err := findGitRootForPath(g.workflowsDir)
	if err != nil {
		depGraphLog.Printf("Failed to find git root, using fallback: %v", err)
		gitRoot = g.workflowsDir
	}
	importCache := parser.NewImportCache(gitRoot)
  • Files reviewed: 16/16 changed files
  • Comments generated: 2

Comment on lines 248 to +255
// If that fails, try resolving with parser's cache-aware resolution
// Note: We create a minimal cache here just for resolution
importCache := parser.NewImportCache(g.findGitRoot())
gitRoot, err := findGitRootForPath(g.workflowsDir)
if err != nil {
depGraphLog.Printf("Failed to find git root, using fallback: %v", err)
gitRoot = g.workflowsDir
}
importCache := parser.NewImportCache(gitRoot)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

findGitRootForPath assumes the input is a file path and unconditionally does filepath.Dir(absPath) internally. Passing g.workflowsDir (a directory) means the git command runs from the parent of the workflows directory, which can be incorrect (e.g., if workflowsDir is already the repo root, it will run from its parent and fail). Consider either updating findGitRootForPath to handle directory inputs or passing a known file path within g.workflowsDir so the working directory is correct.

This issue also appears on line 248 of the same file.

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +127
// ParseBool extracts a boolean value from a map[string]any by key.
// Returns false if the map is nil, the key is absent, or the value is not a bool.
func ParseBool(m map[string]any, key string) bool {
if m == nil {
return false
}
if v, ok := m[key]; ok {
b, _ := v.(bool)
return b
}
return false
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

ParseBool is a new exported utility but there are no unit tests covering its behavior (nil map, missing key, non-bool value, true/false). Since pkg/typeutil already has convert_test.go covering the other helpers, add focused tests there to prevent regressions.

Copilot uses AI. Check for mistakes.
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 8, 2026

@copilot review comments

@pelikhan pelikhan merged commit 2480098 into main Apr 8, 2026
64 of 67 checks passed
@pelikhan pelikhan deleted the copilot/refactor-semantic-function-clustering branch April 8, 2026 13:09
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: Refactoring Opportunities

3 participants