Repository: dotnet/runtime
File: .github/skills/vmr-codeflow-status/scripts/Get-CodeflowStatus.ps1 (PowerShell)

Code before:
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else {
                    Write-Warning "Could not find $traceRepo in VMR source-manifest.json"
                }
            }
        }
    }
}

# --- Step 9: Structured Summary ---
# Emit a JSON summary for the agent to reason over when generating recommendations.
# The agent should use SKILL.md guidance to synthesize contextual recommendations.

$summary = [ordered]@{
    prNumber        = $PRNumber
    repository      = $Repository
    prState         = $pr.state
    currentState    = $currentState
    isCodeflowPR    = ($isMaestroPR -or $isBackflow -or $isForwardFlow)
    flowDirection   = if ($isForwardFlow) { "forward" } elseif ($isBackflow) { "backflow" } else { "unknown" }
    isEmptyDiff     = $isEmptyDiff
    changedFiles    = [int]$pr.changedFiles
    additions       = [int]$pr.additions
    deletions       = [int]$pr.deletions
    subscriptionId  = $subscriptionId
    vmrCommit       = if ($vmrCommit) { Get-ShortSha $vmrCommit } else { $null }
    vmrBranch       = $vmrBranch
}

# Freshness
$hasFresnessData = ($null -ne $vmrCommit -and $null -ne $sourceHeadSha)
$summary.freshness = [ordered]@{
    sourceHeadSha   = if ($sourceHeadSha) { Get-ShortSha $sourceHeadSha } else { $null }
    compareStatus   = $compareStatus
    aheadBy         = $aheadBy
    behindBy        = $behindBy
    isUpToDate      = if ($hasFresnessData) { ($vmrCommit -eq $sourceHeadSha -or $compareStatus -eq 'identical') } else { $null }
}

# Force pushes
$summary.forcePushes = [ordered]@{
    count           = $forcePushEvents.Count
    lastActor       = if ($lastForcePushActor) { $lastForcePushActor } else { $null }
    lastTime        = if ($lastForcePushTime) { $lastForcePushTime.ToString("o") } else { $null }
}

Review comment (security):
`isCodeflowPR` is currently set to `($isMaestroPR -or $isBackflow -or $isForwardFlow)`, which will classify any PR authored by `dotnet-maestro[bot]` as a codeflow PR even when the title doesn't indicate forward/backflow (i.e., flowDirection stays `"unknown"`). This contradicts the intent of `isCodeflowPR` as an explicit codeflow/non-codeflow classifier and can cause the agent to emit darc/codeflow guidance for non-codeflow Maestro PRs. Consider computing `isCodeflowPR` from the same primary signals used for flow detection (e.g., `$isBackflow -or $isForwardFlow`) and, if needed, emit a separate `isMaestroAuthored` field for dependency-flow PRs.
```suggestion
    isCodeflowPR    = ($isBackflow -or $isForwardFlow)
    flowDirection   = if ($isForwardFlow) { "forward" } elseif ($isBackflow) { "backflow" } else { "unknown" }
    isMaestroAuthored = $isMaestroPR
```

Code after:
                                $snapshotCommit = $snapshotEntry.commitSha
                                Write-Status "PR snapshot commit" "$(Get-ShortSha $snapshotCommit) for $($snapshotEntry.path)"

                                if ($snapshotCommit -eq $fixMergeCommit) {
                                    Write-Host "  ✅ Fix IS in the PR's VMR snapshot" -ForegroundColor Green
                                }
                                else {
                                    $snapshotCheck = Invoke-GitHubApi "/repos/$traceFullRepo/compare/$fixMergeCommit...$snapshotCommit"
                                    if ($snapshotCheck) {
                                        if ($snapshotCheck.status -eq "ahead" -or $snapshotCheck.status -eq "identical") {
                                            Write-Host "  ✅ Fix is included in PR snapshot" -ForegroundColor Green
                                        }
                                        else {
                                            Write-Host "  ❌ Fix is NOT in the PR's VMR snapshot" -ForegroundColor Red
                                            Write-Host "  The PR needs a codeflow update to pick up this fix." -ForegroundColor Yellow
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else {
                    Write-Warning "Could not find $traceRepo in VMR source-manifest.json"
                }
            }
        }
    }
}

# --- Step 9: Structured Summary ---
# Emit a JSON summary for the agent to reason over when generating recommendations.
# The agent should use SKILL.md guidance to synthesize contextual recommendations.

$summary = [ordered]@{
    prNumber        = $PRNumber
    repository      = $Repository
    prState         = $pr.state
    currentState    = $currentState
    isCodeflowPR    = ($isBackflow -or $isForwardFlow)
    isMaestroAuthored = $isMaestroPR
    flowDirection   = if ($isForwardFlow) { "forward" } elseif ($isBackflow) { "backflow" } else { "unknown" }
    isEmptyDiff     = $isEmptyDiff
    changedFiles    = [int]$pr.changedFiles
    additions       = [int]$pr.additions
    deletions       = [int]$pr.deletions
    subscriptionId  = $subscriptionId
    vmrCommit       = if ($vmrCommit) { Get-ShortSha $vmrCommit } else { $null }
    vmrBranch       = $vmrBranch
}