#!/usr/bin/env pwsh $ErrorActionPreference = "Stop" $Utf8 = [System.Text.UTF8Encoding]::new($false) [Console]::OutputEncoding = $Utf8 $OutputEncoding = $Utf8 $Root = Split-Path -Parent $PSScriptRoot Set-Location -Path $Root function Assert-NativeSuccess { param([string]$Step) if ($LASTEXITCODE -ne 0) { throw "$Step failed with exit code $LASTEXITCODE" } } function Invoke-Step { param( [string]$Name, [scriptblock]$Command ) Write-Host "==> $Name" & $Command Assert-NativeSuccess -Step $Name } $GoPath = (& go env GOPATH).Trim() Assert-NativeSuccess -Step "Locate GOPATH" $GoBin = Join-Path $GoPath "bin" if (Test-Path (Join-Path $GoBin "go1.20.14.exe")) { $env:PATH = "$GoBin;$env:PATH" } New-Item -ItemType Directory -Force -Path (Join-Path $Root "dist") | Out-Null Invoke-Step "Sync root workspace" { $env:GOTOOLCHAIN = "go1.25.0" $env:GOWORK = (Resolve-Path "go.work").Path go work sync } Invoke-Step "Sync Win7 workspace" { $env:GOTOOLCHAIN = "go1.25.0" $env:GOWORK = (Resolve-Path "app-win7/go.work").Path go work sync } Invoke-Step "Validate harness governance" { python scripts/validate_agent_context.py Assert-NativeSuccess -Step "Validate agent context" python -m unittest discover -s tests -p "test_*.py" Assert-NativeSuccess -Step "Run governance tests" python scripts/validate_harness_governance.py } Invoke-Step "Validate core architecture boundary" { python scripts/check_core_boundaries.py --self-test Assert-NativeSuccess -Step "Self-test core boundary matcher" python scripts/check_core_boundaries.py } Invoke-Step "Validate Go and dependency pins" { Remove-Item Env:GOTOOLCHAIN -ErrorAction SilentlyContinue Remove-Item Env:GOWORK -ErrorAction SilentlyContinue python scripts/check_go_versions.py } Invoke-Step "Vet and test core with Go 1.20.14" { $env:GOTOOLCHAIN = "go1.20.14" $env:GOWORK = "off" go -C core vet ./... Assert-NativeSuccess -Step "Vet core" go -C core test -count=1 ./... } Invoke-Step "Test and build modern target with Go 1.25.0" { $env:GOTOOLCHAIN = "go1.25.0" $env:GOWORK = (Resolve-Path "go.work").Path Remove-Item Env:GOOS -ErrorAction SilentlyContinue Remove-Item Env:GOARCH -ErrorAction SilentlyContinue $env:CGO_ENABLED = "0" go -C app-modern test -count=1 ./ui/gio ./platform/windows Assert-NativeSuccess -Step "Test modern adapters" $env:GOOS = "windows" $env:GOARCH = "amd64" go -C app-modern build -trimpath "-ldflags=-H=windowsgui" -o ../dist/SoftBox.exe ./cmd/softbox } Invoke-Step "Test and build Win7 target with Go 1.20.14" { $env:GOTOOLCHAIN = "go1.20.14" $env:GOWORK = (Resolve-Path "app-win7/go.work").Path Remove-Item Env:GOOS -ErrorAction SilentlyContinue Remove-Item Env:GOARCH -ErrorAction SilentlyContinue $env:CGO_ENABLED = "0" go -C app-win7 test -count=1 ./ui/gio ./platform/windows Assert-NativeSuccess -Step "Test Win7 adapters" $env:GOOS = "windows" $env:GOARCH = "amd64" go -C app-win7 build -trimpath "-ldflags=-H=windowsgui" -o ../dist/SoftBox-win7.exe ./cmd/softbox } Write-Host "Phase 0 verification passed."