Skip to content

refactor: split safe_outputs_generation.go (1549 lines) into focused modules#20296

Merged
pelikhan merged 2 commits intomainfrom
copilot/refactor-safe-outputs-generation
Mar 10, 2026
Merged

refactor: split safe_outputs_generation.go (1549 lines) into focused modules#20296
pelikhan merged 2 commits intomainfrom
copilot/refactor-safe-outputs-generation

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

pkg/workflow/safe_outputs_generation.go had grown to 1549 lines handling 4+ distinct concerns, making it hard to navigate, test, and extend.

Split into 6 focused modules

File Lines Responsibility
safe_outputs_config_generation.go 492 generateSafeOutputsConfig — transforms SafeOutputsConfig → JSON for MCP server
safe_outputs_config_helpers.go 290 resolveMaxForConfig, all generate* map builders, generateCustomJobToolDefinition
safe_outputs_state.go 250 Reflection-based state inspection: HasSafeOutputsEnabled, GetEnabledSafeOutputToolNames, checkAllEnabledToolsPresent, applyDefaultCreateIssue
safe_outputs_runtime.go 40 formatSafeOutputsRunsOn, formatDetectionRunsOn, usesPatchesAndCheckouts
safe_outputs_tools_filtering.go 468 generateFilteredToolsJSON, addRepoParameterIfNeeded
safe_outputs_dispatch.go 164 populateDispatchWorkflowFiles, generateDispatchWorkflowTool
safe_outputs_generation.go 7 Package comment redirecting to new files

Notes

  • All files under 500 lines; no file previously under this threshold was changed
  • Public API (exported function signatures) unchanged
  • No behavioral changes — pure structural refactor
  • safeOutputFieldMapping (reflection driver for HasSafeOutputsEnabled / GetEnabledSafeOutputToolNames) now lives in safe_outputs_state.go alongside the functions that consume it

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 origin 64/pkg/tool/linustatus git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git HEAD .cfg 64/pkg/tool/linu--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 GO111MODULE x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git ty-test.md GO111MODULE 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 bash /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git 40\} ature-branch.patrev-parse /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 (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha /tmp/go-build1298537183/b419/_pkg_.a -trimpath /opt/hostedtoolcache/node/24.14.0/x64/bin/node -p main -lang=go1.25 node /tmp�� /tmp/TestHashStability_SameInputSameOutput3976350795/001/stability-test.md resolved$ /opt/hostedtoolcache/node/24.14.0/x64/bin/node go1.25.0 -c=4 -nolocalimports node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel docker /usr/bin/git test/race-image:git go /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)
  • 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 -bool -buildtags nfig/composer/vendor/bin/bash -errorsas -ifaceassert -nilfunc /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -ato�� -bool -buildtags cal/bin/bash -errorsas -ifaceassert -nilfunc bash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha runs/20260310-014823-34822/test-259628496/.github/workflows stmain.go ache/node/24.14.0/x64/bin/node l om/aymanbagabas/rev-parse 64/bin/go bash t-25�� sistency_GoAndJavaScript214108935/001/test-empty-frontmatter.md ache/go/1.25.0/xGO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet 8971258/b390/_pkgit GO111MODULE 64/bin/go /opt/hostedtoolcache/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/v3 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel go /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel go /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 d -n 10 (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 64/pkg/tool/linux_amd64/vet /usr/bin/git om/davecgh/go-spgit om/davecgh/go-sprev-parse ache/go/1.25.0/x--show-toplevel git rev-�� --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile /usr/bin/git 2533061/b348/_pkgit (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 origin REDACTED ache/go/1.25.0/x64/bin/bash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -t security tnet/tools/bash OUTPUT -d 168.63.129.16 bash --no�� --noprofile 53 ache/go/1.25.0/x64/bin/bash ACCEPT (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 --noprofile (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 -v origin /home/REDACTED/.local/bin/bash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha 27 --log-level rgo/bin/bash --log-target auto k/_temp/ghcca-no--show-toplevel bash --no�� --noprofile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -t security ash OUTPUT -d 168.63.129.16 bash --no�� --noprofile owner k/_temp/ghcca-node/node/bin/bash 0 -j ACCEPT bash (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 command -v debian-sa1 > /dev/null && debian-sa1 1 1 manager_token_te-buildtags cal/bin/bash ion_test.go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha /tmp/gh-aw-test-runs/20260310-014823-34822/test-1730557616/.github/workflows rev-parse /usr/bin/gh "prettier" --chegit GOPROXY 64/bin/go gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq (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 Fj/loOf-cgjR6MKzrev-parse /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel go /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 f() { test "$1" = get && echo "******"; }; f get f() { test "$1" = get && echo "******"; }; f get k/_temp/ghcca-node/node/bin/bash (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel -tests /usr/bin/gh prettier --check 64/bin/go gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq /opt/hostedtoolcache/node/24.14.0/x64/bin/node ts_generation.gogit log 64/bin/go node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha 5129-39972/test-2384346990 git 0/x64/bin/node --show-toplevel go /usr/bin/git git t-ha�� ithub/workflows/ai-moderator.md git /usr/bin/git --show-toplevel go /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 --noprofile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha -json GO111MODULE 8537183/b398/fileutil.test GOINSECURE GOMOD GOMODCACHE 8537183/b398/fileutil.test e=/t�� 4823-34822/test-1191440973 GOPROXY (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 8537183/b424/_terev-parse /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet /usr/bin/bash -bool -buildtags /usr/bin/git bash (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 --show-toplevel infocmp /usr/bin/git xterm-color 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/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE de/node/bin/bash-importcfg GOINSECURE GOMOD GOMODCACHE go estl�� -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 git /home/REDACTED/.cargo/bin/bash --show-toplevel go /usr/bin/git bash --no�� --noprofile git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /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 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE ndor/bin/git GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 git /home/REDACTED/work/_temp/uv-python-dir/bash --show-toplevel go /usr/bin/git bash --no�� --noprofile git /usr/bin/git --show-toplevel x_amd64/vet /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 GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 git /opt/hostedtoolcache/uv/0.10.9/x86_64/bash --show-toplevel go /usr/bin/git bash --no�� --noprofile git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /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 GO111MODULE 0/x64/bin/bash GOINSECURE GOMOD GOMODCACHE go estl�� -json GO111MODULE 86_64/git GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 git /usr/local/sbin/bash --show-toplevel go /usr/bin/git bash --no�� --noprofile git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /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 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE 0/x64/bin/git GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 git /usr/local/.ghcup/bin/bash --show-toplevel go /usr/bin/git bash --no�� 5129-39972/test-2258850839/.github/workflows git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /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 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go estl�� -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 git /home/REDACTED/.config/composer/vendor/bin/bash --show-toplevel go /usr/bin/git bash --no�� 5129-39972/test-2258850839/.github/workflows git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /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 GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go estl�� -json GO111MODULE 64/bin/git GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 git /home/REDACTED/.dotnet/tools/bash --show-toplevel go /usr/bin/git bash --no�� --noprofile git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /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 npx prettier --cGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go sh -c ts_config_helpers.go node 64/bin/go tierignore git 64/bin/go go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --show-toplevel bash /usr/bin/git --noprofile 8537183/b383/_terev-parse 64/pkg/tool/linu--show-toplevel git rev-�� 40\} ster.patch /usr/bin/git kflow.test -importcfg ortcfg.link git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/a70c5eada06553e3510ac27f2c3bda9d3705bccb
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/a70c5eada06553e3510ac27f2c3bda9d3705bccb --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel git 0/x64/bin/node git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git 64/bin/bash 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 FETCH_HEAD^{commit} .cfg 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha matter-with-arrays.md GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 4097826274/.github/workflows GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha --show-toplevel go /usr/bin/git -json GO111MODULE p/bin/git git rev-�� --show-toplevel go /usr/bin/git 0a7cc0348eea8a9fgit GO111MODULE bin/bash 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 ts_generation.go GOCACHE 64/bin/go tierignore git 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -maxdepth 4 /usr/bin/git d -name bin git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/link 64/pkg/tool/linux_amd64/vet /tmp/go-build129git resolved$ /usr/bin/git 64/pkg/tool/linux_amd64/vet (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 ts_generation.go -e 64/bin/go 64/pkg/tool/linu/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet git 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha ts_generation.go log 64/bin/go -n1 --format=format:-atomic aaa6bb2d70a945e1-bool go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha ts_runtime.go c 64/bin/go - 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/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 ts_generation.go log 64/bin/go -d git 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha --show-toplevel node /usr/bin/git /tmp/TestHashConnode l /usr/bin/git git add initial.txt git /usr/bin/git --show-toplevel go /usr/bin/git git (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 --show-toplevel git /usr/bin/git --show-toplevel git 0/x64/bin/node git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /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 FETCH_HEAD^{commit} .cfg 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 -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env 312532b8:pkg/workflow/safe_outpuremote.origin.url GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha --show-toplevel go 0/x64/bin/npm -json GO111MODULE git 0/x64/bin/npm rev-�� --show-toplevel go /usr/bin/git 0a7cc0348eea8a9fgit GO111MODULE 0/x64/bin/node 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 GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ndor/bin/git GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion --show-toplevel go /usr/bin/git git rev-�� 319820110/.github/workflows git /usr/bin/git --show-toplevel ache/go/1.25.0/xrev-parse 0/x64/bin/node 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 GOSUMDB GOWORK 64/bin/go sh -c ts_dispatch.go node 64/bin/go tierignore git 64/bin/go go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOSUMDB GOWORK 64/bin/go node /hom�� ts_dispatch.go scripts/**/*.js 64/bin/go .prettierignore git 64/bin/go go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo /usr/bin/git AxoE/9RkUkKz-hqKgit -pack /usr/bin/git git rev-�� ]*:[[:space:]]*"(create_pull_request|push_to_pull_request_branch)" git /home/REDACTED/work/_temp/uv-python-dir/node --show-toplevel 8537183/b409/_terev-parse ache/node/24.14.--show-toplevel node (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build1298537183/b383/cli.test /tmp/go-build1298537183/b383/cli.test -test.testlogfile=/tmp/go-build1298537183/b383/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE 8971258/b355/importcfg /hom�� k/gh-aw/gh-aw/cmd/gh-aw/main.go **/*.cjs 64/bin/go **/*.json --ignore-path ../../../.pretti--noprofile /opt/hostedtoolcache/go/1.25.0/xGO111MODULE (http block)
    • Triggering command: /tmp/go-build451817090/b359/cli.test /tmp/go-build451817090/b359/cli.test -test.testlogfile=/tmp/go-build451817090/b359/testlog.txt -test.paniconexit0 -test.timeout=10m0s rev-�� --show-toplevel git /usr/bin/git HEAD erignore 0/x64/bin/node git rev-�� --show-toplevel 0/x64/bin/node /usr/bin/git sistency_GoAndJagit -parallel=4 /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 run lint:cjs 64/bin/go GOSUMDB GOWORK 64/bin/go sh -c ts_config_helpers.go node 64/bin/go neration git 64/bin/go go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name --show-toplevel 8537183/b370/importcfg /usr/bin/git k/gh-aw/gh-aw/ingit l ps git rev-�� c2eca5ada842f194bbb3194d..HEAD ps /usr/bin/git t -buildtags /usr/bin/git git (http block)

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


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

Split 1549-line safe_outputs_generation.go into 6 focused modules:
- safe_outputs_config_generation.go: main config generation (492 lines)
- safe_outputs_config_helpers.go: generate* helper functions (290 lines)
- safe_outputs_state.go: state inspection and validation (250 lines)
- safe_outputs_runtime.go: runner configuration (40 lines)
- safe_outputs_tools_filtering.go: tool enumeration/filtering (468 lines)
- safe_outputs_dispatch.go: dispatch workflow handling (164 lines)
- safe_outputs_generation.go: package comment only (7 lines)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor safe_outputs_generation.go into focused modules refactor: split safe_outputs_generation.go (1549 lines) into focused modules Mar 10, 2026
@pelikhan pelikhan marked this pull request as ready for review March 10, 2026 02:12
Copilot AI review requested due to automatic review settings March 10, 2026 02:12
@pelikhan pelikhan merged commit 8391f2a into main Mar 10, 2026
111 checks passed
@pelikhan pelikhan deleted the copilot/refactor-safe-outputs-generation branch March 10, 2026 02:16
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_outputs_generation.go by splitting safe-outputs generation logic into smaller, responsibility-focused modules to improve navigability and maintainability while keeping the external API stable.

Changes:

  • Split safe-outputs config generation, helpers, state inspection, runtime helpers, tool filtering, and dispatch-workflow logic into dedicated files.
  • Kept a small safe_outputs_generation.go as a package comment/redirect to the new modules.
  • Centralized reflection-based safe-outputs state inspection and static-tool presence validation.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/workflow/safe_outputs_config_generation.go Generates the safe-outputs runtime config JSON from WorkflowData.SafeOutputs.
pkg/workflow/safe_outputs_config_helpers.go Shared helper builders for per-tool config maps + custom safe-job tool schema generation.
pkg/workflow/safe_outputs_state.go Reflection-based “enabled” inspection + enabled-tool enumeration + static tool presence validation.
pkg/workflow/safe_outputs_runtime.go Runner selection helpers and detection of patch/checkout requirements.
pkg/workflow/safe_outputs_tools_filtering.go Filters static tools JSON to enabled tools, enhances descriptions, injects repo param, adds custom/dispatch tools.
pkg/workflow/safe_outputs_dispatch.go Dispatch-workflow file extension mapping + dispatch tool schema generation.
pkg/workflow/safe_outputs_generation.go Replaced prior monolith with a short module index comment.

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

You can also share your feedback on Copilot code review. Take the survey.

// state of a SafeOutputsConfig. It uses reflection to check which tool types
// are enabled without requiring a large switch statement.

var safeOutputReflectionLog = logger.New("workflow:safe_outputs_config_helpers_reflection")
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The logger name workflow:safe_outputs_config_helpers_reflection is misleading now that this code lives in the safe-outputs state module. Consider renaming the logger tag to match the new module (to keep log filtering/debugging intuitive).

Suggested change
var safeOutputReflectionLog = logger.New("workflow:safe_outputs_config_helpers_reflection")
var safeOutputReflectionLog = logger.New("workflow:safe_outputs_state_reflection")

Copilot uses AI. Check for mistakes.
"description": inputDef.Description,
"required": inputDef.Required,
}
if inputDef.Default != "" {
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

In the safe-jobs inputs loop, the condition if inputDef.Default != "" is incorrect because InputDefinition.Default is any (often nil when unset). This currently causes an unset default to be serialized as "default": null in the generated config JSON. Use a nil check (and preserve empty-string defaults) so that defaults are only emitted when explicitly provided.

Suggested change
if inputDef.Default != "" {
if inputDef.Default != nil {

Copilot uses AI. Check for mistakes.
// Create a copy of the tool to avoid modifying the original
enhancedTool := make(map[string]any)
maps.Copy(enhancedTool, tool)

Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

maps.Copy(enhancedTool, tool) is a shallow copy. Because inputSchema/properties are nested maps, later mutations (e.g., adding the repo parameter) will also mutate the original tool map from allTools, making the “avoid modifying the original” comment inaccurate and risking unintended side effects if allTools is reused. Consider deep-copying the nested maps you mutate (at least inputSchema and properties) or drop the copy/comment and mutate intentionally.

Suggested change
// Deep-copy nested maps that may be mutated (at least inputSchema and properties)
if inputSchema, ok := enhancedTool["inputSchema"].(map[string]any); ok {
newInputSchema := make(map[string]any, len(inputSchema))
for k, v := range inputSchema {
newInputSchema[k] = v
}
// If there is a properties map inside inputSchema, deep-copy it as well
if props, ok := inputSchema["properties"].(map[string]any); ok {
newProps := make(map[string]any, len(props))
for k, v := range props {
newProps[k] = v
}
newInputSchema["properties"] = newProps
}
enhancedTool["inputSchema"] = newInputSchema
}

Copilot uses AI. Check for mistakes.
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.

[file-diet] Refactor safe_outputs_generation.go (1549 lines) into focused modules

3 participants