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]$RequestedNodeName = "test-1", [string]$DefaultNodeName = "test-2", [string]$MatrixNodeName = "test-1", [string]$ResultPath = "artifacts\c19z62-remote-workspace-real-adapter-admin-handoff-bundle-compatibility-smoke-result.json" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath $sourceResultPath = "artifacts\c19z62-remote-workspace-real-adapter-admin-handoff-bundle-source-result.json" $requiredBundleFields = @( "schema_version", "bundle_status", "admin_status", "admin_action", "sections", "counts", "guardrails", "readiness_summary", "operator_checklist", "operator_action_map" ) $requiredSections = @("readiness_summary", "operator_checklist", "operator_action_map") $requiredCountFields = @("section_count", "checklist_total_count", "checklist_passed_count", "action_count", "blocked_action_count") $requiredGuardrailFields = @("activation_blocked", "process_start_allowed", "health_probe_enabled", "payload_traffic", "allows_payload_traffic", "allows_process_start") $requiredActionMapFields = @("schema_version", "readiness_summary_schema", "readiness_state", "operator_action", "activation_decision", "process_start_allowed", "health_probe_enabled", "payload_traffic", "action_count", "actions") function Get-PropertyValue { param([object]$Item, [string]$Name, [object]$Default = $null) if ($null -eq $Item) { return $Default } if ($Item -is [System.Collections.IDictionary]) { if ($Item.Contains($Name)) { return $Item[$Name] } return $Default } $property = $Item.PSObject.Properties[$Name] if ($null -eq $property) { return $Default } return $property.Value } function Test-ArrayItem { param([object]$Items, [string]$Want) foreach ($item in @($Items)) { if ([string]$item -eq $Want) { return $true } } return $false } function Test-RequiredItems { param([object]$Items, [string[]]$Required) foreach ($item in $Required) { if (-not (Test-ArrayItem -Items $Items -Want $item)) { return $false } } return $true } function Test-ObjectHasFields { param([object]$Item, [string[]]$Fields) if ($null -eq $Item) { return $false } foreach ($field in $Fields) { if ($Item -is [System.Collections.IDictionary]) { if (-not $Item.Contains($field)) { return $false } continue } if ($null -eq $Item.PSObject.Properties[$field]) { return $false } } return $true } & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z61-remote-workspace-real-adapter-admin-handoff-bundle-smoke.ps1") ` -ApiBaseUrl $ApiBaseUrl ` -ClusterID $ClusterID ` -ActorUserID $ActorUserID ` -RequestedNodeName $RequestedNodeName ` -DefaultNodeName $DefaultNodeName ` -MatrixNodeName $MatrixNodeName ` -ResultPath $sourceResultPath | Out-Null $sourceFile = Join-Path $repoRoot $sourceResultPath $sourceResult = Get-Content -Raw -Path $sourceFile | ConvertFrom-Json $bundle = Get-PropertyValue -Item $sourceResult -Name "admin_handoff_bundle" -Default $null $counts = Get-PropertyValue -Item $bundle -Name "counts" -Default $null $guardrails = Get-PropertyValue -Item $bundle -Name "guardrails" -Default $null $summary = Get-PropertyValue -Item $bundle -Name "readiness_summary" -Default $null $checklist = @((Get-PropertyValue -Item $bundle -Name "operator_checklist" -Default @())) $actionMap = Get-PropertyValue -Item $bundle -Name "operator_action_map" -Default $null $actions = @((Get-PropertyValue -Item $actionMap -Name "actions" -Default @())) $bundleFieldsCompatible = Test-ObjectHasFields -Item $bundle -Fields $requiredBundleFields $sectionsCompatible = Test-RequiredItems -Items (Get-PropertyValue -Item $bundle -Name "sections" -Default @()) -Required $requiredSections $countsCompatible = ( (Test-ObjectHasFields -Item $counts -Fields $requiredCountFields) -and [int](Get-PropertyValue -Item $counts -Name "section_count" -Default -1) -eq 3 -and [int](Get-PropertyValue -Item $counts -Name "action_count" -Default -1) -eq 6 -and [int](Get-PropertyValue -Item $counts -Name "blocked_action_count" -Default -1) -eq 6 -and [int](Get-PropertyValue -Item $counts -Name "checklist_total_count" -Default -1) -ge 1 -and [int](Get-PropertyValue -Item $counts -Name "checklist_passed_count" -Default -1) -eq [int](Get-PropertyValue -Item $counts -Name "checklist_total_count" -Default -2) ) $guardrailsCompatible = ( (Test-ObjectHasFields -Item $guardrails -Fields $requiredGuardrailFields) -and [bool](Get-PropertyValue -Item $guardrails -Name "activation_blocked" -Default $false) -and -not [bool](Get-PropertyValue -Item $guardrails -Name "process_start_allowed" -Default $true) -and -not [bool](Get-PropertyValue -Item $guardrails -Name "health_probe_enabled" -Default $true) -and [string](Get-PropertyValue -Item $guardrails -Name "payload_traffic" -Default "") -eq "none" -and -not [bool](Get-PropertyValue -Item $guardrails -Name "allows_payload_traffic" -Default $true) -and -not [bool](Get-PropertyValue -Item $guardrails -Name "allows_process_start" -Default $true) ) $adminValuesCompatible = ( [string](Get-PropertyValue -Item $bundle -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_admin_handoff_bundle.v1" -and [string](Get-PropertyValue -Item $bundle -Name "bundle_status" -Default "") -eq "complete" -and [string](Get-PropertyValue -Item $bundle -Name "admin_status" -Default "") -eq "not_ready" -and [string](Get-PropertyValue -Item $bundle -Name "admin_action" -Default "") -eq "keep_real_adapter_disabled" ) $summaryCompatible = ( [string](Get-PropertyValue -Item $summary -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_disabled_runtime_readiness_summary.v1" -and [string](Get-PropertyValue -Item $summary -Name "readiness_state" -Default "") -eq "blocked_until_real_runtime_stage" -and [string](Get-PropertyValue -Item $summary -Name "operator_action" -Default "") -eq "keep_real_adapter_disabled" -and -not [bool](Get-PropertyValue -Item $summary -Name "process_start_allowed" -Default $true) -and [string](Get-PropertyValue -Item $summary -Name "payload_traffic" -Default "") -eq "none" ) $checklistCompatible = ( $checklist.Count -eq [int](Get-PropertyValue -Item $counts -Name "checklist_total_count" -Default -1) -and @($checklist | Where-Object { -not [bool](Get-PropertyValue -Item $_ -Name "passed" -Default $false) }).Count -eq 0 ) $actionMapCompatible = ( (Test-ObjectHasFields -Item $actionMap -Fields $requiredActionMapFields) -and [string](Get-PropertyValue -Item $actionMap -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_disabled_runtime_operator_action_map.v1" -and [int](Get-PropertyValue -Item $actionMap -Name "action_count" -Default -1) -eq 6 -and $actions.Count -eq 6 -and @($actions | Where-Object { [string](Get-PropertyValue -Item $_ -Name "status" -Default "") -ne "blocked" }).Count -eq 0 -and @($actions | Where-Object { [bool](Get-PropertyValue -Item $_ -Name "allows_process_start" -Default $true) -or [bool](Get-PropertyValue -Item $_ -Name "allows_payload_traffic" -Default $true) }).Count -eq 0 ) $checks = [ordered]@{ source_smoke_passed = ([bool]$sourceResult.passed) source_schema_expected = ([string]$sourceResult.schema_version -eq "c19z61.remote_workspace_real_adapter_admin_handoff_bundle_smoke.v1") bundle_present = ($null -ne $bundle) bundle_fields_compatible = $bundleFieldsCompatible sections_compatible = $sectionsCompatible counts_compatible = $countsCompatible guardrails_compatible = $guardrailsCompatible admin_values_compatible = $adminValuesCompatible summary_compatible = $summaryCompatible checklist_compatible = $checklistCompatible action_map_compatible = $actionMapCompatible } $failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key }) $result = [ordered]@{ schema_version = "c19z62.remote_workspace_real_adapter_admin_handoff_bundle_compatibility_smoke.v1" source_result_path = $sourceFile cluster_id = $ClusterID required_bundle_fields = $requiredBundleFields required_bundle_sections = $requiredSections required_count_fields = $requiredCountFields required_guardrail_fields = $requiredGuardrailFields required_action_map_fields = $requiredActionMapFields admin_handoff_bundle = $bundle 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 "C19Z62 remote workspace real-adapter admin handoff bundle compatibility smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')" } Write-Host "C19Z62 remote workspace real-adapter admin handoff bundle compatibility smoke passed. Result: $fullResultPath" $result