Skip to content

refactor: resolve semantic function clustering issues in pkg/workflow#22474

Merged
pelikhan merged 8 commits intomainfrom
copilot/refactor-safe-output-config
Mar 23, 2026
Merged

refactor: resolve semantic function clustering issues in pkg/workflow#22474
pelikhan merged 8 commits intomainfrom
copilot/refactor-safe-output-config

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

Semantic analysis identified two parallel safe-output config generation systems diverging on field coverage, plus several smaller code hygiene issues.

Dual config system — documentation + staged field gap

Two paths generate safe-output handler config and must stay in sync:

  • generateSafeOutputsConfig()GH_AW_SAFE_OUTPUTS_CONFIG_PATH (config.json, consumed at MCP server startup)
  • addHandlerManagerConfigEnvVar()GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG (consumed at handler runtime)

Added cross-reference comments to both files documenting the dual-system contract and the sync requirement.

The recent "Add per-handler staged mode" PR updated compiler_safe_outputs_config.go and safe_outputs_permissions.go but left 34 of 36 handlers in safe_outputs_config_generation.go without staged emission. Fixed by propagating staged: true to all handlers using a new addStagedIfTrue(config, staged bool) helper:

// Before — only close_pull_request and dispatch_repository emitted staged
safeOutputsConfig["update_issue"] = generateMaxConfig(data.SafeOutputs.UpdateIssues.Max, 1)

// After — all handlers emit staged when set
config := generateMaxConfig(data.SafeOutputs.UpdateIssues.Max, 1)
addStagedIfTrue(config, data.SafeOutputs.UpdateIssues.Staged)
safeOutputsConfig["update_issue"] = config

The smoke-claude.lock.yml recompile correctly picks up the previously-silent push-to-pull-request-branch.staged: true flag.

safeUintToInt moved to map_helpers.go

Thin wrapper lived in frontmatter_extraction_metadata.go while safeUint64ToInt (which it calls) was already in map_helpers.go. Moved alongside its sibling.

parseIntValue vs ConvertToInt — usage guidance added

Added doc comments clarifying intent:

  • parseIntValue — strict numeric-only parse, returns (value, ok); use when the caller must distinguish zero from invalid
  • ConvertToInt — lenient, also handles strings, returns 0 on failure; use for heterogeneous sources (metrics, log parsing)

update_entity_helpers.go split by entity domain

543-line file mixed infrastructure with four concrete entity domains. Extracted domain-specific types and parsers into dedicated files following the existing create_*.go pattern:

New file Contents
update_issue_helpers.go UpdateIssuesConfig, parseUpdateIssuesConfig
update_discussion_helpers.go UpdateDiscussionsConfig, parseUpdateDiscussionsConfig
update_pull_request_helpers.go UpdatePullRequestsConfig, parseUpdatePullRequestsConfig

update_entity_helpers.go now contains only the shared infrastructure (UpdateEntityConfig, parseUpdateEntityConfigTyped, field parsing modes, etc.) and references the split files in its header comment. UpdateReleaseConfig was already in update_release.go.

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 2230918/b004/vetrev-parse .cfg git rev-�� --show-toplevel ache/go/1.25.0/x64/pkg/tool/linu--jq /usr/bin/git se 2230918/b213/vetrev-parse ache/go/1.25.0/x--show-toplevel 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 /opt/hostedtoolcrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel bash /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 0/x64/bin/node git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git 0/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 ./../pkg/workflo-errorsas (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name --show-toplevel wc ache/node/24.14.0/x64/bin/node 64/pkg/tool/linunode git /usr/bin/git git ache�� --show-toplevel nly /usr/bin/git --show-toplevel git /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 x_amd64/vet /usr/bin/git FETCH_HEAD^{commgit (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 ache/go/1.25.0/xrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel /opt/hostedtoolcrev-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 run --auto /usr/bin/git --detach git /usr/bin/git git rev-�� --show-toplevel resolved$ /opt/hostedtoolcache/node/24.14.0/x64/bin/node --show-toplevel git /usr/bin/tr /opt/hostedtoolcache/node/24.14.0/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 sistency_GoAndJavaScript2076266746/001/test-complex-frontmatter--p (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha 64/pkg/tool/linu--show-toplevel git 64/bin/bash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha /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 run format:cjs .cfg 0 -j ACCEPT ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel kmIpjEVxgPIJbBLrkR/yyjxJESSHc3089fRgrZr/aHz0DOVUCYY4uw-nj1ib /usr/bin/git 3556-14048/test-git /tmp/go-build308rev-parse _.a git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet n-dir/node -unreachable=falgit /tmp/go-build308rev-parse /opt/hostedtoolc--show-toplevel 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 /tmp/TestHashConsistency_GoAndJavaScript2076266746/001/test-frontmatter-with-arrays.md x_amd64/vet /usr/bin/git stall-gh-aw.sh tgit credential.helperev-parse x_amd64/vet git rev-�� --git-dir qTv0wV_/u9hDkdhvconfig /usr/bin/git *.json' '!../../git main 56a5e95df39edcc9--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -test.paniconexit0 -test.v=true /usr/bin/git -test.timeout=10git -test.run=^Test -test.short=true--show-toplevel git -C /tmp/gh-aw-test-runs/20260323-173556-14048/test-2014948560 status /usr/bin/git .github/workflowgit main nch,headSha,disp--show-toplevel 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 --write ../../../**/*.jsrev-parse p/bin/bash git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/git 3556-14048/test-git /tmp/go-build308rev-parse cfg 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 submodules | hea-errorsas (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha it} --local x_amd64/vet http.https://gitgit (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha --get-regexp --local 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 /tmp/TestHashStability_SameInputSameOutput3602068441/001/stability-test.md x_amd64/vet (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 --show-toplevel ache/go/1.25.0/xrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel ache/go/1.25.0/xrev-parse /usr/bin/git 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 --show-toplevel git /usr/bin/git git init�� ache/node/24.14./tmp/TestHashConsistency_GoAndJavaScript918904178/001/test-frontmatter-with-env-git git /usr/bin/git --show-toplevel git /usr/bin/git git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha /tmp/go-build483268711/b441/testutil.test -importcfg /usr/bin/git -s -w -buildmode=exe git -C /tmp/gh-aw-test-runs/20260323-173556-14048/test-2014948560 status /usr/bin/git .github/workflowgit main 64/pkg/tool/linu--show-toplevel git (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 ache/go/1.25.0/xrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel ache/go/1.25.0/xrev-parse /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel git ache/node/24.14.0/x64/bin/node --show-toplevel git /usr/bin/git ache/node/24.14.0/x64/bin/node 6484�� env.NODE_VERSION git ache/node/24.14.0/x64/bin/node --show-toplevel git /usr/bin/git ache/node/24.14.0/x64/bin/node (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 runs/20260323-173556-14048/test-1208614605/.github/workflows -buildtags 268711/b299/vet.cfg l -ifaceassert -nilfunc git rev-�� k/gh-aw/gh-aw/.github/workflows -tests ache/node/24.14.0/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha /lib/php/sessionclean; fi git /usr/bin/git --git-dir x_amd64/vet /usr/bin/git git rev-�� --show-toplevel git /usr/bin/infocmp --git-dir 64/pkg/tool/linurev-parse /usr/bin/git infocmp (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha m0s git /opt/hostedtoolcache/node/24.14.0/x64/bin/node --show-toplevel git /usr/bin/git node js/f�� 3932-24023/test-307537318 git /opt/hostedtoolcache/node/24.14.0/x64/bin/node --show-toplevel git /usr/bin/git node (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 -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE node (http block)
  • https://api.github.com/repos/github/gh-aw
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw --jq .visibility "prettier" --cheremote.origin.url node r: $owner, name: $name) { hasDiscussionsEnabled } } tierignore git 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 runs/20260323-173556-14048/test-100468786/.github/workflows -tests 268711/b384/vet.cfg l (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 --get remote.origin.urrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /opt/hostedtoolc--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha g/cli git /opt/hostedtoolcache/node/24.14.0/x64/bin/node /ref/tags/v8 git /usr/bin/git node js/f�� /usr/bin/find git ache/node/24.14.0/x64/bin/node ions.md find /usr/bin/git bash (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 3556-14048/test-2014948560 -tests _.a js/**/*.json' --git (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 git /usr/bin/git --git-dir x_amd64/vet /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /opt/hostedtoolc--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha g/cli git /opt/hostedtoolcache/node/24.14.0/x64/bin/node tags/v6 git /usr/bin/git node js/f�� /usr/bin/git git o.git --show-toplevel git /usr/bin/git bash (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 git 64/pkg/tool/linux_amd64/compile --show-toplevel git /usr/bin/git 64/pkg/tool/linux_amd64/compile rev-�� artifacts-summary.md git ache/node/24.14.0/x64/bin/node --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 run download 12345 --dir test-logs/run-12345 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 git 0/x64/bin/node --show-toplevel git /usr/bin/git git cjs --show-toplevel git 0/x64/bin/node --show-toplevel git /usr/bin/git git (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 .cfg x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 git 0/x64/bin/node ref/tags/v1.0.0 git /usr/bin/git git cjs --show-toplevel git ache/node/24.14.0/x64/bin/node --show-toplevel git /usr/bin/git git (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 git /usr/bin/git /php.ini git '~E_ALL' git rev-�� --show-toplevel git ache/node/24.14.0/x64/bin/node --show-toplevel 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 run download 3 --dir test-logs/run-3 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 git 64/bin/go --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git 0/x64/bin/node --show-toplevel 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 run download 4 --dir test-logs/run-4 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git ache/node/24.14.0/x64/bin/node --show-toplevel git /usr/bin/git git (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 .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git ache/node/24.14.0/x64/bin/node --show-toplevel git /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 rt/yaml/yaml_def-errorsas (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 -j DROP 64/pkg/tool/linux_amd64/vet -w te '../../../**/*.json' '!../../../pkg/workflow/js/**/*.json' --ignore-path ../../../.prettieriggit security ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -nxv (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 ty-test.md (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile /usr/bin/git 268711/b411/_pkggit -buildtags Name,createdAt,s--show-toplevel git rev-�� --show-toplevel bash /usr/bin/git d0nI/JDYlVuhukXNgit -tests ache/node/24.14.--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 --show-toplevel git /usr/bin/git --show-toplevel git cal/bin/bash 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 -2.15.1.3-py3.12.egg --local x_amd64/vet user.name (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� ster.patch git /usr/bin/git --show-toplevel git ache/go/1.25.0/x/tmp/TestGuardPolicyBlockedUsersExpressionCompiledOutput2452725381/001 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 ormat:cjs --silent >/dev/null 2>&1 --local x_amd64/vet user.email (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha '**/*.ts' '**/*.json' --ignore-path ../../../.pr**/*.json --local x_amd64/vet user.email (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha '**/*.ts' '**/*.-s --local x_amd64/vet pull.rebase (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 get --local x_amd64/vet user.email (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha --show-toplevel git /usr/bin/git JJnzfBuX4 git /usr/bin/git git f]\{�� --show-toplevel git /home/REDACTED/.local/bin/node --show-toplevel stmain.go ache/go/1.25.0/x/tmp/TestHashConsistency_GoAndJavaScript918904178/001/test-frontmatter-with-nested-objects.md 4 -type d -name bin 2>/dev/null | tr '\n' ':')$PATH"; [ -n "$GOROOT" ] && expo (http block)
  • https://api.github.com/repos/githubnext/agentics/git/ref/tags/
    • Triggering command: /usr/bin/gh gh api /repos/githubnext/agentics/git/ref/tags/# --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE sh -c npx prettier --cGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go sh (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 te '../../../**/*.json' '!../../../pkg/workflow/js/**/*.json' ---p (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/link /usr/bin/git Qwjfc586n -buildtags 268711/b412/impo--show-toplevel git rev-�� --show-toplevel sjEuzM2jqMmVy/_hIk68it_nH2gSrVWrsb/WrsaZCqRpvSTiTest User /usr/bin/git licyBlockedUsersgit tmain.go ache/go/1.25.0/x--show-toplevel 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 /opt/hostedtoolcache/node/24.14.0/x64/bin/node --show-toplevel git ache/go/1.25.0/xuser.name node s install --package-lock-only /usr/bin/git --show-toplevel git /usr/bin/git git (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 --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git ache/node/24.14.0/x64/bin/node --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 x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo /usr/bin/git HEAD 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 workflow list --json name,state,path --repo owner/repo /usr/bin/git x_amd64/vet 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/contents/file.md
    • Triggering command: /tmp/go-build483268711/b400/cli.test /tmp/go-build483268711/b400/cli.test -test.testlogfile=/tmp/go-build483268711/b400/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-build1961828615/b001/cli.test /tmp/go-build1961828615/b001/cli.test -test.paniconexit0 -test.timeout=10m0s -test.count=1 3857�� --show-toplevel grep /usr/bin/git ^From [0-9a-f]\{node /tmp/gh-aw/aw-majs/fuzz_mentions_harness.cjs /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel infocmp /usr/bin/git git (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 ./../pkg/workflo-errorsas .go 64/pkg/tool/linu-nilfunc (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name --show-toplevel git /usr/bin/git --verify --quiet /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel docker /usr/bin/git git (http block)

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


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI changed the title [WIP] Refactor semantic function clustering analysis in pkg/ refactor: resolve semantic function clustering issues in pkg/workflow Mar 23, 2026
Copilot AI requested a review from pelikhan March 23, 2026 17:50
@github-actions github-actions bot mentioned this pull request Mar 23, 2026
@pelikhan
Copy link
Contributor

Copy link
Contributor Author

Copilot AI commented Mar 23, 2026

@copilot fix CI / Integration: Workflow Misc Part 2 (pull_request)Failing after 48s

Fixed in 494d3dc. The test introduced in #22490 extracted GH_AW_STOP_TIME from the YAML and tried to parse it directly, but the compiler writes it with %q which wraps the value in YAML double-quotes (e.g. "2026-03-24 21:18:46"). Added strings.Trim(timestamp, ") after the TrimSpace to strip those quotes before parsing.

@github-actions
Copy link
Contributor

Hey @Copilot 👋 — thanks for the thorough semantic analysis pass on pkg/workflow! The staged field gap across 34 handlers is a real correctness issue worth fixing, and the update_entity_helpers.go domain split is exactly the kind of file-organization improvement the codebase guidelines call for. A couple of things that would sharpen this PR:

  • Split functional fix from structural refactoring — this PR bundles four distinct concerns: (1) the staged field bug fix in safe_outputs_config_generation.go, (2) moving safeUintToInt to map_helpers.go, (3) adding doc comments to parseIntValue/ConvertToInt, and (4) splitting update_entity_helpers.go into domain files. The staged propagation fix is a correctness change with immediate runtime impact (it affects the compiled smoke-claude.lock.yml); the rest are pure hygiene. Reviewers benefit from seeing the bug fix in isolation so its correctness is easy to verify.
  • Test coverage for the staged propagationtime_delta_integration_test.go has 4 new lines but they appear unrelated to the staged-field fix. The addStagedIfTrue helper and the 34 updated handler entries in safe_outputs_config_generation.go have no dedicated test asserting that staged: true is emitted when the config flag is set. A unit test in safe_outputs_config_generation_test.go covering at least one handler (e.g. update_issue) would give reviewers confidence the fix is correct.

If you'd like a hand, you can assign this prompt to your coding agent:

This PR (github/gh-aw#22474) bundles a bug fix with code-hygiene refactoring. Please do the following:

1. **Split into two PRs**:
   - PR A (bug fix): changes to `safe_outputs_config_generation.go` (addStagedIfTrue helper + 34 handler updates), `safe_outputs_config_helpers.go`, `compiler_safe_outputs_config.go` cross-reference comments, and the `smoke-claude.lock.yml` recompile.
   - PR B (refactor): move `safeUintToInt` from `frontmatter_extraction_metadata.go` to `map_helpers.go`, add doc comments to `parseIntValue`/`ConvertToInt` in `map_helpers.go`, and split `update_entity_helpers.go` into `update_issue_helpers.go`, `update_discussion_helpers.go`, and `update_pull_request_helpers.go`.

2. **Add a unit test for PR A** in `pkg/workflow/safe_outputs_config_generation_test.go`:
   - Test that when `data.SafeOutputs.UpdateIssues.Staged` is `true`, the generated config for `"update_issue"` contains `"staged": true`.
   - Test that when `Staged` is `false`, the `"staged"` key is absent from the config.
   - Use the existing test patterns in `pkg/workflow/` (table-driven tests with `t.Run`).

3. Run `make agent-finish` after changes to validate build, tests, and lint.

Generated by Contribution Check ·

@pelikhan pelikhan marked this pull request as ready for review March 23, 2026 22:10
Copilot AI review requested due to automatic review settings March 23, 2026 22:10
@pelikhan pelikhan merged commit 6316f1c into main Mar 23, 2026
68 of 112 checks passed
@pelikhan pelikhan deleted the copilot/refactor-safe-output-config branch March 23, 2026 22:14
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

Refactors pkg/workflow safe-output configuration and update-entity parsing to reduce divergence between parallel config generation paths, while improving internal helper organization and documentation.

Changes:

  • Documents the dual safe-outputs config generation systems and propagates staged: true across many handler configs emitted into config.json.
  • Splits update-entity domain configs/parsers into dedicated update_*_helpers.go files and clarifies int parsing helper intent/docs.
  • Fixes integration test parsing for YAML-quoted timestamps and updates the compiled smoke lockfile.

Reviewed changes

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

Show a summary per file
File Description
pkg/workflow/update_pull_request_helpers.go New per-entity config type + parser for update-pull-request.
pkg/workflow/update_issue_helpers.go New per-entity config type + parser for update-issue.
pkg/workflow/update_discussion_helpers.go New per-entity config type + parser for update-discussion.
pkg/workflow/update_entity_helpers.go Keeps only shared update-entity infrastructure; removes domain-specific types/parsers.
pkg/workflow/safe_outputs_config_helpers.go Adds addStagedIfTrue helper for config.json emission.
pkg/workflow/safe_outputs_config_generation.go Propagates staged into many handler configs and improves doc guidance about dual paths.
pkg/workflow/compiler_safe_outputs_config.go Adds documentation clarifying handler-manager config generation as the authoritative field contract.
pkg/workflow/map_helpers.go Moves safeUintToInt and adds doc guidance for parseIntValue vs ConvertToInt.
pkg/workflow/frontmatter_extraction_metadata.go Removes local safeUintToInt (now centralized).
pkg/workflow/time_delta_integration_test.go Strips YAML quoting before timestamp parsing in the test.
.github/workflows/smoke-claude.lock.yml Regenerated lockfile to reflect updated config.json contents.
Comments suppressed due to low confidence (3)

pkg/workflow/safe_outputs_config_generation.go:390

  • missing_data config in config.json doesn't propagate the per-handler staged flag (staged: true) even though the handler manager registry supports it. This breaks the documented dual-config sync requirement and prevents staged mode from being enabled via config.json for missing_data. Add addStagedIfTrue(missingDataConfig, data.SafeOutputs.MissingData.Staged) when building missingDataConfig.
		if data.SafeOutputs.MissingData != nil {
			// Generate config for missing_data with issue creation support
			missingDataConfig := make(map[string]any)

			// Add max if set
			if data.SafeOutputs.MissingData.Max != nil {
				missingDataConfig["max"] = resolveMaxForConfig(data.SafeOutputs.MissingData.Max, 0)
			}

			// Add issue creation config if enabled
			if data.SafeOutputs.MissingData.CreateIssue {
				createIssueConfig := make(map[string]any)
				createIssueConfig["max"] = 1 // Only create one issue per workflow run

				if data.SafeOutputs.MissingData.TitlePrefix != "" {
					createIssueConfig["title_prefix"] = data.SafeOutputs.MissingData.TitlePrefix
				}

				if len(data.SafeOutputs.MissingData.Labels) > 0 {
					createIssueConfig["labels"] = data.SafeOutputs.MissingData.Labels
				}

				safeOutputsConfig["create_missing_data_issue"] = createIssueConfig
			}

			safeOutputsConfig["missing_data"] = missingDataConfig

pkg/workflow/safe_outputs_config_generation.go:449

  • noop config generation still omits the staged flag. If noop supports staged in the handler manager config (it does), config.json should also emit staged: true to keep the dual config systems in sync. Consider switching this block to build a config map, call addStagedIfTrue(config, data.SafeOutputs.NoOp.Staged), then assign it.
		if data.SafeOutputs.NoOp != nil {
			safeOutputsConfig["noop"] = generateMaxConfig(
				data.SafeOutputs.NoOp.Max,
				1, // default max
			)

pkg/workflow/safe_outputs_config_generation.go:363

  • missing_tool config in config.json never includes the per-handler staged flag, even though the handler manager config supports it. This keeps the two safe-outputs config generation paths out of sync and prevents staged mode from being enabled via config.json for missing_tool. Consider calling addStagedIfTrue(missingToolConfig, data.SafeOutputs.MissingTool.Staged) when building missingToolConfig (and similarly for any derived configs if applicable).

This issue also appears in the following locations of the same file:

  • line 365
  • line 445
		if data.SafeOutputs.MissingTool != nil {
			// Generate config for missing_tool with issue creation support
			missingToolConfig := make(map[string]any)

			// Add max if set
			if data.SafeOutputs.MissingTool.Max != nil {
				missingToolConfig["max"] = resolveMaxForConfig(data.SafeOutputs.MissingTool.Max, 0)
			}

			// Add issue creation config if enabled
			if data.SafeOutputs.MissingTool.CreateIssue {
				createIssueConfig := make(map[string]any)
				createIssueConfig["max"] = 1 // Only create one issue per workflow run

				if data.SafeOutputs.MissingTool.TitlePrefix != "" {
					createIssueConfig["title_prefix"] = data.SafeOutputs.MissingTool.TitlePrefix
				}

				if len(data.SafeOutputs.MissingTool.Labels) > 0 {
					createIssueConfig["labels"] = data.SafeOutputs.MissingTool.Labels
				}

				safeOutputsConfig["create_missing_tool_issue"] = createIssueConfig
			}

			safeOutputsConfig["missing_tool"] = missingToolConfig

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

Comment on lines 321 to +328
if data.SafeOutputs.PushToPullRequestBranch != nil {
safeOutputsConfig["push_to_pull_request_branch"] = generateMaxWithTargetConfig(
config := generateMaxWithTargetConfig(
data.SafeOutputs.PushToPullRequestBranch.Max,
1, // default max: 1
data.SafeOutputs.PushToPullRequestBranch.Target,
)
addStagedIfTrue(config, data.SafeOutputs.PushToPullRequestBranch.Staged)
safeOutputsConfig["push_to_pull_request_branch"] = config
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The new staged propagation for push_to_pull_request_branch is a behavior change but doesn't appear to be covered by unit tests (safe_outputs_config_generation_test.go currently only asserts staged for close_pull_request). Adding a focused test that sets PushToPullRequestBranch.Staged=true and asserts config.json includes "staged": true would prevent regressions like the one this PR is addressing.

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +37
if operationStr, ok := operationVal.(string); ok {
cfg.Operation = &operationStr
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

operation is accepted as any string and silently ignored if the YAML value isn't a string. Since downstream code treats unknown operations as "append" by default (see actions/setup/js/update_pr_description_helpers.cjs:updateBody), a typo like "apend" becomes a behavior change without feedback. Consider validating cfg.Operation against the supported set (replace/append/prepend[/replace-island if supported]) and emitting a compiler error or warning when invalid or wrong-typed.

Suggested change
if operationStr, ok := operationVal.(string); ok {
cfg.Operation = &operationStr
operationStr, ok := operationVal.(string)
if !ok {
updatePullRequestLog.Print("Invalid type for 'operation' in update-pull-request config: expected string")
return
}
switch operationStr {
case "append", "prepend", "replace", "replace-island":
cfg.Operation = &operationStr
default:
updatePullRequestLog.Print("Invalid value for 'operation' in update-pull-request config: " +
"expected one of 'append', 'prepend', 'replace', or 'replace-island'")

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] Semantic Function Clustering Analysis: Refactoring Opportunities in pkg/

3 participants