Skip to content

Refactor compiler job assembly - #54847

Merged
pelikhan merged 2 commits into
mainfrom
copilot/fix-9919-1036865607-9d329637-b18c-49f5-897f-c051e2794839
Aug 22, 2026
Merged

Refactor compiler job assembly#54847
pelikhan merged 2 commits into
mainfrom
copilot/fix-9919-1036865607-9d329637-b18c-49f5-897f-c051e2794839

Conversation

Copilot AI commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

buildJobs had grown into a large orchestration function, making compiler_jobs.go harder to read and below the Daily Compiler Quality threshold. This refactor splits job assembly into focused phases without changing generated workflow behavior.

  • Job orchestration

    • Keep buildJobs as the high-level sequence.
    • Move distinct phases into helper methods for activation/main jobs, safe outputs/evals jobs, custom jobs, and finalization.
  • Evals job construction

    • Add buildEvalsJobWrapper to isolate evals job creation and registration.
    • Add focused test coverage for the wrapper adding the evals job.
activationJobCreated, err := c.buildActivationAndMainJobs(data, frontmatter, lockFilename)
if err != nil {
	return err
}

if err := c.buildSafeOutputsAndEvalsJobs(data, markdownPath); err != nil {
	return err
}

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Copilot Request Refactor compiler job assembly Aug 22, 2026
Copilot AI requested a review from pelikhan August 22, 2026 15:27
@pelikhan
pelikhan marked this pull request as ready for review August 22, 2026 15:27
Copilot AI balanced review requested due to automatic review settings August 22, 2026 15:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors compiler job assembly into focused phases while preserving workflow generation behavior.

Changes:

  • Splits buildJobs orchestration into focused helper methods.
  • Adds an evals-job construction and registration wrapper.
  • Tests evals-job registration.
Show a summary per file
File Description
pkg/workflow/compiler_jobs.go Extracts job assembly phases and finalization helpers.
pkg/workflow/evals_job_test.go Verifies the evals wrapper registers its job.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Completed PR review with no actionable findings; no GitHub review comments or final review were emitted.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #54847

@github-actions

github-actions Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #54847 does not have the 'implementation' label and has only 89 new lines of code in business logic directories (threshold is 100).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-22T00:00:00Z
review_event: COMMENT
top_themes:
  - no actionable issues found in refactor-only split
  - wrapper test covers evals job registration path
files_reviewed:
  - pkg/workflow/compiler_jobs.go
  - pkg/workflow/evals_job_test.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 3.16 AIC · ⌖ 6.72 AIC · ⊞ 7K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactor: Compiler Job Assembly — COMMENT

The refactor cleanly decomposes buildJobs into focused helper methods with consistent error wrapping. No correctness or security issues found.

One non-blocking suggestion (see inline): finalizeBuiltJobs should carry a short doc comment explaining the ordering constraints of its three finalization passes, since the original explanatory comments were removed during extraction.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 20.4 AIC · ⌖ 9.04 AIC · ⊞ 6.2K

// finalizeBuiltJobs applies final dependency, permission, and token-reference passes.
func (c *Compiler) finalizeBuiltJobs(data *WorkflowData) error {
if err := c.applyBuiltinJobAugmentations(data); err != nil {
return fmt.Errorf("built-in job needs augmentations could not be applied: %w. Check that jobs referenced in needs actually exist in the workflow", err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ordering constraints for the three finalization passes were removed along with their explanatory comments. These passes have non-obvious sequencing requirements:

  • ensureConclusionIsLastJob must run after all custom jobs exist
  • ensureOTLPOIDCJobPermissions / ensureDriveMemoryJobPermissions must run per-job after all jobs are created (job-level permissions override workflow-level)
  • validateSafeOutputStepTokenReferences catches a runtime-silent empty-token bug and must run last

Consider adding a brief doc comment on finalizeBuiltJobs explaining these ordering constraints so future contributors do not inadvertently reorder the passes.

@copilot please address this.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /codebase-design and /tdd — approving with minor suggestions.

📋 Key Themes & Highlights

Key Themes

  • Missing doc comment: resolveSafeOutputActionSchemas lacks the doc comment that every other new helper has — a small but real consistency gap.
  • Test coverage: The new TestBuildEvalsJobWrapperAddsJob test covers the happy path only; a nil-Evals no-op test would lock in the early-return branch.

Positive Highlights

  • ✅ Mechanical, order-preserving extraction — zero behaviour change risk.
  • ✅ All extracted helpers have clear, consistent doc comments (except one).
  • buildEvalsJobWrapper is a clean "build + register" deep module — one public interface, rich interior.
  • ✅ New test correctly asserts job registration, not just absence of error.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 31.5 AIC · ⌖ 9.95 AIC · ⊞ 7.6K
Comment /matt to run again

return nil
}

func (c *Compiler) resolveSafeOutputActionSchemas(data *WorkflowData, markdownPath string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] resolveSafeOutputActionSchemas is the only extracted helper without a doc comment, making it inconsistent with the other new methods and slightly harder to navigate.

💡 Suggested doc comment
// resolveSafeOutputActionSchemas resolves custom safe-output action schemas early
// so that tool schemas derived from action.yml are available when buildMainJobWrapper
// generates MCP tool metadata. No-op when no custom safe-output actions are configured.
func (c *Compiler) resolveSafeOutputActionSchemas(data *WorkflowData, markdownPath string) {

@copilot please address this.

require.True(t, exists)
assert.Equal(t, string(constants.EvalsJobName), job.Name)
assert.Contains(t, job.Needs, string(constants.AgentJobName))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] TestBuildEvalsJobWrapperAddsJob tests the happy path well, but the error paths in buildEvalsJobWrapper — when buildEvalsJob returns an error, or when jobManager.AddJob fails due to a duplicate job name — have no coverage.

💡 Suggested additional tests
func TestBuildEvalsJobWrapperNilEvalsIsNoop(t *testing.T) {
    compiler := NewCompiler()
    data := &WorkflowData{AI: "copilot"} // no Evals set
    err := compiler.buildEvalsJobWrapper(data)
    require.NoError(t, err)
    _, exists := compiler.jobManager.GetJob(string(constants.EvalsJobName))
    assert.False(t, exists, "no evals job should be added when Evals is nil")
}

A nil-evals test locks in the early-return branch and documents the intended no-op behaviour.

@copilot please address this.

@github-actions github-actions Bot mentioned this pull request Aug 22, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ponytail review: this refactor splits a monolithic function into named phases, but a few of the new helpers only have one caller and add indirection without reducing complexity.

net: -25 lines possible.

Generated by ✂️ Ponytail Reviewer for #54847 · auto · 26.2 AIC · ⌖ 5.53 AIC · ⊞ 7.3K
Comment /ponytail to run again

return nil
}

func (c *Compiler) resolveSafeOutputActionSchemas(data *WorkflowData, markdownPath string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L324-332: yagni: 9-line helper with a single caller wrapping one if check. Inline the body into buildJobs.

}

// Build additional custom jobs from frontmatter jobs section
// buildFrontmatterCustomJobs builds additional jobs declared in the workflow frontmatter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L376-385: yagni: single-caller wrapper that only forwards to buildCustomJobs plus a log line. Inline into buildJobs, dropping one indirection layer.

return nil
}

// buildEvalsJobWrapper builds and adds the BinEval evals job if evals are declared in frontmatter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L361-374: yagni: single-caller helper duplicating buildEvalsJob's nil-check/AddJob dance that used to live inline in buildJobs. Fold back into buildSafeOutputsAndEvalsJobs and drop the dedicated wrapper test in evals_job_test.go.

@pelikhan
pelikhan merged commit 76ed85f into main Aug 22, 2026
110 checks passed
@pelikhan
pelikhan deleted the copilot/fix-9919-1036865607-9d329637-b18c-49f5-897f-c051e2794839 branch August 22, 2026 16:03
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.5

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.

[deep-report] Split buildJobs in compiler_jobs.go to raise Daily Compiler Quality score above threshold

3 participants