Skip to content

Commit 5cc04ae

Browse files
committed
Add forward flow scanning to -CheckMissing
-CheckMissing now scans open forward flow PRs (product repo → dotnet/dotnet) in addition to missing backflow PRs. For each forward flow PR it detects: - Conflict (Maestro 'Conflict detected' comment) - Staleness (opposite codeflow merged while PR was open) - Healthy (no issues) Summary section now shows both directions. Also fixes: dotnet-maestro comment author matching (gh CLI returns 'dotnet-maestro' not 'dotnet-maestro[bot]' for login field). Tested against dotnet/sdk (4 forward PRs: 2 healthy, 1 stale, 1 conflict) and dotnet/runtime (3 forward PRs: 2 healthy, 1 stale).
1 parent c0c18fd commit 5cc04ae

2 files changed

Lines changed: 88 additions & 9 deletions

File tree

.github/skills/vmr-codeflow-status/SKILL.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ description: Analyze VMR codeflow PR status for dotnet repositories. Use when in
55

66
# VMR Codeflow Status
77

8-
Analyze the health of VMR codeflow PRs (backflow from `dotnet/dotnet` to product repositories like `dotnet/sdk`).
8+
Analyze the health of VMR codeflow PRs in both directions:
9+
- **Backflow**: `dotnet/dotnet` → product repos (e.g., `dotnet/sdk`)
10+
- **Forward flow**: product repos → `dotnet/dotnet`
911

1012
## When to Use This Skill
1113

@@ -14,8 +16,8 @@ Use this skill when:
1416
- You need to check if a specific fix has flowed through the VMR pipeline to a codeflow PR
1517
- A PR has a Maestro staleness warning ("codeflow cannot continue") or conflict
1618
- You need to understand what manual commits would be lost if a codeflow PR is closed
17-
- You want to know if expected backflow PRs are missing for a repo/branch
18-
- Asked questions like "is this codeflow PR up to date", "has the runtime revert reached this PR", "why is the codeflow blocked"
19+
- You want to check the overall state of flow for a repo (backflow and forward flow health)
20+
- Asked questions like "is this codeflow PR up to date", "has the runtime revert reached this PR", "why is the codeflow blocked", "what is the state of flow for the sdk"
1921

2022
## Quick Start
2123

@@ -29,7 +31,7 @@ Use this skill when:
2931
# Show individual VMR commits that are missing
3032
./scripts/Get-CodeflowStatus.ps1 -PRNumber 52727 -Repository "dotnet/sdk" -ShowCommits
3133
32-
# Check if any backflow PRs are missing for a repo
34+
# Check overall flow health for a repo (backflow + forward flow)
3335
./scripts/Get-CodeflowStatus.ps1 -Repository "dotnet/roslyn" -CheckMissing
3436
3537
# Check a specific branch only
@@ -44,7 +46,7 @@ Use this skill when:
4446
| `-Repository` | Target repo in `owner/repo` format (default: `dotnet/sdk`) |
4547
| `-TraceFix` | Trace a repo PR through the pipeline (e.g., `dotnet/runtime#123974`) |
4648
| `-ShowCommits` | Show individual VMR commits between PR snapshot and branch HEAD |
47-
| `-CheckMissing` | Check if backflow PRs are expected but missing for a repository |
49+
| `-CheckMissing` | Check overall flow health: missing backflow PRs and forward flow PR status |
4850
| `-Branch` | With `-CheckMissing`, only check a specific branch |
4951

5052
## What the Script Does
@@ -58,6 +60,7 @@ Use this skill when:
5860
7. **Traces fixes** (optional) — Checks if a specific fix has flowed through VMR → codeflow PR
5961
8. **Recommends actions** — Suggests force trigger, close/reopen, merge as-is, resolve conflicts, or wait
6062
9. **Checks for missing backflow** (optional) — Finds branches where a backflow PR should exist but doesn't
63+
10. **Scans forward flow** (optional) — Checks open forward flow PRs into `dotnet/dotnet` for staleness and conflicts
6164

6265
## Interpreting Results
6366

.github/skills/vmr-codeflow-status/scripts/Get-CodeflowStatus.ps1

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,90 @@ if ($CheckMissing) {
260260
}
261261
}
262262

263+
# --- Forward flow: check PRs from this repo into the VMR ---
264+
$repoShortName = $Repository -replace '^dotnet/', ''
265+
Write-Host ""
266+
Write-Section "Forward flow PRs ($Repository → dotnet/dotnet)"
267+
268+
$fwdPRsJson = gh search prs --repo dotnet/dotnet --author "dotnet-maestro[bot]" --state open "Source code updates from dotnet/$repoShortName" --json number,title --limit 50 2>$null
269+
$fwdPRs = @()
270+
if ($LASTEXITCODE -eq 0 -and $fwdPRsJson) {
271+
try { $fwdPRs = ($fwdPRsJson -join "`n") | ConvertFrom-Json } catch { $fwdPRs = @() }
272+
}
273+
# Filter to exact repo match (avoid dotnet/sdk matching dotnet/sdk-container-builds)
274+
$fwdPRs = @($fwdPRs | Where-Object { $_.title -match "from dotnet/$([regex]::Escape($repoShortName))$" })
275+
276+
$fwdHealthy = 0
277+
$fwdStale = 0
278+
$fwdConflict = 0
279+
280+
if ($fwdPRs.Count -eq 0) {
281+
Write-Host " No open forward flow PRs found" -ForegroundColor DarkGray
282+
}
283+
else {
284+
foreach ($fpr in $fwdPRs) {
285+
$fprBranch = if ($fpr.title -match '^\[([^\]]+)\]') { $Matches[1] } else { "unknown" }
286+
if ($Branch -and $fprBranch -ne $Branch) { continue }
287+
288+
# Get PR details for staleness/conflict check
289+
$fprDetailJson = gh pr view $fpr.number -R dotnet/dotnet --json body,comments,updatedAt 2>&1
290+
if ($LASTEXITCODE -ne 0) {
291+
Write-Host " PR #$($fpr.number) [$fprBranch]: ⚠️ Could not fetch details" -ForegroundColor Yellow
292+
continue
293+
}
294+
$fprDetail = ($fprDetailJson -join "`n") | ConvertFrom-Json
295+
296+
# Check for staleness warnings and conflicts in comments
297+
$hasStaleness = $false
298+
$hasConflict = $false
299+
if ($fprDetail.comments) {
300+
foreach ($comment in $fprDetail.comments) {
301+
if ($comment.author.login -match '^dotnet-maestro') {
302+
if ($comment.body -match 'codeflow cannot continue|the source repository has received code changes') { $hasStaleness = $true }
303+
if ($comment.body -match 'Conflict detected') { $hasConflict = $true }
304+
}
305+
}
306+
}
307+
308+
$status = "✅ Healthy"
309+
$color = "Green"
310+
if ($hasConflict) {
311+
$status = "🔴 Conflict"
312+
$color = "Red"
313+
$fwdConflict++
314+
}
315+
elseif ($hasStaleness) {
316+
$status = "⚠️ Stale"
317+
$color = "Yellow"
318+
$fwdStale++
319+
}
320+
else {
321+
$fwdHealthy++
322+
}
323+
324+
Write-Host " PR #$($fpr.number) [$fprBranch]: $status" -ForegroundColor $color
325+
Write-Host " https://github.com/dotnet/dotnet/pull/$($fpr.number)" -ForegroundColor DarkGray
326+
}
327+
}
328+
263329
Write-Section "Summary"
264-
Write-Host " Branches with open backflow PRs: $coveredCount" -ForegroundColor Green
265-
Write-Host " Branches up to date (no PR needed): $upToDateCount" -ForegroundColor Green
330+
Write-Host " Backflow ($Repository ← dotnet/dotnet):" -ForegroundColor White
331+
Write-Host " Branches with open PRs: $coveredCount" -ForegroundColor Green
332+
Write-Host " Branches up to date: $upToDateCount" -ForegroundColor Green
266333
if ($missingCount -gt 0) {
267-
Write-Host " Branches MISSING backflow PRs: $missingCount" -ForegroundColor Red
334+
Write-Host " Branches MISSING backflow PRs: $missingCount" -ForegroundColor Red
335+
}
336+
else {
337+
Write-Host " No missing backflow PRs ✅" -ForegroundColor Green
338+
}
339+
Write-Host " Forward flow ($Repository → dotnet/dotnet):" -ForegroundColor White
340+
if ($fwdPRs.Count -eq 0) {
341+
Write-Host " No open forward flow PRs" -ForegroundColor DarkGray
268342
}
269343
else {
270-
Write-Host " No missing backflow PRs detected ✅" -ForegroundColor Green
344+
if ($fwdHealthy -gt 0) { Write-Host " Healthy: $fwdHealthy" -ForegroundColor Green }
345+
if ($fwdStale -gt 0) { Write-Host " Stale: $fwdStale" -ForegroundColor Yellow }
346+
if ($fwdConflict -gt 0) { Write-Host " Conflicted: $fwdConflict" -ForegroundColor Red }
271347
}
272348
return
273349
}

0 commit comments

Comments
 (0)