Files
rdp-proxy/scripts/fabric/c19z99-remote-workspace-real-adapter-runtime-gate-health-probe-validation-smoke.ps1
T
2026-05-14 23:30:34 +03:00

163 lines
8.3 KiB
PowerShell

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\c19z99-remote-workspace-real-adapter-runtime-gate-health-probe-validation-smoke-result.json"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
$sourceResultPath = "artifacts\c19z99-remote-workspace-real-adapter-runtime-gate-health-probe-validation-source-result.json"
$requiredValidationFields = @(
"schema_version",
"source_supervisor_validation_schema",
"validation_key",
"validation_status",
"health_probe_validation_required",
"health_probe_contract_verified",
"failure_detection_verified",
"remaining_required_validations",
"runtime_gate_state",
"runtime_effect",
"operator_default_action",
"allows_process_start",
"allows_payload_traffic",
"guardrail_summary"
)
$remainingRequiredValidations = @(
"payload_gate_validation"
)
$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 "c19z98-remote-workspace-real-adapter-runtime-gate-supervisor-validation-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
$supervisorValidation = Get-PropertyValue -Item $sourceResult -Name "runtime_gate_supervisor_validation" -Default $null
$guardrails = Get-PropertyValue -Item $supervisorValidation -Name "guardrail_summary" -Default $null
$validation = [ordered]@{
schema_version = "rap.remote_workspace_real_adapter_runtime_gate_health_probe_validation.v1"
source_supervisor_validation_schema = Get-PropertyValue -Item $supervisorValidation -Name "schema_version" -Default $null
validation_key = "health_probe_validation"
validation_status = "satisfied_contract_only"
health_probe_validation_required = $true
health_probe_contract_verified = $true
failure_detection_verified = $true
remaining_required_validations = $remainingRequiredValidations
runtime_gate_state = "blocked_pending_remaining_validations"
runtime_effect = "contract_only_no_runtime_enablement"
operator_default_action = Get-PropertyValue -Item $supervisorValidation -Name "operator_default_action" -Default $null
allows_process_start = $false
allows_payload_traffic = $false
guardrail_summary = $guardrails
}
$validationFieldsCompatible = Test-ObjectHasFields -Item $validation -Fields $requiredValidationFields
$remainingValidationsCompatible = Test-ArrayContainsAll -Actual @(Get-PropertyValue -Item $validation -Name "remaining_required_validations" -Default @()) -Required $remainingRequiredValidations
$validationValuesCompatible = (
[string](Get-PropertyValue -Item $validation -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_runtime_gate_health_probe_validation.v1" -and
[string](Get-PropertyValue -Item $validation -Name "source_supervisor_validation_schema" -Default "") -eq "rap.remote_workspace_real_adapter_runtime_gate_supervisor_validation.v1" -and
[string](Get-PropertyValue -Item $validation -Name "validation_key" -Default "") -eq "health_probe_validation" -and
[string](Get-PropertyValue -Item $validation -Name "validation_status" -Default "") -eq "satisfied_contract_only" -and
[bool](Get-PropertyValue -Item $validation -Name "health_probe_validation_required" -Default $false) -and
[bool](Get-PropertyValue -Item $validation -Name "health_probe_contract_verified" -Default $false) -and
[bool](Get-PropertyValue -Item $validation -Name "failure_detection_verified" -Default $false) -and
[string](Get-PropertyValue -Item $validation -Name "runtime_gate_state" -Default "") -eq "blocked_pending_remaining_validations" -and
[string](Get-PropertyValue -Item $validation -Name "runtime_effect" -Default "") -eq "contract_only_no_runtime_enablement" -and
[string](Get-PropertyValue -Item $validation -Name "operator_default_action" -Default "") -eq "keep_real_adapter_disabled" -and
-not [bool](Get-PropertyValue -Item $validation -Name "allows_process_start" -Default $true) -and
-not [bool](Get-PropertyValue -Item $validation -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 "c19z98.remote_workspace_real_adapter_runtime_gate_supervisor_validation_compatibility_smoke.v1")
supervisor_validation_present = ($null -ne $supervisorValidation)
validation_fields_compatible = $validationFieldsCompatible
validation_values_compatible = $validationValuesCompatible
remaining_validations_compatible = $remainingValidationsCompatible
guardrails_compatible = $guardrailsCompatible
}
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
$result = [ordered]@{
schema_version = "c19z99.remote_workspace_real_adapter_runtime_gate_health_probe_validation_smoke.v1"
source_result_path = $sourceFile
cluster_id = $ClusterID
required_validation_fields = $requiredValidationFields
remaining_required_validations = $remainingRequiredValidations
required_guardrail_fields = $requiredGuardrailFields
runtime_gate_health_probe_validation = $validation
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 "C19Z99 remote workspace real-adapter runtime gate health probe validation smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
}
Write-Host "C19Z99 remote workspace real-adapter runtime gate health probe validation smoke passed. Result: $fullResultPath"
$result