Skip to content

[test-quarantine] Fix guardrails that let the workflow re-attempt rejected actions - #67620

Merged
wtgodbe merged 1 commit into
dotnet:mainfrom
wtgodbe:wtgodbe/quarantine-guardrails
Jul 6, 2026
Merged

wtgodbe merged 1 commit into
dotnet:mainfrom
wtgodbe:wtgodbe/quarantine-guardrails

Conversation

@wtgodbe

@wtgodbe wtgodbe commented Jul 6, 2026

Copy link
Copy Markdown
Member

Problem

The daily Test Quarantine agent recently re-attempted two actions that maintainers had already rejected (run 28656097334):

  1. Bad unquarantine — #67577 tried to unquarantine TlsHandshakeFeatureTests.SetsTlsHandshakeFeatureForHttps even though its tracking issue Quarantine SetsTlsHandshakeFeatureForHttps #49306 carries the re-quarantine label (must never be auto-unquarantined).
  2. Bad re-quarantine — #67576 re-quarantined TestServerTests.WebSocketsWorks despite maintainer "do not quarantine" comments on the already-rejected [test-quarantine] Re-Quarantine TestServerTests.WebSocketsWorks #67443 and [test-quarantine] Re-Quarantine TestServerTests.WebSocketsWorks #67415.

Root causes

Fix

Two new deterministic pre-activation steps (Python over the GitHub REST API, full token, bypassing MCP filtering) inject JSON into the agent prompt, and two body guardrails now consume it:

  • requarantine_issue_numbers — every issue labeled re-quarantine. The unquarantine guardrail gains an authoritative check (a): if a candidate's [QuarantinedTest] issue number is in this set, it is permanently skipped (fail-closed if the data is missing). The old diff-parse check remains as check (b).
  • closed_quarantine_prs — closed-but-unmerged [test-quarantine] PRs from the last 30 days, each with title, body, and trusted-author comments. The closed-PR guardrail now uses this instead of MCP search, so bot-authored PRs and their maintainer comments are always visible.

Review feedback applied: inject the PR body (grouped PRs don't list every test in the title), filter comments to trusted author_association in the fetch step (shrinks payload + keeps untrusted text out of the prompt), treat injected text as untrusted/non-instruction, and make the fallback path python3/urllib + explicitly fail-closed.

Also bumped the gh-aw CLI to v0.81.6 and recompiled the lockfile (gh-aw-actions/setup v0.80.9 → v0.81.6).

Validation

Only the test-quarantine workflow files change.

Copilot AI review requested due to automatic review settings July 6, 2026 18:06
@wtgodbe
wtgodbe requested a review from a team as a code owner July 6, 2026 18:06

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.

Pull request overview

Updates the daily test-quarantine agentic workflow to deterministically prevent re-attempting maintainer-rejected quarantine/unquarantine actions by injecting authoritative GitHub REST API data into the prompt, and updating guardrails to consume it.

Changes:

  • Add pre-activation REST API fetches for (1) issue numbers labeled re-quarantine and (2) recently closed-but-unmerged test-quarantine PRs with trusted-author comments.
  • Update the unquarantine guardrail to treat re-quarantine issue labels as an authoritative permanent block (in addition to merged PR diff parsing).
  • Bump gh-aw tooling and recompile the generated *.lock.yml workflow plus action pins.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
.github/workflows/test-quarantine.md Adds deterministic pre-activation fetch steps and updates prompt guardrails to use injected issue/PR context.
.github/workflows/test-quarantine.lock.yml Recompiled workflow lockfile reflecting new steps, new gh-aw versions, and regenerated runtime wiring.
.github/aw/actions-lock.json Updates pinned gh-aw action versions used by the workflow compilation.

Comment thread .github/workflows/test-quarantine.md Resolved
Comment thread .github/workflows/test-quarantine.md Resolved
Comment thread .github/workflows/test-quarantine.md Resolved
Comment thread .github/workflows/test-quarantine.md Resolved
@wtgodbe
wtgodbe force-pushed the wtgodbe/quarantine-guardrails branch from 77fd04a to 347dc8f Compare July 6, 2026 18:16
@wtgodbe

wtgodbe commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Addressed the review feedback (commit amended):

  • urlopen timeouts (search_issues, search_prs, get_comments): added timeout=30 to every call in both new pre-activation steps.
  • Heredoc delimiter collision: the closed_quarantine_prs write now uses a random, collision-checked delimiter (CLOSED_QUAR_EOF_<token_hex>), matching GitHub's recommended pattern for values containing user-controlled text.
  • lock.yml add_labels per-item validation: that's generated output from the gh-aw v0.81.6 compiler, not hand-written, so I didn't edit it. The label surface is already constrained — add_labels.allowed: ["re-quarantine"] is enforced both as a prompt constraint and in the safe-outputs handler config, so only re-quarantine can ever be applied.

Recompiled; gh aw compile reports 0 errors / 0 warnings.

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/test-quarantine.md Resolved
Comment thread .github/workflows/test-quarantine.md Resolved
@wtgodbe
wtgodbe force-pushed the wtgodbe/quarantine-guardrails branch from 347dc8f to 1f529ef Compare July 6, 2026 18:24
@wtgodbe

wtgodbe commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Addressed — both new pre-activation steps now build the /search/issues URL with urllib.parse.urlencode({"q": query, "per_page": 100}) and pass raw (unencoded) query strings, instead of hand-encoding with +/%22. Verified live that the encoded requests return identical results ([49306] for the re-quarantine issues; the closed-PR set still includes #67443 and #67415). Recompiled: 0 errors / 0 warnings.

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Comment on lines +138 to +139
data = json.loads(resp.read())
results.extend(data.get("items", []))
Comment on lines +188 to +189
data = json.loads(resp.read())
results.extend(data.get("items", []))
Comment on lines 1642 to 1645
"labels": {
"required": true,
"type": "array",
"itemType": "string",
"itemSanitize": true,
"itemMaxLength": 128
"type": "array"
},
if not github_output:
print("ERROR: GITHUB_OUTPUT is not set, cannot pass data to agent", file=sys.stderr)
sys.exit(1)
js = json.dumps(data)
…ected actions

Two recent misbehaviors (run 28656097334): PR dotnet#67577 tried to unquarantine
SetsTlsHandshakeFeatureForHttps despite issue dotnet#49306 carrying the re-quarantine
label, and PR dotnet#67576 re-quarantined WebSocketsWorks despite maintainer "do not
quarantine" comments on the already-rejected dotnet#67443/dotnet#67415.

Root causes:
- The unquarantine re-quarantine check only parsed merged-PR diffs and left the
  match/exclude decision to the model; it never consulted the re-quarantine
  issue label the maintainer set.
- The closed-PR comment check relied on MCP search_pull_requests, whose DIFC
  filter silently drops the workflow's own app/github-actions-authored PRs, so
  the maintainer comments were never seen.

Fixes (deterministic pre-activation steps + injected data):
- Fetch re-quarantine issue numbers; block unquarantine of any test whose
  tracking issue is labeled re-quarantine (authoritative, exact match).
- Fetch closed-but-unmerged [test-quarantine] PRs + comments with a full token,
  bypassing the DIFC filter; the closed-PR check now uses this instead of MCP.

Recompiled lockfile with gh-aw CLI v0.81.6 (setup action v0.80.9 -> v0.81.6).

Co-authored-by: Copilot <[email protected]>
@wtgodbe
wtgodbe force-pushed the wtgodbe/quarantine-guardrails branch from 1f529ef to c82b6b0 Compare July 6, 2026 18:34
@wtgodbe

wtgodbe commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Addressed the code comments (commit amended):

  • incomplete_results (both searches): each search loop now checks data.get("incomplete_results") per page and sys.exit(...) fails closed if the Search API returns a partial result — for the issue-number blocklist and the closed-PR/comment fetch alike, so a partial set can never silently weaken the guardrail.

  • Output size: closed_quarantine_prs now enforces MAX_OUTPUT_BYTES = 120000 (safely under the 131072-byte env-var limit) and fails closed with a clear error if the serialized payload would exceed it, rather than being silently truncated downstream.

  • lock.yml add_labels.labels per-item constraints: this is compiler-generated output (gh-aw v0.81.6), not hand-written, so I'm not editing it directly. The effective guardrail is unchanged: add_labels.allowed: ["re-quarantine"] is enforced in the safe-outputs handler config, so only that single label can ever be applied regardless of the schema's per-item validation.

Recompiled: 0 errors / 0 warnings.

@wtgodbe
wtgodbe merged commit f676999 into dotnet:main Jul 6, 2026
10 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 7, 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.

2 participants