feat: unify standalone and 1ES compilers#226
Conversation
Move helper functions, MCPG generation, and MCP validation from standalone.rs to common.rs. Extract compile_shared() function with CompileConfig struct so both standalone and 1ES compilers can share the common compilation flow. Standalone compiler is now a thin wrapper that provides target-specific values (AWF domains, MCPG config, firewall version) via extra_replacements. This is a pure refactor - standalone output is byte-identical to before (verified via golden snapshot comparison). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the legacy Agency job type (agencyJob) with direct Copilot CLI invocation, AWF network isolation, and MCP Gateway — matching the standalone pipeline execution model. Changes: - templates/1es-base.yml: Complete rewrite. All three jobs (PerformAgenticTask, AnalyzeSafeOutputs, ProcessSafeOutputs) now use templateContext.type: buildJob with the same step sequence as standalone. Dropped Agency concepts: commandOptions, globalOptions, logLevel, mcpConfiguration, agentContextRoot, AgencyArtifact. - src/compile/onees.rs: Rewritten as thin wrapper using compile_shared(). Removed generate_agent_context_root, generate_mcp_configuration, generate_inline_steps. Only 1ES-specific setup/teardown helpers remain. - src/compile/common.rs: Moved generate_allowed_domains from standalone. Removed dead is_custom_mcp function. - src/compile/standalone.rs: Removed now-unnecessary imports. Both compilers now share the same execution model and compile flow. Standalone output is verified byte-identical to pre-refactor baseline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove Agency/agencyJob references from AGENTS.md and module docs. Update 1ES target description to reflect shared execution model (Copilot CLI + AWF + MCPG). Remove obsolete 1ES-specific marker documentation (agent_context_root, mcp_configuration, global_options, log_level). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add integration tests that compile fixtures and verify the output is valid, parseable YAML. Tests cover: - 1ES: valid YAML with correct 'extends' and 'resources' structure - Standalone minimal: valid YAML with 'jobs' key - Standalone pipeline-trigger: valid YAML - Standalone complete: compile-only (has pre-existing indentation issue in multi-repository output) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…d teardown_job - generate_repositories: remove hardcoded 6-space indent on sub-fields; output flat YAML and let replace_with_indent handle template-level indentation - generate_checkout_steps: same fix, remove hardcoded 14-space join - generate_teardown_job (common.rs): match setup_job pattern — output flat YAML starting at column 0 instead of baking in 2-space indent; move template placeholder from column 0 to column 2 to match setup_job - generate_setup_job/teardown_job (onees.rs): fix step indentation from 4 to 6 to match the steps: nesting depth in templateContext - Upgrade complete-agent test from compile-only to full YAML validation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔍 Rust PR ReviewSummary: Solid refactor with good test coverage — one minor performance bug, one fragile architecture pattern, and a missing golden test for the 1ES behavioral change. Findings🐛 Bugs / Logic Issues
|
… ordering - compile_shared() now accepts &CompileContext instead of building its own, eliminating duplicate git remote I/O on every compilation - extra_replacements are applied before shared replacements, so targets can cleanly override shared markers (e.g., 1ES setup/teardown jobs) via the intended CompileConfig mechanism - 1ES compiler no longer pre-replaces markers in the template string before calling compile_shared; uses extra_replacements instead Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add assertions verifying that key pipeline content is present in the compiled 1ES output: Copilot CLI install, AWF, MCPG, SafeOutputs, copilot invocation, threat analysis, safe output execution, and all three job names. Also verify no Agency remnants (agencyJob, AgencyArtifact, commandOptions). These catch placeholder substitution regressions that the structural YAML validity and no-unreplaced-markers tests would miss. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔍 Rust PR ReviewSummary: Excellent refactor overall — clean unification, good test coverage. Two actionable issues found, one minor doc nit. Findings🐛 Bugs / Logic Issues
🔒 Security Concerns
|
- Remove orphaned schedule doc comment accidentally prepended to generate_parameters() during earlier refactoring - Escape single quotes in service connection names when emitting azureSubscription YAML values to prevent malformed pipeline output Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔍 Rust PR ReviewSummary: Clean refactoring with solid architecture — the shared compilation model works correctly. A few dead-code items were left behind, and the "cargo clippy clean" claim in the PR description doesn't hold. Findings🐛 Bugs / Logic Issues
|
Summary
Unifies the standalone and 1ES compilers to share the same execution model (Copilot CLI + AWF + MCPG) and compilation flow. Replaces the legacy Agency job type in 1ES with direct Copilot CLI invocation.
Compiler unification
compile_shared()+CompileConfigintocommon.rs— both compilers are now thin wrappers that provide target-specific values and delegate to the shared functionCompileConfig.extra_replacementsare applied before shared replacements, allowing targets to override shared markers (e.g., 1ES-specific setup/teardown jobs)compile_shared()accepts a pre-built&CompileContextto avoid duplicate git I/Ocommon.rs:generate_setup_job,generate_teardown_job,generate_prepare_steps,generate_finalize_steps,generate_agentic_depends_on,generate_mcpg_config,generate_mcpg_docker_env,generate_allowed_domains, and all MCP validation functions1ES modernisation (breaking change for 1ES users)
templateContext.type: agencyJobwithbuildJobrunning Copilot CLI directlycommandOptions,globalOptions,logLevel,mcpConfiguration,agentContextRoot,AgencyArtifactBug fixes
generate_repositories: removed hardcoded indentation, now outputs flat YAML forreplace_with_indentto handlegenerate_checkout_steps: same hardcoded indentation fixgenerate_teardown_job: matched thegenerate_setup_jobpattern (flat output, template provides indentation context)generate_setup_job/generate_teardown_job: corrected step indentation to matchtemplateContext.stepsnesting depthTests
File sizes (before → after)
standalone.rsonees.rscommon.rs1es-base.yml878 tests pass,
cargo clippyclean