-
Notifications
You must be signed in to change notification settings - Fork 472
refactor(workflow): split compiler_yaml_main_job.go into focused modules #44651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8aa83c9
Initial plan
Copilot 5db1361
refactor(workflow): split compiler_yaml_main_job.go into focused modules
Copilot 4f509c2
docs(adr): add draft ADR-44651 for splitting compiler_yaml_main_job.g…
github-actions[bot] 4ae943f
fix(compiler_yaml_checkout): correct doc comment for generateLegacyAg…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
docs/adr/44651-split-compiler-yaml-main-job-into-phase-modules.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # ADR-44651: Split compiler_yaml_main_job.go into Phase-Focused Modules | ||
|
|
||
| **Date**: 2026-07-10 | ||
| **Status**: Draft | ||
| **Deciders**: pelikhan, copilot-swe-agent | ||
|
|
||
| --- | ||
|
|
||
| ### Context | ||
|
|
||
| `pkg/workflow/compiler_yaml_main_job.go` had grown to 1265 lines spanning 23 methods across 5 distinct compilation phases: checkout, runtime setup, AI execution, post-agent cleanup, and orchestration. The single-file layout made targeted edits expensive because readers had to mentally filter across phases to locate a specific method, and navigating to a phase-specific bug required scrolling past unrelated code. The file had become a maintenance liability as the compiler's feature set expanded. | ||
|
|
||
| ### Decision | ||
|
|
||
| We will split the monolithic `compiler_yaml_main_job.go` into four phase-aligned files (`compiler_yaml_checkout.go`, `compiler_yaml_runtime_setup.go`, `compiler_yaml_ai_execution.go`, `compiler_yaml_post_agent.go`) within the same `package workflow`, reducing the orchestrator to a ~42-line phase dispatcher. No logic is changed and no imports are rewired — the split is purely mechanical to improve code navigability and reduce per-file cognitive load. | ||
|
|
||
| ### Alternatives Considered | ||
|
|
||
| #### Alternative 1: Add region comments and IDE navigation hints within the single file | ||
|
|
||
| Add structured comments (e.g. `// --- Phase 1: Checkout ---`) and rely on IDE symbol navigation to improve discoverability within the existing file. This avoids any file system change and keeps the full compilation flow visible in one scroll. It was rejected because it doesn't reduce file size or parallel-edit conflicts, and region comments are not a Go convention — they would require team discipline to maintain consistently. | ||
|
|
||
| #### Alternative 2: Extract into sub-packages (e.g. `workflow/phases/checkout`) | ||
|
|
||
| Move each phase into its own sub-package to enforce encapsulation at the language level. This would grant each phase a private namespace and prevent accidental cross-phase coupling. It was rejected because the methods share many unexported helpers, types, and the `Compiler` receiver from `package workflow`; extracting them would require either a large interface refactor or circular imports, making this a significantly larger and riskier change than a pure file split. | ||
|
|
||
| ### Consequences | ||
|
|
||
| #### Positive | ||
| - Each phase now lives in its own file, matching file name to responsibility and reducing per-file line count from ~1265 to ~250–500 lines. | ||
| - Parallel edits to different phases no longer require touching the same file, reducing merge conflicts in active development. | ||
| - Onboarding is faster: a developer investigating checkout behaviour can open `compiler_yaml_checkout.go` directly. | ||
|
|
||
| #### Negative | ||
| - The full end-to-end compilation flow is no longer readable in a single file; understanding the sequence now requires reading `compiler_yaml_main_job.go` plus the four phase files. | ||
| - All files remain in `package workflow`, so no encapsulation boundary is enforced — cross-phase coupling can still accumulate silently. | ||
|
|
||
| #### Neutral | ||
| - The `Compiler` method set grows across files, which is idiomatic Go but can be unexpected for developers coming from languages where a type's methods must be co-located. | ||
| - The `compiler_yaml_ai_execution.go` file absorbs two phases (3 and 4) and remains ~497 lines; a future split may be warranted if it grows further. | ||
|
|
||
| --- | ||
|
|
||
| *ADR created by [adr-writer agent]. Review and finalize before changing status from Draft to Accepted.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/codebase-design] Phase 3 (
generateEngineInstallAndPreAgentSteps) lives inai_execution.go, but it covers git credentials, MCP setup, and engine installation — none of which is AI execution. A future reader navigating to 'AI execution' code will land here and need to mentally separate the two phases.💡 Suggested rename or split
Consider either:
compiler_yaml_engine_setup_and_execution.goto reflect that it covers both setup and run phases.compiler_yaml_engine_setup.goand keep onlygenerateAgentRunStepsincompiler_yaml_ai_execution.go.Option 1 is the lower-effort fix and is consistent with the file-per-phase pattern established by the other new files.
@copilot please address this.