gitlink-cli/skills/gitlink-shared/examples/validate-maintenance-report...

23 lines
871 B
PowerShell

param(
[Parameter(Mandatory = $true)]
[string]$Path
)
$ErrorActionPreference = 'Stop'
$raw = Get-Content -Raw -Encoding utf8 $Path
$report = $raw | ConvertFrom-Json
$required = @('schema_version', 'mode', 'decision', 'severity', 'counts', 'security_gate', 'verification', 'top_actions', 'findings', 'limitations')
foreach ($name in $required) {
if ($null -eq $report.PSObject.Properties[$name]) {
throw "missing report field: $name"
}
}
if ($report.mode -notin @('executive', 'standard', 'full')) { throw "invalid report mode" }
if ($report.top_actions.Count -gt 5) { throw "executive report has more than five top actions" }
if ($raw -match "`e\[|<span|</span>") { throw "JSON contains presentation markers" }
if ($raw.Contains([char]0xfffd)) { throw "JSON contains UTF-8 replacement character" }
Write-Output "maintenance report contract passed: $Path"