# ============================================================================== # ClassNotify P1 RC2 Acceptance Gate RC-2: Supplemental Verification for Group A # Authorization: ChatGPT Independent Architecture Reviewer # Scope: Pre-flight + Group A Bounded UI Polling & Full Roundtrip UI Automation ACK # Target RCArtifactId: P1-RC2-20260922-151442-F2C14966 # ============================================================================== param ( [string]$BaseUrl = "https://classnotify.paradise.eu.org", [string]$AuditUrl = "https://audit.paradise.eu.org", [string]$RCArtifactId = "P1-RC2-20260922-151442-F2C14966", [string]$ExpectedInstallerSha256 = "F2C14966E99B47A5A67436F7E4E1FB72A363FCB560BF19C07BDF23DEA5BDADD9", [string]$EvidenceBaseDir = "C:\Users\Administrator\.gemini\antigravity\scratch\ClassNotify\acceptance_evidence" ) $ErrorActionPreference = "Stop" # Load credentials if (-not $env:CLASSNOTIFY_E2E_PASSWORD) { $env:CLASSNOTIFY_E2E_PASSWORD = [System.Environment]::GetEnvironmentVariable('CLASSNOTIFY_E2E_PASSWORD', 'User') } if (-not $env:CLASSNOTIFY_E2E_USERNAME) { $env:CLASSNOTIFY_E2E_USERNAME = [System.Environment]::GetEnvironmentVariable('CLASSNOTIFY_E2E_USERNAME', 'User') if (-not $env:CLASSNOTIFY_E2E_USERNAME) { $env:CLASSNOTIFY_E2E_USERNAME = "teacher_rc1" } } if (-not $env:CLASSNOTIFY_SCHOOLADMIN_PASSWORD) { $env:CLASSNOTIFY_SCHOOLADMIN_PASSWORD = [System.Environment]::GetEnvironmentVariable('CLASSNOTIFY_SCHOOLADMIN_PASSWORD', 'User') } if (-not $env:CLASSNOTIFY_SCHOOLADMIN_USERNAME) { $env:CLASSNOTIFY_SCHOOLADMIN_USERNAME = [System.Environment]::GetEnvironmentVariable('CLASSNOTIFY_SCHOOLADMIN_USERNAME', 'User') if (-not $env:CLASSNOTIFY_SCHOOLADMIN_USERNAME) { $env:CLASSNOTIFY_SCHOOLADMIN_USERNAME = "admin_bj4" } } $evidenceId = "EVIDENCE-RC2-SUPPLEMENTAL-A-" + (Get-Date -Format 'yyyyMMdd-HHmmss') $localEvidenceDir = Join-Path $EvidenceBaseDir $evidenceId New-Item -ItemType Directory -Path $localEvidenceDir -Force | Out-Null $consoleLogPath = Join-Path $localEvidenceDir "console-output.txt" Start-Transcript -Path $consoleLogPath -Append -Force | Out-Null Write-Host "==========================================================" -ForegroundColor Cyan Write-Host " ClassNotify P1 RC2 — Gate RC-2: Supplemental Group A " -ForegroundColor Cyan Write-Host " Target RCArtifactId: $RCArtifactId" -ForegroundColor Cyan Write-Host " Evidence ID: $evidenceId" -ForegroundColor Cyan Write-Host "==========================================================" -ForegroundColor Cyan $passed = 0 $failed = 0 $trackedNotificationIds = [System.Collections.Generic.List[string]]::new() function Report-Result([string]$testName, $condition, [string]$details = "") { $boolCond = [bool]$condition if ($boolCond) { Write-Host " [PASS] $testName" -ForegroundColor Green if ($details) { Write-Host " $details" -ForegroundColor DarkGray } $script:passed++ } else { Write-Host " [FAIL] $testName" -ForegroundColor Red if ($details) { Write-Host " $details" -ForegroundColor Yellow } $script:failed++ } } try { # -------------------------------------------------------------------------- # PRE-FLIGHT CHECKS # -------------------------------------------------------------------------- Write-Host "`n>>> [Pre-Flight] System & Environment Verification..." -ForegroundColor Yellow # 1. Local Installer Hash $installerPath = "C:\Users\Administrator\.gemini\antigravity\scratch\ClassNotify\rc2_artifacts\ClassNotifySetup.exe" $localHash = (Get-FileHash -Path $installerPath -Algorithm SHA256).Hash.ToUpper() Report-Result "Local ClassNotifySetup.exe SHA256 matches baseline" ($localHash -eq $ExpectedInstallerSha256) $localHash # 2. Service & Client State $svcRunning = (Get-Service -Name ClassNotifyService -ErrorAction SilentlyContinue).Status -eq 'Running' $cliProc = Get-Process -Name ClassNotify.Client -ErrorAction SilentlyContinue | Select-Object -First 1 $svcProc = Get-Process -Name ClassNotify.Service -ErrorAction SilentlyContinue | Select-Object -First 1 Report-Result "ClassNotifyService is RUNNING in Session 0" ($svcRunning -and $svcProc.SessionId -eq 0) "PID: $($svcProc.Id)" Report-Result "ClassNotify.Client is running in user session" ($null -ne $cliProc) "PID: $($cliProc.Id), Session: $($cliProc.SessionId)" # 3. Device Binding Add-Type -AssemblyName System.Security $rawCreds = [System.IO.File]::ReadAllBytes("C:\ProgramData\ClassNotify\device_credentials.json") $entropy = [System.Text.Encoding]::UTF8.GetBytes("ClassNotify_Device_Credential_V1") $dec = [System.Security.Cryptography.ProtectedData]::Unprotect($rawCreds, $entropy, [System.Security.Cryptography.DataProtectionScope]::LocalMachine) $credObj = [System.Text.Encoding]::UTF8.GetString($dec) | ConvertFrom-Json $targetDeviceId = $credObj.DeviceId $targetClassId = $credObj.ClassId $targetTenantId = $credObj.TenantId Report-Result "Device bound to $targetClassId in $targetTenantId" ($targetClassId -eq "cls_802") "DeviceId: $targetDeviceId" # 4. Authentication $teacherLoginRes = Invoke-RestMethod -Uri "$BaseUrl/api/auth/login" -Method Post ` -Body (@{username=$env:CLASSNOTIFY_E2E_USERNAME; password=$env:CLASSNOTIFY_E2E_PASSWORD} | ConvertTo-Json) -ContentType "application/json" $teacherHeaders = @{ Authorization = "Bearer $($teacherLoginRes.token)" } Report-Result "Teacher authentication succeeded" ($null -ne $teacherLoginRes.token) # -------------------------------------------------------------------------- # GROUP A: FOCUSED NOTIFICATION FULL BUSINESS CHAIN # -------------------------------------------------------------------------- Write-Host "`n>>> [Group A] Online Notification Full Chain with Bounded Polling..." -ForegroundColor Yellow Add-Type -AssemblyName UIAutomationClient Add-Type -AssemblyName UIAutomationTypes # Helper function: Bounded polling for WPF notification window function Wait-ForNotificationWindow([int]$procId, [string]$expectedSnippet, [int]$timeoutSec = 10) { $desktop = [System.Windows.Automation.AutomationElement]::RootElement $procCond = [System.Windows.Automation.PropertyCondition]::new([System.Windows.Automation.AutomationElement]::ProcessIdProperty, $procId) $deadline = (Get-Date).AddSeconds($timeoutSec) while ((Get-Date) -lt $deadline) { $windows = $desktop.FindAll([System.Windows.Automation.TreeScope]::Children, $procCond) foreach ($w in $windows) { if ($null -ne $w) { if ($expectedSnippet) { $txtCond = [System.Windows.Automation.PropertyCondition]::new([System.Windows.Automation.AutomationElement]::NameProperty, $expectedSnippet) $foundTxt = $w.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $txtCond) if ($foundTxt) { return $w } } else { return $w } } } Start-Sleep -Milliseconds 500 } # Fallback: check if any window owned by process exists $allWins = $desktop.FindAll([System.Windows.Automation.TreeScope]::Children, $procCond) if ($allWins.Count -gt 0) { return $allWins[0] } return $null } # A1. Notice $noticeReq = @{ classId = $targetClassId studentName = "张三" title = "课堂练习通知" message = "请各位同学翻开课本第 42 页完成练习题。" type = 0 voice = $false durationSeconds = 15 } | ConvertTo-Json $noticeRes = Invoke-RestMethod -Uri "$BaseUrl/api/notification/send" -Method Post -Headers $teacherHeaders -Body $noticeReq -ContentType "application/json" $noticeId = $noticeRes.messageId $trackedNotificationIds.Add($noticeId) Report-Result "Group A1: Notice sent via API (ID: $noticeId)" ($noticeRes.success -eq $true) # Bounded polling for Notice receipt/dispatch $currCli = Get-Process -Name ClassNotify.Client -ErrorAction SilentlyContinue | Select-Object -First 1 $noticeWin = Wait-ForNotificationWindow -procId $currCli.Id -expectedSnippet "课堂练习通知" -timeoutSec 10 $noticeWinFound = ($null -ne $noticeWin) Report-Result "Group A1: Notice WPF window rendered on interactive desktop" $noticeWinFound "Window: $($noticeWin.Current.NativeWindowHandle)" Start-Sleep -Seconds 2 # A2. Call $callReq = @{ classId = $targetClassId studentName = "李四" title = "办公室呼叫" message = "请李四同学下课后前往年级办公室。" type = 1 voice = $false durationSeconds = 15 } | ConvertTo-Json $callRes = Invoke-RestMethod -Uri "$BaseUrl/api/notification/send" -Method Post -Headers $teacherHeaders -Body $callReq -ContentType "application/json" $callId = $callRes.messageId $trackedNotificationIds.Add($callId) Report-Result "Group A2: Call sent via API (ID: $callId)" ($callRes.success -eq $true) $callWin = Wait-ForNotificationWindow -procId $currCli.Id -expectedSnippet "办公室呼叫" -timeoutSec 10 $callWinFound = ($null -ne $callWin) Report-Result "Group A2: Call WPF window rendered on interactive desktop" $callWinFound "Window: $($callWin.Current.NativeWindowHandle)" Start-Sleep -Seconds 2 # A3. Urgent with Real UI Automation ACK $urgentReq = @{ classId = $targetClassId studentName = "全体师生" title = "消防应急演练" message = "校园消防应急疏散演练即将开始,请听从广播指挥。" type = 2 voice = $false durationSeconds = 30 } | ConvertTo-Json $tSent = [DateTime]::UtcNow $urgentRes = Invoke-RestMethod -Uri "$BaseUrl/api/notification/send" -Method Post -Headers $teacherHeaders -Body $urgentReq -ContentType "application/json" $urgentId = $urgentRes.messageId $trackedNotificationIds.Add($urgentId) Report-Result "Group A3: Urgent notification sent via API (ID: $urgentId)" ($urgentRes.success -eq $true) # Bounded polling for Urgent window $urgentWin = Wait-ForNotificationWindow -procId $currCli.Id -expectedSnippet "消防应急演练" -timeoutSec 10 $urgentWinFound = ($null -ne $urgentWin) Report-Result "Group A3: Urgent WPF Notification Window active on desktop" $urgentWinFound "Handle: $($urgentWin.Current.NativeWindowHandle)" $clickedAck = $false if ($urgentWin) { $btnCond = [System.Windows.Automation.PropertyCondition]::new([System.Windows.Automation.AutomationElement]::NameProperty, "我知道了") $btn = $urgentWin.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $btnCond) if ($btn) { $invPattern = $btn.GetCurrentPattern([System.Windows.Automation.InvokePattern]::Pattern) -as [System.Windows.Automation.InvokePattern] $invPattern.Invoke() $clickedAck = $true } } Report-Result "Group A3: Clicked '我知道了' button via UIAutomation" $clickedAck # Bounded polling for Server receipt status -> Acknowledged $isAcked = $false $receipt = $null for ($i = 0; $i -lt 20; $i++) { Start-Sleep -Milliseconds 500 $history = Invoke-RestMethod -Uri "$BaseUrl/api/notification/history?classId=$targetClassId&limit=10" -Headers $teacherHeaders $urgentRecord = $history | Where-Object { $_.id -eq $urgentId } $receipt = $urgentRecord.receipts | Where-Object { $_.deviceId -eq $targetDeviceId } if ($receipt.status -eq "Acknowledged") { $isAcked = $true break } } Report-Result "Group A3: Server confirms receipt status is 'Acknowledged'" $isAcked "ReceiptStatus: $($receipt.status)" if ($receipt.deliveredAt -and $receipt.acknowledgedAt) { $tDelivered = [DateTime]::Parse($receipt.deliveredAt) $tAck = [DateTime]::Parse($receipt.acknowledgedAt) $latencyMs = ($tAck - $tSent).TotalMilliseconds Report-Result "Group A3: Latency tracked (Sent -> Delivered -> Acknowledged)" $true "TotalLatency: $([Math]::Round($latencyMs))ms" } # Cross-tier verification with PostgreSQL on Tokyo VPS $sshReceiptCmd = "python3 /root/query_db.py receipt $urgentId" $pgReceipt = ssh -o BatchMode=yes -o ConnectTimeout=10 -i "C:\Users\Administrator\.ssh\id_rsa_tokyo" -o StrictHostKeyChecking=no root@158.179.179.29 $sshReceiptCmd $receiptConsistent = ($pgReceipt -match $targetDeviceId -and $pgReceipt -match "Acknowledged") Report-Result "Group A3: PostgreSQL Receipt record confirms 'Acknowledged' state" $receiptConsistent } finally { # No firewall rule to remove in Group A } Stop-Transcript | Out-Null # Write IDs json $idsObj = [ordered]@{ evidenceId = $evidenceId rcArtifactId = $RCArtifactId deviceId = $targetDeviceId classId = $targetClassId tenantId = $targetTenantId notificationIds = $trackedNotificationIds } $idsJson = $idsObj | ConvertTo-Json -Depth 5 [System.IO.File]::WriteAllText((Join-Path $localEvidenceDir "ids.json"), $idsJson) Copy-Item $PSCommandPath (Join-Path $localEvidenceDir "test_rc2_supplemental_a.ps1") -Force # Fetch sanitized server log $remoteServerLog = ssh -o BatchMode=yes -o ConnectTimeout=10 -i "C:\Users\Administrator\.ssh\id_rsa_tokyo" -o StrictHostKeyChecking=no root@158.179.179.29 "journalctl -u classnotify -n 100 --no-pager" [System.IO.File]::WriteAllText((Join-Path $localEvidenceDir "sanitized-server.log"), $remoteServerLog) $summaryMd = @" # Gate RC-2 Supplemental Group A Verification Summary - **EvidenceId**: $evidenceId - **RCArtifactId**: $RCArtifactId - **TestTimestamp**: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss zzz') - **TestHost**: $env:COMPUTERNAME - **Assertions Passed**: $passed - **Assertions Failed**: $failed - **Gate Status**: $(if ($failed -eq 0) { "PASS" } else { "FAIL" }) ## Tracked Artifacts - **Target Device**: $targetDeviceId ($targetClassId) - **Notifications Tested**: $($trackedNotificationIds.Count) "@ [System.IO.File]::WriteAllText((Join-Path $localEvidenceDir "result-summary.md"), $summaryMd) $scriptSha256 = (Get-FileHash -Path $PSCommandPath -Algorithm SHA256).Hash.ToUpper() $manifestObj = [ordered]@{ evidenceId = $evidenceId rcArtifactId = $RCArtifactId sourceSnapshotId = "20260922-150944-515691C8" installerSha256 = $ExpectedInstallerSha256 testScriptSha256 = $scriptSha256 testHost = $env:COMPUTERNAME startedAt = (Get-Date).ToString("o") passed = $passed failed = $failed productionSourceModified = $false evidenceFiles = @( "EVIDENCE_MANIFEST.json", "test_rc2_supplemental_a.ps1", "console-output.txt", "sanitized-server.log", "result-summary.md", "ids.json" ) } $manifestJson = $manifestObj | ConvertTo-Json -Depth 5 [System.IO.File]::WriteAllText((Join-Path $localEvidenceDir "EVIDENCE_MANIFEST.json"), $manifestJson) # Upload Evidence package to Tokyo VPS Write-Host "`n>>> Uploading Evidence package to Tokyo VPS (/srv/classnotify-audit/acceptance/P1-RC2/RC-2/$evidenceId)..." -ForegroundColor Yellow $remoteEvDir = "/srv/classnotify-audit/acceptance/P1-RC2/RC-2/$evidenceId" ssh -o BatchMode=yes -o ConnectTimeout=10 -i "C:\Users\Administrator\.ssh\id_rsa_tokyo" -o StrictHostKeyChecking=no root@158.179.179.29 "mkdir -p $remoteEvDir" scp -r -i "C:\Users\Administrator\.ssh\id_rsa_tokyo" -o StrictHostKeyChecking=no "$localEvidenceDir\*" "root@158.179.179.29:${remoteEvDir}/" ssh -o BatchMode=yes -o ConnectTimeout=10 -i "C:\Users\Administrator\.ssh\id_rsa_tokyo" -o StrictHostKeyChecking=no root@158.179.179.29 "chmod -R 555 $remoteEvDir" Write-Host "==========================================================" -ForegroundColor Green Write-Host " Gate RC-2 Supplemental Group A Completed! " -ForegroundColor Green Write-Host " Results: $passed Passed, $failed Failed " -ForegroundColor $(if ($failed -eq 0) { "Green" } else { "Red" }) Write-Host " Evidence URL: https://audit.paradise.eu.org/acceptance/P1-RC2/RC-2/$evidenceId/result-summary.md" -ForegroundColor Green Write-Host "==========================================================" -ForegroundColor Green if ($failed -gt 0) { exit 1 } exit 0