Skip to content

refactor: address 5 semantic function clustering findings in pkg/workflow#22503

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/refactor-semantic-function-clustering-5d3ab581-8db5-4b7a-b55b-d38174cd72a3
Closed

refactor: address 5 semantic function clustering findings in pkg/workflow#22503
Copilot wants to merge 4 commits intomainfrom
copilot/refactor-semantic-function-clustering-5d3ab581-8db5-4b7a-b55b-d38174cd72a3

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

Semantic analysis identified five code quality issues in pkg/workflow: a undocumented dual safe-output config system, a staged field gap across ~37 handlers, a misplaced utility function, undifferentiated sibling functions, and a mixed-concern file.

Changes

Issue 1 — Cross-reference dual config-generation paths (High)

Added architecture comments to both safe_outputs_config_generation.go and compiler_safe_outputs_config.go documenting that two parallel paths produce safe-output handler config (GH_AW_SAFE_OUTPUTS_CONFIG_PATH vs GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG) and that both must be updated when adding new handler fields.

Issue 2 — staged field gap in old config path (Medium)

compiler_safe_outputs_config.go emits staged for all 39 handlers; safe_outputs_config_generation.go emitted it for only 2. Added staged propagation to all ~37 remaining handler blocks so GH_AW_SAFE_OUTPUTS_CONFIG_PATH stays in sync with GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG.

// Before: only close_pull_request and dispatch_repository emitted staged
if data.SafeOutputs.CreateIssues != nil {
    config := generateMaxWithAllowedLabelsConfig(...)
    safeOutputsConfig["create_issue"] = config  // staged silently dropped
}

// After: all handlers propagate staged
if data.SafeOutputs.CreateIssues != nil {
    config := generateMaxWithAllowedLabelsConfig(...)
    if data.SafeOutputs.CreateIssues.Staged {
        config["staged"] = true
    }
    safeOutputsConfig["create_issue"] = config
}

Issue 3 — safeUintToInt moved to map_helpers.go (Low)

Removed the thin safeUintToInt(u uint) int wrapper from frontmatter_extraction_metadata.go and placed it alongside safeUint64ToInt, parseIntValue, ConvertToInt, and ConvertToFloat in map_helpers.go where the full integer conversion family belongs.

Issue 4 — parseIntValue vs ConvertToInt documented (Low)

Added doc comments to both functions in map_helpers.go clarifying the intended split:

  • parseIntValue(int, bool) return, handles int/int64/uint64/float64, no string support; use when explicit success/failure signalling is needed
  • ConvertToIntint return (0 on failure), adds string parsing via strconv.Atoi, no uint64; use when silent fallback is acceptable or input may be a string

Issue 5 — update_entity_helpers.go split evaluation (Low)

Added a Future Refactoring Consideration comment noting that parseUpdateIssuesConfig, parseUpdateDiscussionsConfig, and parseUpdatePullRequestsConfig could migrate to per-entity files (matching update_release.go), but deferred given the shared generic helpers justify the current grouping.

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 GO111MODULE 64/bin/go git 7433�� --show-toplevel go /usr/bin/git 55/001/test-frongit GO111MODULE 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 go /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel go ache/node/24.14.--show-toplevel 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 GOSUMDB GOWORK 64/bin/go GOINSECURE GOMOD erignore ache/go/1.25.0/xGO111MODULE env 755727/b391/_pkgGOINSECURE GO111MODULE 64/bin/go GOINSECURE b/gh-aw/cmd/gh-a-c GOMODCACHE go (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 add origin /usr/bin/git ****** node 64/bin/go git conf�� user.name Test User /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -json 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/ai-inference/git/ref/tags/v1 --jq .object.sha xterm-color 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/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha -json GO111MODULE ache/node/24.14.0/x64/bin/node GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet t-68�� sistency_WithImports1480045271/001/main.md -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha --stat 106feffaac4d9207733a38f48b00b89cb4f94eeb..HEAD /usr/bin/git add origin /usr/bin/git git rev-�� --show-toplevel /usr/bin/git /usr/bin/git -v 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 -json GO111MODULE 64/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 api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha REDACTED.os go /usr/bin/git lex-frontmatter-git GO111MODULE x_amd64/link git rev-�� --show-toplevel x_amd64/link /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel go /usr/bin/git -json GO111MODULE ache/go/1.25.0/x--show-toplevel git rev-�� --show-toplevel go 0/x64/bin/npm -json GO111MODULE ache/go/1.25.0/x--show-toplevel 0/x64/bin/npm (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 user.name Test User /usr/bin/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha user.email test@example.com /usr/bin/git d lint:cjs 64/bin/go git conf�� user.name Test User /usr/bin/git "prettier" --chegit sh 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel go /usr/bin/git artifacts-summargit GO111MODULE ache/go/1.25.0/x--show-toplevel git rev-�� --show-toplevel go /usr/bin/git 2906-28702/test-git GO111MODULE ache/go/1.25.0/x--show-toplevel 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 GOSUMDB GOWORK 64/bin/go GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/xGO111MODULE env 755727/b416/_pkgGOINSECURE GO111MODULE 64/bin/go GOINSECURE b/gh-aw/pkg/mathenv GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha 755727/b402/_pkgGOINSECURE GO111MODULE 64/bin/go GOINSECURE bagabas/go-udiffenv GOMODCACHE go env -tzP/zN1m-49v1YaGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE 755727/b402/impoGOPROXY (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha 755727/b413/_pkgGOINSECURE GO111MODULE 64/bin/go GOINSECURE b/gh-aw/pkg/loggenv GOMODCACHE go env sdFl/I7quLUnZ5FkGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE 755727/b413/imporev-parse (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 --get remote.origin.url (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 go /usr/bin/git git rev-�� nt/action/git/ref/tags/v999.999.999 git /usr/bin/git --show-toplevel 64/pkg/tool/linurev-parse /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 add origin (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel x_amd64/link /usr/bin/git git rev-�� -aw/git/ref/tags/v1.0.0 git /usr/bin/git --show-toplevel us/3YdcVDbgE0y5Grev-parse /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 -json GO111MODULE (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha --show-toplevel /usr/lib/git-core/git /usr/bin/git run --auto /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git bin 2>/dev/nullgit go /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 runs/20260323-202906-28702/test-2236452593/.github/workflows GO111MODULE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linux_amd64/vet env -json GO111MODULE /usr/bin/gcc GOINSECURE GOMOD GOMODCACHE gcc (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 user.name Test User /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel NREluUd/9VMISMi9rev-parse /usr/bin/git 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 runs/20260323-202906-28702/test-4293836715/.github/workflows GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go l GOMOD GOMODCACHE go env k/gh-aw/gh-aw GO111MODULE 5496331/b441/testutil.test GOINSECURE GOMOD GOMODCACHE 5496331/b441/testutil.test (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 -u origin /usr/bin/git git rev-�� --show-toplevel git /usr/bin/infocmp --git-dir go /usr/bin/git infocmp (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 x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 x_amd64/link GOINSECURE GOMOD GOMODCACHE x_amd64/link env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE EC/vKfaaJsUtRlxjremote.origin.url (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path 32e719668dfe2973GOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD erignore go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 sh -c npx prettier --c-errorsas GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go sh (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 GOMOD GOMODCACHE 0XVD7GS/mRL0tEU7status env plorer.md GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env y_with_repos_array_c3462151236/001 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.0.0 --jq .object.sha --show-toplevel BkAlss8NoqMJPDT0us/3YdcVDbgE0y5Gdx8vjli/alK5YuEvtest@example.com /usr/bin/git 64 GO111MODULE Name,createdAt,s--show-toplevel git rev-�� --show-toplevel go /usr/bin/git licyBlockedUsersgit GO111MODULE /opt/hostedtoolc--show-toplevel 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 64/bin/go GOINSECURE GOMOD GOMODCACHE i6ZQGuH4B-Y9 -c npx prettier --c-p GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go node (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 64/bin/go GOINSECURE GOMOD GOMODCACHE node /opt�� prettier --check 64/bin/go **/*.ts **/*.json --ignore-path golangci-lint (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE sh -c "prettier" --che-s GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE sh -c "prettier" --che-test.timeout=10m0s GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go /opt/hostedtoolcTest User (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 64/bin/go GOINSECURE GOMOD GOMODCACHE node /opt�� prettier --check 64/bin/go **/*.ts **/*.json --ignore-path 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 64/bin/go GOINSECURE GOMOD GOMODCACHE go env ithout_min-integrity927684111/001 GO111MODULE 64/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 ache/go/1.25.0/x64/pkg/tool/linux_amd64/link /usr/bin/git /ref/tags/v8 GO111MODULE 5496331/b412/imp--show-toplevel git rev-�� --show-toplevel sjEuzM2jqMmVy/_hIk68it_nH2gSrVWrsb/WrsaZCqRpvSTiHMe1VZH/oBSxT97sjEuzM2jqMmVy /usr/bin/gh licyBlockedUsersgit GO111MODULE (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 2236452593/.github/workflows GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 erignore go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build2555496331/b400/cli.test /tmp/go-build2555496331/b400/cli.test -test.testlogfile=/tmp/go-build2555496331/b400/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/xGO111MODULE env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name GOSUMDB GOWORK 64/bin/go GOINSECURE GOMOD erignore ache/go/1.25.0/xGO111MODULE env 755727/b437/_pkgGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)

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


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

- Add cross-reference comments between safe_outputs_config_generation.go
  and compiler_safe_outputs_config.go (Issue 1)
- Add `staged` field to all ~37 handler blocks in
  safe_outputs_config_generation.go (Issue 2, was only 2/39)
- Move safeUintToInt from frontmatter_extraction_metadata.go to
  map_helpers.go where the integer conversion family lives (Issue 3)
- Add clarifying doc comments to parseIntValue and ConvertToInt
  distinguishing their use cases (Issue 4)
- Add Future Refactoring Consideration comment to
  update_entity_helpers.go documenting the split-vs-keep evaluation (Issue 5)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/0e60275b-4a39-4f39-8587-69b973d606dd
Copilot AI changed the title [WIP] Refactor semantic function clustering analysis based on review refactor: address 5 semantic function clustering findings in pkg/workflow Mar 23, 2026
Copilot AI requested a review from pelikhan March 23, 2026 20:32
@pelikhan pelikhan marked this pull request as ready for review March 23, 2026 20:43
Copilot AI review requested due to automatic review settings March 23, 2026 20:43
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 and documents safe-outputs configuration generation and related helpers in pkg/workflow, primarily to keep the legacy config.json generation path aligned with the newer env-var-based handler manager config.

Changes:

  • Documented the dual safe-outputs config-generation architecture in both legacy and new paths.
  • Propagated the staged flag across the legacy safe-outputs config generator to match the newer compiler path.
  • Consolidated integer conversion helpers (safeUintToInt) and clarified intended usage of parseIntValue vs ConvertToInt via doc comments.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/workflow/update_entity_helpers.go Adds a “future refactoring” note about potentially splitting entity-specific parsers.
pkg/workflow/safe_outputs_config_generation.go Adds architecture docs and propagates staged into generated handler configs.
pkg/workflow/map_helpers.go Moves safeUintToInt here and adds/expands doc comments for int conversion helpers.
pkg/workflow/frontmatter_extraction_metadata.go Removes local safeUintToInt now that it lives in map_helpers.go.
pkg/workflow/compiler_safe_outputs_config.go Adds top-level documentation describing the “new path” safe-outputs handler config generation.

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

Comment on lines +45 to +49
// parseIntValue safely parses various numeric types to int.
// Returns (value, true) on success, (0, false) on unsupported type or overflow.
//
// Supported input types: int, int64, uint64, float64.
// Strings are NOT supported — use ConvertToInt for string-to-int conversion.
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.

parseIntValue’s updated docstring claims it returns (0,false) on overflow, but the implementation doesn’t check overflow for int64 or float64 conversions (both can overflow int on 32-bit targets like wasm, and float64→int is implementation-defined when out of range). Add explicit range checks (and handle NaN/Inf) and return (0,false) on overflow, or adjust the comment to match current behavior.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

Hey @Copilot 👋 — thanks for driving this cleanup of pkg/workflow! The five-finding sweep is a great read: the staged-field gap fix (Issue 2) alone prevents silent config drift between the two safe-output config paths, and the safeUintToInt relocation into map_helpers.go makes the integer-conversion family much easier to discover.

One thing that would help this land cleanly:

  • Add tests for the staged propagation (Issue 2)safe_outputs_config_generation.go already has a rich test suite in safe_outputs_config_generation_test.go (18 test functions, table-driven with t.Run subtests and testify/assert). The ~37 handler blocks that now emit staged have no coverage for the new branch. A test that sets Staged: true on a handful of representative handler configs (e.g. CreateIssues, AddComments, ClosePullRequest) and asserts the resulting JSON map contains "staged": true would close the gap. The existing TestGenerateSafeOutputsConfigDispatchWorkflow is a good template — it calls generateSafeOutputsConfig, unmarshals the JSON, and asserts on specific keys.

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

In pkg/workflow/safe_outputs_config_generation_test.go, add a new table-driven test function called TestGenerateSafeOutputsConfig_StagedPropagation.

Test that the `staged` field is correctly propagated in the output of generateSafeOutputsConfig for at least the following handler types:
  - CreateIssues (maps to "create_issue" in the config)
  - AddComments (maps to "add_comment")
  - ClosePullRequest (maps to "close_pull_request")
  - CreatePullRequests (maps to "create_pull_request")

For each handler, define two sub-cases:
  1. Staged: true  → assert the parsed JSON map for that handler key contains "staged": true
  2. Staged: false → assert the parsed JSON map for that handler key does NOT contain the "staged" key (or it is false)

Follow the existing test style:
  - Use a `tests []struct{name string; data *WorkflowData; check func(*testing.T, map[string]any)}` table
  - Loop with t.Run(tt.name, func(t *testing.T) { result := generateSafeOutputsConfig(tt.data); ... })
  - Unmarshal result JSON with require.NoError and then run tt.check
  - Use testify/assert and testify/require for assertions

After writing the tests, run `make agent-finish` to verify build, tests, lint, and recompile all pass.

Generated by Contribution Check ·

@pelikhan
Copy link
Contributor

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