-
Notifications
You must be signed in to change notification settings - Fork 307
Description
The compiler_activation_jobs.go file has grown to 821 lines, exceeding the maintainability guideline of 600 lines for a single file. This impacts code navigation, increases cognitive load, and makes the file harder to maintain as the codebase evolves.
Problem
Current state:
compiler_activation_jobs.go: 821 lines (37% over guideline)- Functions: 4 major functions + helpers
- Largest function:
buildActivationJob()at 242 lines
Why this matters:
- File size impacts developer productivity (slower navigation, harder to understand)
- Mixed concerns: Pre-activation checks AND activation/main job building in same file
- Approaching the "hard limit" where refactoring becomes mandatory
- Trend: File size growing over time as features added
Suggested Changes
Split into two focused files of ~350-470 lines each:
File 1: compiler_pre_activation_job.go (~350 lines)
Responsibility: Pre-activation checks before main workflow execution
// Functions to move here:
- buildPreActivationJob()
- extractPreActivationCustomFields()
- Membership check helpers
- Stop-time validation logicRationale: Pre-activation is a distinct phase focused on validation and permission checks.
File 2: compiler_activation_main_jobs.go (~470 lines)
Responsibility: Activation and main job orchestration
// Functions to move here:
- buildActivationJob()
- buildMainJob()
- Reaction step builders
- Lock-for-agent step builders
- Compute-text step buildersRationale: Activation and main job building share common concerns (reactions, locks, outputs).
Files Affected
- Split source:
pkg/workflow/compiler_activation_jobs.go(821 lines → DELETE) - New file 1:
pkg/workflow/compiler_pre_activation_job.go(~350 lines) - New file 2:
pkg/workflow/compiler_activation_main_jobs.go(~470 lines) - Update tests:
pkg/workflow/compiler_activation_jobs_test.go(may need split too) - Update imports: Other compiler files importing these functions
Implementation Approach
Phase 1: Prepare (30 min)
- Create branch for refactoring
- Run baseline tests to ensure starting point is green
- Document current function exports
Phase 2: Split File (3-4 hours)
-
Create
compiler_pre_activation_job.go- Move
buildPreActivationJob()and related helpers - Update logger:
logger.New("workflow:compiler_pre_activation_job") - Add proper file documentation
- Move
-
Create
compiler_activation_main_jobs.go- Move
buildActivationJob()andbuildMainJob() - Update logger:
logger.New("workflow:compiler_activation_main_jobs") - Add proper file documentation
- Move
-
Delete
compiler_activation_jobs.go -
Update imports in dependent files:
compiler.gocompiler_jobs.go- Other files referencing these methods
Phase 3: Verify (1 hour)
- Run
make fmt- ensure code formatted - Run
make test-unit- verify all tests pass - Run
make lint- check for issues - Run
make agent-finish- complete validation
Phase 4: Tests (optional split, 1-2 hours)
If compiler_activation_jobs_test.go is also large (>500 lines), consider splitting:
compiler_pre_activation_job_test.gocompiler_activation_main_jobs_test.go
Success Criteria
- Two new files created with clear responsibilities
- Each file between 300-500 lines (ideal maintainability range)
- All tests pass (
make test-unit) - Code formatted and linted (
make agent-finish) - No functionality changes - pure refactoring
- Proper logger namespaces for each new file
- File documentation added explaining responsibilities
Priority
MEDIUM-HIGH - File is maintainable now but approaching hard limit. Better to refactor proactively.
Estimated Effort
1 day (6-8 hours including testing and validation)
Source
Extracted from Daily Compiler Code Quality Report - 2026-02-06 #14159
The report identified this as a Medium Priority action with the note: "Consider splitting into 2 files of ~350 and ~470 lines when making significant changes."
References
- §21755331004 - Analysis run
AI generated by Discussion Task Miner - Code Quality Improvement Agent
- expires on Feb 8, 2026, 9:05 PM UTC