# ============================================================================== # ChronoGrid P2P - Agent Verification Pipeline v2 # Runs compilation, test, and specification alignment checks across all crates. # Exit code 0 = all checks passed. Non-zero = failure. # ============================================================================== $ErrorActionPreference = "Continue" $RootDir = "$PSScriptRoot\.." $StartTime = Get-Date $FailCount = 0 # Locate Perl — required by openssl-sys build script (bundled-sqlcipher-vendored-openssl) if (-not (Get-Command perl -ErrorAction SilentlyContinue)) { $PerlCandidates = @( "C:\Strawberry\perl\bin", "C:\Perl\bin", "C:\Program Files\Git\usr\bin", "C:\Program Files (x86)\Git\usr\bin" ) foreach ($perlDir in $PerlCandidates) { if (Test-Path "$perlDir\perl.exe") { $env:PATH = "$perlDir;$env:PATH" Write-Host " INFO: Found perl at $perlDir\perl.exe" -ForegroundColor Yellow break } } if (-not (Get-Command perl -ErrorAction SilentlyContinue)) { Write-Host " WARN: perl not found - openssl-sys (chronogrid_core/ffi) builds may fail." -ForegroundColor Yellow } } # Locate cargo — try common install locations if not already on PATH $CargoExe = "cargo" if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) { $CandidatePaths = @( "$env:USERPROFILE\.cargo\bin\cargo.exe", "C:\Users\$env:USERNAME\.cargo\bin\cargo.exe", "D:\Users\$env:USERNAME\.cargo\bin\cargo.exe", "$env:LOCALAPPDATA\Programs\Rust\bin\cargo.exe", "C:\Users\mtkel\.cargo\bin\cargo.exe" ) foreach ($candidate in $CandidatePaths) { if (Test-Path $candidate) { $CargoExe = $candidate $env:PATH = "$([System.IO.Path]::GetDirectoryName($candidate));$env:PATH" Write-Host " INFO: Found cargo at $candidate" -ForegroundColor Yellow break } } if ($CargoExe -eq "cargo") { Write-Host " WARN: cargo not found on PATH or common locations. Rust checks will be skipped." -ForegroundColor Yellow Write-Host " Run this script from a terminal where 'cargo' is available." -ForegroundColor Yellow } } function Write-Step { param([string]$Message) $elapsed = [int]((Get-Date) - $StartTime).TotalSeconds Write-Host "`n[${elapsed}s] $Message" -ForegroundColor Cyan } function Write-Pass { param([string]$Message) Write-Host " PASS: $Message" -ForegroundColor Green } function Write-Fail { param([string]$Message) Write-Host " FAIL: $Message" -ForegroundColor Red $script:FailCount++ } Write-Host "============================================================" -ForegroundColor Cyan Write-Host " CHRONOGRID P2P - AGENT VERIFICATION PIPELINE v2" -ForegroundColor Cyan Write-Host " $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -ForegroundColor Cyan Write-Host "============================================================" -ForegroundColor Cyan # --- 1. chronogrid_crypto --- Write-Step "1. Checking chronogrid_crypto (compile + tests)..." Set-Location "$RootDir\crates\chronogrid_crypto" cargo check --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_crypto failed cargo check" } else { Write-Pass "chronogrid_crypto compiles" } cargo test --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_crypto tests failed" } else { Write-Pass "chronogrid_crypto tests pass" } # --- 2. chronogrid_core --- Write-Step "2. Checking chronogrid_core (compile + tests)..." Set-Location "$RootDir\crates\chronogrid_core" cargo check --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_core failed cargo check" } else { Write-Pass "chronogrid_core compiles" } cargo test --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_core tests failed" } else { Write-Pass "chronogrid_core tests pass" } # --- 3. chronogrid_net --- Write-Step "3. Checking chronogrid_net (compile + tests)..." Set-Location "$RootDir\crates\chronogrid_net" cargo check --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_net failed cargo check" } else { Write-Pass "chronogrid_net compiles" } cargo test --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_net tests failed" } else { Write-Pass "chronogrid_net tests pass" } # --- 4. chronogrid_ai --- Write-Step "4. Checking chronogrid_ai (compile + tests)..." Set-Location "$RootDir\crates\chronogrid_ai" cargo check --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_ai failed cargo check" } else { Write-Pass "chronogrid_ai compiles" } cargo test --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_ai tests failed" } else { Write-Pass "chronogrid_ai tests pass" } # --- 5. chronogrid_ffi --- Write-Step "5. Checking chronogrid_ffi (compile + tests)..." Set-Location "$RootDir\crates\chronogrid_ffi" cargo check --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_ffi failed cargo check" } else { Write-Pass "chronogrid_ffi compiles" } cargo test --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_ffi tests failed" } else { Write-Pass "chronogrid_ffi tests pass" } # --- 6. chronogrid_daemon (if scaffolded) --- Write-Step "6. Checking chronogrid_daemon (if scaffolded)..." $DaemonCargoToml = "$RootDir\apps\chronogrid_daemon\Cargo.toml" if (Test-Path $DaemonCargoToml) { Set-Location "$RootDir\apps\chronogrid_daemon" cargo check --quiet 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "chronogrid_daemon failed cargo check" } else { Write-Pass "chronogrid_daemon compiles" } } else { Write-Host " SKIP: chronogrid_daemon not yet scaffolded (Task 2.7)" -ForegroundColor Yellow } # --- 7. Schema Validation --- Write-Step "7. Validating schema.sql contains required tables..." $SchemaPath = "$RootDir\docs\API_CONTRACTS\schema.sql" $SchemaContent = Get-Content $SchemaPath -Raw $RequiredTables = @( "namespaces", "projects", "tasks", "notes", "task_note_links", "ingestion_logs", "crdt_docs" ) $Phase2Tables = @( "time_blocks", "attachments", "calendar_feeds", "node_peers", "automation_rules", "ingestion_configs" ) foreach ($table in $RequiredTables) { if ($SchemaContent -match "CREATE TABLE IF NOT EXISTS $table") { Write-Pass "Schema contains table: $table" } else { Write-Fail "Schema MISSING required table: $table" } } $Phase2Count = 0 foreach ($table in $Phase2Tables) { if ($SchemaContent -match "CREATE TABLE IF NOT EXISTS $table") { $Phase2Count++ Write-Pass "Schema contains Phase 2 table: $table" } else { Write-Host " INFO: Phase 2 table not yet added: $table" -ForegroundColor Yellow } } if ($Phase2Count -eq $Phase2Tables.Count) { Write-Pass "All Phase 2 schema tables present ($Phase2Count/$($Phase2Tables.Count))" } else { Write-Host " INFO: $Phase2Count/$($Phase2Tables.Count) Phase 2 tables present (add remaining in Task 2.1)" -ForegroundColor Yellow } # --- 8. Flutter Analysis --- Write-Step "8. Checking Flutter shell (analyze)..." $FlutterDir = "$RootDir\apps\chronogrid_flutter" if (Test-Path "$FlutterDir\pubspec.yaml") { Set-Location $FlutterDir flutter analyze --no-pub 2>&1 if ($LASTEXITCODE -ne 0) { Write-Fail "Flutter analysis errors detected" } else { Write-Pass "Flutter analysis clean" } } else { Write-Fail "Flutter pubspec.yaml not found at $FlutterDir" } # --- 9. FRB Codegen Output Check --- Write-Step "9. Checking FRB codegen output (if generated)..." $FrbGenerated = "$RootDir\crates\chronogrid_ffi\src\frb_generated.rs" $DartGenerated = "$RootDir\apps\chronogrid_flutter\lib\src\rust\frb_generated.dart" if (Test-Path $FrbGenerated) { Write-Pass "FRB Rust generated file exists" } else { Write-Host " INFO: frb_generated.rs not yet generated (run: flutter_rust_bridge_codegen generate)" -ForegroundColor Yellow } if (Test-Path $DartGenerated) { Write-Pass "FRB Dart generated file exists" } else { Write-Host " INFO: frb_generated.dart not yet generated (run: flutter_rust_bridge_codegen generate)" -ForegroundColor Yellow } # --- 10. DECISION_LOG.md Check --- Write-Step "10. Checking DECISION_LOG.md is present and non-empty..." $DecisionLog = "$RootDir\DECISION_LOG.md" if (Test-Path $DecisionLog) { $LogSize = (Get-Item $DecisionLog).Length if ($LogSize -gt 500) { Write-Pass "DECISION_LOG.md present ($LogSize bytes)" } else { Write-Fail "DECISION_LOG.md is suspiciously small ($LogSize bytes) - may be empty" } } else { Write-Fail "DECISION_LOG.md not found" } # --- Summary --- $Elapsed = [int]((Get-Date) - $StartTime).TotalSeconds Write-Host "`n============================================================" -ForegroundColor Cyan if ($FailCount -eq 0) { Write-Host " ALL VERIFICATION CHECKS PASSED ($Elapsed seconds)" -ForegroundColor Green Write-Host "============================================================" -ForegroundColor Cyan Exit 0 } else { Write-Host " $FailCount CHECK(S) FAILED ($Elapsed seconds)" -ForegroundColor Red Write-Host " Fix all failures before committing." -ForegroundColor Red Write-Host "============================================================" -ForegroundColor Cyan Exit 1 }