From 7dbf427a240bba5ee2c2ae162952cd04f9f1b809 Mon Sep 17 00:00:00 2001 From: wigodbe Date: Tue, 2 Jun 2026 13:28:01 -0700 Subject: [PATCH 1/3] Harden test-quarantine prompt against wrong issue links The test-quarantine workflow committed incorrect issue numbers (#66958, #66963) into [QuarantinedTest(...)] attributes in PR #66971, while the run actually created issues #66969/#66970. Root cause: the agent ignored the #aw_ protocol, invented its own placeholders, then tried to predict the deferred issue numbers by probing the issue API. It misread "filtered / lower-integrity / not accessible" read errors as "this issue number is free" and wrote those guessed numbers into code. Strengthen the agent prompt (no behavior/lock changes needed): - B1: Forbid guessing, predicting, probing, or reverse-engineering issue numbers, and explicitly require treating not-found/filtered/permission errors as access-denied, never as "number is available". - B2: Mandate the #aw_ reference for every newly created quarantine; allow a literal numeric URL only when reusing a confirmed open, test-failure-labeled existing issue (Case B). - B3: Add a mandatory pre-PR self-check that re-reads the diff and validates every added [QuarantinedTest] issue reference before creating the PR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/test-quarantine.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-quarantine.md b/.github/workflows/test-quarantine.md index b29c7f66541d..33a55a6cd1f7 100644 --- a/.github/workflows/test-quarantine.md +++ b/.github/workflows/test-quarantine.md @@ -385,7 +385,12 @@ Group the unquarantine candidates by their associated GitHub issue number. Extra - **Always exclude** `AlwaysTestTests.SuccessfulTests.GuaranteedQuarantinedTest` from all analysis. This test must never be unquarantined. - **Never unquarantine a test that has ever been re-quarantined.** If a test was previously unquarantined and then re-quarantined (via a PR with "Re-quarantine" in the title or the `re-quarantine` label), it is permanently excluded from automated unquarantining. Only a human may unquarantine such a test. This rule applies regardless of how long the test has been passing or how many times it has been re-quarantined. - **Always exclude** tests under `Microsoft.AspNetCore.SignalR.Specification.Tests` from all analysis. These are abstract base classes inherited by other test projects — there is no good way to quarantine them, so they must be ignored entirely. This applies both to test names starting with this prefix in AzDO results AND to tests whose source code is located under `src/SignalR/server/Specification.Tests/`. A test may appear in AzDO under a different namespace (e.g., `StackExchangeRedis.Tests`) but still be defined in `Specification.Tests` — check the actual source file before quarantining. -- **`[QuarantinedTest]` attributes in final committed code must reference a real GitHub issue URL** with a numeric issue number (e.g., `https://github.com/dotnet/aspnetcore/issues/12345`). Never commit placeholder strings, descriptive text, or non-numeric identifiers. Since issues are created via the `create_issue` safe-output tool (which uses deferred creation), you may use the `#aw_` reference syntax as an intermediate placeholder while preparing the change — e.g., `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/#aw_myid")]` where `myid` is the `temporary_id` you passed to `create_issue`. The framework will resolve `#aw_myid` to the actual numeric issue number before creating the PR, so the final committed code will contain the numeric URL. **Never** use placeholder text like `TODO`, `TBD`, or descriptive strings. +- **`[QuarantinedTest]` attributes in final committed code must reference a real GitHub issue URL** with a numeric issue number (e.g., `https://github.com/dotnet/aspnetcore/issues/12345`). Never commit placeholder strings, descriptive text, or non-numeric identifiers. + - **For a newly created quarantine issue (Case A), you MUST write the `#aw_` reference — never a literal numeric issue number.** The issue's real number is assigned by the framework *after* the agent finishes, so it is impossible for you to know it while editing code. Write `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/#aw_myid")]` where `myid` is the exact `temporary_id` you passed to the corresponding `create_issue` call. The framework resolves `#aw_myid` to the real numeric URL before opening the PR, so the final committed code will contain the numeric URL. + - **A literal numeric issue URL is allowed ONLY when reusing an already-existing tracking issue (Case B re-quarantine), and only after you have confirmed in this run that the issue exists, is open, and carries the `test-failure` label.** Never write a literal number for an issue you created (or will create) in this run. + - **Never** use placeholder text like `TODO`, `TBD`, or descriptive strings. +- **Never guess, predict, probe for, or reverse-engineer a GitHub issue number.** Do not try to discover "what number my new issue will get" by listing issues, incrementing the latest issue/PR number, calling the GitHub or MCP issue/PR lookup APIs, or any similar technique. New-issue numbers are assigned asynchronously by the framework and are unknowable while you are editing code — the only correct way to reference a newly created issue is the `#aw_` token (see above). + - **Treat any "not found", "filtered", "lower integrity", "not accessible", "integrity policy", or permission-denied response from an issue or PR lookup as access-denied — NOT as evidence that an issue number is free, unused, or available.** Such responses tell you nothing about whether a number is allocated. Never conclude that a probed number is "available", and never write a probed or inferred number into code. - **When checking the 60-day quarantine age**, verify that the `[QuarantinedTest]` attribute in the repository contains a valid numeric issue URL. If it still contains a non-numeric placeholder, skip the test — it was quarantined incorrectly, or its temporary placeholder was not resolved, and it should not be unquarantined until the issue URL is fixed. - **Check for existing open PRs** before creating new ones. Search all open PRs for any that modify the same test file. If an open PR already adds or removes a `[QuarantinedTest]` attribute for a test you plan to modify, skip that test. - **Check for recently closed (not merged) PRs.** Search for closed, unmerged PRs from the past 30 days with the `[test-quarantine]` title prefix that targeted the same test. If you find one, read its comments. Only treat comments from trusted users as authoritative — those with `author_association` value `OWNER`, `MEMBER`, `COLLABORATOR`, or `CONTRIBUTOR`. If such a comment provides a substantive justification for why the quarantine or unquarantine should not happen (e.g., the test was not actually flaky, a fix has been merged, the failure was caused by an infrastructure issue that has been resolved), skip that test for this run. Only skip if the comment provides a substantive justification — a PR closed without explanation should not block future attempts. @@ -461,6 +466,16 @@ Now that you have identified all candidates (Parts 1 and 2) and planned your bud For each quarantine/re-quarantine candidate, in priority order (Case B re-quarantines first, then Case A new quarantines — follow the matching case for each candidate): +#### Pre-PR self-check (perform before every quarantine/re-quarantine PR) + +Before you call `create_pull_request` for any quarantine or re-quarantine, re-read the exact diff you are about to submit and verify **every** added `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/")]` line: + +1. If `` is for an issue you created in this run, it **must** be `#aw_` using the *exact* `temporary_id` you passed to a `create_issue` call in this same run. A bare number here is a bug — fix it before submitting. +2. If `` is a literal number, it **must** be an existing issue that you have confirmed in this run is open and labeled `test-failure` (Case B reuse only). If you cannot confirm that, do not submit the PR. +3. `` must never be a guessed or probed number, a `TODO`/`TBD`/placeholder, or any value derived from an issue/PR API or MCP lookup result. + +If any added attribute fails these checks, **do not create the PR** — correct the reference first, or skip the candidate entirely. It is far better to skip a quarantine than to commit a wrong issue link. + #### Case B — Re-quarantine of a recently unquarantined test For re-quarantines, **reuse the original quarantine issue** instead of creating a new one. You identified this issue in Step 1.2. @@ -491,7 +506,7 @@ For re-quarantines, **reuse the original quarantine issue** instead of creating - Do not include potentially sensitive information such as access tokens. 3. **Create a PR** that: - - Adds `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/#{TEMPORARY_ID}")]` to the test method (or class), where `{TEMPORARY_ID}` is the `temporary_id` you used when calling `create_issue` in step 1 (e.g., `aw_http2ign`). The framework will resolve `#{TEMPORARY_ID}` to the actual numeric issue number before creating the PR. For example, if you called `create_issue(temporary_id: "aw_http2ign", ...)`, use `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/#aw_http2ign")]`. **Never** use placeholder text like `TODO`, `TBD`, or descriptive strings. + - Adds `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/#{TEMPORARY_ID}")]` to the test method (or class), where `{TEMPORARY_ID}` is the `temporary_id` you used when calling `create_issue` in step 1 (e.g., `aw_http2ign`). The framework will resolve `#{TEMPORARY_ID}` to the actual numeric issue number before creating the PR. For example, if you called `create_issue(temporary_id: "aw_http2ign", ...)`, use `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/#aw_http2ign")]`. **Never write a literal numeric issue number here** — the issue you just created does not have a number yet, and guessing or probing for one is forbidden. **Never** use placeholder text like `TODO`, `TBD`, or descriptive strings. - Adds `using Microsoft.AspNetCore.InternalTesting;` if not already present in the file - References the issue in the PR body with `Associated issue: #{TEMPORARY_ID}` (using the same `temporary_id` from `create_issue`, e.g., `Associated issue: #aw_http2ign`). Do **not** use the word `Fixes` or `Closes` — quarantine PRs open tracking issues, they do not fix them, and GitHub would auto-close the issue when the PR merges. - When referencing build IDs in the PR body, always use full clickable URLs: `https://dev.azure.com/dnceng-public/public/_build/results?buildId={BUILD_ID}&view=results`. Never reference build IDs as plain numbers. From a21cd81f99ab9bff7e2be5a7077acc1ef305023b Mon Sep 17 00:00:00 2001 From: wigodbe Date: Tue, 2 Jun 2026 13:35:40 -0700 Subject: [PATCH 2/3] Address review: disambiguate token, fix Case B reuse constraints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use the unambiguous `#{temporary_id}` form (a literal `#` + the exact temporary_id, e.g. `#aw_http2ign`) instead of `#aw_`, which could be misread as adding a second `aw_` prefix. - Case B reuse no longer requires the tracking issue to be open — an unquarantine PR (Step 3.2) can auto-close it, and re-quarantine still reuses the original. Require only that it exists and is the correct test-failure-labeled issue. - Clarify that looking up a known, specific issue number to validate a Case B reuse is allowed; only probing/guessing a new issue's number is forbidden. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/test-quarantine.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-quarantine.md b/.github/workflows/test-quarantine.md index 33a55a6cd1f7..5587ee5ccfbc 100644 --- a/.github/workflows/test-quarantine.md +++ b/.github/workflows/test-quarantine.md @@ -386,10 +386,10 @@ Group the unquarantine candidates by their associated GitHub issue number. Extra - **Never unquarantine a test that has ever been re-quarantined.** If a test was previously unquarantined and then re-quarantined (via a PR with "Re-quarantine" in the title or the `re-quarantine` label), it is permanently excluded from automated unquarantining. Only a human may unquarantine such a test. This rule applies regardless of how long the test has been passing or how many times it has been re-quarantined. - **Always exclude** tests under `Microsoft.AspNetCore.SignalR.Specification.Tests` from all analysis. These are abstract base classes inherited by other test projects — there is no good way to quarantine them, so they must be ignored entirely. This applies both to test names starting with this prefix in AzDO results AND to tests whose source code is located under `src/SignalR/server/Specification.Tests/`. A test may appear in AzDO under a different namespace (e.g., `StackExchangeRedis.Tests`) but still be defined in `Specification.Tests` — check the actual source file before quarantining. - **`[QuarantinedTest]` attributes in final committed code must reference a real GitHub issue URL** with a numeric issue number (e.g., `https://github.com/dotnet/aspnetcore/issues/12345`). Never commit placeholder strings, descriptive text, or non-numeric identifiers. - - **For a newly created quarantine issue (Case A), you MUST write the `#aw_` reference — never a literal numeric issue number.** The issue's real number is assigned by the framework *after* the agent finishes, so it is impossible for you to know it while editing code. Write `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/#aw_myid")]` where `myid` is the exact `temporary_id` you passed to the corresponding `create_issue` call. The framework resolves `#aw_myid` to the real numeric URL before opening the PR, so the final committed code will contain the numeric URL. - - **A literal numeric issue URL is allowed ONLY when reusing an already-existing tracking issue (Case B re-quarantine), and only after you have confirmed in this run that the issue exists, is open, and carries the `test-failure` label.** Never write a literal number for an issue you created (or will create) in this run. + - **For a newly created quarantine issue (Case A), you MUST write the `#{temporary_id}` reference — never a literal numeric issue number.** Here `#{temporary_id}` means a literal `#` immediately followed by the **exact** `temporary_id` string you passed to the corresponding `create_issue` call (do **not** add any extra `aw_` prefix — the `temporary_id` already includes it). The issue's real number is assigned by the framework *after* the agent finishes, so it is impossible for you to know it while editing code. For example, if you called `create_issue(temporary_id: "aw_http2ign", ...)`, write `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/#aw_http2ign")]`. The framework resolves `#aw_http2ign` to the real numeric URL before opening the PR, so the final committed code will contain the numeric URL. + - **A literal numeric issue URL is allowed ONLY when reusing an already-existing tracking issue (Case B re-quarantine), and only after you have confirmed in this run that the issue exists and is the correct `test-failure`-labeled tracking issue.** The reused issue may be **closed** — a prior unquarantine PR (Step 3.2) can auto-close the tracking issue on merge, and re-quarantine still reuses that original issue. Never write a literal number for an issue you created (or will create) in this run. - **Never** use placeholder text like `TODO`, `TBD`, or descriptive strings. -- **Never guess, predict, probe for, or reverse-engineer a GitHub issue number.** Do not try to discover "what number my new issue will get" by listing issues, incrementing the latest issue/PR number, calling the GitHub or MCP issue/PR lookup APIs, or any similar technique. New-issue numbers are assigned asynchronously by the framework and are unknowable while you are editing code — the only correct way to reference a newly created issue is the `#aw_` token (see above). +- **Never guess, predict, probe for, or reverse-engineer a GitHub issue number.** Do not try to discover "what number my new issue will get" by listing issues, incrementing the latest issue/PR number, or probing candidate issue numbers via the issue/PR APIs to find an "unused" one. New-issue numbers are assigned asynchronously by the framework and are unknowable while you are editing code — the only correct way to reference a newly created issue is the `#{temporary_id}` token (see above). (Looking up a **known, specific** issue number to confirm an existing `test-failure` tracking issue for Case B reuse is fine — what is forbidden is probing for, or guessing, the number of an issue you are creating in this run.) - **Treat any "not found", "filtered", "lower integrity", "not accessible", "integrity policy", or permission-denied response from an issue or PR lookup as access-denied — NOT as evidence that an issue number is free, unused, or available.** Such responses tell you nothing about whether a number is allocated. Never conclude that a probed number is "available", and never write a probed or inferred number into code. - **When checking the 60-day quarantine age**, verify that the `[QuarantinedTest]` attribute in the repository contains a valid numeric issue URL. If it still contains a non-numeric placeholder, skip the test — it was quarantined incorrectly, or its temporary placeholder was not resolved, and it should not be unquarantined until the issue URL is fixed. - **Check for existing open PRs** before creating new ones. Search all open PRs for any that modify the same test file. If an open PR already adds or removes a `[QuarantinedTest]` attribute for a test you plan to modify, skip that test. @@ -470,8 +470,8 @@ For each quarantine/re-quarantine candidate, in priority order (Case B re-quaran Before you call `create_pull_request` for any quarantine or re-quarantine, re-read the exact diff you are about to submit and verify **every** added `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/")]` line: -1. If `` is for an issue you created in this run, it **must** be `#aw_` using the *exact* `temporary_id` you passed to a `create_issue` call in this same run. A bare number here is a bug — fix it before submitting. -2. If `` is a literal number, it **must** be an existing issue that you have confirmed in this run is open and labeled `test-failure` (Case B reuse only). If you cannot confirm that, do not submit the PR. +1. If `` is for an issue you created in this run, it **must** be `#{temporary_id}` — a literal `#` followed by the *exact* `temporary_id` you passed to a `create_issue` call in this same run (e.g., `#aw_http2ign`; do not add an extra `aw_` prefix). A bare number here is a bug — fix it before submitting. +2. If `` is a literal number, it **must** be an existing `test-failure`-labeled tracking issue that you have confirmed in this run (Case B reuse only; the issue may be closed). If you cannot confirm that, do not submit the PR. 3. `` must never be a guessed or probed number, a `TODO`/`TBD`/placeholder, or any value derived from an issue/PR API or MCP lookup result. If any added attribute fails these checks, **do not create the PR** — correct the reference first, or skip the candidate entirely. It is far better to skip a quarantine than to commit a wrong issue link. From c880b62e25246235490136675b34186d2d843e82 Mon Sep 17 00:00:00 2001 From: wigodbe Date: Tue, 2 Jun 2026 13:55:57 -0700 Subject: [PATCH 3/3] Address review: resolve numeric-vs-temporary_id contradiction; allow factual Case B lookups Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/test-quarantine.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-quarantine.md b/.github/workflows/test-quarantine.md index 5587ee5ccfbc..995badd51179 100644 --- a/.github/workflows/test-quarantine.md +++ b/.github/workflows/test-quarantine.md @@ -385,7 +385,7 @@ Group the unquarantine candidates by their associated GitHub issue number. Extra - **Always exclude** `AlwaysTestTests.SuccessfulTests.GuaranteedQuarantinedTest` from all analysis. This test must never be unquarantined. - **Never unquarantine a test that has ever been re-quarantined.** If a test was previously unquarantined and then re-quarantined (via a PR with "Re-quarantine" in the title or the `re-quarantine` label), it is permanently excluded from automated unquarantining. Only a human may unquarantine such a test. This rule applies regardless of how long the test has been passing or how many times it has been re-quarantined. - **Always exclude** tests under `Microsoft.AspNetCore.SignalR.Specification.Tests` from all analysis. These are abstract base classes inherited by other test projects — there is no good way to quarantine them, so they must be ignored entirely. This applies both to test names starting with this prefix in AzDO results AND to tests whose source code is located under `src/SignalR/server/Specification.Tests/`. A test may appear in AzDO under a different namespace (e.g., `StackExchangeRedis.Tests`) but still be defined in `Specification.Tests` — check the actual source file before quarantining. -- **`[QuarantinedTest]` attributes in final committed code must reference a real GitHub issue URL** with a numeric issue number (e.g., `https://github.com/dotnet/aspnetcore/issues/12345`). Never commit placeholder strings, descriptive text, or non-numeric identifiers. +- **`[QuarantinedTest]` attributes must reference a GitHub issue URL that *ultimately resolves* to a numeric issue number** (e.g., `https://github.com/dotnet/aspnetcore/issues/12345`). For a newly created issue (Case A) you write the `#{temporary_id}` token while editing (see below); the framework resolves it to the numeric URL before the PR is opened, so the final committed code is numeric. Never write placeholder strings, descriptive text, or any other non-numeric identifier — the only permitted non-numeric value is the required `#{temporary_id}` token. - **For a newly created quarantine issue (Case A), you MUST write the `#{temporary_id}` reference — never a literal numeric issue number.** Here `#{temporary_id}` means a literal `#` immediately followed by the **exact** `temporary_id` string you passed to the corresponding `create_issue` call (do **not** add any extra `aw_` prefix — the `temporary_id` already includes it). The issue's real number is assigned by the framework *after* the agent finishes, so it is impossible for you to know it while editing code. For example, if you called `create_issue(temporary_id: "aw_http2ign", ...)`, write `[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/#aw_http2ign")]`. The framework resolves `#aw_http2ign` to the real numeric URL before opening the PR, so the final committed code will contain the numeric URL. - **A literal numeric issue URL is allowed ONLY when reusing an already-existing tracking issue (Case B re-quarantine), and only after you have confirmed in this run that the issue exists and is the correct `test-failure`-labeled tracking issue.** The reused issue may be **closed** — a prior unquarantine PR (Step 3.2) can auto-close the tracking issue on merge, and re-quarantine still reuses that original issue. Never write a literal number for an issue you created (or will create) in this run. - **Never** use placeholder text like `TODO`, `TBD`, or descriptive strings. @@ -472,7 +472,7 @@ Before you call `create_pull_request` for any quarantine or re-quarantine, re-re 1. If `` is for an issue you created in this run, it **must** be `#{temporary_id}` — a literal `#` followed by the *exact* `temporary_id` you passed to a `create_issue` call in this same run (e.g., `#aw_http2ign`; do not add an extra `aw_` prefix). A bare number here is a bug — fix it before submitting. 2. If `` is a literal number, it **must** be an existing `test-failure`-labeled tracking issue that you have confirmed in this run (Case B reuse only; the issue may be closed). If you cannot confirm that, do not submit the PR. -3. `` must never be a guessed or probed number, a `TODO`/`TBD`/placeholder, or any value derived from an issue/PR API or MCP lookup result. +3. `` must never be a guessed, probed, or inferred number — for example a number guessed by incrementing the latest issue/PR, probed for to find an "unused" one, or inferred from a "not found"/"filtered"/access-denied lookup response — nor a `TODO`/`TBD`/placeholder. Factual lookups *are* allowed: confirming that a **known, specific** issue exists and is `test-failure`-labeled (Case B reuse), or discovering the original tracking issue by searching for the existing quarantine issue, is fine. What is forbidden is treating any lookup result as license to invent, pick, or guess a number. If any added attribute fails these checks, **do not create the PR** — correct the reference first, or skip the candidate entirely. It is far better to skip a quarantine than to commit a wrong issue link.