refactor: redesign CompileContext with rich metadata and async constructor#212
Conversation
…uctor Replace the ad-hoc inferred_org: Option<&str> field with a properly structured CompileContext that follows the ExecutionContext pattern: - ado_context: Option<AdoContext> — full ADO metadata (org, project, repo) - compile_dir: &Path — for future extensions needing path resolution - async fn new() — resolves ADO context from git remote eagerly - ado_org() convenience accessor This eliminates the split where standalone.rs inferred the org inline (30-line block) and passed it separately to generate_mcpg_config(). Now CompileContext is built once, early, and passed uniformly to all extension methods — validate() and mcpg_servers() both receive the same fully-populated context. Test helpers: for_test() and for_test_with_org() avoid async in tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔍 Rust PR ReviewSummary: Clean refactor with one notable behavioral change and a minor dead-field concern — otherwise looks good. Findings
|
- Remove compile_dir from CompileContext (unused, was speculative).
compile_dir is still accepted by new() for ADO inference but not
stored — it can be re-added when an extension actually needs it.
- Simplify ado_org() to use and_then + ? instead of map + unwrap_or
+ filter chain. rsplit("/").next() always returns Some, so the
unwrap_or("") was unreachable.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔍 Rust PR ReviewSummary: Clean refactoring — looks good with a couple of minor observations worth noting for future work. Findings✅ What Looks Good
|
Summary
Redesigns
CompileContextto follow theExecutionContextpattern — a single struct built eagerly with all resolved metadata, passed uniformly to every extension method.Problem
CompileContext.inferred_orgwas:Noneatvalidate()time (not yet resolved)generate_mcpg_config()was calledstandalone.rs::compile()as a 30-line block that was tightly coupled to the ADO extensionSolution
CompileContext::new().await— async constructor that infers ADO context from git remotectx.ado_org()— convenience accessor for the org namestandalone.rsandonees.rsvalidate,mcpg_servers) receive the same fully-populated contextChanges
extensions.rsCompileContextwithado_context,compile_dir,async fn new(), test helpersstandalone.rsonees.rsCompileContext::new().await(same as standalone)All 842 tests pass.