param( [string]$ApiBaseUrl = "http://192.168.200.61:18121/api/v1", [string]$ClusterID = "cfc0743d-d960-49fb-9de8-96e063d5e4aa", [string]$ActorUserID = "f67d943f-5397-4b3a-a229-695fe67ad700", [string]$EntryNodeName = "test-1", [string]$ExitNodeName = "test-2", [string]$EntryBaseUrl = "http://192.168.200.61:19131", [string]$ResultPath = "artifacts\c19z5-remote-workspace-mailbox-preflight-provenance-smoke-result.json" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath $sourceResultPath = "artifacts\c19z5-remote-workspace-mailbox-preflight-provenance-source-result.json" function Get-PropertyValue { param([object]$Item, [string]$Name, [object]$Default = $null) if ($null -eq $Item) { return $Default } $property = $Item.PSObject.Properties[$Name] if ($null -eq $property) { return $Default } return $property.Value } $source = & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z4-remote-workspace-mailbox-preflight-action-hints-smoke.ps1") ` -ApiBaseUrl $ApiBaseUrl ` -ClusterID $ClusterID ` -ActorUserID $ActorUserID ` -EntryNodeName $EntryNodeName ` -ExitNodeName $ExitNodeName ` -EntryBaseUrl $EntryBaseUrl ` -ResultPath $sourceResultPath $sourceFile = Join-Path $repoRoot $sourceResultPath $sourceResult = Get-Content -Raw -Path $sourceFile | ConvertFrom-Json $preflight = Get-PropertyValue -Item $sourceResult -Name "preflight" -Default $null $preflightJson = Get-PropertyValue -Item $preflight -Name "json" -Default $null $context = Get-PropertyValue -Item $preflightJson -Name "action_context" -Default $null $resumeSequence = [int64](Get-PropertyValue -Item $context -Name "resume_sequence" -Default -1) $firstRetained = [int64](Get-PropertyValue -Item $context -Name "first_retained_sequence" -Default -1) $missingDropped = [int](Get-PropertyValue -Item $context -Name "missing_dropped_count" -Default -1) $checks = [ordered]@{ source_smoke_passed = ([bool]$sourceResult.passed) action_reason_visible = ([string](Get-PropertyValue -Item $preflightJson -Name "action_reason" -Default "") -eq "consumer_cursor_before_first_retained_sequence") action_context_present = ($null -ne $context) context_cursor_visible = ($resumeSequence -eq 1 -and [string](Get-PropertyValue -Item $context -Name "resume_from" -Default "") -eq "ack") context_retained_bounds_visible = ($firstRetained -gt $resumeSequence -and [int64](Get-PropertyValue -Item $context -Name "last_retained_sequence" -Default -1) -ge $firstRetained) context_missing_formula_visible = ($missingDropped -eq ($firstRetained - $resumeSequence - 1)) context_dropped_visible = ([int64](Get-PropertyValue -Item $context -Name "mailbox_dropped_total" -Default 0) -ge 3) } $failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key }) $result = [ordered]@{ schema_version = "c19z5.remote_workspace_mailbox_preflight_provenance_smoke.v1" source_result_path = $sourceFile cluster_id = $ClusterID adapter_session_id = [string](Get-PropertyValue -Item $sourceResult -Name "adapter_session_id" -Default "") preflight = $preflight checks = $checks failed_checks = $failed passed = ($failed.Count -eq 0) } $fullResultPath = Join-Path $repoRoot $ResultPath $resultDir = Split-Path -Parent $fullResultPath if ($resultDir) { New-Item -ItemType Directory -Force -Path $resultDir | Out-Null } $result | ConvertTo-Json -Depth 100 | Set-Content -Encoding UTF8 -Path $fullResultPath if (-not $result.passed) { throw "C19Z5 remote workspace mailbox preflight provenance smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')" } Write-Host "C19Z5 remote workspace mailbox preflight provenance smoke passed. Result: $fullResultPath" $result