Skip to content

Split pkg/workflow/awf_config.go into types / schema / build / policy files - #55496

Merged
pelikhan merged 4 commits into
mainfrom
copilot/deep-report-split-awf-config
Aug 24, 2026
Merged

Split pkg/workflow/awf_config.go into types / schema / build / policy files#55496
pelikhan merged 4 commits into
mainfrom
copilot/deep-report-split-awf-config

Conversation

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

pkg/workflow/awf_config.go had grown to 1,090 lines mixing schema validation, config construction, and model-policy resolution — the repo's 2nd-largest non-test Go file and under active churn. This splits it along those seams, matching the "one file per functionality" convention in pkg/workflow.

Pure code move: no logic changes. Verified by diffing sorted file contents before/after — the only deltas are the new per-file package/import/header blocks.

File layout

File Lines Contents
awf_config.go 377 Package doc header + AWFConfigFile and the AWF*Config types
awf_config_schema.go 92 //go:embed schema, cached compiled schema, validateAWFConfigJSON, normalizeTemplatableModelFallbackEnabled, buildAWFConfigSchemaURL
awf_config_build.go 546 BuildAWFConfigJSON + build/extract helpers (extractPlatformType, extractModelFallback, extractBoundedQueriesConfig, resolveAWFContainerAgentTimeoutMinutes, …)
awf_config_policy.go 101 resolveModelPolicyForAWFConfig, intersectModelPolicyRules, unionModelPolicyRules, splitDomainList

Doc references

  • pkg/workflow/README.md: BuildAWFConfigJSON row now points at awf_config_build.go. Type rows are unchanged since the types stayed put.
  • .github/skills/awf-release-integrator/SKILL.md: AWF integration file list extended with the three new files so release integration still covers all the mapping code.

Each new file carries a short header cross-referencing its siblings, e.g.:

// This file builds the AWF configuration file JSON from workflow data.
// See awf_config.go for the config file types, awf_config_schema.go for schema
// validation, and awf_config_policy.go for model policy and domain resolution.

Note: golint-custom still flags BuildAWFConfigJSON for length (339 lines), as it did before the move — decomposing that function is out of scope here and would stop this from being a mechanical, reviewable move.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Split awf_config.go into separate files for validation, construction, and resolution Split pkg/workflow/awf_config.go into types / schema / build / policy files Aug 24, 2026
Copilot AI requested a review from pelikhan August 24, 2026 19:47
@pelikhan
pelikhan marked this pull request as ready for review August 24, 2026 20:06
Copilot AI balanced review requested due to automatic review settings August 24, 2026 20:06
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #55496

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-24T00:00:00Z
review_event: COMMENT
top_themes:
  - mechanical refactor only
  - no changed-line correctness regressions found
  - sub-agent unavailable
files_reviewed:
  - .github/skills/awf-release-integrator/SKILL.md
  - pkg/workflow/README.md
  - pkg/workflow/awf_config.go
  - pkg/workflow/awf_config_build.go
  - pkg/workflow/awf_config_policy.go
  - pkg/workflow/awf_config_schema.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · pi · gpt54 · 6.36 AIC · ⌖ 7.77 AIC · ⊞ 7K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking issues found in the changed lines.

### Review notes

This appears to be a mechanical split of pkg/workflow/awf_config.go into build/schema/policy files, and the moved symbols still resolve from the same package without changed call sites. I also checked for duplicate definitions, changed exported symbol locations, and obvious missed test/doc references in the touched files; nothing actionable stood out.

The requested grumpy-coder sub-agent was unavailable in this environment, so that advisory pass was skipped.

🔎 Code quality review by PR Code Quality Reviewer · pi · gpt54 · 6.36 AIC · ⌖ 7.77 AIC · ⊞ 7K
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean structural refactor — no logic changes, and the file boundaries are well-chosen. Types stay in awf_config.go, construction in awf_config_build.go, schema validation in awf_config_schema.go, and policy/domain resolution in awf_config_policy.go. The shared awfConfigLog package-level variable remains accessible across all files. README and skill documentation are updated to match. LGTM.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet46 · 27.2 AIC · ⌖ 8.96 AIC · ⊞ 6.2K

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Splits the monolithic AWF configuration implementation into focused type, build, schema, and policy files.

Changes:

  • Moves existing logic into responsibility-specific files.
  • Updates generated API documentation and release-integration guidance.
  • Preserves package-level APIs and behavior.
Show a summary per file
File Description
.github/skills/awf-release-integrator/SKILL.md Adds the new AWF files to integration guidance.
pkg/workflow/README.md Updates the BuildAWFConfigJSON source path.
pkg/workflow/awf_config.go Retains AWF configuration types and logger.
pkg/workflow/awf_config_build.go Contains configuration construction and extraction logic.
pkg/workflow/awf_config_schema.go Contains schema embedding and validation.
pkg/workflow/awf_config_policy.go Contains model and domain policy helpers.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 6/6 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread pkg/workflow/README.md
| `artifact_manager.go` | `NewArtifactManager` | `func NewArtifactManager() *ArtifactManager` | NewArtifactManager creates a new artifact manager |
| `auto_update_workflow.go` | `GenerateAutoUpdateWorkflow` | `func GenerateAutoUpdateWorkflow(opts GenerateAutoUpdateWorkflowOptions) error` | GenerateAutoUpdateWorkflow generates or removes the agentic-auto-upgrade. |
| `awf_config.go` | `BuildAWFConfigJSON` | `func BuildAWFConfigJSON(config AWFCommandConfig) (string, error)` | BuildAWFConfigJSON generates a compact JSON config file for AWF from the provided command configuration. |
| `awf_config_build.go` | `BuildAWFConfigJSON` | `func BuildAWFConfigJSON(config AWFCommandConfig) (string, error)` | BuildAWFConfigJSON generates a compact JSON config file for AWF from the provided command configuration. |

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two small abstractions look like they can be collapsed back into the AWF builder without changing behavior. net: -28 lines possible.

Generated by ✂️ Ponytail Reviewer for #55496 · codex · mai10 · 13 AIC · ⌖ 2.06 AIC · ⊞ 18.3K
Comment /ponytail to run again

// resolveModelPolicyForAWFConfig applies policy precedence independently per list:
// allowed rules are narrowed using intersection with env policy, while blocked
// rules are widened using union with env policy.
func resolveModelPolicyForAWFConfig(workflowData *WorkflowData) ([]string, []string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pkg/workflow/awf_config_policy.go:34-96: yagni: a new policy helper file plus three one-call helpers for a single builder path. Inline the policy merge logic in BuildAWFConfigJSON and drop the extra layer.

return workflowData.SandboxConfig.Agent.Platform
}

// extractModelFallback returns an AWFModelFallbackConfig if the workflow has configured

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pkg/workflow/awf_config_build.go:425-531: yagni: eight one-call extractor helpers just to map one field into an AWF struct. Inline the few lines in BuildAWFConfigJSON and keep the builder local; the indirection adds churn without new behavior.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /codebase-design — requesting changes on one cross-file coupling issue introduced by the split.

📋 Key Themes & Highlights

Key Issue

  • Implicit cross-file logger dependency: awfConfigLog is declared in awf_config.go (the types file) but consumed by both awf_config_build.go and awf_config_schema.go. This is the one seam that didn't get cut cleanly — both new files silently rely on a package-level variable from a sibling file, which is exactly what file splits should eliminate. The fix is to move the logger declaration into awf_config_build.go (dominant user) and give awf_config_schema.go its own awfConfigSchemaLog with a scoped namespace.

Positive Highlights

  • ✅ Excellent split rationale: types / schema / build / policy maps cleanly onto the four distinct responsibilities
  • ✅ Every new file has a cross-reference header — easy to navigate
  • ✅ PR description is thorough: pre/post line counts, file table, doc reference updates all present
  • ✅ Skill and README updates are included in the same commit — nothing fell through

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet46 · 55.5 AIC · ⌖ 10 AIC · ⊞ 7.6K
Comment /matt to run again

Comments that could not be inline-anchored

pkg/workflow/awf_config_build.go:791

[/codebase-design] awfConfigLog is declared in awf_config.go (the types file) but used here — a reader of this file cannot see where the logger comes from. The split aimed to make each file self-contained, but the logger still silently leaks across the seam.

<details>
<summary>💡 Suggested fix</summary>

Move awfConfigLog out of awf_config.go (types-only) and into awf_config_build.go, which owns the majority of log calls:

// awf_config_build.go
var awfConfigLog = logger.Ne</details>

<details><summary>pkg/workflow/awf_config_schema.go:27</summary>

**[/codebase-design]** `getCompiledAWFConfigSchema` uses `awfConfigLog` which is declared in a different file (`awf_config.go`). This creates a hidden cross-file dependency that breaks the &quot;each file is self-contained&quot; goal of the split.

&lt;details&gt;
&lt;summary&gt;💡 Suggested fix&lt;/summary&gt;

Either move the logger declaration to this file (see the comment on `awf_config_build.go`), or introduce a local `awfConfigSchemaLog`:

```go
var awfConfigSchemaLog = logger.New(&quot;workflow:awf_config_schema&quot;)

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

gh-aw-pr-sous-chef
@copilot PR Sous Chef triage: this PR still needs a forward-progress pass before maintainer investigation is likely to be productive.

Please do one focused follow-up pass:

  • address the current blocking github-actions review and any remaining reviewer feedback directly in the PR threads
  • refresh the branch if needed and use the pr-finisher skill before handing back for review
  • the blocked workflow approvals for this head were handled in this run; no extra workflow action is needed unless new commits land

Run: https://github.com/github/gh-aw/actions/runs/32774702076

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 25.7 AIC · ⌖ 8.08 AIC · ⊞ 8.7K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

gh-aw-pr-sous-chef
@copilot PR Sous Chef triage: this PR still needs a forward-progress pass before maintainer investigation is likely to be productive.
...

Follow-up pass done:

  • Blocking /codebase-design review: awfConfigLog now lives in awf_config_build.go (its dominant user) and awf_config_schema.go has its own scoped awfConfigSchemaLog (workflow:awf_config_schema), so neither new file depends on a logger declared in the types file.
  • Reviewer note on stale docs: updated the awf_config.go references in docs/adr/34693-*, docs/adr/35286-*, and docs/adr/35694-* to awf_config_build.go.

Build passes and the AWF config tests are green; golint-custom still reports only the pre-existing BuildAWFConfigJSON length warning.

Copilot AI requested a review from gh-aw-bot August 24, 2026 20:52
@pelikhan
pelikhan merged commit 0093896 into main Aug 24, 2026
33 of 34 checks passed
@pelikhan
pelikhan deleted the copilot/deep-report-split-awf-config branch August 24, 2026 23:04
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.5

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.

[deep-report] Split pkg/workflow/awf_config.go (1,090 lines) into schema-validation / config-build / policy-resolution files

4 participants