Skip to content

[Code Quality] Extract helper functions from generateCreateAwInfo in compiler_yaml.go #13242

@github-actions

Description

@github-actions

Description

The generateCreateAwInfo() function in pkg/workflow/compiler_yaml.go is 155 lines long, making it difficult to understand and test. The function builds the aw_info.json structure with multiple concerns mixed together.

Current State

  • File: pkg/workflow/compiler_yaml.go
  • Function: generateCreateAwInfo() (lines 348-502)
  • Size: 155 lines (exceeds 100-200 line guideline)
  • Complexity: Mixes engine config, network config, and metadata building

Suggested Changes

Extract three helper functions to separate concerns:

  1. buildEngineInfo() - Extract engine configuration building (~50 lines)

    • Model name, version, provider
    • Engine-specific settings
    • Tool configurations
  2. buildNetworkInfo() - Extract network configuration (~30 lines)

    • Allowed domains
    • Network permissions
    • Access restrictions
  3. buildRunMetadata() - Extract metadata collection (~40 lines)

    • GitHub context (repo, run ID, actor)
    • Workflow metadata
    • Runtime information

Files Affected

  • pkg/workflow/compiler_yaml.go - Refactor generateCreateAwInfo() function
  • pkg/workflow/compiler_yaml_test.go - Add tests for new helper functions

Success Criteria

  • Each helper function is 30-50 lines
  • generateCreateAwInfo() orchestrates, doesn't implement
  • All existing tests pass (currently 1,113 test lines)
  • Test coverage maintained at 1.89:1 ratio
  • aw_info.json structure remains unchanged

Source

Extracted from Daily Compiler Code Quality Report - 2026-02-02

Quote from report:

Extract helper functions in compiler_yaml.go

  • Issue: generateCreateAwInfo() is 155 lines
  • Focus areas:
    • Engine configuration building (50 lines → buildEngineInfo())
    • Network configuration (30 lines → buildNetworkInfo())
    • Metadata collection (40 lines → buildRunMetadata())

Priority

Medium - Second priority recommendation from compiler quality analysis. Improves readability of YAML generation code.

Benefits

  • Clearer separation: Each helper handles one concern
  • Easier testing: Can test engine, network, and metadata building independently
  • Better maintainability: Changes to one area don't affect others
  • Follows guidelines: Reduces function length to acceptable range

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 16, 2026, 9:16 AM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions