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\c19z61-remote-workspace-real-adapter-admin-handoff-bundle-smoke-result.json" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath $sourceResultPath = "artifacts\c19z61-remote-workspace-real-adapter-admin-handoff-bundle-source-result.json" $requiredBundleSections = @( "readiness_summary", "operator_checklist", "operator_action_map" ) $requiredBundleFields = @( "schema_version", "bundle_status", "admin_status", "admin_action", "sections", "counts", "guardrails", "readiness_summary", "operator_checklist", "operator_action_map" ) 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 "c19z60-remote-workspace-real-adapter-disabled-action-map-compatibility-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 $actionMap = Get-PropertyValue -Item $sourceResult -Name "action_map" -Default $null $summary = Get-PropertyValue -Item $sourceResult -Name "readiness_summary" -Default $null if ($null -eq $summary) { $summary = [ordered]@{ schema_version = Get-PropertyValue -Item $actionMap -Name "readiness_summary_schema" -Default $null readiness_state = Get-PropertyValue -Item $actionMap -Name "readiness_state" -Default $null operator_action = Get-PropertyValue -Item $actionMap -Name "operator_action" -Default $null activation_decision = Get-PropertyValue -Item $actionMap -Name "activation_decision" -Default $null process_start_allowed = Get-PropertyValue -Item $actionMap -Name "process_start_allowed" -Default $null health_probe_enabled = Get-PropertyValue -Item $actionMap -Name "health_probe_enabled" -Default $null payload_traffic = Get-PropertyValue -Item $actionMap -Name "payload_traffic" -Default $null } } $actions = @((Get-PropertyValue -Item $actionMap -Name "actions" -Default @())) $checklist = @((Get-PropertyValue -Item $sourceResult -Name "operator_checklist" -Default @())) if ($checklist.Count -eq 0) { $checklist = @((Get-PropertyValue -Item $sourceResult -Name "expected_actions" -Default @()) | ForEach-Object { [ordered]@{ name = [string](Get-PropertyValue -Item $_ -Name "action_key" -Default "") passed = $true evidence = "derived from C19Z60 action compatibility" } }) } $guardrails = [ordered]@{ activation_blocked = ([string](Get-PropertyValue -Item $actionMap -Name "activation_decision" -Default "") -eq "blocked") process_start_allowed = [bool](Get-PropertyValue -Item $actionMap -Name "process_start_allowed" -Default $true) health_probe_enabled = [bool](Get-PropertyValue -Item $actionMap -Name "health_probe_enabled" -Default $true) payload_traffic = Get-PropertyValue -Item $actionMap -Name "payload_traffic" -Default $null allows_payload_traffic = (@($actions | Where-Object { [bool](Get-PropertyValue -Item $_ -Name "allows_payload_traffic" -Default $true) }).Count -gt 0) allows_process_start = (@($actions | Where-Object { [bool](Get-PropertyValue -Item $_ -Name "allows_process_start" -Default $true) }).Count -gt 0) } $counts = [ordered]@{ section_count = $requiredBundleSections.Count checklist_total_count = $checklist.Count checklist_passed_count = @($checklist | Where-Object { [bool](Get-PropertyValue -Item $_ -Name "passed" -Default $false) }).Count action_count = $actions.Count blocked_action_count = @($actions | Where-Object { [string](Get-PropertyValue -Item $_ -Name "status" -Default "") -eq "blocked" }).Count } $bundle = [ordered]@{ schema_version = "rap.remote_workspace_real_adapter_admin_handoff_bundle.v1" bundle_status = "complete" admin_status = "not_ready" admin_action = "keep_real_adapter_disabled" sections = $requiredBundleSections counts = $counts guardrails = $guardrails readiness_summary = $summary operator_checklist = $checklist operator_action_map = $actionMap } $bundleFieldsCompatible = Test-ObjectHasFields -Item $bundle -Fields $requiredBundleFields $sectionsCompatible = Test-RequiredItems -Items (Get-PropertyValue -Item $bundle -Name "sections" -Default @()) -Required $requiredBundleSections $countsCompatible = ( [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) -gt 0 -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 = ( [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" ) $checks = [ordered]@{ source_smoke_passed = ([bool]$sourceResult.passed) source_schema_expected = ([string]$sourceResult.schema_version -eq "c19z60.remote_workspace_real_adapter_disabled_action_map_compatibility_smoke.v1") bundle_fields_compatible = $bundleFieldsCompatible sections_compatible = $sectionsCompatible counts_compatible = $countsCompatible guardrails_compatible = $guardrailsCompatible admin_values_compatible = $adminValuesCompatible } $failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key }) $result = [ordered]@{ schema_version = "c19z61.remote_workspace_real_adapter_admin_handoff_bundle_smoke.v1" source_result_path = $sourceFile cluster_id = $ClusterID required_bundle_fields = $requiredBundleFields required_bundle_sections = $requiredBundleSections 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 "C19Z61 remote workspace real-adapter admin handoff bundle smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')" } Write-Host "C19Z61 remote workspace real-adapter admin handoff bundle smoke passed. Result: $fullResultPath" $result