Files
rdp-proxy/scripts/fabric/c19z59-remote-workspace-real-adapter-disabled-action-map-smoke.ps1
T
2026-05-14 23:30:34 +03:00

232 lines
11 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\c19z59-remote-workspace-real-adapter-disabled-action-map-smoke-result.json"
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
$sourceResultPath = "artifacts\c19z59-remote-workspace-real-adapter-disabled-action-map-source-result.json"
$requiredActionFields = @(
"action_key",
"status",
"severity",
"reason",
"derived_from",
"blocks_activation",
"allows_process_start",
"allows_payload_traffic"
)
$requiredActionKeys = @(
"keep_real_adapter_disabled",
"review_real_runtime_stage_gates",
"validate_real_adapter_config_projection",
"prepare_process_supervisor_preconditions",
"prepare_process_health_probe_signals",
"keep_payload_forwarding_disabled"
)
$allowedDerivedFrom = @(
"handoff_v4_complete",
"mode_matrix_v3_compatible",
"requested_and_default_config_shapes_visible",
"activation_blocked",
"process_start_disabled",
"health_probe_disabled",
"payload_traffic_none",
"missing_gates_visible",
"missing_health_signals_visible"
)
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-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 Get-ChecklistItem {
param([object[]]$Items, [string]$Name)
return @($Items | Where-Object { [string](Get-PropertyValue -Item $_ -Name "name" -Default "") -eq $Name } | Select-Object -First 1)
}
function Get-ActionByKey {
param([object[]]$Actions, [string]$Key)
return @($Actions | Where-Object { [string](Get-PropertyValue -Item $_ -Name "action_key" -Default "") -eq $Key } | Select-Object -First 1)
}
function Test-ActionFields {
param([object[]]$Actions)
if ($Actions.Count -eq 0) { return $false }
foreach ($action in $Actions) {
if (-not (Test-ObjectHasFields -Item $action -Fields $requiredActionFields)) { return $false }
}
return $true
}
function Test-ActionKeysPresent {
param([object[]]$Actions)
foreach ($key in $requiredActionKeys) {
if ($null -eq (Get-ActionByKey -Actions $Actions -Key $key)) { return $false }
}
return $true
}
function Test-ActionsReferenceChecklist {
param([object[]]$Actions, [object[]]$Checklist)
foreach ($action in $Actions) {
$derived = Get-PropertyValue -Item $action -Name "derived_from" -Default @()
foreach ($name in @($derived)) {
if (-not (Test-ArrayItem -Items $allowedDerivedFrom -Want ([string]$name))) { return $false }
$checklistItem = Get-ChecklistItem -Items $Checklist -Name ([string]$name)
if ($null -eq $checklistItem -or -not [bool](Get-PropertyValue -Item $checklistItem -Name "passed" -Default $false)) { return $false }
}
}
return $true
}
function Test-ActionsKeepRuntimeDisabled {
param([object[]]$Actions)
if ($Actions.Count -eq 0) { return $false }
foreach ($action in $Actions) {
if (-not [bool](Get-PropertyValue -Item $action -Name "blocks_activation" -Default $false)) { return $false }
if ([bool](Get-PropertyValue -Item $action -Name "allows_process_start" -Default $true)) { return $false }
if ([bool](Get-PropertyValue -Item $action -Name "allows_payload_traffic" -Default $true)) { return $false }
}
return $true
}
function New-Action {
param([string]$Key, [string]$Severity, [string]$Reason, [string[]]$DerivedFrom)
return [ordered]@{
action_key = $Key
status = "blocked"
severity = $Severity
reason = $Reason
derived_from = $DerivedFrom
blocks_activation = $true
allows_process_start = $false
allows_payload_traffic = $false
}
}
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z58-remote-workspace-real-adapter-readiness-handoff-summary-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
$summary = Get-PropertyValue -Item $sourceResult -Name "readiness_summary" -Default $null
$checklist = @((Get-PropertyValue -Item $sourceResult -Name "operator_checklist" -Default @()))
$actions = @(
(New-Action -Key "keep_real_adapter_disabled" -Severity "info" -Reason "runtime stage is intentionally blocked until real adapter execution gates are introduced" -DerivedFrom @("handoff_v4_complete", "mode_matrix_v3_compatible", "activation_blocked")),
(New-Action -Key "review_real_runtime_stage_gates" -Severity "warn" -Reason "activation gates are visible and still missing for real runtime stage" -DerivedFrom @("activation_blocked", "missing_gates_visible")),
(New-Action -Key "validate_real_adapter_config_projection" -Severity "info" -Reason "requested and default config projections are visible with raw values redacted" -DerivedFrom @("requested_and_default_config_shapes_visible")),
(New-Action -Key "prepare_process_supervisor_preconditions" -Severity "warn" -Reason "external process start remains disabled until supervisor preconditions are satisfied" -DerivedFrom @("process_start_disabled")),
(New-Action -Key "prepare_process_health_probe_signals" -Severity "warn" -Reason "health probe remains disabled until external process and channel signals exist" -DerivedFrom @("health_probe_disabled", "missing_health_signals_visible")),
(New-Action -Key "keep_payload_forwarding_disabled" -Severity "info" -Reason "payload forwarding is intentionally blocked while real adapter runtime is disabled" -DerivedFrom @("payload_traffic_none"))
)
$actionMap = [ordered]@{
schema_version = "rap.remote_workspace_real_adapter_disabled_runtime_operator_action_map.v1"
readiness_summary_schema = Get-PropertyValue -Item $summary -Name "schema_version" -Default $null
readiness_state = Get-PropertyValue -Item $summary -Name "readiness_state" -Default $null
operator_action = Get-PropertyValue -Item $summary -Name "operator_action" -Default $null
activation_decision = Get-PropertyValue -Item $summary -Name "activation_decision" -Default $null
process_start_allowed = Get-PropertyValue -Item $summary -Name "process_start_allowed" -Default $null
health_probe_enabled = Get-PropertyValue -Item $summary -Name "health_probe_enabled" -Default $null
payload_traffic = Get-PropertyValue -Item $summary -Name "payload_traffic" -Default $null
action_count = $actions.Count
actions = $actions
}
$actionFieldsCompatible = Test-ActionFields -Actions $actions
$actionKeysCompatible = Test-ActionKeysPresent -Actions $actions
$actionsReferenceChecklist = Test-ActionsReferenceChecklist -Actions $actions -Checklist $checklist
$actionsKeepRuntimeDisabled = Test-ActionsKeepRuntimeDisabled -Actions $actions
$summaryStillDisabled = (
[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
[string](Get-PropertyValue -Item $summary -Name "activation_decision" -Default "") -eq "blocked" -and
-not [bool](Get-PropertyValue -Item $summary -Name "process_start_allowed" -Default $true) -and
-not [bool](Get-PropertyValue -Item $summary -Name "health_probe_enabled" -Default $true) -and
[string](Get-PropertyValue -Item $summary -Name "payload_traffic" -Default "") -eq "none"
)
$checks = [ordered]@{
source_smoke_passed = ([bool]$sourceResult.passed)
source_schema_expected = ([string]$sourceResult.schema_version -eq "c19z58.remote_workspace_real_adapter_readiness_handoff_summary_compatibility_smoke.v1")
action_map_schema_expected = ([string]$actionMap.schema_version -eq "rap.remote_workspace_real_adapter_disabled_runtime_operator_action_map.v1")
required_action_keys_declared = ($requiredActionKeys.Count -eq 6)
action_count_expected = ($actions.Count -eq $requiredActionKeys.Count)
action_fields_compatible = $actionFieldsCompatible
action_keys_compatible = $actionKeysCompatible
actions_reference_checklist = $actionsReferenceChecklist
actions_keep_runtime_disabled = $actionsKeepRuntimeDisabled
summary_still_disabled = $summaryStillDisabled
}
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
$result = [ordered]@{
schema_version = "c19z59.remote_workspace_real_adapter_disabled_action_map_smoke.v1"
source_result_path = $sourceFile
cluster_id = $ClusterID
required_action_fields = $requiredActionFields
required_action_keys = $requiredActionKeys
action_map = $actionMap
readiness_summary = $summary
operator_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 "C19Z59 remote workspace real-adapter disabled action map smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
}
Write-Host "C19Z59 remote workspace real-adapter disabled action map smoke passed. Result: $fullResultPath"
$result