Problem
pkg/workflow/compiler_yaml_main_job.go:538–741 contains a single 203-line function generatePostAgentCollectionAndUpload that handles at least 8 distinct responsibilities:
- Engine output file collection and cleanup
- MCP logs path collection
- DIFC proxy log path collection
- MCPScripts log path collection
- Log parsing for
GITHUB_STEP_SUMMARY (multiple engines: main, MCP scripts, MCP gateway)
- Firewall log parsing
- Token usage summary generation
- AWF reflect summary generation
- Agent drain output collection
- Unified artifact upload
This violates the Single Responsibility Principle and creates maintenance challenges:
- New post-agent features are appended inline, growing the function further
- Unit testing individual collection or parsing steps is not possible without invoking the entire function
- The function signature requires all output paths to be passed in (
artifactPaths []string), forcing accumulation across unrelated concerns
Location
pkg/workflow/compiler_yaml_main_job.go, function generatePostAgentCollectionAndUpload, lines 538–741 (203 lines)
Recommended Refactoring
Extract cohesive groups into descriptively named helpers:
// collectArtifactPaths gathers all paths for the unified artifact upload.
func (c *Compiler) collectArtifactPaths(data *WorkflowData, engine CodingAgentEngine) []string
// generateSummarySteps emits all GITHUB_STEP_SUMMARY log-parsing steps.
func (c *Compiler) generateSummarySteps(yaml *strings.Builder, data *WorkflowData, engine CodingAgentEngine)
// generatePostAgentCollectionAndUpload orchestrates the above.
func (c *Compiler) generatePostAgentCollectionAndUpload(...) error {
artifactPaths = c.collectArtifactPaths(data, engine)
c.generateSummarySteps(yaml, data, engine)
c.generateArtifactUpload(yaml, data, artifactPaths, checkoutMgr)
return nil
}
Impact
- Severity: Medium (maintainability)
- Risk: High change frequency — new post-agent features are regularly added here
- Testing: Current structure makes regression testing difficult; refactoring enables per-helper tests
Validation
Estimated Effort: Medium
Generated by Sergo · Run §25243999835
Generated by Sergo - Serena Go Expert · ● 767.1K · ◷
Problem
pkg/workflow/compiler_yaml_main_job.go:538–741contains a single 203-line functiongeneratePostAgentCollectionAndUploadthat handles at least 8 distinct responsibilities:GITHUB_STEP_SUMMARY(multiple engines: main, MCP scripts, MCP gateway)This violates the Single Responsibility Principle and creates maintenance challenges:
artifactPaths []string), forcing accumulation across unrelated concernsLocation
pkg/workflow/compiler_yaml_main_job.go, functiongeneratePostAgentCollectionAndUpload, lines 538–741 (203 lines)Recommended Refactoring
Extract cohesive groups into descriptively named helpers:
Impact
Validation
Estimated Effort: Medium
Generated by Sergo · Run §25243999835