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\c19z81-remote-workspace-real-adapter-runtime-gate-preflight-operator-handoff-bundle-smoke-result.json" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath $sourceResultPath = "artifacts\c19z81-remote-workspace-real-adapter-runtime-gate-preflight-operator-handoff-bundle-source-result.json" $requiredBundleFields = @( "schema_version", "source_action_hints_schema", "handoff_status", "runtime_gate_state", "operator_default_action", "checklist_schema", "status_summary_schema", "action_hints_schema", "required_item_count", "blocked_item_count", "hint_count", "handoff_sections", "allows_process_start", "allows_payload_traffic", "guardrail_summary" ) $requiredSectionKeys = @("checklist", "status_summary", "action_hints", "guardrails") $requiredGuardrailFields = @("activation_blocked", "process_start_allowed", "health_probe_enabled", "payload_traffic", "allows_process_start", "allows_payload_traffic") 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-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 } function Test-ArrayContainsAll { param([object[]]$Actual, [string[]]$Required) $values = @($Actual | ForEach-Object { [string]$_ }) foreach ($item in $Required) { if ($values -notcontains $item) { return $false } } return $true } & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z80-remote-workspace-real-adapter-runtime-gate-preflight-action-hints-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 $hints = Get-PropertyValue -Item $sourceResult -Name "runtime_gate_preflight_action_hints" -Default $null $guardrails = Get-PropertyValue -Item $hints -Name "guardrail_summary" -Default $null $handoffSections = @( [ordered]@{ key = "checklist" schema_version = "rap.remote_workspace_real_adapter_runtime_gate_preflight_checklist.v1" status = "blocked_required_items_missing" operator_action = "review_required_preflight_items" }, [ordered]@{ key = "status_summary" schema_version = "rap.remote_workspace_real_adapter_runtime_gate_preflight_status_summary.v1" status = "blocked_all_required_items_missing" operator_action = "review_blocking_counts" }, [ordered]@{ key = "action_hints" schema_version = Get-PropertyValue -Item $hints -Name "schema_version" -Default $null status = Get-PropertyValue -Item $hints -Name "hint_status" -Default $null operator_action = "follow_preflight_actions_without_runtime_enablement" }, [ordered]@{ key = "guardrails" schema_version = "rap.remote_workspace_real_adapter_runtime_gate_guardrails.v1" status = "runtime_disabled" operator_action = "keep_real_adapter_disabled" } ) $bundle = [ordered]@{ schema_version = "rap.remote_workspace_real_adapter_runtime_gate_preflight_operator_handoff_bundle.v1" source_action_hints_schema = Get-PropertyValue -Item $hints -Name "schema_version" -Default $null handoff_status = "blocked_preflight_operator_review_required" runtime_gate_state = Get-PropertyValue -Item $hints -Name "runtime_gate_state" -Default $null operator_default_action = Get-PropertyValue -Item $hints -Name "operator_default_action" -Default $null checklist_schema = "rap.remote_workspace_real_adapter_runtime_gate_preflight_checklist.v1" status_summary_schema = "rap.remote_workspace_real_adapter_runtime_gate_preflight_status_summary.v1" action_hints_schema = Get-PropertyValue -Item $hints -Name "schema_version" -Default $null required_item_count = 6 blocked_item_count = 6 hint_count = Get-PropertyValue -Item $hints -Name "hint_count" -Default $null handoff_sections = $handoffSections allows_process_start = Get-PropertyValue -Item $hints -Name "allows_process_start" -Default $null allows_payload_traffic = Get-PropertyValue -Item $hints -Name "allows_payload_traffic" -Default $null guardrail_summary = $guardrails } $bundleFieldsCompatible = Test-ObjectHasFields -Item $bundle -Fields $requiredBundleFields $sectionKeysCompatible = Test-ArrayContainsAll -Actual @($handoffSections | ForEach-Object { Get-PropertyValue -Item $_ -Name "key" -Default "" }) -Required $requiredSectionKeys $bundleValuesCompatible = ( [string](Get-PropertyValue -Item $bundle -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_runtime_gate_preflight_operator_handoff_bundle.v1" -and [string](Get-PropertyValue -Item $bundle -Name "source_action_hints_schema" -Default "") -eq "rap.remote_workspace_real_adapter_runtime_gate_preflight_action_hints.v1" -and [string](Get-PropertyValue -Item $bundle -Name "handoff_status" -Default "") -eq "blocked_preflight_operator_review_required" -and [string](Get-PropertyValue -Item $bundle -Name "runtime_gate_state" -Default "") -eq "blocked" -and [string](Get-PropertyValue -Item $bundle -Name "operator_default_action" -Default "") -eq "keep_real_adapter_disabled" -and [string](Get-PropertyValue -Item $bundle -Name "checklist_schema" -Default "") -eq "rap.remote_workspace_real_adapter_runtime_gate_preflight_checklist.v1" -and [string](Get-PropertyValue -Item $bundle -Name "status_summary_schema" -Default "") -eq "rap.remote_workspace_real_adapter_runtime_gate_preflight_status_summary.v1" -and [string](Get-PropertyValue -Item $bundle -Name "action_hints_schema" -Default "") -eq "rap.remote_workspace_real_adapter_runtime_gate_preflight_action_hints.v1" -and [int](Get-PropertyValue -Item $bundle -Name "required_item_count" -Default -1) -eq 6 -and [int](Get-PropertyValue -Item $bundle -Name "blocked_item_count" -Default -1) -eq 6 -and [int](Get-PropertyValue -Item $bundle -Name "hint_count" -Default -1) -eq 6 -and -not [bool](Get-PropertyValue -Item $bundle -Name "allows_process_start" -Default $true) -and -not [bool](Get-PropertyValue -Item $bundle -Name "allows_payload_traffic" -Default $true) ) $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_process_start" -Default $true) -and -not [bool](Get-PropertyValue -Item $guardrails -Name "allows_payload_traffic" -Default $true) ) $checks = [ordered]@{ source_smoke_passed = ([bool]$sourceResult.passed) source_schema_expected = ([string]$sourceResult.schema_version -eq "c19z80.remote_workspace_real_adapter_runtime_gate_preflight_action_hints_compatibility_smoke.v1") action_hints_present = ($null -ne $hints) bundle_fields_compatible = $bundleFieldsCompatible bundle_values_compatible = $bundleValuesCompatible section_keys_compatible = $sectionKeysCompatible guardrails_compatible = $guardrailsCompatible } $failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key }) $result = [ordered]@{ schema_version = "c19z81.remote_workspace_real_adapter_runtime_gate_preflight_operator_handoff_bundle_smoke.v1" source_result_path = $sourceFile cluster_id = $ClusterID required_bundle_fields = $requiredBundleFields required_section_keys = $requiredSectionKeys required_guardrail_fields = $requiredGuardrailFields runtime_gate_preflight_operator_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 "C19Z81 remote workspace real-adapter runtime gate preflight operator handoff bundle smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')" } Write-Host "C19Z81 remote workspace real-adapter runtime gate preflight operator handoff bundle smoke passed. Result: $fullResultPath" $result