Skip to content

[Code Quality] Split compiler_activation_jobs.go into two focused files (821 lines → ~350 + ~470) #14423

@github-actions

Description

@github-actions

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 logic

Rationale: 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 builders

Rationale: 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)

  1. Create branch for refactoring
  2. Run baseline tests to ensure starting point is green
  3. Document current function exports

Phase 2: Split File (3-4 hours)

  1. Create compiler_pre_activation_job.go

    • Move buildPreActivationJob() and related helpers
    • Update logger: logger.New("workflow:compiler_pre_activation_job")
    • Add proper file documentation
  2. Create compiler_activation_main_jobs.go

    • Move buildActivationJob() and buildMainJob()
    • Update logger: logger.New("workflow:compiler_activation_main_jobs")
    • Add proper file documentation
  3. Delete compiler_activation_jobs.go

  4. Update imports in dependent files:

    • compiler.go
    • compiler_jobs.go
    • Other files referencing these methods

Phase 3: Verify (1 hour)

  1. Run make fmt - ensure code formatted
  2. Run make test-unit - verify all tests pass
  3. Run make lint - check for issues
  4. 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.go
  • compiler_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

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 8, 2026, 9:05 PM UTC

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions