Skip to content

Add validated Known Build Error support to test quarantine - #69039

Merged
PureWeen merged 9 commits into
dotnet:mainfrom
PureWeen:pureween-assess-quarantine-fix-workflow
Sep 11, 2026
Merged

PureWeen merged 9 commits into
dotnet:mainfrom
PureWeen:pureween-assess-quarantine-fix-workflow

Conversation

@PureWeen

@PureWeen PureWeen commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

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:

  1. A tracking issue with validated Build Insights Known Build Error (KBE) JSON.
  2. A short investigation comment.
  3. The existing draft quarantine PR linked to that issue.

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

Existing CI/Helix evidence
        |
        v
Deterministic Case A eligibility receipt
        |
        v
Agent proposes a matcher for one candidate
        |
        v
Repository handler validates evidence, eligibility, and matcher
        |
        +--> verified: issue with KBE JSON
        |
        +--> unproven eligibility/matcher: ordinary tracking issue, no KBE

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-failure issue 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_synthdemo resolved to issue 55 in 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 only AdaptiveCapacityDictionaryTests.cs.

No ASP.NET Core test actually failed in this demonstration. It changed no upstream state and applied no Known Build Error label. This is earlier-revision integration evidence, not an end-to-end run of the latest follow-up commit.

Hardening from review

  • Reconstruct assembly quarantine history across the test project, including separate and deleted files and renamed test sources.
  • Track class-level quarantine history across same-project partial declarations, including sibling renames and deletions. Resolve the actual inheritance chain at each applicable transition, not just whether its types existed, including historical intermediates no longer used today.
  • Resolve partial inherited runners conservatively, retaining the selected project through every base-type hop. Reject duplicate full runner identities across projects before accepting a direct method match.
  • Cover Source B authentication, changed-file pagination, and renames.
  • Limit the custom issue handler to one invocation, reuse exact-title open issues through paginated issue listing rather than GitHub Search, and serialize overlapping safe-output runs without cancelling an in-progress write.
  • Reject missing or empty RUNNER_TEMP explicitly before evidence collection or issue-handler evidence access.
  • Preserve Arcade's ordered literal substring matching, with coverage for prefixes/suffixes, nonadjacent lines, ordering, same-line rejection, and collisions in both evidence sources.
  • Run both fixture suites in a separate read-only pull-request workflow, without secrets, persisted checkout credentials, 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.

  • Both the Python collector fixtures and Node handler fixtures pass locally on this head.
  • The Node suite extracts and executes the actual inline safe-output handler rather than a copy.
  • Quarantine workflow checks executed both suites successfully on this same head.
  • The documentation follow-up adds a collector overview and descriptive new-quarantine/re-quarantine terminology. The collector's executable AST, workflow markdown, and generated lock are unchanged from 67a94a6f58.
  • Fourteen focused partial-type cases cover sibling quarantine removal, renames/deletions, inherited and multi-hop resolution, historical applicability, project isolation, and unchanged method-specific freshness. Regression cases failed before their corrections; existing-behavior controls remained green.
  • Twelve additional cases cover late versus pre-existing inheritance, historical-only and newly adopted intermediates, unresolved historical inheritance, assembly applicability, and cross-project runner ambiguity. Eight expose incorrect behavior on d149f79cc0; four preserve existing behavior. All twelve pass on this head.
  • Strict compilation with repository-pinned gh-aw v0.88.2 passes. The generated lock file remains compiler-owned.
  • Earlier eligible Case A and ineligible already-quarantined staged runs exercised handler acceptance and rejection without GitHub writes.

The collector correction in 67a94a6f58 addresses two independently reproduced findings:

  • Regression introduced by 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.
  • Defect present in both f7ca7a6e77 and d149f79cc0: 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 receives Known Build Error only when all required validation succeeds and TEST_QUARANTINE_ENABLE_KBE is exactly true.

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:

  • An individual Source A/B test, not a work-item grouping.
  • Exact C# source resolution, including inherited tests reported as DerivedType.BaseMethod.
  • Project-scoped partial-type history, with the actual runner-to-method inheritance chain resolved at the applicable type or assembly quarantine transition.
  • No current method, type, inherited runner-type, or assembly quarantine.
  • No latest applicable quarantine-removal transition; Case A classification, never Case B.
  • is_consistent_regression == false for Source A.
  • At least two distinct failure builds strictly after the conservative cutoff.
  • Exact evidence build/run/result identity.
  • Exclusion of Source B PRs that touched a declaring or runner path, including previous_filename for renames.

The cutoff includes first-parent origin/main changes 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-kbe guidance follows existing runtime/Arcade conventions and prefers:

  1. A specific, case-sensitive literal failure message.
  2. An ordered array of literal substrings when one message is insufficient.
  3. A bounded regex only when volatile content prevents a safe literal.

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.Contains contract, 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
  • One exact fully qualified test and at most one new Case A issue/PR/comment chain per activation.
  • Threat detection must succeed before writes.
  • Exact-title open tracking issues are reused without editing or relabeling them.
  • Human log excerpts are secret-scrubbed and HTML-escaped.
  • Existing Case B re-quarantine and unquarantine workflow actions remain separate and unchanged; the collector corrections above affect historical classification.
  • This adds no automatic test fixing, PR approval, or merging. Draft quarantine PRs retain human review.

@PureWeen PureWeen changed the title Capture the real error signature in new quarantine issues Create validated KBEs for new test quarantines Sep 4, 2026

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .github/workflows/test-quarantine.md Resolved
Comment thread .github/workflows/test-quarantine.md Resolved
Comment thread .github/workflows/test-quarantine.md Resolved
@PureWeen
PureWeen force-pushed the pureween-assess-quarantine-fix-workflow branch from 529157d to 387bb03 Compare September 4, 2026 10:00
Copilot AI added 5 commits September 4, 2026 10:54
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
@PureWeen
PureWeen force-pushed the pureween-assess-quarantine-fix-workflow branch from ef562ab to 48b6a87 Compare September 4, 2026 15:56
@PureWeen
PureWeen requested review from a team and wtgodbe September 4, 2026 17:23
@PureWeen
PureWeen marked this pull request as ready for review September 6, 2026 15:39
Copilot AI lite review requested due to automatic review settings September 6, 2026 15:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity · 1 Low severity

New issues introduced by this change (3)
Severity Finding
Medium severity .github/​workflows/​test-quarantine.md — The Part 1 evidence file is written using a RUNNER_TEMP fallback to /tmp, but subsequent steps read…
Medium severity .github/​workflows/​test-quarantine.md — For literal-array matchers, orderedLiteralMatch currently uses substring matching…
Low severity .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_issue safe-output script that re-validates eligibility/evidence identity, enforces matcher specificity rules, and conditionally emits the 4-key Build Insights JSON + Known Build Error label behind TEST_QUARANTINE_ENABLE_KBE.
  • Introduce shared matcher/duplicate-search instructions and a create-kbe skill, 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.

Comment thread .github/workflows/test-quarantine.md Resolved
Comment thread .github/workflows/test-quarantine.md Resolved
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
@PureWeen PureWeen changed the title Create validated KBEs for new test quarantines Add validated Known Build Error support to test quarantine Sep 9, 2026
Copilot AI added 2 commits September 9, 2026 13:40
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
Comment thread .github/workflows/test-quarantine.md Resolved
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
@PureWeen
PureWeen merged commit d5aa21e into dotnet:main Sep 11, 2026
18 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 12, 2026
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.

4 participants