$ErrorActionPreference = "Stop" $root = "C:\Users\Administrator\.gemini\antigravity\scratch\ClassNotify" $artifactDir = "C:\Users\Administrator\.gemini\antigravity\brain\6a85e1d1-76c5-4355-a1fd-b02c82575fbe" $proofLogPath = Join-Path $root "turn116_round2_proofs.txt" Write-Host "================================================================================" -ForegroundColor Cyan Write-Host " ClassNotify Turn 116 Round 2 Rigorous Reality Proofs & In-Place Upgrade Suite " -ForegroundColor Cyan Write-Host "================================================================================" -ForegroundColor Cyan $proofLog = [System.Text.StringBuilder]::new() function LogProof($msg) { Write-Host $msg [void]$proofLog.AppendLine($msg) } LogProof "Turn 116 Round 2 Verification Execution: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" # ----------------------------------------------------------------------------- # Proof A: Static Gate: Zero ActivationWindow in Source Code & Physical Deletion # ----------------------------------------------------------------------------- LogProof "`n--- [PROOF A: ZERO ACTIVATIONWINDOW SOURCE & PHYSICAL DELETION] ---" $actXaml = Join-Path $root "src\Windows\ClassNotify.Client\ActivationWindow.xaml" $actCs = Join-Path $root "src\Windows\ClassNotify.Client\ActivationWindow.xaml.cs" if (Test-Path $actXaml) { throw "FAIL: ActivationWindow.xaml still exists physically!" } if (Test-Path $actCs) { throw "FAIL: ActivationWindow.xaml.cs still exists physically!" } LogProof " [PASS] ActivationWindow.xaml physically deleted" LogProof " [PASS] ActivationWindow.xaml.cs physically deleted" $clientSourceFiles = Get-ChildItem -Path (Join-Path $root "src\Windows\ClassNotify.Client") -Recurse -Include "*.cs", "*.xaml" $matchesA = $clientSourceFiles | Select-String -Pattern "ActivationWindow" if ($matchesA.Count -gt 0) { foreach ($m in $matchesA) { LogProof " Found: $($m.Path):$($m.LineNumber): $($m.Line)" } throw "FAIL: Source code still contains ActivationWindow references!" } LogProof " [PASS] Grep ActivationWindow in src\Windows\ClassNotify.Client source: 0 occurrences" $legacyStrings = $clientSourceFiles | Select-String -Pattern "班级设备激活|稍后激活|立即激活" if ($legacyStrings.Count -gt 0) { foreach ($m in $legacyStrings) { LogProof " Found: $($m.Path):$($m.LineNumber): $($m.Line)" } throw "FAIL: Source code still contains legacy activation prompt strings!" } LogProof " [PASS] Grep legacy activation UI strings in client source: 0 occurrences" # ----------------------------------------------------------------------------- # Proof B: Static Gate: Zero Local Destructive Unbind Capability # ----------------------------------------------------------------------------- LogProof "`n--- [PROOF B: ZERO LOCAL DESTRUCTIVE UNBIND CAPABILITY] ---" $srcDirs = @( (Join-Path $root "src\Shared"), (Join-Path $root "src\Windows"), (Join-Path $root "src\Server") ) $matchesB = Get-ChildItem -Path $srcDirs -Recurse -Filter "*.cs" | Select-String -Pattern "RequestReleaseBindings|ReleaseBindingsResult|release-bindings" if ($matchesB.Count -gt 0) { foreach ($m in $matchesB) { LogProof " Found: $($m.Path):$($m.LineNumber): $($m.Line)" } throw "FAIL: Source code still contains destructive unbind capability!" } LogProof " [PASS] Grep RequestReleaseBindings: 0 occurrences" LogProof " [PASS] Grep ReleaseBindingsResult: 0 occurrences" LogProof " [PASS] Grep /api/device/release-bindings: 0 occurrences" LogProof " [PASS] Authority Boundary: Classroom-facing client has 0 destructive unbind capability" # ----------------------------------------------------------------------------- # Proof C: Real In-Place Upgrade Under Active Running Binaries (Zero Manual Kill) # ----------------------------------------------------------------------------- LogProof "`n--- [PROOF C: REAL IN-PLACE UPGRADE UNDER ACTIVE PROCESSES (ZERO MANUAL KILL)] ---" # Step 1: Assert processes are currently running and locked $svcBefore = Get-Process -Name "ClassNotify.Service" -ErrorAction SilentlyContinue $cliBefore = Get-Process -Name "ClassNotify.Client" -ErrorAction SilentlyContinue if (-not $svcBefore) { Start-Service ClassNotifyService Start-Sleep -Seconds 2 $svcBefore = Get-Process -Name "ClassNotify.Service" -ErrorAction Stop } LogProof " Active Running Service Before Upgrade: PID $($svcBefore.Id) ($($svcBefore.Path))" if ($cliBefore) { LogProof " Active Running Client Before Upgrade: PID $($cliBefore.Id) ($($cliBefore.Path))" } else { LogProof " Client not running prior to upgrade, service will be tested" } # Step 2: Record staging hash $stagingClientExe = Join-Path $root "packaging_p2\staging\Client\ClassNotify.Client.exe" $stagingHash = (Get-FileHash -Path $stagingClientExe -Algorithm SHA256).Hash LogProof " Expected Staging Payload Client SHA256: $stagingHash" # Step 3: Execute Inno Setup installer directly with /VERYSILENT (NO prior manual kill!) $installerExe = Join-Path $root "dist\ClassNotifySetup.exe" if (-not (Test-Path $installerExe)) { throw "Installer not found at: $installerExe" } LogProof " Launching ClassNotifySetup.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART ..." $sw = [System.Diagnostics.Stopwatch]::StartNew() $proc = Start-Process -FilePath $installerExe -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART" -PassThru $hasExited = $proc.WaitForExit(60000) $sw.Stop() if (-not $hasExited) { throw "FAIL: Installer did not complete within 60 seconds!" } LogProof " Installer ExitCode: $($proc.ExitCode) (Completed in $([math]::Round($sw.Elapsed.TotalSeconds, 1))s)" if ($proc.ExitCode -ne 0) { throw "FAIL: Installer failed with ExitCode $($proc.ExitCode)" } # Step 4: Verify installed files on disk $installedClientExe = "C:\Program Files\ClassNotify\Client\ClassNotify.Client.exe" $installedServiceExe = "C:\Program Files\ClassNotify\Service\ClassNotify.Service.exe" if (-not (Test-Path $installedClientExe)) { throw "Installed client not found: $installedClientExe" } if (-not (Test-Path $installedServiceExe)) { throw "Installed service not found: $installedServiceExe" } $installedHash = (Get-FileHash -Path $installedClientExe -Algorithm SHA256).Hash $installedVersion = (Get-Item $installedClientExe).VersionInfo.FileVersion LogProof " Installed Client SHA256: $installedHash" LogProof " Installed Client FileVersion: $installedVersion" if ($installedHash -ne $stagingHash) { throw "FAIL: Installed SHA256 ($installedHash) does not match Staging SHA256 ($stagingHash)!" } LogProof " [PASS] Hash Match: installed SHA256 == release artifact SHA256" # Step 5: Verify runtime service and client status Start-Sleep -Seconds 4 $svcAfter = Get-Process -Name "ClassNotify.Service" -ErrorAction SilentlyContinue $cliAfter = Get-Process -Name "ClassNotify.Client" -ErrorAction SilentlyContinue if (-not $svcAfter) { throw "FAIL: ClassNotify.Service is not running after upgrade!" } LogProof " [PASS] Running Service After Upgrade: PID $($svcAfter.Id), SessionId: $($svcAfter.SessionId)" if ($cliAfter) { LogProof " [PASS] Running Client After Upgrade: PID $($cliAfter.Id), SessionId: $($cliAfter.SessionId)" $runningPath = $cliAfter.Path LogProof " [PASS] Running Client Path: $runningPath" if ($runningPath -ne $installedClientExe) { throw "FAIL: Running client path does not match target installed path!" } } else { LogProof " [INFO] Client not started immediately by session, will verify via watchdog" } # ----------------------------------------------------------------------------- # Proof D: Zero Disturbance Soak and Recovery Verification (Popup Count = 0) # ----------------------------------------------------------------------------- LogProof "" LogProof "--- [PROOF D: ZERO DISTURBANCE SOAK AND POPUP COUNT = 0] ---" # Check foreground window helper $winHelperDef = @' using System; using System.Runtime.InteropServices; using System.Text; public class WinHelper { [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll")] public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count); [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId); public static string GetActiveWindowTitle() { IntPtr hwnd = GetForegroundWindow(); StringBuilder sb = new StringBuilder(256); GetWindowText(hwnd, sb, 256); return sb.ToString(); } public static uint GetActiveWindowPid() { IntPtr hwnd = GetForegroundWindow(); uint pid = 0; GetWindowThreadProcessId(hwnd, out pid); return pid; } } '@ if (-not ([System.Management.Automation.PSTypeName]'WinHelper').Type) { Add-Type -TypeDefinition $winHelperDef } $initialFgTitle = [WinHelper]::GetActiveWindowTitle() $initialFgPid = [WinHelper]::GetActiveWindowPid() LogProof " Initial Foreground Window: '$initialFgTitle' (PID $initialFgPid)" $foregroundViolations = 0 # Test cycle 1: Service restart (simulating crash/recovery) LogProof " Simulating Service Restart (Watchdog recovery cycle)..." Restart-Service ClassNotifyService Start-Sleep -Seconds 5 $fgTitle1 = [WinHelper]::GetActiveWindowTitle() $fgPid1 = [WinHelper]::GetActiveWindowPid() LogProof " After Service Restart Foreground: '$fgTitle1' (PID $fgPid1)" if ($fgTitle1 -like "*ClassNotify*" -or $fgTitle1 -like "*激活*" -or $fgTitle1 -like "*大屏*") { $foregroundViolations++ LogProof " VIOLATION: Service restart triggered foreground popup!" } # Test cycle 2: Second instance launch with BackgroundRecovery intent LogProof " Simulating Second Instance Launch with --intent=BackgroundRecovery..." $subProc = Start-Process -FilePath $installedClientExe -ArgumentList "--intent=BackgroundRecovery" -PassThru $subHasExited = $subProc.WaitForExit(15000) if (-not $subHasExited) { throw "FAIL: BackgroundRecovery instance timed out after 15 seconds!" } LogProof " Second Instance ExitCode: $($subProc.ExitCode) (Must be 0)" if ($subProc.ExitCode -ne 0) { throw "FAIL: BackgroundRecovery instance did not exit cleanly!" } $fgTitle2 = [WinHelper]::GetActiveWindowTitle() $fgPid2 = [WinHelper]::GetActiveWindowPid() LogProof " After Second Instance Foreground: '$fgTitle2' (PID $fgPid2)" if ($fgTitle2 -like "*ClassNotify*" -or $fgTitle2 -like "*激活*" -or $fgTitle2 -like "*大屏*") { $foregroundViolations++ LogProof " VIOLATION: BackgroundRecovery triggered foreground popup!" } # Test cycle 3: Soak observation LogProof " Performing zero-disturbance observation..." for ($i = 1; $i -le 10; $i++) { Start-Sleep -Seconds 1 $curFg = [WinHelper]::GetActiveWindowTitle() if ($curFg -like "*ClassNotify*" -or $curFg -like "*激活*" -or $curFg -like "*班级设备*") { $foregroundViolations++ LogProof " VIOLATION detected at ${i}s: '$curFg'" } } LogProof " Total Unexpected Foreground Popups: $foregroundViolations" if ($foregroundViolations -gt 0) { throw "FAIL: Zero Disturbance violated! Popups detected: $foregroundViolations" } LogProof " [PASS] Zero Disturbance Invariant Proven: Foreground popup count = 0" # ----------------------------------------------------------------------------- # Summary # ----------------------------------------------------------------------------- LogProof "`n================================================================================" LogProof " ALL TURN 116 ROUND 2 PROOFS (A, B, C, D) 100% PASSED!" LogProof "================================================================================" $proofLog.ToString() | Out-File -FilePath $proofLogPath -Encoding UTF8 -Force Write-Host "Proof log saved to: $proofLogPath" -ForegroundColor Green