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\c19z76-remote-workspace-real-adapter-runtime-gate-preflight-checklist-compatibility-smoke-result.json" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath $sourceResultPath = "artifacts\c19z76-remote-workspace-real-adapter-runtime-gate-preflight-checklist-source-result.json" $requiredChecklistFields = @( "schema_version", "source_phase_boundary_schema", "preflight_status", "runtime_gate_state", "activation_policy", "operator_default_action", "required_item_count", "satisfied_item_count", "blocked_item_count", "allows_process_start", "allows_payload_traffic", "items", "guardrail_summary" ) $requiredItemFields = @("key", "title", "status", "required", "blocks_runtime_gate", "evidence") $requiredPreflightKeys = @( "explicit_operator_gate_enablement", "real_adapter_binary_path_validated", "service_account_and_permissions_validated", "process_supervisor_limits_validated", "health_probe_signal_contract_validated", "payload_forwarding_gate_validated" ) $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 "c19z75-remote-workspace-real-adapter-runtime-gate-preflight-checklist-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 $checklist = Get-PropertyValue -Item $sourceResult -Name "runtime_gate_preflight_checklist" -Default $null $items = @(Get-PropertyValue -Item $checklist -Name "items" -Default @()) $guardrails = Get-PropertyValue -Item $checklist -Name "guardrail_summary" -Default $null $checklistFieldsCompatible = Test-ObjectHasFields -Item $checklist -Fields $requiredChecklistFields $itemFieldsCompatible = (@($items | Where-Object { -not (Test-ObjectHasFields -Item $_ -Fields $requiredItemFields) }).Count -eq 0) $itemKeysCompatible = Test-ArrayContainsAll -Actual @($items | ForEach-Object { Get-PropertyValue -Item $_ -Name "key" -Default "" }) -Required $requiredPreflightKeys $itemValuesCompatible = (@($items | Where-Object { [string](Get-PropertyValue -Item $_ -Name "status" -Default "") -ne "not_satisfied" -or -not [bool](Get-PropertyValue -Item $_ -Name "required" -Default $false) -or -not [bool](Get-PropertyValue -Item $_ -Name "blocks_runtime_gate" -Default $false) -or [string](Get-PropertyValue -Item $_ -Name "evidence" -Default "") -ne "contract_only_preflight_not_provided" }).Count -eq 0) $checklistValuesCompatible = ( [string](Get-PropertyValue -Item $checklist -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_runtime_gate_preflight_checklist.v1" -and [string](Get-PropertyValue -Item $checklist -Name "source_phase_boundary_schema" -Default "") -eq "rap.remote_workspace_real_adapter_runtime_gate_phase_boundary.v1" -and [string](Get-PropertyValue -Item $checklist -Name "preflight_status" -Default "") -eq "blocked_required_items_missing" -and [string](Get-PropertyValue -Item $checklist -Name "runtime_gate_state" -Default "") -eq "blocked" -and [string](Get-PropertyValue -Item $checklist -Name "activation_policy" -Default "") -eq "explicit_operator_enablement_required" -and [string](Get-PropertyValue -Item $checklist -Name "operator_default_action" -Default "") -eq "keep_real_adapter_disabled" -and [int](Get-PropertyValue -Item $checklist -Name "required_item_count" -Default -1) -eq $requiredPreflightKeys.Count -and [int](Get-PropertyValue -Item $checklist -Name "satisfied_item_count" -Default -1) -eq 0 -and [int](Get-PropertyValue -Item $checklist -Name "blocked_item_count" -Default -1) -eq $requiredPreflightKeys.Count -and -not [bool](Get-PropertyValue -Item $checklist -Name "allows_process_start" -Default $true) -and -not [bool](Get-PropertyValue -Item $checklist -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 "c19z75.remote_workspace_real_adapter_runtime_gate_preflight_checklist_smoke.v1") checklist_present = ($null -ne $checklist) checklist_fields_compatible = $checklistFieldsCompatible checklist_values_compatible = $checklistValuesCompatible item_fields_compatible = $itemFieldsCompatible item_keys_compatible = $itemKeysCompatible item_values_compatible = $itemValuesCompatible guardrails_compatible = $guardrailsCompatible } $failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key }) $result = [ordered]@{ schema_version = "c19z76.remote_workspace_real_adapter_runtime_gate_preflight_checklist_compatibility_smoke.v1" source_result_path = $sourceFile cluster_id = $ClusterID required_checklist_fields = $requiredChecklistFields required_item_fields = $requiredItemFields required_preflight_keys = $requiredPreflightKeys required_guardrail_fields = $requiredGuardrailFields runtime_gate_preflight_checklist = $checklist 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 "C19Z76 remote workspace real-adapter runtime gate preflight checklist compatibility smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')" } Write-Host "C19Z76 remote workspace real-adapter runtime gate preflight checklist compatibility smoke passed. Result: $fullResultPath" $result