Skip to content

refactor(compile): split agentic-pipeline shape out of standalone_ir.rs and lift Agent-job conditions into Declarations#995

Merged
jamesadevine merged 3 commits into
mainfrom
jamesadevine/refactor-agentic-pipeline-split-987
Jun 13, 2026
Merged

refactor(compile): split agentic-pipeline shape out of standalone_ir.rs and lift Agent-job conditions into Declarations#995
jamesadevine merged 3 commits into
mainfrom
jamesadevine/refactor-agentic-pipeline-split-987

Conversation

@jamesadevine

@jamesadevine jamesadevine commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR delivers two related refactors in the compile pipeline path:

  1. Extract canonical agentic pipeline shape into src/compile/agentic_pipeline.rs

    • Moves shared Setup → Agent → Detection → SafeOutputs → Teardown construction out of standalone_ir.rs.
    • Keeps standalone_ir.rs as a thin wrapper, aligned with job_ir.rs / stage_ir.rs / onees_ir.rs.
    • Retargets wrapper imports and related doc references to the new module.
  2. Lift Agent-job condition construction into extension declarations

    • Adds agent_conditions: Vec<Condition> to Declarations.
    • Moves Agent condition clause construction into AdoScriptExtension::build_agent_conditions().
    • Removes build_agentic_condition and introduces fold_agent_conditions to fold extension-contributed clauses with leading Condition::Succeeded.
    • Preserves previous empty-condition behavior (no explicit Agent job condition).

Follow-up review feedback is also addressed in src/compile/agentic_pipeline.rs:

  • Removed a stale #[allow(unused_imports)] block/comment.
  • Updated wire_explicit_dependencies to resolve Teardown through prefix.id("Teardown")? for consistent typed ID handling.

No intended behavior change from the review-follow-up cleanup; fixture outputs remain unchanged.

Test plan

  • cargo build
  • cargo test
  • cargo clippy --all-targets -- -D warnings
  • cargo test agentic_pipeline
  • cargo test fold_agent_conditions
  • cargo test --test bash_lint_tests
  • Secret scan on changed file: src/compile/agentic_pipeline.rs (no findings)
  • Parallel validation run (Code Review + CodeQL): no findings

jamesadevine and others added 2 commits June 13, 2026 14:43
…tic_pipeline.rs

Move every per-job builder, condition builder, variable hoist, dependency
wiring, helper step builder, StandaloneCtx, JobPrefix, BuiltPipelineContext,
build_pipeline_context, and build_canonical_jobs out of standalone_ir.rs
(2,385 lines) into a new src/compile/agentic_pipeline.rs.

standalone_ir.rs shrinks back to its one-screen wrapper, parallel to the
existing job_ir.rs / stage_ir.rs / onees_ir.rs target wrappers. Imports in
those wrappers retargeted at super::agentic_pipeline::build_pipeline_context.

Doc-comment references in extensions/ado_script.rs and extensions/exec_context/
updated to the new module path.

Pure file move — zero behaviour change. All 1832 tests pass, no .yml fixture
drift, clippy clean.

Part of the work for issue #987.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ations

Add `agent_conditions: Vec<Condition>` to `Declarations`. The
canonical-jobs builder folds every extension's contribution into a single
`Condition::And([Succeeded, ...])` via the new `fold_agent_conditions`
helper inside `agentic_pipeline::build_agent_job`; an empty
contribution set leaves the Agent job unconditional (matching pre-lift
behaviour).

Move every clause previously built by `build_agentic_condition` into
`AdoScriptExtension::build_agent_conditions()` — which already owns
`pr_filters`, `pipeline_filters`, and the synth-PR trigger:

  - synth-PR-skip (Ne synthPr.AW_SYNTHETIC_PR_SKIP, 'true')
  - PR-filter gate (Or with synth carve-out when synthetic_pr_active)
  - pipeline-filter gate (Or Build.Reason != ResourceTrigger, ...)
  - User `expression:` escape hatches (Condition::Custom)

`build_agentic_condition` is deleted. `agentic_pipeline` no longer
hard-codes knowledge of `synthPr` / `prGate` / `pipelineGate` step
IDs or signals; future cross-extension Agent-job gating signals plug in
declaratively via `Declarations::agent_conditions`.

New unit tests in `extensions/ado_script.rs` pin the contribution
shape per trigger configuration; new `fold_agent_conditions` tests in
`agentic_pipeline` pin the leading-Succeeded fold contract.

Closes the second half of issue #987 (the first half — file move from
standalone_ir.rs to agentic_pipeline.rs — landed in the previous
commit). Zero `.yml` fixture drift, 1841 tests pass (was 1832 + 9
new), clippy clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Rust PR Review

Summary: Looks good — clean, well-tested refactor with zero behaviour change. Two minor observations worth a quick cleanup pass before merge.

Findings

⚠️ Suggestions

  • src/compile/agentic_pipeline.rs:73–75 — Stale comment on the #[allow(unused_imports)] block:

    // Suppress unused; this module is wired up in a sibling commit.
    #[allow(unused_imports)]
    use super::common::{generate_acquire_ado_token, generate_executor_ado_env};

    This comment was copied verbatim from standalone_ir.rs where it described a pending sibling commit. In agentic_pipeline.rs both functions are already called via the common:: qualified path (lines 203, 210, 217), so the unqualified use statement is genuinely redundant — not pending. The stale "wired up in a sibling commit" wording could mislead a future contributor into thinking there is outstanding work. The simplest fix is to remove the use, the #[allow], and the comment entirely.

  • src/compile/agentic_pipeline.rswire_explicit_dependencies, Teardown branch — All four other job IDs are resolved through prefix.id(...)? (typed, fallible), but Teardown falls through to a bare string comparison:

    } else if j.id.as_str() == "Teardown" {

    Functionally correct today — JobPrefix::id always returns the unprefixed "Teardown" regardless of prefix — but the inconsistency means anyone who later adds "Teardown" to the prefixed arm in JobPrefix::id would silently break the wiring without a compile error. Pre-computing let teardown_id = prefix.id("Teardown")?; alongside the other four IDs at the top of the function would make the pattern uniform.

✅ What Looks Good

  • Zero fixture drift across all 33 lock-file fixtures is the best possible signal for a refactor of this scope.
  • Declarations::agent_conditions design — typed OutputRef over static step IDs means a future step-ID rename becomes a graph-validation compile error rather than a silently broken runtime condition.
  • fold_agent_conditions contract — the None-for-empty path preserves the pre-lift behaviour (Agent job with no explicit condition: inherits ADO's implicit succeeded()), and the And([Succeeded, ...]) path preserves emission order. Both paths are pinned by unit tests.
  • Error propagation in build_agent_conditionsStepId::new(...)? for static step-ID strings propagates a contract violation as a compile-phase error rather than a runtime panic.
  • Declarations::Default coverageagent_conditions correctly defaults to Vec::new() via #[derive(Default)], and ..Declarations::default() in ado_script.rs::declarations zero-initialises every unset field cleanly.

Generated by Rust PR Reviewer for issue #995 · sonnet46 2.9M ·

@jamesadevine

Copy link
Copy Markdown
Collaborator Author

@copilot address feedback and suggestions

Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

@copilot address feedback and suggestions

Addressed in 3e7bdce.

  • Removed the stale #[allow(unused_imports)] block and sibling-commit comment in src/compile/agentic_pipeline.rs.
  • Updated wire_explicit_dependencies to resolve Teardown via prefix.id("Teardown")? and compare typed IDs consistently.

Validation run: targeted cargo test filters for agentic_pipeline/fold_agent_conditions, cargo clippy --all-targets -- -D warnings, and parallel validation (Code Review + CodeQL) all passed.

@jamesadevine jamesadevine merged commit 39f92de into main Jun 13, 2026
@jamesadevine jamesadevine deleted the jamesadevine/refactor-agentic-pipeline-split-987 branch June 13, 2026 15:03
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.

2 participants