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\c20z5-remote-workspace-real-adapter-operator-validation-closeout-smoke-result.json" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath $sourceResultPath = "artifacts\c20z5-remote-workspace-real-adapter-operator-validation-closeout-source-result.json" $requiredValidationItems = @("operator_confirmation", "binary_validation", "permission_validation", "supervisor_validation", "health_probe_validation", "payload_gate_validation") $requiredCloseoutFields = @("schema_version", "source_checklist_schema", "closeout_status", "closeout_marker", "validation_chain_status", "validated_items", "remaining_items", "enablement_boundary", "enablement_decision", "enablement_status", "runtime_gate_state", "runtime_effect", "operator_default_action", "next_required_phase", "allows_process_start", "allows_payload_traffic", "guardrail_summary", "closeout_notes") $requiredGuardrailFields = @("activation_blocked", "process_start_allowed", "health_probe_enabled", "payload_traffic", "allows_process_start", "allows_payload_traffic") $requiredCloseoutNotes = @("operator_validation_closeout_complete_contract_only", "new_explicit_request_validated_by_contract", "terminal_boundary_required_before_any_runtime_change", "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 "c20z4-remote-workspace-real-adapter-operator-validation-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 "operator_validation_checklist" -Default $null $guardrails = Get-PropertyValue -Item $checklist -Name "guardrail_summary" -Default $null $closeout = [ordered]@{ schema_version = "rap.remote_workspace_real_adapter_operator_validation_closeout.v1" source_checklist_schema = Get-PropertyValue -Item $checklist -Name "schema_version" -Default $null closeout_status = "complete_contract_only" closeout_marker = "c20z5_real_adapter_operator_validation_closeout_complete" validation_chain_status = "complete_contract_only" validated_items = $requiredValidationItems remaining_items = @() enablement_boundary = "runtime_enablement_requires_next_explicit_runtime_stage" enablement_decision = "validated_contract_only_not_enabled" enablement_status = "validated_not_enabled" runtime_gate_state = "validated_contract_only_not_enabled" runtime_effect = "contract_only_no_runtime_enablement" operator_default_action = "keep_real_adapter_disabled_until_next_explicit_runtime_stage" next_required_phase = "c20_terminal_complete" allows_process_start = $false allows_payload_traffic = $false guardrail_summary = $guardrails closeout_notes = $requiredCloseoutNotes } $closeoutFieldsCompatible = Test-ObjectHasFields -Item $closeout -Fields $requiredCloseoutFields $validatedItemsCompatible = Test-ArrayEquals -Actual @($closeout.validated_items) -Expected $requiredValidationItems $remainingItemsCompatible = Test-ArrayEquals -Actual @($closeout.remaining_items) -Expected @() $closeoutNotesCompatible = Test-ArrayContainsAll -Actual @($closeout.closeout_notes) -Expected $requiredCloseoutNotes $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) ) $closeoutValuesCompatible = ( [string]$closeout.source_checklist_schema -eq "rap.remote_workspace_real_adapter_operator_validation_checklist.v1" -and [string]$closeout.closeout_status -eq "complete_contract_only" -and [string]$closeout.validation_chain_status -eq "complete_contract_only" -and [string]$closeout.enablement_status -eq "validated_not_enabled" -and [string]$closeout.runtime_gate_state -eq "validated_contract_only_not_enabled" -and [string]$closeout.runtime_effect -eq "contract_only_no_runtime_enablement" -and -not [bool]$closeout.allows_process_start -and -not [bool]$closeout.allows_payload_traffic ) $checks = [ordered]@{ source_smoke_passed = ([bool]$sourceResult.passed) source_schema_expected = ([string]$sourceResult.schema_version -eq "c20z4.remote_workspace_real_adapter_operator_validation_checklist_smoke.v1") checklist_present = ($null -ne $checklist) closeout_fields_compatible = $closeoutFieldsCompatible closeout_values_compatible = $closeoutValuesCompatible validated_items_compatible = $validatedItemsCompatible remaining_items_compatible = $remainingItemsCompatible closeout_notes_compatible = $closeoutNotesCompatible guardrails_compatible = $guardrailsCompatible } $failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key }) $result = [ordered]@{ schema_version = "c20z5.remote_workspace_real_adapter_operator_validation_closeout_smoke.v1" source_result_path = $sourceFile cluster_id = $ClusterID required_closeout_fields = $requiredCloseoutFields required_validation_items = $requiredValidationItems required_guardrail_fields = $requiredGuardrailFields required_closeout_notes = $requiredCloseoutNotes operator_validation_closeout = $closeout 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 "C20Z5 remote workspace real-adapter operator validation closeout smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')" } Write-Host "C20Z5 remote workspace real-adapter operator validation closeout smoke passed. Result: $fullResultPath" $result