Skip to content

Add implementation-time parallel safety preflight - #11826

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/parallel-safety-preflight
Oct 8, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/parallel-safety-preflight

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Adds the repo-owned testfx-parallel-safety-preflight skill and applies it before declaration choices and again against the final diff in ResourceLock refactoring. The preflight traces effective assembly scheduling and transitive readers/writers, requires a concrete conflicting observer, and chooses the narrowest correct shared read/write declaration without weakening assembly-level safety.

The implementation-time checks cover listener/producer attribution, inherited CI state such as TF_BUILD, exact environment/culture/static restoration, deterministic rendezvous, and bounded cleanup that awaits the original workers' termination. Four repository-backed examples illustrate these boundaries.

The original shared audit rubric and specialist reviewer are unchanged. Existing indirect-reader protection is preserved. The workflow retains its one-project scope, edit allowlist, and scheduling restrictions. Prompt-body wiring is the only workflow source change; the regenerated lock changes only its body hash, with no action-pin, permission, manifest, or generated-step changes. This follow-up is informed by #11192, #11542, and #11712; it does not patch those PRs or introduce runtime/product features.

Validation

Results obtained for commit aa619c89a7db49da55c90fc30990b8a043c94248:

Command Result
gh aw compile resource-lock-refactoring --strict --no-check-update Passed with gh-aw v0.89.21; 1 workflow compiled, 0 warnings.
python .github\scripts\check_action_pins.py Passed: 2,562 references across 56 files.
gh aw list resource-lock-refactoring --json Passed: compiled is Yes.
git --no-pager diff --check Passed.
git --no-pager diff --cached --check Passed before committing.
Focused PowerShell/Python command below Passed skill metadata/references/placement/formatting, unchanged frontmatter and metadata-only regeneration, and all four examples against current source.

No live workflow dispatch, .NET build, or product test run was performed. This is a guidance/prompt-only change with no C# changes; focused checks validate the examples and workflow structure rather than claim new runtime behavior.

Exact focused check command (PowerShell, repository root)
@'
from pathlib import Path
import json
import re
import subprocess
import yaml

root = Path.cwd()
def read(path):
    return root.joinpath(*path.split('/')).read_text(encoding='utf-8-sig')
def head(path):
    return subprocess.check_output(['git', 'show', 'HEAD:' + path], encoding='utf-8')
skill_path = '.github/skills/testfx-parallel-safety-preflight/SKILL.md'
workflow_path = '.github/workflows/resource-lock-refactoring.md'
lock_path = '.github/workflows/resource-lock-refactoring.lock.yml'
skill, workflow, lock = map(read, [skill_path, workflow_path, lock_path])
metadata = yaml.safe_load(skill.split('---', 2)[1])
assert metadata['name'] == 'testfx-parallel-safety-preflight'
assert 'before implementing or refactoring' in metadata['description']
assert 'repeat against the final diff' in metadata['description']
for reference in re.findall(r'`(\.github/[^`]+)`', skill + workflow):
    assert root.joinpath(*reference.split('/')).is_file(), reference
assert workflow.index(skill_path) < workflow.index('## Select exactly one bounded change')
assert 'repeat the implementation preflight' in workflow
assert workflow.split('---', 2)[1] == head(workflow_path).split('---', 2)[1]
assert lock.splitlines()[1:] == head(lock_path).splitlines()[1:], 'Generated steps or pins changed'
old_meta = json.loads(head(lock_path).splitlines()[0].split(': ', 1)[1])
new_meta = json.loads(lock.splitlines()[0].split(': ', 1)[1])
assert new_meta['strict'] is True
assert old_meta['frontmatter_hash'] == new_meta['frontmatter_hash']
assert old_meta['body_hash'] != new_meta['body_hash']
for path, content in [(skill_path, skill), (workflow_path, workflow)]:
    assert content.isascii(), path
    assert content.endswith('\n') and not content.endswith('\n\n'), path
    assert all(line == line.rstrip() for line in content.splitlines()), path
print('PASS: skill metadata/references/placement/formatting; unchanged workflow frontmatter and metadata-only lock regeneration')

unit = 'test/UnitTests/Microsoft.Testing.Extensions.UnitTests/'
crash, mutation, provider, service = [read(unit + file) for file in ['CrashDumpTests.cs', 'CrashDumpMutationTests.cs', 'OpenTelemetryProviderExtensionsTests.cs', 'OpenTelemetryPlatformServiceTests.cs']]
handler = read('src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpProcessLifetimeHandler.cs')
publisher = read('src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpArtifactPublisher.cs')
key = 'Microsoft.Testing.Extensions.CrashDump.ProcessKilledByHangDumpAppDomainData'
assert key in crash and key in mutation
assert 'Mode = ResourceAccessMode.Read' in crash and 'Mode = ResourceAccessMode.Read' in mutation
assert '[ResourceLock(ProcessKilledByHangDumpAppDomainDataResource)]' in crash
assert 'OnTestHostProcessExitedAsync_MissingDumpPattern_ThrowsInvariantViolation' in mutation
assert 'public bool HasExitedGracefully => false' in mutation
assert 'AppDomain.CurrentDomain.GetData("ProcessKilledByHangDump")' in handler
assert 'ApplicationStateGuard.Ensure(_configuration.DumpFileNamePattern is not null)' in publisher
assert 'AppDomain.CurrentDomain.SetData("ProcessKilledByHangDump", processKilledByHangDump)' in crash
print('PASS: CrashDump example has a named indirect observer, shared reader/writer key, and exact restoration')
assert 'AddTestingPlatformDiagnostics_RawListenerObservesBuilderActivityWithoutProvider' in provider
assert 'DiagnosticsAndProviderRegistration_IsIdempotentAndOrdered' in provider
assert '[ResourceLock(OpenTelemetryPlatformService.ActivitySourceName)]' in provider
read_lock = '[ResourceLock(OpenTelemetryPlatformService.ActivitySourceName, Mode = ResourceAccessMode.Read)]'
assert read_lock in provider and read_lock in service
assert 'activity.OperationName.StartsWith(_namePrefix, StringComparison.Ordinal)' in service
assert 'TestingPlatformSemanticConventions.Activities.TestHostBuilder' in read('src/Platform/Microsoft.Testing.Platform/Hosts/TestHostBuilder.CommonServices.cs')
print('PASS: activity example has a named raw observer/producer, compatible declarations, and identity filtering')
assert '"TF_BUILD"' in provider
assert 'WithEnvironmentAsync' in provider and 'WithEnvironment' in provider
assert 'Environment.SetEnvironmentVariable(name, null)' in provider
assert 'Environment.SetEnvironmentVariable(entry.Key, entry.Value)' in provider
assert 'Environment.GetEnvironmentVariable("TF_BUILD")' in read('src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/TestingPlatformResourceDetector.cs')
print('PASS: CI example has a production TF_BUILD read, explicit absence arrangement, and snapshot restoration')
tasks = read('src/Platform/Microsoft.Testing.Platform/Helpers/TaskExtensions.cs')
assert 'await Task.WhenAny(target, cancellationTask.Task)' in tasks
assert 'if (!target.IsCompleted)' in tasks
assert 'await task.WaitAsync(timeout)' in tasks
assert 'throw new OperationCanceledException(cancellationToken)' in tasks
print('PASS: worker example distinguishes the original task from cancellation/timeout wait wrappers')
'@ | python -

This is the exact check run before committing, when HEAD was the unchanged base. To rerun against the committed change, use HEAD^: instead of HEAD: in head(path) so the comparison remains against the same pre-change snapshot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fe5070d9-0f10-47a6-bd7e-a31beb2d83ed
Copilot AI balanced review requested due to automatic review settings October 8, 2026 11:23
@github-actions github-actions Bot added the needs/merge-conflict-resolution PR has merge conflicts that must be resolved. label Oct 8, 2026

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.

🟢 Approval recommended

The guidance is consistent with repository concurrency rules, its examples match current code, and the generated workflow retains strict settings and pinned actions.

0 open findings

What changed in this PR

Adds implementation-time parallel-safety guidance to the ResourceLock refactoring workflow.

Changes:

  • Adds a reusable parallel-safety preflight skill with repository-backed examples.
  • Runs the preflight before implementation and final validation.
  • Regenerates the strict workflow lock metadata.
File Description
.github/​skills/​testfx-parallel-safety-preflight/​SKILL.md Defines the preflight guidance.
.github/​workflows/​resource-lock-refactoring.md Integrates the preflight into the workflow.
.github/​workflows/​resource-lock-refactoring.lock.yml Updates the generated body hash only.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Regenerate the ResourceLock workflow lock to preserve updated base dependency pins and the implementation preflight prompt.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fe5070d9-0f10-47a6-bd7e-a31beb2d83ed
Copilot AI balanced review requested due to automatic review settings October 8, 2026 12:11
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed needs/merge-conflict-resolution PR has merge conflicts that must be resolved. labels Oct 8, 2026

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.

🟢 Approval recommended

The guidance is consistent with repository policy, its examples match current code, and generated workflow changes are limited to metadata.

0 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) October 8, 2026 12:26
@Evangelink
Amaury Levé (Evangelink) merged commit a88b284 into main Oct 8, 2026
15 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/parallel-safety-preflight branch October 8, 2026 12:29
@github-actions github-actions Bot removed the state/needs-review Awaiting review from the team. label Oct 8, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 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.

3 participants