test(trigger-e2e): add deterministic gate/synth-PR trigger-condition E2E suite#1504
Conversation
…E2E suite Add an ADO-native, non-agentic E2E test framework for the runtime trigger conditions managed by ado-script (gate.js PR filters and exec-context-pr-synth.js synthetic-PR promotion), modeled on the executor-e2e native bundle. A parameterized victim pipeline runs only the two bundles and reports the decision via REST-observable build tags; an orchestrator harness creates real PRs and queues the victim many ways, asserting the gate decision. Test-only bundle: excluded from ado-script.zip exactly like executor-e2e. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f30758a5-81c8-4024-ab01-52ad22b4f877
🔍 Rust PR ReviewSummary: Looks good — well-structured test harness with a few worth-noting items.
Findings
|
89a6fd0 to
1f0f34e
Compare
🔍 Rust PR ReviewSummary: Well-structured test-only addition — looks good overall with one potential flakiness concern worth addressing. Findings🐛 Bugs / Logic Issues
|
…n-e2e-framework-3ac5fe0798461db2
- Derive the synthetic-PR spec from the PR's real target branch
(promoteSynthSpec/excludeSynthSpec) instead of a hardcoded "main", so
gate/synth scenarios evaluate correctly on any default branch.
- Guard createPrContext against an explicitly-empty files map (avoid the
entries[0]! undefined-destructuring crash; treat {} like omitted).
- Cancel an orphaned victim build in the runner's finally block when the
queue-phase poll throws (waitForBuild timeout), threading the queued build
id via runVictim's onQueued callback; add unit tests for the cancel path.
- setPullRequestLabels: name the specific failing label so a partial attach
surfaces as a clear setup error, not a confusing gate mismatch.
- filter_ir.rs: add a SYNC annotation pointing at gate-spec.ts::FACT_META so
fact policy/dependency changes flag the hand-maintained mirror.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f30758a5-81c8-4024-ab01-52ad22b4f877
🔍 Rust PR ReviewSummary: Well-structured E2E framework with one latent bug and a minor coupling concern. Findings🐛 Bugs / Logic Issues
|
- Fix latent multi-file push bug: pushAddFileBranch always uses new-branch semantics, so createPrContext's per-file loop would fail with a ref conflict on the second file. Add AdoRest.pushAddFilesBranch that batches all files into a single commit, and use it in createPrContext. - Decouple the shared AdoRest client from trigger-e2e env vars: waitForBuild now takes generic 15min/10s defaults; the TRIGGER_E2E_BUILD_TIMEOUT_MS / _POLL_MS knobs are read in trigger-e2e queue.ts and passed as opts, so an executor-e2e run can't be silently retimed. - Add change-count-pass scenario (two files, within range → runs), completing the numeric_range pass/skip coverage and exercising the batched push path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f30758a5-81c8-4024-ab01-52ad22b4f877
🔍 Rust PR ReviewSummary: Looks good — clean, well-structured E2E harness with a handful of minor observations worth tracking. Findings
|
…catalog Close the gate-spec.ts / FACT_META drift hole that types.gen.ts cannot cover: policy and dependency VALUES were invisible to any type-checker, so a Rust-side change to Fact::failure_policy()/dependencies() (or a new/removed Fact) would only surface as a wrong spec at runtime. - Rust: add Fact::ALL (completeness enforced at compile time by a wildcard-free exhaustiveness match) and generate_fact_catalog(); expose it via a hidden export-fact-catalog CLI command. - codegen: emit committed fact-catalog.gen.json alongside types.gen.ts. - CI: extend the ado-script drift-check git-diff to cover the catalog, so a Rust change forces a regen + commit. - TS: factMetaCatalog() projects FACT_META into the catalog shape and a gate-spec.test.ts test deep-compares it to fact-catalog.gen.json. Verified: corrupting the catalog fails the unit test; adding a Fact variant fails compilation until Fact::ALL is updated. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f30758a5-81c8-4024-ab01-52ad22b4f877
🔍 Rust PR ReviewSummary: Looks good — well-engineered test infrastructure with solid compile-time guardrails. Findings
|
- main.rs: wrap the export-gate-schema / export-fact-catalog fs writes and
create_dir_all in .with_context so a CLI write failure names the target path.
- filter_ir.rs: document that Fact::ALL's [Fact; 14] length literal is a second
compile-time guard that must track the variant count.
- gate-spec.ts: replace predicateFacts' (p as { fact? }).fact duck-typing with a
discriminant switch + never-exhaustiveness default, so a renamed/added
PredicateSpec field or variant is a compile error instead of a silently
under-specified fact list.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f30758a5-81c8-4024-ab01-52ad22b4f877
…ride Address remaining PR review doc suggestions: - createPrContext: document that a scenario doing further setup work after a successful createPrContext must teardown the PrContext itself before rethrowing, since the runner won't run cleanup until setup() returns. - README: call out that the hardcoded AZS-1ES pool name in both pipelines may need changing for the operator's ADO project. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f30758a5-81c8-4024-ab01-52ad22b4f877
🔍 Rust PR ReviewSummary: Looks good — well-designed test infrastructure with thoughtful cleanup guarantees and solid codegen-drift detection. A couple of minor nits. Findings
|
… tree and CLI reference - Add trigger-e2e/ to AGENTS.md architecture tree (missing after #1504 added the deterministic gate/synth-PR E2E suite) - Add export-fact-catalog to docs/cli.md hidden build-time tools section (parallel to export-gate-schema; generates fact-catalog.gen.json consumed by trigger-e2e/) - Update AGENTS.md CLI description to mention export-fact-catalog alongside export-gate-schema Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Adds an ADO-native, deterministic (non-agentic) E2E test framework for the runtime front-matter trigger conditions managed by ado-script — the
gate.jsPR filter evaluator and theexec-context-pr-synth.jssynthetic-PR promotion bundle — modeled on the existing executor-e2e native bundle.The executor-e2e suite covers Stage 3 safe-output execution but nothing decides whether the agent runs at all. This suite closes that gap with no LLM in the loop:
GATE_SPEC/PR_SYNTH_SPECas template parameters,Key design: a real open PR lets
exec-context-pr-synthsetAW_SYNTHETIC_PR=true, so the gate runs full PR-filter evaluation even on an API-queued (Manual-reason) build — one victim covers synth-promotion and every gate filter authentically, with no server-side build-validation policy. Failing filters self-cancel to a terminalcanceledresult.What's added
scripts/ado-script/src/trigger-e2e/— test-only harness bundle:gate-spec.ts— faithful TS port of the Rustbuild_gate_spec/lower_pr_filtersspec construction; imports the codegen'dtypes.gen.tsso schema drift is a compile error.scenario.ts/runner.ts/queue.ts— scenario contract + isolated always-cleanup runner + victim queue/poll.scenarios/— synth-PR (promote / branch- & path-mismatch), gate filters pass+skip (labels, changed-files, draft, target-branch, build-reason, change-count, time-window), bypass, self-cancel.github-issue.ts/index.ts— failure-issue filing (reusing executor-e2e GitHub primitives) + env-driven entry point.tests/trigger-e2e/— hand-authoredvictim-pipeline.yml(parameterized),azure-pipelines.ymlorchestrator, andREADME.mdwith the one-time ADO registration handoff.scripts/ado-script/src/executor-e2e/ado-rest.ts— added sharedqueueBuild/waitForBuild/setPullRequestLabelshelpers + optionalisDraftoncreatePullRequest.Not shipped
Excluded from
ado-script.zipexactly like executor-e2e: kept out of thebuildchain, emits to gitignoredtest-bin/trigger-e2e.js, and added toNON_BUNDLE_DIRSinbundle-coverage.test.ts. The runtime zip still contains only production bundles.Test plan
npm run typecheck(scripts/ado-script) ✅gate-specfact derivation/ordering/policies/tag-suffixes/encoding + runner isolation/assertions/cleanup ✅npm run build:trigger-e2e→ 38 KB bundle emitted totest-bin/✅bundle-coverageguard test ✅executor-e2eupload-pipeline-artifact rejection) is pre-existing and reproduces on a clean baseline — a Windows-only node-shebang spawn issue, unrelated to this change.Live end-to-end validation (running against an ADO project + one-time victim/orchestrator pipeline registration) is a manual handoff documented in
tests/trigger-e2e/README.mdand cannot be run in CI/local without ADO access.