Skip to content

refactor: split compiler_types.go grab-bag into workflow_data.go and safe_outputs_config.go#43071

Merged
pelikhan merged 3 commits into
mainfrom
copilot/refactor-semantic-function-clustering
Jul 3, 2026
Merged

refactor: split compiler_types.go grab-bag into workflow_data.go and safe_outputs_config.go#43071
pelikhan merged 3 commits into
mainfrom
copilot/refactor-semantic-function-clustering

Conversation

Copilot AI commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

pkg/workflow/compiler_types.go had grown to 835 lines mixing unrelated concerns: the Compiler type, the central WorkflowData domain struct, and five safe-output config types that belong alongside their extraction logic.

Changes

  • workflow_data.go (new) — extracts WorkflowData, its PinContext() method, and the three SkipIf*Config types it directly references
  • safe_outputs_config.go (prepended) — receives BaseSafeOutputConfig, SafeOutputsConfig, SafeOutputMessagesConfig, MentionsConfig, SecretMaskingConfig, co-locating them with the parsing logic that was already there
  • compiler_types.go (reduced) — retains only CompilerOption/With* constructors, FileCreationTracker, Compiler struct, NewCompiler, and its accessor methods; unused actionpins import removed

Pure mechanical split — no logic changes.

…safe_outputs_config.go

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor semantic function clustering in compiler_types.go refactor: split compiler_types.go grab-bag into workflow_data.go and safe_outputs_config.go Jul 3, 2026
Copilot AI requested a review from pelikhan July 3, 2026 03:19
@pelikhan
pelikhan marked this pull request as ready for review July 3, 2026 03:21
Copilot AI review requested due to automatic review settings July 3, 2026 03:21
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 3, 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.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

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

This PR refactors pkg/workflow/compiler_types.go by splitting out two clusters of types into more focused files: core workflow domain data (WorkflowData + related skip-if configs) and safe-output configuration types, aligning type definitions with their primary parsing/extraction logic.

Changes:

  • Introduced pkg/workflow/workflow_data.go containing WorkflowData, PinContext(), and SkipIf*Config types.
  • Moved safe-output config types (e.g., SafeOutputsConfig, MentionsConfig, SecretMaskingConfig) into the top of pkg/workflow/safe_outputs_config.go.
  • Reduced pkg/workflow/compiler_types.go to compiler construction/options and removed the unused actionpins import.
Show a summary per file
File Description
pkg/workflow/workflow_data.go New home for WorkflowData and closely-related workflow frontmatter domain structs/methods.
pkg/workflow/safe_outputs_config.go Co-locates safe-output configuration type definitions with the existing parsing/extraction code.
pkg/workflow/compiler_types.go Slimmed down to compiler types/options; removes moved domain/config definitions.

Review details

Tip

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

Comments suppressed due to low confidence (1)

pkg/workflow/compiler_types.go:462

  • Dangling comment at end of file refers to SkipIfMatchConfig, but the type was moved to workflow_data.go. This leaves an orphaned/misleading comment in compiler_types.go after the refactor.
// SkipIfMatchConfig holds the configuration for skip-if-match conditions

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Low

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (388 new lines in pkg/workflow/) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/43071-split-compiler-types-into-semantic-files.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI could not infer (deciders, timeline, organizational constraints), refine the decision rationale, and confirm the alternatives are accurate
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-43071: Split compiler_types.go into Semantic Files

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 43071-split-compiler-types-into-semantic-files.md for PR #43071).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · 70.5 AIC · ⌖ 12.6 AIC · ⊞ 8.5K ·
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.

Review: Pure mechanical file split ✅

This is a clean refactor with no logic changes — splitting an 835-line grab-bag into three focused files. All imports in the new files are used and correct; getDefaultGHHost() referenced in PinContext() is available within the same package.

One minor nit (non-blocking, inline): add a blank line between SkipIfCheckFailingConfig and WorkflowData in workflow_data.go — the new file is a good chance to tidy what the original skipped.

No logic issues, no correctness concerns.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 68 AIC · ⌖ 5.96 AIC · ⊞ 4.9K

Branch string // optional branch name to check (defaults to triggering ref or PR base branch)
AllowPending bool // if true, pending/in-progress checks are not treated as failing (default: treat pending as failing)
}
type WorkflowData struct {

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.

Missing blank line between SkipIfCheckFailingConfig and WorkflowData struct definitions. The original compiler_types.go also lacked it, but extracting into a new file is a good opportunity to fix:\n\ngo\n}\n\n// WorkflowData holds all compiler-time data for a single workflow.\ntype WorkflowData struct {\n\n\n@copilot please address this.

@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.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • patchdiff.githubusercontent.com
  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "patchdiff.githubusercontent.com"
    - "proxy.golang.org"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer · 108.8 AIC · ⌖ 5.38 AIC · ⊞ 5.4K
Comment /review to run again

@@ -460,376 +459,3 @@ func (c *Compiler) GetSharedActionResolver() *ActionResolver {
}

// SkipIfMatchConfig holds the configuration for skip-if-match conditions

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.

Orphaned doc comment at EOF — the type it annotated was moved to workflow_data.go.

💡 Details

Line 461 is:

// SkipIfMatchConfig holds the configuration for skip-if-match conditions

The SkipIfMatchConfig type was correctly moved to workflow_data.go (line 11), but this doc comment was left behind with no declaration following it. In Go, a comment immediately before a declaration becomes godoc for that declaration; a free-floating comment at EOF implies to every future reader (and refactoring tools) that a declaration is missing or was accidentally deleted.

Fix: Delete line 461 from compiler_types.go.

Branch string // optional branch name to check (defaults to triggering ref or PR base branch)
AllowPending bool // if true, pending/in-progress checks are not treated as failing (default: treat pending as failing)
}
type WorkflowData struct {

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.

Missing blank line between SkipIfCheckFailingConfig and WorkflowData type declarations.

💡 Details

SkipIfCheckFailingConfig's closing } is on line 33 and type WorkflowData struct opens immediately on line 34 with no blank separator. Go convention (per gofmt and the official style guide) requires a blank line between top-level declarations. The missing blank line makes a 150-field struct visually run together with the preceding type, making the file harder to scan.

Fix: Add a blank line between the two type declarations.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Summary

Applied /codebase-design — no blocking issues. This is a clean, well-scoped refactor.

5 inline suggestions:

  1. workflow_data.go:1 — Add a file-level doc comment describing WorkflowData's role as the central DTO.
  2. workflow_data.go:11SkipIf*Config types are not co-located with their parser (stop_after.go) — clarify the placement intent.
  3. workflow_data.go:34 — Missing blank line between SkipIfCheckFailingConfig and WorkflowData.
  4. workflow_data.go:188WorkflowData's 155+ fields have no internal section grouping; safe_outputs_config.go sets a higher standard.
  5. safe_outputs_config.go:16 — New types land before the first // ======== banner rather than inside a labelled section.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 161.4 AIC · ⌖ 7.51 AIC · ⊞ 6.6K ·
Comment /matt 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.

Skills-Based Review 🧠

Applied /codebase-design — commenting (no blocking issues) on minor navigability improvements.

📋 Key Themes & Highlights

Key Themes

  • Inconsistent co-location: SafeOutputsConfig and its parser are now co-located in safe_outputs_config.go (✅ great), but SkipIf*Config types land in workflow_data.go while their parsing lives in stop_after.go — the principle is applied unevenly.
  • Missing navigation aids: WorkflowData is the central DTO for the entire compiler but has no file-level doc comment or internal section headers; safe_outputs_config.go sets a higher standard with its ## Schema Generation Architecture block.
  • Section banner ordering: New types in safe_outputs_config.go are inserted before the first existing // ======== banner rather than inside a clearly labelled section.
  • Minor Go style nit: No blank line between SkipIfCheckFailingConfig and WorkflowData (pre-existing in main, but this PR is the right time to fix it).

Positive Highlights

  • ✅ The split is purely mechanical — diff confirms no logic changes.
  • ✅ Excellent PR description: lists exactly what moved where and why.
  • ✅ Co-locating SafeOutputsConfig types with extractSafeOutputsConfig is exactly the right instinct.
  • ✅ Removing the now-unused actionpins import from compiler_types.go is a clean bonus.
  • compiler_types.go is now focused: options, Compiler struct, constructor, accessors — single responsibility achieved.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 161.4 AIC · ⌖ 7.51 AIC · ⊞ 6.6K
Comment /matt to run again

Branch string // optional branch name to check (defaults to triggering ref or PR base branch)
AllowPending bool // if true, pending/in-progress checks are not treated as failing (default: treat pending as failing)
}
type WorkflowData struct {

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.

[/codebase-design] Missing blank line between SkipIfCheckFailingConfig and WorkflowData — Go convention uses a blank line to visually separate top-level declarations.

💡 Suggested fix

Add a blank line after the closing } of SkipIfCheckFailingConfig (line 33) before type WorkflowData struct:

	 AllowPending bool     // ...
}

type WorkflowData struct {

This is consistent with the rest of the file and is what gofmt-adjacent tooling (e.g. goimports) expects.

@copilot please address this.

ModelPolicyAllowed []string // merged models.allowed policy list (union across imports + main frontmatter)
ModelPolicyBlocked []string // merged models.blocked policy list (union across imports + main frontmatter)
ActionPinMappings map[string]string // action-pin redirect table from aw.json action_pins: maps "owner/repo@version" → "owner/repo@version"
}

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.

[/codebase-design] WorkflowData has 155+ fields in a flat struct with no internal section grouping, while safe_outputs_config.go uses // ======== banners to separate logical groups. Adding section headers here would make this 236-line file much easier to navigate.

💡 Suggested grouping

Logical groups that already exist but are invisible:

  • Identity (Name, WorkflowID, FrontmatterName, FrontmatterEmoji, ...)
  • Triggers & Skip conditions (SkipIfMatch, SkipIfNoMatch, SkipIfCheckFailing, SkipRoles, SkipBots, ...)
  • Execution / runtime (RunsOn, Container, Services, Tools, AI, EngineConfig, ...)
  • Safe-outputs (SafeOutputs, MCPScripts, ...)
  • Caches / performance (CachedPermissions, CachedConcurrencyGroupExpr, CachedAllowedDomainsStr, ...)
  • Action pinning (ActionCache, ActionResolver, ActionPinWarnings, ActionPinMappings, ...)

This is a documentation-only change with no logic impact.

@copilot please address this.

"github.com/github/gh-aw/pkg/parser"
)

// SkipIfMatchConfig holds the configuration for skip-if-match conditions

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.

[/codebase-design] The SkipIf*Config types live in workflow_data.go but their parsing logic lives in stop_after.go. The PR co-locates SafeOutputsConfig with its parser (good!), but applies a different principle here. Consider whether SkipIfMatchConfig, SkipIfNoMatchConfig, and SkipIfCheckFailingConfig belong in stop_after.go — or at minimum, add a file-header comment explaining why they live here.

💡 Options to consider

Option A — Move SkipIf*Config to stop_after.go (co-location with parsing):

  • Matches the co-location principle used for safe_outputs_config.go
  • stop_after.go already has extractSkipIfMatchFromOn, processSkipIfMatchConfiguration, etc.

Option B — Keep them in workflow_data.go but add a comment:

// SkipIfMatchConfig, SkipIfNoMatchConfig, and SkipIfCheckFailingConfig are trigger-filter
// types referenced directly by WorkflowData. Their parsing logic is in stop_after.go.

Either is fine — the key is that the choice is intentional and discoverable.

@copilot please address this.

@@ -0,0 +1,236 @@
package workflow

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.

[/codebase-design] workflow_data.go has no file-level architecture comment, while safe_outputs_config.go has a rich ## Schema Generation Architecture block (lines 168–207) explaining how the pieces fit together. A brief doc comment on this file explaining the role of WorkflowData (central data transfer object populated by the compiler and consumed by all job builders) would make the codebase more navigable for new contributors.

💡 Example
// Package workflow provides the compiler that transforms markdown workflow
// definitions into GitHub Actions YAML.
//
// This file defines WorkflowData, the central data transfer object that carries
// the fully-parsed state of a single workflow through the compilation pipeline.
// It is populated by the Compiler (compiler_types.go) and consumed by all
// job builders (compiler_jobs.go, compiler_activation_job_builder.go, etc.).
//
// SkipIfMatchConfig, SkipIfNoMatchConfig, and SkipIfCheckFailingConfig are
// also here because they are direct fields of WorkflowData; their parsing
// logic lives in stop_after.go.
package workflow

@copilot please address this.


var safeOutputsConfigLog = logger.New("workflow:safe_outputs_config")

// ========================================

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.

[/codebase-design] The // ======== banners (lines 16–18 and 168–170) were already present in safe_outputs_config.go on main. Adding the types above line 16 puts them before the first banner rather than inside a named section. Consider adding an explicit // Safe Output Configuration Types banner at the very top of the new block (or restructuring so types sit inside the existing banner) for visual parity with the extraction section below.

💡 Example
var safeOutputsConfigLog = ...

// ========================================
// Safe Output Configuration Types
// ========================================

// BaseSafeOutputConfig ...
type BaseSafeOutputConfig struct {

The new types currently land before the first banner — the banner that was already there — which means the section header appears to belong to the types below it rather than the new ones.

@copilot please address this.

@pelikhan
pelikhan merged commit 236beb0 into main Jul 3, 2026
29 checks passed
@pelikhan
pelikhan deleted the copilot/refactor-semantic-function-clustering branch July 3, 2026 03:45
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] Semantic function clustering analysis: split the compiler_types.go grab-bag; codebase otherwise well-factored

3 participants