Skip to content

Refactor engine handling behind a dedicated Engine trait and Copilot implementation#284

Merged
jamesadevine merged 3 commits into
mainfrom
copilot/abstract-engine-consolidation
Apr 21, 2026
Merged

Refactor engine handling behind a dedicated Engine trait and Copilot implementation#284
jamesadevine merged 3 commits into
mainfrom
copilot/abstract-engine-consolidation

Conversation

Copilot AI commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

The compiler currently supports only Copilot, but Copilot-specific behavior was spread across compile helpers. This change centralizes engine behavior behind a single abstraction so future engines can be added without further scattering engine-specific logic.

  • Engine abstraction

    • Added src/engine.rs with:
      • Engine trait
      • GitHubCopilotCliEngine implementation
      • shared singleton GITHUB_COPILOT_CLI_ENGINE
    • Encapsulates engine-owned behavior:
      • CLI parameter generation
      • agent ADO env generation for Stage 1
  • Call-site consolidation

    • generate_copilot_params(...) in src/compile/common.rs now delegates to Engine::generate_cli_params(...)
    • generate_copilot_ado_env(...) now delegates to Engine::generate_agent_ado_env(...)
    • Existing output/behavior is preserved; ownership of engine logic is relocated.
  • Focused coverage for the new boundary

    • Added unit tests in src/engine.rs for:
      • Copilot CLI param generation
      • Copilot agent ADO env generation
pub trait Engine {
    fn generate_cli_params(
        &self,
        front_matter: &FrontMatter,
        extensions: &[Extension],
    ) -> Result<String>;

    fn generate_agent_ado_env(&self, read_service_connection: Option<&str>) -> String;
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dev.azure.com
    • Triggering command: /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw_derive-200f38d8081bcd5a/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/compiler_tests-d461b4685455015d.1ket8gxh7k8pnfuz3gzg6yfzy.0m1oya8.rcgu.o /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw_derive-200f38d8081bcd5a/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/compiler_tests-d461b4685455015d.1n00vrauz0tjinbjhe3cmnsgl.0m1oya8.rcgu.o /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw_derive-200f38d8081bcd5a/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/compiler_tests-d461b4685455015d.1saraw1npdjk7qzm3nb8awhct.0m1oya8.rcgu.o /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw_derive-200f38d8081bcd5a/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/compiler_tests-d461b4685455015d.20jt5s1ik51kdhvbu4hrvcifw.0m1oya8.rcgu.o /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw_derive-200f38d8081bcd5a/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/compiler_tests-d461b4685455015d.2370ib6euso0f5xcqo9mphght.0m1oya8.rcgu.o aajbcm53kyup1c265kxdu76.0ufx18v.rcgu.o w5cv0ifwtrl6dpj6xvgeal7.0ufx18v.rcgu.o r3haoo2320pa6tqujx76cqc.0ufx18v.rcgu.o oxkn3sxfhag1w45cx2plmeh.0ufx18v.rcgu.o c1eo3xuvalszt1p3qu2uyno.0ufx18v.rcgu.o bny3d46rl605mmhglksyusw.0ufx18v.rcgu.o kfjsfix4u58clv1wiem7nse.0ufx18v.rcgu.o btilquoykx6nsi0dd1sx8zj.0ufx18v.rcgu.o gphlhul94ia4rb4lerlb5ri.0ufx18v.rcgu.o 08h8sipq36hxu94zkzu7duh.0ufx18v.rcgu.o r2kv94emcaau5up6629u0n2.0ufx18v.rcgu.o ajnfm4bnpmtfrxbgscvtlpm.0ufx18v.rcgu.o ilq4w8mhj2na1l3eehlyh7n.0ufx18v.rcgu.o mayg8wuxe9xp91j7yx6bko8.0ufx18v.rcgu.o (dns block)
    • Triggering command: /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e .o -gnu/bin/self-co/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/rustci3cTD5/sy/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e.0pu4ojy95joxn5dht4g9rg3rz.1uueqyo.rcgu.o k/ado-aw/ado-aw//home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e.0vwcxbuu4wfwy43eqkafpxzh4.1uueqyo.rcgu.o k/ad�� eline-cwi-sc-900/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e.14bqhs5apqw08obnqx2jb5vx5.1uueqyo.rcgu.o k/ado-aw/ado-aw//home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e.15wgf4gwmfx7ewsndr76mwj5r.1uueqyo.rcgu.o bin/cargo k/ado-aw/ado-aw/bash ui7.079gflp.rcgu--norc ebe.079gflp.rcgu--noprofile bin/cargo rol.�� qds.079gflp.rcgu/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests-b84f950a7389b33cc dpi.079gflp.rcgu/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests-b84f950a7389b33-m64 known-linux-gnu//home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests-b84f950a7389b33/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/rustcoNxqbs/symbols.o nta.079gflp.rcgubash -incompat vs3.079gflp.rcgu--noprofile known-linux-gnu//home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests-b84f950a7389b33/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e.0b4swqtj42h2czjsrx6oaub07.1uueqyo.rcgu.o (dns block)
    • Triggering command: /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e s/init_tests-49cremote s/init_tests-49cget-url s/init_tests-49corigin s/in�� s/init_tests-49cb495e99e732cb.454p1re0d1ru9vjbeokvrnsje.05s27fc.rcgu.o s/init_tests-49cb495e99e732cb.4bwfh6qkumpdr9rsfekf3mrmi.05s27fc.rcgu.o target/debug/deps/compiler_tests-d461b4685455015d.1ket8gxh7k8pnfuz3gzg6yfzy.0w4v/home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-0dd8581e95bf1852.0ubdhrr6hs6lm9ydlqd2rpd2r.09mejql.rcgu.o target/debug/depgit .o .o .o .o target/debug/deps/rustcrdj0mb/symbols.o target/debug/deps/init_tests-49cb495e99e732cb.0maajbcm53kyup1c265kxdu76.05s27fc.rcgu.o target/debug/deps/init_tests-49cb495e99e732cb.0qw5cv0ifwtrl6dpj6xvgeal7.05s27fc.rcgu.o target/debug/dep/usr/bin/php8.3 target/debug/dep-c target/debug/dep/etc/php/8.3/fpm/php.ini target/debug/dep-d (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue Apr 21, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/c61d8cab-0ddf-4812-a240-f354ec476027

Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor codebase to implement Engine trait for Copilot Refactor engine handling behind a dedicated Engine trait and Copilot implementation Apr 21, 2026
Copilot AI requested a review from jamesadevine April 21, 2026 18:14
@jamesadevine

Copy link
Copy Markdown
Collaborator

/rust-review

@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Rust PR Reviewer completed successfully!

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Rust PR Review

Summary: Looks good — clean, behavior-preserving refactoring with no new bugs or warnings. A couple of minor items worth noting.

Findings

⚠️ Suggestions

  • src/main.rs:9mod engine; is placed out of alphabetical order (after fuzzy_schedule, should be before ecosystem_domains). Minor consistency nit, but the rest of the module list is alphabetized.

  • src/engine.rs:224-229 — The test for generate_agent_ado_env only exercises the Some(...) path. The None → empty string case is trivial but worth a one-liner to guard against future regressions:

    assert!(GITHUB_COPILOT_CLI_ENGINE.generate_agent_ado_env(None).is_empty());
  • src/compile/common.rs:466-470 — The UFCS delegation form crate::engine::Engine::generate_cli_params(&crate::engine::GITHUB_COPILOT_CLI_ENGINE, ...) is valid but unusual. The idiomatic equivalent crate::engine::GITHUB_COPILOT_CLI_ENGINE.generate_cli_params(...) (with a use crate::engine::Engine as _; import for the trait) is more readable and matches how the concrete value is used elsewhere. Same applies to the generate_agent_ado_env delegation below it.

✅ What Looks Good

  • Logic was moved verbatim — no behavioral changes; cargo check confirms zero new warnings.
  • The Engine trait is object-safe (no generics, no Self bounds), leaving the door open for Box<dyn Engine> dispatch when multiple engines land.
  • GITHUB_COPILOT_CLI_ENGINE as a zero-sized const is the right pattern — no heap allocation needed.
  • The unreachable! invariant guard for bash=None inside the !use_allow_all_tools branch is correctly preserved.
  • Import of CompilerExtension in engine.rs is correctly required (needed to call trait methods on Extension values) — not dead code despite appearances.

Generated by Rust PR Reviewer for issue #284 · ● 1.1M ·

@jamesadevine

Copy link
Copy Markdown
Collaborator

@copilot address feedback.

Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/77ecbe31-8f7e-41c8-b207-0e3fb219d26a

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

Copilot AI commented Apr 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address feedback.

Addressed the Rust review feedback in commit 052ec4c: reordered mod declarations in src/main.rs, switched engine delegation in src/compile/common.rs to idiomatic method-call style, and added the missing None-path unit test in src/engine.rs. Targeted tests and full cargo test pass.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dev.azure.com
    • Triggering command: /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/ado_aw-d5652daa30dfc52e /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests-b84f950a7389b33d.14722s5epvjae3nn3ylxkucko.0cygl86.rcgu.o /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests-b84f950a7389b33d.148cy3pq04g1un12o6x1quzon.0cygl86.rcgu.o /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests-b84f950a7389b33d.17tgrokgra7a7wujk7ooupq97.0cygl86.rcgu.o /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests-b84f950a7389b33d.17vd3t69cj94hlwno3z871y8p.0cygl86.rcgu.o /home/REDACTED/work/ado-aw/ado-aw/target/debug/deps/mcp_http_tests-b84f950a7389b33d.18wuz8jn1878w063h8qkflpn2.0cygl86.rcgu.o w0mwmzyowo1kpet0s11.06tl3bg.rcgu.o ypd5xg7lz6hk3ttv6ip.06tl3bg.rcgu.o dp5d5vmks00swpoek7a.06tl3bg.rcgu.o 3er7j8z0quap9xt1nsa.06tl3bg.rcgu.o tj42h2czjsrx6oaub07.06tl3bg.rcgu.o 78jaukufrg3gliv9cze.06tl3bg.rcgu.o 7eznnqmz2fowqv2vp6j.06tl3bg.rcgu.o l383gcd1je2eprmbclw.06tl3bg.rcgu.o je0ayp7e7i9hmv5ojx4.06tl3bg.rcgu.o 9f25kmtt2xf6mclu5p2.06tl3bg.rcgu.o 3m13jq5nd1e4yrmhe98.06tl3bg.rcgu.o 9rd8j01zg25r6tj6ugk.06tl3bg.rcgu.o ac3oww4kt0a5l8koroq.06tl3bg.rcgu.o v9yeg5q1epczjxvnhrm.06tl3bg.rcgu.o (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@jamesadevine jamesadevine marked this pull request as ready for review April 21, 2026 19:46
@jamesadevine jamesadevine merged commit 86de262 into main Apr 21, 2026
7 checks passed
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.

Abstract engine

2 participants