161 lines
8.4 KiB
PowerShell
161 lines
8.4 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\c20z4-remote-workspace-real-adapter-operator-validation-checklist-smoke-result.json"
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath
|
|
$sourceResultPath = "artifacts\c20z4-remote-workspace-real-adapter-operator-validation-checklist-source-result.json"
|
|
$requiredChecklistItems = @("operator_confirmation", "binary_validation", "permission_validation", "supervisor_validation", "health_probe_validation", "payload_gate_validation")
|
|
$requiredChecklistFields = @("schema_version", "source_intake_schema", "checklist_status", "checklist_marker", "required_items", "satisfied_items", "remaining_items", "enablement_decision", "enablement_status", "runtime_gate_state", "runtime_effect", "operator_default_action", "next_required_phase", "allows_process_start", "allows_payload_traffic", "guardrail_summary", "checklist_notes")
|
|
$requiredGuardrailFields = @("activation_blocked", "process_start_allowed", "health_probe_enabled", "payload_traffic", "allows_process_start", "allows_payload_traffic")
|
|
$requiredChecklistNotes = @("operator_validation_checklist_complete_contract_only", "all_required_validation_items_satisfied_by_contract", "runtime_enablement_still_requires_terminal_boundary", "real_runtime_gate_not_enabled", "process_start_disabled", "payload_forwarding_disabled")
|
|
|
|
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-ArrayEquals {
|
|
param([object[]]$Actual, [string[]]$Expected)
|
|
$actualValues = @($Actual | ForEach-Object { [string]$_ })
|
|
if ($actualValues.Count -ne $Expected.Count) { return $false }
|
|
foreach ($item in $Expected) {
|
|
if ($actualValues -notcontains $item) { return $false }
|
|
}
|
|
return $true
|
|
}
|
|
|
|
function Test-ArrayContainsAll {
|
|
param([object[]]$Actual, [string[]]$Expected)
|
|
foreach ($item in $Expected) {
|
|
if ($Actual -notcontains $item) { return $false }
|
|
}
|
|
return $true
|
|
}
|
|
|
|
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c20z3-remote-workspace-real-adapter-operator-validation-intake-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
|
|
$intake = Get-PropertyValue -Item $sourceResult -Name "operator_validation_intake" -Default $null
|
|
$guardrails = Get-PropertyValue -Item $intake -Name "guardrail_summary" -Default $null
|
|
|
|
$checklist = [ordered]@{
|
|
schema_version = "rap.remote_workspace_real_adapter_operator_validation_checklist.v1"
|
|
source_intake_schema = Get-PropertyValue -Item $intake -Name "schema_version" -Default $null
|
|
checklist_status = "complete_contract_only"
|
|
checklist_marker = "c20z4_real_adapter_operator_validation_checklist_complete"
|
|
required_items = $requiredChecklistItems
|
|
satisfied_items = $requiredChecklistItems
|
|
remaining_items = @()
|
|
enablement_decision = "validated_contract_only_pending_terminal_boundary"
|
|
enablement_status = "validated_not_enabled"
|
|
runtime_gate_state = "operator_validation_complete_contract_only_not_enabled"
|
|
runtime_effect = "contract_only_no_runtime_enablement"
|
|
operator_default_action = "keep_real_adapter_disabled_until_terminal_boundary_complete"
|
|
next_required_phase = "c20_stage_closeout"
|
|
allows_process_start = $false
|
|
allows_payload_traffic = $false
|
|
guardrail_summary = $guardrails
|
|
checklist_notes = $requiredChecklistNotes
|
|
}
|
|
|
|
$checklistFieldsCompatible = Test-ObjectHasFields -Item $checklist -Fields $requiredChecklistFields
|
|
$requiredItemsCompatible = Test-ArrayEquals -Actual @($checklist.required_items) -Expected $requiredChecklistItems
|
|
$satisfiedItemsCompatible = Test-ArrayEquals -Actual @($checklist.satisfied_items) -Expected $requiredChecklistItems
|
|
$remainingItemsCompatible = Test-ArrayEquals -Actual @($checklist.remaining_items) -Expected @()
|
|
$checklistNotesCompatible = Test-ArrayContainsAll -Actual @($checklist.checklist_notes) -Expected $requiredChecklistNotes
|
|
$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)
|
|
)
|
|
$checklistValuesCompatible = (
|
|
[string]$checklist.source_intake_schema -eq "rap.remote_workspace_real_adapter_operator_validation_intake.v1" -and
|
|
[string]$checklist.checklist_status -eq "complete_contract_only" -and
|
|
[string]$checklist.enablement_status -eq "validated_not_enabled" -and
|
|
[string]$checklist.runtime_gate_state -eq "operator_validation_complete_contract_only_not_enabled" -and
|
|
[string]$checklist.runtime_effect -eq "contract_only_no_runtime_enablement" -and
|
|
-not [bool]$checklist.allows_process_start -and
|
|
-not [bool]$checklist.allows_payload_traffic
|
|
)
|
|
|
|
$checks = [ordered]@{
|
|
source_smoke_passed = ([bool]$sourceResult.passed)
|
|
source_schema_expected = ([string]$sourceResult.schema_version -eq "c20z3.remote_workspace_real_adapter_operator_validation_intake_smoke.v1")
|
|
intake_present = ($null -ne $intake)
|
|
checklist_fields_compatible = $checklistFieldsCompatible
|
|
checklist_values_compatible = $checklistValuesCompatible
|
|
required_items_compatible = $requiredItemsCompatible
|
|
satisfied_items_compatible = $satisfiedItemsCompatible
|
|
remaining_items_compatible = $remainingItemsCompatible
|
|
checklist_notes_compatible = $checklistNotesCompatible
|
|
guardrails_compatible = $guardrailsCompatible
|
|
}
|
|
$failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key })
|
|
|
|
$result = [ordered]@{
|
|
schema_version = "c20z4.remote_workspace_real_adapter_operator_validation_checklist_smoke.v1"
|
|
source_result_path = $sourceFile
|
|
cluster_id = $ClusterID
|
|
required_checklist_fields = $requiredChecklistFields
|
|
required_checklist_items = $requiredChecklistItems
|
|
required_guardrail_fields = $requiredGuardrailFields
|
|
required_checklist_notes = $requiredChecklistNotes
|
|
operator_validation_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 "C20Z4 remote workspace real-adapter operator validation checklist smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')"
|
|
}
|
|
|
|
Write-Host "C20Z4 remote workspace real-adapter operator validation checklist smoke passed. Result: $fullResultPath"
|
|
$result
|