Repository navigation
Add /parallel-audit agentic workflow, bump testfx, adopt [ResourceLock] - #55527
Merged
Merged
Conversation
…rceLock] Ports microsoft/testfx's parallel-safety audit agentic workflow (microsoft/testfx#10252) into dotnet/sdk and starts using the [ResourceLock] feature it audits for. Workflow (.github/workflows/parallel-safety-audit{,-command}.md and shared/parallel-safety-audit-shared.md): - Adapted to this repo's gh-aw conventions: PAT-pool import, Copilot engine, cli-proxy + github gh-proxy tooling, fork guard, repo-pinned actions/checkout. - Adapted to this repo's test tree: test/TestAssets and test/TestPackages are excluded from the audit surface (they are test inputs, not test code), the MSTestParallelizeScope opt-in model and the test/Directory.Build.props default are described, and TestAssetsManager identifier collisions are called out. - MSTEST0074-0077 are described as shipping analyzers (they are now, see below) rather than in-flight, including that MSTestAnalysisMode=Recommended plus TreatWarningsAsErrors makes them build errors here. Dependencies: bump Microsoft.Testing.Platform, MSTest and MSTest.Sdk from 4.4.0-preview.26376.8 to *.26379.6 (darc), which brings in the parallel-safety analyzers MSTEST0073-MSTEST0077. Findings from the bump: - MSTEST0074 fired in Microsoft.NET.Build.Tests: It_fails_build_on_failed_sdk_resolution set MSBUILDINCLUDEDEFAULTSDKRESOLVER process-wide, which every concurrently started MSBuild inherits. Scoped it to the build under test with TestCommand.WithEnvironmentVariable instead. - DockerDaemonTests only needed DOCKER_HOST serialized in one test, so the class-level [DoNotParallelize] is replaced by [ResourceLock(WellKnownResources.EnvironmentVariables)] on that test, letting the other 10 tests run in parallel. - AuthHandshakeMessageHandlerTests keeps [DoNotParallelize]: it is order-dependent through AuthHandshakeMessageHandler's process-wide static credential cache, which a resource lock cannot cover. Comment updated to explain why. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c54ee239-4f8b-4400-af31-01010123c057
…ct guidance Review round 1 findings. Critical - the agent never received its inputs. The prompt referenced `steps.resolve.outputs.*` / `steps.extract.outputs.*` GitHub expressions, but gh-aw renders and interpolates the prompt in the `activation` job while those steps run later in the `agent` job, so every one of them reached the agent as literal, unresolved expression text - including the PR number the `add-comment` safe output must target (`target: "*"` has no implicit target). The extraction steps now write their results to fixed paths under `/tmp/gh-aw/parallel-safety-audit/` (pr-number.txt, audit-mode.txt, the three file lists and the region TSV) and the prompt hard-codes those paths. `/tmp/gh-aw` rather than the workspace, because gh-aw runs its own `Checkout PR branch` step after ours. Verified by replaying the extraction over this branch: it emits the three changed test files and their exact HEAD-side line ranges. High - `[ResourceLock(WellKnownResources.EnvironmentVariables | CurrentDirectory | Console)]` does not compile: `WellKnownResources` members are `const string`, not `[Flags]`, and the attribute takes a single resource. Both the prompt and test/AGENTS.md now show the stacked form, which is what `AllowMultiple = true` is for. Trigger and noise: - Drop `synchronize`. dotnet/sdk sees ~10 PRs/day and ~60% touch `test/**`; re-auditing every push multiplied that by commits-per-PR for a report that rarely changes. `/parallel-audit` refreshes on demand. - Guard fork PRs with `head.repo.full_name == github.repository`. `repository.fork` describes the base repo, so it only stops runs inside forks of dotnet/sdk; `pull_request` runs from forks get no secrets and would fail on the PAT pool. - On an automatic run the agent now stays silent (`noop`) unless it has a finding or the PR changed parallelization state. Most test PRs here are scope=off, so a "nothing to flag" comment on each would be pure noise. `/parallel-audit` always answers. Drift: - Record the upstream path/commit and the list of dotnet/sdk adaptations to re-apply when syncing. - Stop hardcoding which projects opt in and asserting the analyzer/warning settings; tell the agent to read them at HEAD instead. Tests: - `ConfigAuthWithIdentityToken` emitted invalid JSON (an unquoted `identitytoken` value). It only passes today because the static credential cache short-circuits the parse. Quoted it. - Correct the `AuthHandshakeMessageHandlerTests` comment: a `[ResourceLock]` can take a custom key for the cache, but it cannot reset the cache between tests, and the cache is private with no way to clear it - order dependence, not key coverage, is why the class stays serialized. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c54ee239-4f8b-4400-af31-01010123c057
- The prompt told the agent to `git diff` the removed side of deletion-only hunks and of deleted config files, but never gave it a revision. Its working directory is the PR head with a clean tree, so a bare `git diff <path>` prints nothing - silently dropping exactly the findings that matter most (a removed `[ResourceLock]`, `[DoNotParallelize]` or `finally` restore). Guessing `origin/<base>...HEAD` would not work either, because gh-aw's own `Checkout PR branch` step re-fetches shallowly over our full clone. Extraction now writes `merge-base.txt` and `head-sha.txt` alongside the other inputs and the prompt uses `git diff "$AUDIT_BASE" "$AUDIT_HEAD" -- <path>` everywhere. - Remove the `has_changed_tests` step output. Nothing consumed it after the previous commit dropped the other outputs, and its comment claimed otherwise. - On an automatic run, suppress readiness-only reports: a finding against an assembly whose scope is `off` (or that is not an MSTest suite) no longer justifies a comment on its own. Most test PRs here touch only scope=off projects, and advice about a suite that does not run in parallel is not worth interrupting a PR for. `/parallel-audit` still always answers. - Point the `AuthHandshakeMessageHandlerTests` comment at the tracking issue (#55526) instead of saying "tracked separately", and stop implying `[DoNotParallelize]` is an ordering contract - it serializes execution, and what these tests rely on is the declaration order that happens to preserve. - Rename the workflow now that it no longer runs on `synchronize`; the old name surfaced in the Actions UI and in the comment footer. Verified by replaying the extraction bash over this branch: it emits the three changed test files, their HEAD-side line ranges, and the two new revision files. Co-authored-by: Copilot App <[email protected]> Copilot-Session: c54ee239-4f8b-4400-af31-01010123c057
Evangelink
had a problem deploying
to
copilot-pat-pool
July 29, 2026 18:37 — with
GitHub Actions
Failure
|
Azure Pipelines: Successfully started running 2 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR ports the microsoft/testfx parallel-safety audit agentic workflow into dotnet/sdk, bumps the in-repo testfx dependency versions, and adopts MSTest’s [ResourceLock] in a couple of parallelized test areas to address (or better-scope) analyzer findings and reduce unnecessary serialization.
Changes:
- Add an agentic workflow (automatic +
/parallel-auditcommand) to audit changed MSTest tests for parallel-safety and appropriate locking/parallelization declarations. - Update
testfx-related dependency pins (Microsoft.Testing.Platform, MSTest, MSTest.Sdk) to4.4.0-preview.26379.6/2.4.0-preview.26379.6in the usual version files. - Fix/adjust tests for parallel-safety: scope
MSBUILDINCLUDEDEFAULTSDKRESOLVERto a child process; replace class-wide[DoNotParallelize]with a method-level[ResourceLock]where appropriate; correct identity-token JSON emission.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildWithGlobalJson.cs | Scope an env var to the launched build process (avoid process-wide mutation). |
| test/Microsoft.NET.Build.Containers.UnitTests/DockerDaemonTests.cs | Replace class-wide non-parallelization with a targeted [ResourceLock] on the env-var mutating test. |
| test/Microsoft.NET.Build.Containers.UnitTests/AuthHandshakeMessageHandlerTests.cs | Expand rationale for [DoNotParallelize] and fix identity-token JSON quoting. |
| test/AGENTS.md | Add guidance on fixing parallel-safety analyzer findings and choosing [ResourceLock] vs [DoNotParallelize]. |
| global.json | Bump MSTest.Sdk MSBuild SDK version. |
| eng/Version.Details.xml | Uptake new testfx dependency versions + sha (KEEP IN SYNC group). |
| eng/Version.Details.props | Update generated version properties for the same testfx bump. |
| .github/workflows/shared/parallel-safety-audit-shared.md | Add shared workflow/prompt body and deterministic extraction logic. |
| .github/workflows/parallel-safety-audit.md | Add the automatic PR-open/ready workflow wiring (imports, permissions, triggers). |
| .github/workflows/parallel-safety-audit.lock.yml | Add the compiled gh-aw lock workflow output. |
| .github/workflows/parallel-safety-audit-command.md | Add /parallel-audit slash-command workflow wiring. |
Copilot's findings
- Files reviewed: 10/12 changed files
- Comments generated: 1
Evangelink
enabled auto-merge
July 30, 2026 11:39
It guarantees mutual exclusion and deferral (the class runs sequentially, after the parallelizable set), not a test execution order. Describe what it actually buys here - preventing concurrent execution, which is what makes the shared static cache deterministic enough for the suite to pass today - and keep the emphasis on the real fix, giving each data row its own registry name (#55526). Co-authored-by: Copilot App <[email protected]> Copilot-Session: c54ee239-4f8b-4400-af31-01010123c057
…r command
The audit workflow failed on this PR's own open event, and the command variant
would never have fired at all. Two separate activation bugs, both found by
inspecting run 30480738833.
1. The automatic `pull_request` variant cannot work in a dotnet org repository.
`pre_activation` failed in 2 seconds with no steps and no runner, and the job
annotation says:
Branch "refs/pull/55527/merge" is not allowed to deploy to copilot-pat-pool
due to environment protection rules.
Every job of a PAT-pool workflow runs in the `copilot-pat-pool` environment,
whose deployment branch policy allows `main` only. That restriction is
deliberate - `shared/pat_pool.README.md` calls for "Protected branches only"
so agentic workflows are confined to protected branches. A `pull_request` run
is on `refs/pull/<n>/merge`, so it is rejected before any step executes. This
is why the repo's existing agentic workflows trigger on `issues` and
`issue_comment`, which run on `main`.
The only way to get a protected-branch ref for a PR event is
`pull_request_target`, which would hand a privileged token and the PAT pool to
a job that checks out untrusted PR head code and runs an agent over it. Not a
trade worth making for an advisory audit, so the automatic variant is removed
and the audit is maintainer-invoked only.
2. `strategy: centralized` was carried over from testfx, which has a
repository-wide command router (`agentic_commands.yml`). dotnet/sdk has none,
and centralized compiles the workflow down to a bare `workflow_dispatch`, so
`/parallel-audit` would never have fired. Removed, so it compiles to a real
`issue_comment` trigger like `add-tactics-template-on-comment.md`.
Follow-on simplification: with a single maintainer-invoked entry point there is
no "automatic" mode, so the audit always answers. Removed the mode plumbing
(`MODE` output, `audit-mode.txt`, the pull_request branch of the resolve step and
its now-unused event inputs) and the stay-silent branching in the prompt.
The reason the automatic variant is absent is recorded at the top of
parallel-safety-audit-command.md so it is not re-added into the same wall.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: c54ee239-4f8b-4400-af31-01010123c057
YuliiaKovalova
approved these changes
Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports microsoft/testfx's parallel-safety audit agentic workflow into this repo, takes the current testfx build, and starts using the
[ResourceLock]attribute the audit is about.1.
/parallel-auditagentic workflowPorted from microsoft/testfx#10252 (
.github/workflows/shared/parallel-safety-audit-shared.md@7c5348a4). A maintainer comments/parallel-auditon a PR and the agent audits the MSTest tests that PR changes for parallel-safety — process-global state mutation, shared filesystem paths, mismatches between what a test touches and the[ResourceLock]/[DoNotParallelize]it declares, and over-serialization — then posts one ranked, scope-aware, confidence-tagged comment. Read-only and advisory..github/workflows/parallel-safety-audit-command.md— the/parallel-auditcommand..github/workflows/shared/parallel-safety-audit-shared.md— tools, permissions, the deterministic bash pre-extraction, and the prompt.Upstream's automatic on-open variant is deliberately not ported. I did port it initially, and it failed on this PR's own open event — which is how the constraint surfaced. Every job of a PAT-pool workflow runs in the
copilot-pat-poolenvironment, whose deployment branch policy allowsmainonly;shared/pat_pool.README.mdasks for "Protected branches only" precisely so agentic workflows stay on protected branches. Apull_requestrun is onrefs/pull/<n>/merge, so GitHub rejects it before any step executes:The only way to get a protected-branch ref for a PR event is
pull_request_target, which would hand a privileged token and the PAT pool to a job that checks out untrusted PR head code and runs an agent over it. That is not a trade worth making for an advisory audit, so the audit is maintainer-invoked only. The reasoning is recorded at the top of the workflow so it is not re-added into the same wall. This also happens to settle the cost/noise question: no automatic runs, no per-PR credit burn, and nothing posted unless a human asked.Adapted to this repo:
issue-triage.md/add-tactics-template-on-comment.md: PAT-pool import,environment: copilot-pat-pool,engine: copilot,cli-proxy+github: mode: gh-proxy,actions/checkouton the pin already in.github/aw/actions-lock.json.strategy: centralized— that compiles down to a bareworkflow_dispatchand depends on a repository-wide command router (testfx hasagentic_commands.yml; this repo does not), so the command would never have fired. The default strategy compiles to a realissue_commenttrigger, matchingadd-tactics-template-on-comment.md.test/TestAssets/andtest/TestPackages/are excluded from the audit surface — they are test inputs, not test code.MSTestParallelizeScope+test/Directory.Build.props), not a hand-written[assembly: Parallelize].MSTestAnalysisMode=Recommended+TreatWarningsAsErrors), so the audit's stated value is what the analyzers cannot see: mutations reached through helpers/fixtures, cross-test collision judgement, and runsettings-only opt-ins.SdkTest,TestAssetsManageridentifier:collisions,TestCommand.WithEnvironmentVariable.The shared file header records the upstream path/commit and the list of adaptations to re-apply when syncing, and the prompt tells the agent to verify repository facts (which projects opt in,
MSTestPackageVersion,MSTestAnalysisMode,TreatWarningsAsErrors) against HEAD rather than trusting the prompt text.2. testfx dependency bump
Ordinary Darc uptake of the current testfx build:
Microsoft.Testing.Platform,MSTestandMSTest.Sdk4.4.0-preview.26376.8→4.4.0-preview.26379.6, all three on the same sha per the KEEP IN SYNC comment.[ResourceLock]already existed at the old pin; the payload here is the new parallel-safety analyzers MSTEST0074–0077 (plus MSTEST0078–0080). Happy to split this into its own PR if that makes diagnosis or revert easier.3.
[ResourceLock]adoption and the bugs the bump foundOnly three test projects enable parallelization, so only they are analyzer-visible. I built all three.
Microsoft.NET.Build.Tests— MSTEST0074 fired on a real latent bug:It_fails_build_on_failed_sdk_resolutionsetMSBUILDINCLUDEDEFAULTSDKRESOLVERprocess-wide, which every MSBuild started by a concurrently running test inherits, breaking SDK resolution for those tests. Fixed by elimination — the variable is now scoped to the build under test withTestCommand.WithEnvironmentVariable, so thetry/finallyrestore is no longer needed.DockerDaemonTests— class-level[DoNotParallelize]replaced by[ResourceLock(WellKnownResources.EnvironmentVariables)]on the one test that mutatesDOCKER_HOST, so the other 10 tests in the class stop being deferred to the serial tail.AuthHandshakeMessageHandlerTests— keeps[DoNotParallelize]. Parallelizing it fails because the tests are coupled throughAuthHandshakeMessageHandler'sprivate staticcredential cache: a[ResourceLock]can take a custom key for it but cannot reset it between tests. While investigating I foundConfigAuthWithIdentityTokenemitting invalid JSON (unquotedidentitytokenvalue), masked because the cache short-circuits the parse — quoted here, root cause tracked in AuthHandshakeMessageHandlerTests are order-dependent through a process-wide static credential cache #55526.test/AGENTS.md— parallel-safety guidance, in priority order: eliminate the shared state →[ResourceLock]→[DoNotParallelize].Validation
gh aw compile— 0 errors, 0 warnings;.github/aw/actions-lock.jsonleft untouched. Verified the compiled workflow carries a realissue_commenttrigger.Microsoft.NET.Build.Containers.UnitTests: 292 total, 0 failed, 286 succeeded, 6 skipped (run repeatedly).Microsoft.NET.Build.Testsanddotnet-watch.Testsbuild clean withTreatWarningsAsErrorsafter the fix.Security review of the generated workflow
gh aw compileflagged theCOPILOT_PAT_0–COPILOT_PAT_9secrets as new to this workflow file. They are the repository's existing Copilot PAT pool, consumed through the unmodifiedshared/pat_pool.mdimport exactly asissue-triage.mdandadd-tactics-template-on-comment.mdalready do; no new secret is introduced to the repository and none is exposed to the agent (the PAT only populatesCOPILOT_GITHUB_TOKENfor the engine, and perpat_pool.README.mdit carries only Copilot-requests read permission). No new actions are introduced:actions/checkoutuses the SHA already pinned in.github/aw/actions-lock.json. Permissions stay atcontents: read+pull-requests: read+copilot-requests: write; the agent is read-only over the code and its single writing capability is theadd-commentsafe output. Network isdefaults.Worth a reviewer's explicit attention: this workflow runs on
issue_comment(so, onmainwith secrets available) and checks out the PR head to analyze it. That is deliberate and is whatroles: [admin, maintainer, write]gates — a trusted user has to ask for each audit. Auditing fork PRs is supported for the same reason. The residual risk is prompt injection from PR content steering the report, which is bounded by the read-only PAT and the safe-outputs-only write path; the prompt also frames PR content as untrusted. The one item a human should confirm is that the lock file was generated with gh-aw v0.83.1 while the repo's existing locks were generated with v0.82.9 — the compiler version differs, but I reverted the incidental.github/aw/actions-lock.jsonchurn so no shared pin changed.Notes for reviewers
Reviewed in several rounds; the notable fixes were:
${{ steps.* }}outputs produced in theagentjob while gh-aw renders the prompt in theactivationjob, so the agent received literal unresolved expression text for every input — including the PR number its comment must target. Extraction now writes to fixed files under/tmp/gh-aw/parallel-safety-audit/that the prompt reads.git diffdeleted content but gave it no revision; a baregit diffin a clean checkout prints nothing, which would have silently dropped exactly the "someone removed a[ResourceLock]" findings. It now getsmerge-base.txt/head-sha.txtand uses them explicitly.