Skip to content

Refactor: Split compiler_activation_jobs.go into focused modules (827→362+476 lines)#14431

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/split-compiler-activation-jobs
Closed

Refactor: Split compiler_activation_jobs.go into focused modules (827→362+476 lines)#14431
Copilot wants to merge 2 commits intomainfrom
copilot/split-compiler-activation-jobs

Conversation

Copy link
Contributor

Copilot AI commented Feb 7, 2026

compiler_activation_jobs.go exceeded the 600-line maintainability guideline at 827 lines with mixed concerns (pre-activation validation + activation/main job orchestration).

Changes

Split into two focused files:

  • compiler_pre_activation_job.go (362 lines)

    • buildPreActivationJob() - membership checks, stop-time validation, reaction setup
    • extractPreActivationCustomFields() - custom job field extraction
    • Logger: workflow:compiler_pre_activation_job
  • compiler_activation_main_jobs.go (476 lines)

    • buildActivationJob() - timestamp checks, comments, issue locking
    • buildMainJob() - agent job setup, permissions, safe-outputs config
    • Logger: workflow:compiler_activation_main_jobs

Technical Details

  • Pure refactoring - zero functional changes
  • Helper methods remain in original locations (compiler_jobs.go, role_checks.go)
  • Test file (compiler_activation_jobs_test.go, 464 lines) unchanged - all tests pass without modification
  • Each file now within 300-500 line target range
Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Split compiler_activation_jobs.go into two focused files (821 lines → ~350 + ~470)</issue_title>
<issue_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 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 github/gh-aw#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

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Split compiler_activation_jobs.go into two focused files Refactor: Split compiler_activation_jobs.go into focused modules (827→362+476 lines) Feb 7, 2026
Copilot AI requested a review from pelikhan February 7, 2026 21:58
@pelikhan pelikhan closed this Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants