Repository navigation
Add validated Known Build Error support to test quarantine - #69039
Conversation
PureWeen
left a comment
There was a problem hiding this comment.
Three high-confidence correctness/reliability issues survived independent review and cross-checking. The action pin, generated lock consistency, temporary-ID wiring, staged handler contract, and output escaping did not produce actionable findings.
529157d to
387bb03
Compare
Quarantine issues recorded the agent's prose description of a failure rather than the failure itself. That text is not matchable, and the Azure DevOps build it came from ages out of public retention, so within a few weeks the issue is the only surviving record of the failure and it no longer contains the actual error. Anyone picking the test up later has nothing precise to work from. The collector already fetched errorMessage and stackTrace per test to build the agent prompt, so the data was always present; only the paraphrasing destroyed it. It now derives an Arcade Known Issue payload from that same text and the agent pastes it verbatim instead of describing it. The signature is a literal substring of the real errorMessage. Volatile fragments (ports, GUIDs, timings, addresses, paths, counters) are located and the longest contiguous stable run between them is taken; fragments are never stitched together, because Arcade matches with String.Contains and a stitched string would never match anything. When no trustworthy signature can be derived the payload is omitted and the reason recorded, rather than emitting one that would match half the repository. ExcludeConsoleLog is set because one xunit console log is shared by every test in a Helix work item, so including it attributes unrelated failures to the issue. The section uses the "### Known Issue Error Message" heading to avoid colliding with the template's human-readable "## Error Message" prose. The "Known Build Error" label is deliberately not applied. A Known Build Error means a failure still blocks other people's builds, and a quarantined test no longer blocks anything. Registering these is a separate human decision; this change only prepares a valid payload. The marker embeds a sha256 prefix of the ErrorMessage so any consumer can detect paraphrasing or truncation without access to the originating run. This detects mangling, not forgery, and the tests demonstrate that boundary. Tests extract the derivation from the workflow between sentinel comments and execute it, so they exercise the shipped code rather than a copy. They include an independent reproduction of the signature a human hand-wrote for the real Known Build Error on dotnet#68708. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d5905c51-843f-4d8c-9852-cbbcf77d7723
Generate quarantine issues through a deterministic safe-output handler that validates runtime-style matchers against captured test evidence and gates Build Insights enrollment. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d5905c51-843f-4d8c-9852-cbbcf77d7723
Co-authored-by: Copilot App <[email protected]> Copilot-Session: d5905c51-843f-4d8c-9852-cbbcf77d7723
Co-authored-by: Copilot App <[email protected]> Copilot-Session: d5905c51-843f-4d8c-9852-cbbcf77d7723
Track assembly-level quarantine removals across project history, fail closed on ambiguous source associations, and cover renamed or inherited test layouts. Enforce a single custom issue call and use deterministic exact-title issue reuse. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d5905c51-843f-4d8c-9852-cbbcf77d7723
ef562ab to
48b6a87
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
There are a couple of concrete correctness/safety gaps (inconsistent RUNNER_TEMP fallback paths and overly-permissive literal-array matching) plus CI execution coverage concerns for the new validation scripts.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Lite
Findings: 2
New issues introduced by this change (3)
| Severity | Finding |
|---|---|
.github/workflows/test-quarantine.md — The Part 1 evidence file is written using a RUNNER_TEMP fallback to /tmp, but subsequent steps read… |
|
.github/workflows/test-quarantine.md — For literal-array matchers, orderedLiteralMatch currently uses substring matching… |
|
.github/workflows/scripts/test-quarantine/README.md — The repo now contains executable validation scripts for the handler and collector, but I couldn't… |
What changed in this PR
This PR hardens the test-quarantine agentic workflow to deterministically validate “Case A” quarantine eligibility and, when fully verified, generate a quarantine tracking issue that can optionally include Build Insights Known Build Error (KBE) JSON via a repository-owned safe-output handler.
Changes:
- Persist deterministic Part 1 evidence and generate a collector-authored Case A eligibility receipt (uploaded as a short-lived artifact) before the agent runs.
- Add a new
create_quarantine_issuesafe-output script that re-validates eligibility/evidence identity, enforces matcher specificity rules, and conditionally emits the 4-key Build Insights JSON +Known Build Errorlabel behindTEST_QUARANTINE_ENABLE_KBE. - Introduce shared matcher/duplicate-search instructions and a
create-kbeskill, plus local validation scripts/docs for the handler and collector.
| File | Description |
|---|---|
| .github/workflows/test-quarantine.md | Captures deterministic evidence, runs the eligibility collector, injects eligible tests, and adds the create_quarantine_issue safe-output handler + skill wiring. |
| .github/workflows/test-quarantine.lock.yml | Regenerated gh-aw compiled workflow reflecting the new safe-output script, skill, concurrency, and env wiring. |
| .github/workflows/shared/create-kbe.instructions.md | New shared guidance for duplicate detection + matcher selection for KBEs. |
| .github/workflows/scripts/test-quarantine/collect_case_a_eligibility.py | Deterministic Case A eligibility collector (source/quarantine/history resolution and PR-changed-file exclusion). |
| .github/workflows/scripts/test-quarantine/test_collect_case_a_eligibility.py | Python fixture coverage for collector edge cases (assembly quarantine history, renames, inherited runners, Source B changed-file exclusion, etc.). |
| .github/workflows/scripts/test-quarantine/test_kbe_issue_handler.js | Node-based executable validation for the embedded safe-output handler logic extracted from the workflow source. |
| .github/workflows/scripts/test-quarantine/README.md | Documentation for the evidence flow, safety properties, and how to run validations locally. |
| .github/skills/create-kbe/SKILL.md | Adds a workflow skill to guide matcher selection and required duplicate searching. |
Suppressed comments (1)
.github/workflows/test-quarantine.md:1196
- This writes the closed-prs receipt to RUNNER_TEMP with a /tmp fallback, but later passes the path as "${RUNNER_TEMP}/test-quarantine-closed-prs.json". If RUNNER_TEMP is unavailable, the file ends up in a different directory and the collector invocation will fail. Make RUNNER_TEMP required (or consistently derive the temp dir once) to keep the evidence location deterministic.
pathlib.Path(
os.environ.get("RUNNER_TEMP", "/tmp"),
"test-quarantine-closed-prs.json",
).write_text(json.dumps(parsed, separators=(",", ":")), encoding="utf-8")
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Run quarantine fixtures in isolated pull request CI, document ordered substring matching, and fail clearly when RUNNER_TEMP is missing or empty. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d5905c51-843f-4d8c-9852-cbbcf77d7723
Resolve partial inherited runners within their project and apply logical type quarantine history only to methods and runners present at the transition. Preserve method-scoped freshness, cover the regression cases, and bound historical indexing work. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d5905c51-843f-4d8c-9852-cbbcf77d7723
Resolve inherited tests against the chain present at quarantine transitions, including historical-only intermediates. Reject cross-project runner ambiguity before direct matches and preserve method-scoped freshness policy. Add red/green regression coverage and document identity limits. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d5905c51-843f-4d8c-9852-cbbcf77d7723
Explain the collector's responsibilities and use descriptive new-quarantine and re-quarantine terminology while preserving receipt identifiers and workflow behavior. Co-authored-by: Copilot App <[email protected]> Copilot-Session: d5905c51-843f-4d8c-9852-cbbcf77d7723


Note
Ready for workflow-safety review. Automatic Known Build Error enrollment remains disabled until a separately approved post-merge canary. The fork demonstration below exercises real GitHub outputs with synthetic evidence; it does not prove live Build Insights enrollment.
What this changes
The test-quarantine workflow already gathers failing tests, builds, test results, errors, and stack traces. This PR preserves that evidence and adds a deterministic eligibility collector and repository-owned issue handler for new Case A quarantines.
For one eligible new quarantine, the workflow can produce:
The collector enforces the repository's Case A eligibility rules. The agent proposes a narrow matcher, but the handler independently validates the evidence and eligibility receipt and owns the final issue format, title, labels, and KBE JSON. Agent-written excerpts and links are for human display, not validation evidence.
Evidence and output boundary
The collector records exact source and quarantine state, history, cutoff, and build/run/result identity. The handler binds that receipt to the Part 1 evidence SHA-256 and repository/ref/commit identity before accepting it for KBE generation.
Unproven eligibility or an incomplete, broad, or colliding matcher cannot activate a KBE. Where tracking evidence is valid, the handler falls back to an ordinary
test-failureissue without KBE JSON or labeling. Missing required evidence or failed threat detection stops the affected issue write.Working fork demonstration
I exercised the GitHub write path in my public fork with deliberately synthetic failure data:
That run created exactly one issue, one comment, and one draft PR. Threat detection and safe-output processing ran, and
aw_synthdemoresolved to issue55in the comment target, PR body, and committed[QuarantinedTest("https://github.com/PureWeen/aspnetcore/issues/55")]attribute. The demo PR targets this feature branch and changes onlyAdaptiveCapacityDictionaryTests.cs.No ASP.NET Core test actually failed in this demonstration. It changed no upstream state and applied no
Known Build Errorlabel. This is earlier-revision integration evidence, not an end-to-end run of the latest follow-up commit.Hardening from review
RUNNER_TEMPexplicitly before evidence collection or issue-handler evidence access.pull_request_target, or an artifact handoff to privileged jobs.Repository commit
71e388eab781698fa8e4e8afa5f3df464788f4c1, which removed an assembly quarantine from a separate ProjectTemplates fixture file, is a representative real history case used to exercise the collector.Validation
Current PR head:
857c99944bb65d307c93fe5719c22bec46336611.67a94a6f58.d149f79cc0; four preserve existing behavior. All twelve pass on this head.The collector correction in
67a94a6f58addresses two independently reproduced findings:d149f79cc0: type existence was insufficient to establish that a runner inherited the test when quarantine was removed. Late inheritance must not become Case B solely because the runner type already existed. A runner that already inherited the test remains Case B.f7ca7a6e77andd149f79cc0: a unique direct method in one project could mask an inherited match for the same full runner name in another project, even with evidence naming the latter assembly. The bounded correction rejects that ambiguous identity instead of selecting the direct match.These are collector/receipt reproductions using real temporary Git histories and synthetic CI records, not observed production incidents. The correction retains method-specific freshness and Source B exclusions; it does not broaden either to unrelated sibling-file edits.
Assembly-qualified aggregation is not redesigned: Part 1 still groups by normalized test name, and a representative assembly is not used to select a source project. Method-level file/hunk quarantine history also remains unchanged. Unresolved historical inheritance is unproven, not evidence that the runner never inherited the test.
The correction does not change the matcher semantics or GitHub output path exercised by the earlier fork demonstration. Fixture tests do not run an agent or prove live Build Insights enrollment. A full ASP.NET Core product test run is not a substitute for those workflow integration boundaries.
Rollout remains separate
Every newly created tracking issue receives
test-failure. It receivesKnown Build Erroronly when all required validation succeeds andTEST_QUARANTINE_ENABLE_KBEis exactlytrue.This PR does not create or enable that variable. Keep it absent or disabled on merge, observe a real eligible workflow run with enrollment off, and separately approve a single enrollment-on canary before broader use. Disabling the variable prevents new enrollment; it does not undo an issue already enrolled.
The fork demonstration does not establish shared DNCENG Known Build Errors project enrollment or matching of a real Build Insights occurrence. Those remain the explicit live-canary acceptance boundary.
Detailed eligibility and matcher rules
Deterministic Case A gates
KBE generation requires:
DerivedType.BaseMethod.is_consistent_regression == falsefor Source A.previous_filenamefor renames.The cutoff includes first-parent
origin/mainchanges to every declaring/runner file, quarantine-removal history, and trusted prior suppression/attempt history. An unrelated same-file edit can defer a valid candidate rather than accepting stale evidence.Matcher contract
The
create-kbeguidance follows existing runtime/Arcade conventions and prefers:For arrays, each element must match a later line than the previous element. Matching lines need not be adjacent, and prefixes and suffixes are allowed. This follows Arcade's per-line
String.Containscontract, not whole-line equality; the same semantics apply when checking collisions against other tests.The handler rejects bare test names, stack frames, exception types, generic assertion/timeout/crash/infrastructure text, cross-test matches, unsafe regex constructs, and oversized bounds.
A verified issue ends with exactly one Build Insights block:
{ "ErrorMessage": "...", "ErrorPattern": "", "BuildRetry": false, "ExcludeConsoleLog": true }Exactly one matcher field is populated. KBE JSON alone is not enrollment; the label remains gated by the rollout variable.
Operational boundaries