Infra, Ops & WorkflowSûr100100/100

Find Regression Risk (.NET)

Detects potential regression risks in a PR by cross-referencing lines the PR REMOVES against lines ADDED by recent labeled bug-fix PRs (`i/regression`, `t/bug`, `p/0`, `p/1`) touching the same files. Purely mechanical — no AI/LLM. Emits a CLEAN / OVERLAP / REVERT verdict plus structured findings. Triggers on: "does this PR revert a previous fix", "check PR for regression risk", "find regression risks in PR", "is this change reverting a bug fix". Do NOT use for: assessing ship-readiness of a release branch (use release-readiness), investigating CI failures (use azdo-build-investigator), or general code review (use code-review).

ou envoie-le directement à ton agent.

Installer dans ton projet

$ curl -fsSL https://arboristhree.xyz/cli/install-skill.mjs -o /tmp/arboris-install-skill.mjs && node /tmp/arboris-install-skill.mjs find-regression-risk__dotnet-maui__github-skills-a4a671f6b93b
Contenu à copier
---
name: find-regression-risk
description: >-
  Detects potential regression risks in a PR by cross-referencing lines the PR
  REMOVES against lines ADDED by recent labeled bug-fix PRs (`i/regression`,
  `t/bug`, `p/0`, `p/1`) touching the same files. Purely mechanical — no AI/LLM.
  Emits a CLEAN / OVERLAP / REVERT verdict plus structured findings. Triggers on:
  "does this PR revert a previous fix", "check PR for regression risk",
  "find regression risks in PR", "is this change reverting a bug fix".
  Do NOT use for: assessing ship-readiness of a release branch (use
  release-readiness), investigating CI failures (use azdo-build-investigator),
  or general code review (use code-review).
metadata:
  origin: .NET
  author: dotnet-maui
  version: "1.0"
compatibility: Requires PowerShell (pwsh), git, and GitHub CLI (gh) authenticated against the target repository.
---

# find-regression-risk

Detects potential regression risks in a PR by cross-referencing removed lines against lines added by recent labeled bug-fix PRs.

## How It Works

Purely mechanical — no AI/LLM. Five-step algorithm:

1. **PR diff** — collects lines REMOVED by the PR under review.
2. **Git history** — `git log --follow --since=6mo` finds recent PRs that touched the same files.
3. **Label filter** — keeps PRs (or their linked issues) labeled `i/regression`, `t/bug`, `p/0`, or `p/1`.
4. **Fix diff** — fetches each fix PR's diff and collects lines it ADDED to the same file.
5. **Compare** — whitespace-insensitive string equality:
   - 🔴 **REVERT** — removed line matches a line a fix PR added (highest risk).
   - 🟡 **OVERLAP** — same file modified, but no exact line revert.
   - 🟢 **CLEAN** — no bug-fix PRs touch the same files.

## Standalone Invocation

```powershell
# Analyze a specific PR (auto-detects files)
pwsh -NoProfile -Command '& ./.github/scripts/Find-RegressionRisks.ps1 -PRNumber 33908 -OutputDir /tmp/out'

# Analyze specific files only
pwsh -NoProfile -Command '& ./.github/scripts/Find-RegressionRisks.ps1 -PRNumber 33908 -OutputDir /tmp/out -FilePaths @("src/Core/src/Platform/Android/MauiWindowInsetListener.cs")'
```

## Parameters

| Parameter | Required | Default | Description |
|-----------|----------|---------|-------------|
| `-PRNumber` | Yes | — | PR number to analyze |
| `-Repo` | No | `dotnet/maui` | Repository in `owner/name` form |
| `-FilePaths` | No | auto-detect | Implementation files to check |
| `-MonthsBack` | No | `6` | History window for git log |
| `-MaxRecentPRsPerFile` | No | `20` | Rate-limit guard per file |
| `-BaseBranch` | No | `main` | Base branch for `git log` scope |
| `-OutputDir` | No | — | Directory for output files |
| `-WriteInlineFindings` | No | off | Emit `inline-findings.json` |

## Outputs

When `-OutputDir` is specified:

- **`result.txt`** — single token: `CLEAN`, `OVERLAP`, or `REVERT`
- **`risks.json`** — structured findings for downstream agents
- **`content.md`** — markdown summary for the PR comment
- **`inline-findings.json`** — (only with `-WriteInlineFindings`) inline annotations

## Integration

The script runs as **STEP 4** in `Review-PR.ps1` (Regression Cross-Reference, after UI test detection and before the Gate step). Its `content.md` is assembled into the AI summary review by `post-ai-summary-comment.ps1`.

When REVERT risks are detected, the regression tests from the reverted fix PRs are executed:
- **UI tests** → `BuildAndRunHostApp.ps1 -Platform <plat> -TestFilter <filter>`
- **Device tests** → `Run-DeviceTests.ps1 -Project <proj> -Platform <plat> -TestFilter <filter>`
- **Unit/XAML tests** → `dotnet test <project> --filter <filter>`

The expert reviewer agent (`maui-expert-reviewer.md`, dimension #6) reads `risks.json` to check for REVERT entries.

## Known Limitations

- **Inline findings**: The `-WriteInlineFindings` flag emits deletion-side (LEFT) annotations, but `post-inline-review.ps1` currently only posts RIGHT-side comments. LEFT-side findings are silently dropped. This is documented as future work.
- **Whitespace-only changes**: By design, an indent-only change to a fix line won't trigger a REVERT (the normalization collapses whitespace). This avoids false positives from reformatting.
- **`pwsh -File` array parameters**: When invoking standalone from bash, use `pwsh -Command '& ./script.ps1 -FilePaths @(...)'` syntax. `pwsh -File` doesn't evaluate `@()` expressions.

## Tests

```powershell
pwsh -NoProfile -File .github/scripts/tests/Test-FindRegressionRisks.ps1
```
Colle ce Markdown dans ton agent ou utilise les boutons ci-dessus pour l’écrire dans ton projet.

Ce que fait Find Regression Risk (.NET)

🔴 **REVERT** — removed line matches a line a fix PR added (highest risk).
🟡 **OVERLAP** — same file modified, but no exact line revert.
🟢 **CLEAN** — no bug-fix PRs touch the same files.
**`result.txt`** — single token: `CLEAN`, `OVERLAP`, or `REVERT`

Comment utiliser Find Regression Risk (.NET)

1
Copie le prompt
Un clic copie le prompt packagé (ou l'envoie à ton agent).
2
L'agent installe le skill
Il ajoute le SKILL.md et ses ressources à ton projet.
3
Activation automatique
Le skill s'active dès que le contexte correspond.

Déclencheurs pour Find Regression Risk (.NET)

Dis simplement à ton agent quelque chose comme :

Applique le skill find-regression-risk__dotnet-maui__github-skills-a4a671f6b93b à cette tâche
Utilise find-regression-risk__dotnet-maui__github-skills-a4a671f6b93b pour améliorer cette implémentation
Passe en revue ce sujet avec find-regression-risk__dotnet-maui__github-skills-a4a671f6b93b

Skills liés à Find Regression Risk (.NET)

Add CLI Command (.NET)
Add or change a dotnet CLI command, subcommand, or option across the relevant CLI projects. USE FOR: adding or changing a dotnet CLI command/subcommand, adding a new Option<T> or Argument<T>, registering a subcommand in the command tree, changing an option's help description or a command's runtime message, wiring a command parser, or updating --help output.
Add Dotnet Aot Command (.NET)
Add, enable, or review a dotnet CLI command or feature in the Native AOT CLI (src/Cli/dotnet-aot) and prove its compatibility. USE FOR: migrating a command or option to AOT, reviewing an AOT migration PR, defining conservative eligibility and managed fallback, changing AotSourceFiles.props or AotDependencies.props, validating AOT/managed parity, NativeAOT-publishing tests, checking binary-size impact, or using the dn harness and separated SDK layout. DO NOT USE FOR: resolving IL trim/AOT analyzer warnings alone (use dotnet-aot-compat), running dotnet.Tests incrementally (use incremental-test), or pure managed CLI work.
Add Net Analyzer (.NET)
Add, port, or change a .NET code analysis rule (CA####) under src/Microsoft.CodeAnalysis.NetAnalyzers. USE FOR: implementing a new CA analyzer and its code fixer, porting a rule or PR from the retired dotnet/roslyn-analyzers repo, allocating a diagnostic ID from DiagnosticCategoryAndIdRanges.txt, choosing RuleLevel/severity/category, wiring resx + xlf strings, recording the rule in AnalyzerReleases.Unshipped.md, regenerating the analyzer documentation/sarif files, and writing MSTest analyzer/code-fix tests with the VerifyCS/VerifyVB harness. DO NOT USE FOR: NETSDK#### MSBuild diagnostics (src/Tasks), CS####/BC#### compiler diagnostics or IDE#### analyzers (dotnet/roslyn), or CONTAINER#### diagnostics (src/Containers).