refactor(compile): reduce complexity of build_agent_job in agentic_pipeline.rs - #2272
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…peline.rs build_agent_job was flagged by clippy::too_many_lines at 160/100 lines. It was a single monolithic function assembling every step of the Agent job inline: checkouts, engine/compiler install, MCPG/ado-proxy startup, create-pull-request base prep, token minting, the agent run itself, teardown, and artifact publish. Extracted eight well-named helper functions, each owning one logically distinct phase, with original doc comments preserved and attached to the new function: - push_agent_checkout_steps — checkout: self + additional repo checkouts. - push_agent_install_and_prepare_steps — read token, engine install, compiler download, integrity check, MCPG config, tooling, prompt, Docker install, AWF download, image pre-pull, extension/user steps. - push_agent_mcp_startup_steps — AWF path step, Azure WIF refresh sidecars, ado-proxy startup, MCPG startup, topology-peer check, debug-only backend check. Returns whether ado-proxy is enabled. - push_agent_create_pr_base_prep_steps — create-pull-request diff-base fetch/deepen steps. - push_agent_run_steps — GitHub App/provider token minting plus the actual AWF-sandboxed agent run. - push_agent_collect_and_stop_steps — token revocation, safe-output collection/summary, MCPG/WIF/ado-proxy teardown. - push_agent_finalize_steps — post_steps, log copy, artifact publish. build_agent_job itself now reads as a short, linear sequence of calls to these helpers plus job/variable/condition assembly. No behavior change: identical steps are emitted in identical order under identical conditions — this is a pure extraction. Before/after: clippy::too_many_lines reported build_agent_job at 160/100 lines; it no longer appears in the too_many_lines violation list for this file. Verification: - cargo build --bin ado-aw — succeeds. - cargo test — full suite, 3406+ tests pass, 0 failed (incl. all 79 tests in compile::agentic_pipeline). - cargo clippy --all-targets --all-features — clean. - Only src/compile/agentic_pipeline.rs is touched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What was complex
build_agent_jobinsrc/compile/agentic_pipeline.rswas flagged byclippy::too_many_linesat 160/100 lines. It was a single monolithic function assembling every step of the Agent job inline: checkouts, engine/compiler install, integrity check, MCPG/ado-proxy startup, create-pull-request diff-base prep, GitHub App/provider token minting, the agent run itself, token revocation, safe-output collection/summary, MCPG/ado-proxy teardown, post-steps, log copy, and artifact publish — all in one body, making it hard to follow and to test each phase in isolation.What changed
Extracted eight well-named helper functions, each owning one logically distinct phase, with their original doc comments preserved and attached to the new function:
push_agent_checkout_steps—checkout: self+ additional named repo checkouts.push_agent_install_and_prepare_steps— read token, engine install, compiler download, integrity check, MCPG config, tooling, prompt, Docker install, AWF download, image pre-pull, extension/usersteps:.push_agent_mcp_startup_steps— AWF path step, Azure WIF refresh sidecars, ado-proxy startup, MCPG startup, topology-peer liveness check, debug-only MCP backend check. Returns whether ado-proxy is enabled so later steps can gate on it.push_agent_create_pr_base_prep_steps—create-pull-requestdiff-base fetch/deepen steps (local + cross-org repos).push_agent_run_steps— GitHub App / external provider token minting immediately before, plus the actual AWF-sandboxed agent run.push_agent_collect_and_stop_steps— GitHub App token revocation, safe-output collection + summary rendering, MCPG/WIF/ado-proxy teardown in reverse start order.push_agent_finalize_steps— userpost_steps:, log copy, and theagent_outputs_$(Build.BuildId)artifact publish.build_agent_jobitself now reads as a short, linear sequence of calls to these helpers plus job/variable/condition assembly.No behavior change: the same steps are emitted in the same order under the same conditions — this is a pure extraction, not a logic change.
Before/after complexity
clippy::too_many_linesreportedbuild_agent_jobat 160/100 lines.build_agent_jobno longer appears in theclippy::too_many_linesviolation list for this file (confirmed viacargo clippy --all-targets --all-features --message-format=json -- -W clippy::too_many_lines).Verification
cargo build --bin ado-aw— succeeds.cargo test— full suite, 3406+ tests pass, 0 failed, including all 79 tests incompile::agentic_pipeline.cargo clippy --all-targets --all-features— clean, no warnings.src/compile/agentic_pipeline.rsis touched. (Skipped running a project-widecargo fmt/rustfmtpass after discovering the installedrustfmt 1.9.0reformats large swaths of unrelated, already-committed code across 79 files; the one new function's line-wrap was fixed manually to stay within the repo's existing style.)Note on duplicate-avoidance
Before selecting a target, I checked for existing open PRs addressing other high-ranking
too_many_linescandidates and found two already in flight: #2267 (build_safeoutputs_job) and #2243 (check_pipeline). Both were skipped to avoid duplicate work;build_agent_jobwas the next-largest untouched, non-duplicated candidate.Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
releaseassets.githubusercontent.comspsprodeus21.vssps.visualstudio.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.