# ============================================================================== # ClassNotify P2.1 - Build Inno Setup Installer & Size Optimization Report # Hardened Edition: Sealed Manifest Gate (702 files) + Safe Metric Calculations # ============================================================================== $ErrorActionPreference = "Stop" $root = "C:\Users\Administrator\.gemini\antigravity\scratch\ClassNotify" $packagingDir = Join-Path $root "packaging_p2" $issPath = Join-Path $packagingDir "ClassNotifySetup_p2.iss" $outputDir = Join-Path $packagingDir "output" $stagingDir = Join-Path $packagingDir "staging" $manifestPath = Join-Path $packagingDir "sealed_payload_manifest.json" $iscc = "C:\Users\Administrator\AppData\Local\Programs\Inno Setup 7\ISCC.exe" if (-not (Test-Path $iscc)) { throw "Inno Setup compiler not found at: $iscc" } if (-not (Test-Path $issPath)) { throw "ISS script not found at: $issPath" } # ============================================================================== # Gate: 702-File Byte-for-Byte Sealed Manifest Verification (CR-03) # ============================================================================== Write-Host "==========================================================" -ForegroundColor Cyan Write-Host " ClassNotify P2.1 - Sealed Manifest Gate (702 Files) " -ForegroundColor Cyan Write-Host "==========================================================" -ForegroundColor Cyan if (-not (Test-Path $manifestPath)) { throw "[SEALED MANIFEST GATE FAILED] Manifest file not found at: $manifestPath" } $manifestJson = Get-Content $manifestPath -Raw -Encoding UTF8 | ConvertFrom-Json if ($manifestJson.baseline -ne "P1_GA_F2C14966") { throw "[SEALED MANIFEST GATE FAILED] Unexpected baseline! Expected P1_GA_F2C14966, got $($manifestJson.baseline)" } $expectedFiles = $manifestJson.files Write-Host "Expected sealed files count : $($expectedFiles.Count) (Pinned to $($manifestJson.baseline))" -ForegroundColor Yellow $stagingFiles = Get-ChildItem -Path $stagingDir -Recurse -File Write-Host "Actual staged files count : $($stagingFiles.Count)" -ForegroundColor Yellow if ($stagingFiles.Count -ne $expectedFiles.Count) { throw "[SEALED MANIFEST GATE FAILED] File count mismatch! Expected $($expectedFiles.Count), found $($stagingFiles.Count)." } $lookup = @{} foreach ($ef in $expectedFiles) { $lookup[$ef.path.Replace('/', '\')] = $ef } $stagingPrefixLen = $stagingDir.Length $hashFailures = 0 Write-Host "Verifying paths, file sizes, and SHA256 hashes against GA sealed baseline..." -ForegroundColor Yellow foreach ($sf in $stagingFiles) { $rel = $sf.FullName.Substring($stagingPrefixLen).TrimStart('\') if (-not $lookup.ContainsKey($rel)) { throw "[SEALED MANIFEST GATE FAILED] Unexpected extra file found: $rel" } $expected = $lookup[$rel] if ($sf.Length -ne $expected.size) { throw "[SEALED MANIFEST GATE FAILED] File size mismatch for $rel! Expected $($expected.size) bytes, actual $($sf.Length) bytes." } $actualHash = (Get-FileHash -Path $sf.FullName -Algorithm SHA256).Hash.ToUpper() if ($actualHash -ne $expected.sha256) { Write-Host "[HASH MISMATCH] ${rel}: expected $($expected.sha256), actual $actualHash" -ForegroundColor Red $hashFailures++ } } if ($hashFailures -gt 0) { throw "[SEALED MANIFEST GATE FAILED] $hashFailures payload files deviated from GA sealed baseline!" } Write-Host "[SEALED MANIFEST GATE PASSED] All $($expectedFiles.Count) files verified 100% byte-for-byte identical to P1 GA sealed baseline!`n" -ForegroundColor Green # ============================================================================== # Compilation with ISCC # ============================================================================== if (Test-Path $outputDir) { Remove-Item $outputDir -Recurse -Force } New-Item -ItemType Directory -Path $outputDir -Force | Out-Null Write-Host "Starting compilation with ISCC.exe (Solid LZMA2/max)..." -ForegroundColor Yellow $sw = [System.Diagnostics.Stopwatch]::StartNew() & $iscc "/O$outputDir" $issPath if ($LASTEXITCODE -ne 0) { throw "ISCC compilation failed with exit code $LASTEXITCODE" } $sw.Stop() $newInstaller = Join-Path $outputDir "ClassNotifySetup.exe" if (-not (Test-Path $newInstaller)) { throw "Built installer not found at: $newInstaller" } $newSize = (Get-Item $newInstaller).Length $newSizeMb = [math]::Round($newSize / 1MB, 2) $newHash = (Get-FileHash -Path $newInstaller -Algorithm SHA256).Hash.ToUpper() # ============================================================================== # Metrics & Size Comparison (CR-02 Division-by-Zero Protected) # ============================================================================== $p1Installer = Join-Path $root "rc2_artifacts\ClassNotifySetup.exe" $p1Size = 0 $p1SizeMb = 0 $reductionMb = "N/A" $reductionPct = "N/A" if (Test-Path $p1Installer) { $p1Size = (Get-Item $p1Installer).Length $p1SizeMb = [math]::Round($p1Size / 1MB, 2) if ($p1Size -gt 0) { $reductionBytes = $p1Size - $newSize $reductionMb = [math]::Round($reductionBytes / 1MB, 2) $reductionPct = [math]::Round(($reductionBytes / $p1Size) * 100, 2) } } Write-Host "`n==========================================================" -ForegroundColor Green Write-Host " P2.1 COMPILATION & SIZE OPTIMIZATION RESULTS " -ForegroundColor Green Write-Host "==========================================================" -ForegroundColor Green Write-Host "Sealed Files Gate : 702/702 PASS (Byte-for-byte identical)" -ForegroundColor Green Write-Host "Compile Time : $([math]::Round($sw.Elapsed.TotalSeconds, 1)) seconds" if ($p1Size -gt 0) { Write-Host "P1 GA Installer : $p1SizeMb MB ($p1Size bytes)" Write-Host "P2.1 New Installer: $newSizeMb MB ($newSize bytes)" Write-Host "Size Reduction : -$reductionMb MB (-$reductionPct%)" -ForegroundColor Cyan } else { Write-Host "P2.1 New Installer: $newSizeMb MB ($newSize bytes)" Write-Host "P1 Baseline : Not present locally (Skipped comparison)" } Write-Host "New SHA256 Hash : $newHash" -ForegroundColor Yellow Write-Host "==========================================================`n" -ForegroundColor Green