| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- # Edge builder & validator for cockpit-primary-area-guardrails
- # Written by AI agent. Runs in PowerShell (Windows sandbox safe).
- param(
- [string]$EffortDir = ""
- )
- if (-not $EffortDir) {
- $EffortDir = Split-Path $PSScriptRoot -Parent
- }
- $TicketsDir = Join-Path $EffortDir "issues"
- $MapPath = Join-Path $EffortDir "map.md"
- Write-Host "Building native `Blocked by:` edges and validating ticket count..."
- # Declare expected tickets and their blocking edges
- $ExpectedTickets = @{
- "01-primary-area-config-contract.md" = "None"
- "02-camera-limit-numeric-contract.md" = "01"
- "03-camera-contract-composition-and-entry-state.md" = "01,02"
- "04-research-cesium-ground-fog-mechanisms.md" = "None"
- "05-research-overlay-rectangle-pop-mechanisms.md" = "None"
- "06-research-three-fog-shader-reuse.md" = "None"
- "07-fog-implementation-spec.md" = "01,04,06"
- "08-coarse-to-fine-transition-solution.md" = "01,05,07"
- }
- $ExpectedMapTaskCount = 8
- # Function to fix one ticket
- function Fix-Edge {
- param([string]$TicketPath)
- $TicketName = Split-Path $TicketPath -Leaf
- if (-not $ExpectedTickets.ContainsKey($TicketName)) {
- Write-Host "Unknown ticket: $TicketName"
- return $false
- }
- $ExpectedEdge = $ExpectedTickets[$TicketName]
- $EdgeLine = "Blocked by: $ExpectedEdge"
- $Content = Get-Content $TicketPath -Raw
- if ($Content -match "(?m)^Blocked by: .*$") {
- $Content = $Content -replace "(?m)^Blocked by: .*$", $EdgeLine
- } else {
- $Content = $EdgeLine + "`n`n" + $Content
- }
- $Content | Set-Content $TicketPath -Encoding UTF8 -NoNewline
- Write-Host " Fixed $TicketName : $EdgeLine"
- return $true
- }
- # Build edges
- $Success = $true
- foreach ($Ticket in Get-ChildItem $TicketsDir -Filter "*.md") {
- $Fixed = Fix-Edge $Ticket.FullName
- if (-not $Fixed) { $Success = $false }
- }
- # Validate count
- $ActualTicketCount = (Get-ChildItem $TicketsDir -Filter "*.md").Count
- if ($ActualTicketCount -ne $ExpectedMapTaskCount) {
- Write-Host "Ticket count mismatch: expected $ExpectedMapTaskCount, actual $ActualTicketCount"
- $Success = $false
- }
- # Validate each `Blocked by:`
- foreach ($Ticket in Get-ChildItem $TicketsDir -Filter "*.md") {
- $Content = Get-Content $Ticket.FullName -Raw
- if ($Content -match "(?m)^Blocked by: (.*?)$") {
- $Edge = $Matches[1]
- $Refs = $Edge -split "," | ForEach-Object { $_.Trim() }
- foreach ($Ref in $Refs) {
- if ($Ref -ne "None") {
- $Referenced = Get-ChildItem $TicketsDir -Filter "$Ref*.md"
- if (-not $Referenced) {
- Write-Host " Invalid reference in $($Ticket.Name): $Ref"
- $Success = $false
- }
- }
- }
- } else {
- Write-Host " Missing `Blocked by:` in $($Ticket.Name)"
- $Success = $false
- }
- }
- # Validate resolved research tickets (04 and 05 are resolved; 06 is open)
- $ResolvedResearch = @("04-research-cesium-ground-fog-mechanisms.md", "05-research-overlay-rectangle-pop-mechanisms.md")
- foreach ($Name in $ResolvedResearch) {
- $Ticket = Join-Path $TicketsDir $Name
- if (Test-Path $Ticket) {
- $Content = Get-Content $Ticket -Raw
- if ($Content -notmatch "(?m)^Status: resolved$") {
- Write-Host " Research ticket $Name not resolved"
- $Success = $false
- }
- } else {
- Write-Host " Missing research ticket $Name"
- $Success = $false
- }
- }
- if ($Success) {
- Write-Host "All edges built and validated successfully. Total tickets: $ActualTicketCount"
- } else {
- Write-Host "Validation failed. Please fix above issues."
- exit 1
- }
|