Spaces:
Sleeping
Sleeping
File size: 5,728 Bytes
6a1cba7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | param(
[string]$ExpectedVersion = "1.3.0",
[string]$OutputRoot = "tmp\release_validation",
[string]$SlopDetectorPath = "D:\Sanctum\ai-slop-detector",
[switch]$WithSlop
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..")).Path
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$outDir = Join-Path $repoRoot (Join-Path $OutputRoot "v1_3_0_$timestamp")
function Invoke-Step {
param(
[string]$Name,
[scriptblock]$Body
)
Write-Host ""
Write-Host "==> $Name"
& $Body
Write-Host "PASS: $Name"
}
function Assert-True {
param(
[bool]$Condition,
[string]$Message
)
if (-not $Condition) {
throw $Message
}
}
Push-Location $repoRoot
try {
Invoke-Step "CLI version is $ExpectedVersion" {
$version = python -m stem_ai --version
Write-Host $version
Assert-True ($version -eq "STEM BIO-AI $ExpectedVersion") "Unexpected CLI version: $version"
}
Invoke-Step "pytest regression suite" {
python -m pytest -q
}
Invoke-Step "package build" {
python -m build --no-isolation
}
Invoke-Step "local audit artifacts with --explain" {
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
python -m stem_ai . --level 3 --format all --out $outDir --explain
}
Invoke-Step "audit JSON contract" {
$jsonFiles = @(Get-ChildItem -LiteralPath $outDir -Filter "*_experiment_results.json")
Assert-True ($jsonFiles.Count -eq 1) "Expected one experiment_results JSON, found $($jsonFiles.Count)"
$result = Get-Content -LiteralPath $jsonFiles[0].FullName -Raw | ConvertFrom-Json
Assert-True ($result.stem_ai_version -eq $ExpectedVersion) "stem_ai_version mismatch: $($result.stem_ai_version)"
Assert-True ($result.schema_version -eq "stem-ai-local-cli-result-v1.3") "schema_version mismatch: $($result.schema_version)"
Assert-True ($null -ne $result.evidence_ledger -and $result.evidence_ledger.Count -gt 0) "evidence_ledger missing or empty"
Assert-True ($null -ne $result.detector_summary) "detector_summary missing"
Assert-True ($null -ne $result.ast_signal_summary) "ast_signal_summary missing"
Assert-True ($null -ne $result.stage_4_rubric) "stage_4_rubric missing"
Assert-True ($null -ne $result.replication_score) "replication_score missing"
Assert-True ([string]$result.replication_tier -match "^R[0-4]$") "replication_tier invalid: $($result.replication_tier)"
$badIds = @($result.evidence_ledger | Where-Object { [string]$_.finding_id -match "\\" })
Assert-True ($badIds.Count -eq 0) "finding_id contains Windows backslash"
$s4Findings = @($result.evidence_ledger | Where-Object { [string]$_.detector -like "S4_*" })
Assert-True ($s4Findings.Count -gt 0) "Stage 4 findings missing from evidence_ledger"
Write-Host "score=$($result.score.final_score) tier=$($result.score.formal_tier)"
Write-Host "replication_score=$($result.replication_score) replication_tier=$($result.replication_tier)"
Write-Host "evidence_ledger=$($result.evidence_ledger.Count)"
}
Invoke-Step "explain artifact contract" {
$explainFiles = @(Get-ChildItem -LiteralPath $outDir -Filter "*_explain.txt")
Assert-True ($explainFiles.Count -eq 1) "Expected one explain artifact, found $($explainFiles.Count)"
$explain = Get-Content -LiteralPath $explainFiles[0].FullName -Raw
Assert-True ($explain.Contains("STEM BIO-AI Explain Report")) "Explain header missing"
Assert-True ($explain.Contains("finding_id:")) "Explain finding_id lines missing"
Assert-True ($explain.Contains("AST Signal Summary")) "Explain AST summary missing"
Assert-True ($explain.Contains("Stage 4 Replication Rubric")) "Explain Stage 4 rubric missing"
Assert-True ($explain.Contains("DISCLAIMER:")) "Explain disclaimer missing"
}
Invoke-Step "markdown and PDF artifacts exist" {
$mdFiles = @(Get-ChildItem -LiteralPath $outDir -Filter "*_report.md")
$pdfFiles = @(Get-ChildItem -LiteralPath $outDir -Filter "*.pdf")
Assert-True ($mdFiles.Count -eq 1) "Expected one Markdown report, found $($mdFiles.Count)"
Assert-True ($pdfFiles.Count -eq 1) "Expected one PDF report, found $($pdfFiles.Count)"
Assert-True ($pdfFiles[0].Length -gt 1000) "PDF report appears too small"
}
if ($WithSlop -and (Test-Path -LiteralPath $SlopDetectorPath)) {
Invoke-Step "slop detector clean scan" {
$slopOut = Join-Path $outDir "slop_report.json"
Push-Location $SlopDetectorPath
try {
python -m slop_detector.cli --project $repoRoot --json --output $slopOut
}
finally {
Pop-Location
}
$slop = Get-Content -LiteralPath $slopOut -Raw | ConvertFrom-Json
Assert-True ($slop.overall_status -eq "clean") "Slop status is not clean: $($slop.overall_status)"
Assert-True ([int]$slop.deficit_files -eq 0) "Slop deficit_files is not zero: $($slop.deficit_files)"
Write-Host "slop overall_status=$($slop.overall_status) clean_files=$($slop.clean_files) deficit_files=$($slop.deficit_files)"
}
}
else {
Write-Host ""
Write-Host "SKIP: external slop detector clean scan (pass -WithSlop to enable)"
}
Write-Host ""
Write-Host "STEM BIO-AI v$ExpectedVersion validation PASSED"
Write-Host "Artifacts: $outDir"
}
finally {
Pop-Location
}
|