-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Description
The file pkg/workflow/compiler_orchestrator.go contains 1,077 lines, exceeding the 800-line guideline by 35%. This makes the file difficult to navigate and maintain. The file handles multiple distinct compilation phases that can be logically separated.
Current Issues
- File Size: 1,077 lines vs 800-line maximum guideline
- Mixed Responsibilities: Frontmatter parsing, engine setup, tools processing, workflow construction
- Long Functions: Multiple functions exceed 100 lines:
processToolsAndMarkdown: ~200+ linessetupEngineAndImports: ~200+ linesParseWorkflowFile: ~70+ lines
- Navigation Difficulty: Hard to find specific compilation logic
Suggested File Split
Split into 4 focused files (~250-300 lines each):
1. compiler_orchestrator_frontmatter.go
Responsibility: Frontmatter parsing and validation
parseFrontmatterAndPrintFailures()validateFrontmatterConfig()- Frontmatter result types
- Estimated lines: ~250
2. compiler_orchestrator_engine.go
Responsibility: Engine setup and configuration
setupEngineAndImports()processEngineDetection()- Engine result types
- Estimated lines: ~250
3. compiler_orchestrator_tools.go
Responsibility: Tools and markdown processing
processToolsAndMarkdown()extractMarkdownContent()processToolConfiguration()- Tools result types
- Estimated lines: ~300
4. compiler_orchestrator_workflow.go
Responsibility: Workflow data construction and orchestration
ParseWorkflowFile()(main orchestration)buildWorkflowData()- Core orchestration logic
- Estimated lines: ~250-300
Benefits
- Improved Navigation: Find specific compilation logic faster
- Better Maintainability: Smaller files are easier to understand
- Clearer Separation: Each file has single, clear responsibility
- Easier Testing: Test files can mirror the split structure
- Reduced Cognitive Load: Developers work with 250-300 line files vs 1077
Files Affected
Original file (to be split):
pkg/workflow/compiler_orchestrator.go(1,077 lines)
New files (to be created):
pkg/workflow/compiler_orchestrator_frontmatter.go(~250 lines)pkg/workflow/compiler_orchestrator_engine.go(~250 lines)pkg/workflow/compiler_orchestrator_tools.go(~300 lines)pkg/workflow/compiler_orchestrator_workflow.go(~250-300 lines)
Test file (may need updates):
pkg/workflow/compiler_orchestrator_test.go(678 lines, test-to-source ratio: 0.63)
Implementation Approach
Phase 1: Extract Helper Modules (Low Risk)
- Create new files with extracted functions
- Keep original file as orchestrator
- Run tests after each extraction
- Verify
make build && make testpasses
Phase 2: Refactor Large Functions (Medium Risk)
- Extract sub-functions from 200+ line functions
- Move to appropriate module files
- Maintain backward compatibility
Phase 3: Clean Up Orchestrator (Low Risk)
- Slim down main orchestrator file
- Remove duplicated code
- Final test verification
Success Criteria
- Original file reduced from 1,077 to ~250-300 lines
- 4 new files created with clear, focused responsibilities
- No functions exceed 100 lines in new files
- All existing tests pass without modification
- Test-to-source ratio maintained (current: 0.63)
-
make build && make testpasses -
make lintreports no issues -
make recompilesuccessfully regenerates workflows - No regression in compilation behavior
Reference Example
Use pkg/workflow/compiler_jobs.go (503 lines, score: 93/100) as a reference for ideal file structure and organization.
Estimated Effort
1 day (8 hours)
- 3 hours: Extract and create new files
- 2 hours: Refactor large functions into helpers
- 2 hours: Testing and verification
- 1 hour: Documentation and cleanup
Source
Extracted from Daily Compiler Code Quality Report #11729 - Analysis of compiler_orchestrator.go (2026-01-25)
Priority
Medium - File size exceeds guidelines significantly, but code quality is otherwise good (score: 80/100). Refactoring improves maintainability without urgent functional issues.
AI generated by Discussion Task Miner - Code Quality Improvement Agent
- expires on Feb 8, 2026, 2:04 PM UTC