Payload/scripts/kaden/harness/harness-stop-gate.ps1
|
#Requires -Version 5.1 <# .SYNOPSIS Cursor stop-hook gate: strict validate for in-scope review_ready slices. .DESCRIPTION Silent (exit 0) while no in-scope slice claims review_ready. When the feature current_slice (or any slice with an open turn) is review_ready, runs validate-review-loop -RequireReviewReady -Strict. Writes one harness-gate-failure.json per feature on failure (aggregated; not rewritten when the failure signature is unchanged). Historical idle review_ready slices are skipped so unrelated features do not thrash the gate file on every stop. Install: .\scripts\kaden\harness\setup-harness-hooks.ps1 #> [CmdletBinding()] param( [string]$RepoRoot = '' ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' $modulePath = Join-Path $PSScriptRoot 'lib\HarnessContract.psm1' Import-Module $modulePath -Force if ([string]::IsNullOrWhiteSpace($RepoRoot)) { $RepoRoot = Get-HarnessRepoRoot -StartPath $PSScriptRoot } $gate = Invoke-HarnessReviewReadyGate -RepoRoot $RepoRoot if ($gate.verdict -eq 'PASS') { exit 0 } foreach ($failure in $gate.failures) { Write-Output "[harness-stop-gate] BLOCKED $($failure.feature)/$($failure.slice) - see $($failure.path)" foreach ($finding in $failure.report.findings) { $line = " [$($finding.code)] $($finding.message)" $nextCmd = [string](Get-HarnessProperty -Object $finding -Name 'next_command') if (-not [string]::IsNullOrWhiteSpace($nextCmd)) { $line += " -> $nextCmd" } Write-Output $line } } exit 1 |