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\c19z68-remote-workspace-real-adapter-admin-handoff-full-chain-summary-compatibility-smoke-result.json" ) Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).ProviderPath $sourceResultPath = "artifacts\c19z68-remote-workspace-real-adapter-admin-handoff-full-chain-summary-source-result.json" $requiredSummaryFields = @("schema_version", "source_rollup_schema", "chain_status", "proven_stage_count", "admin_status", "primary_action", "runtime_effect", "guardrail_summary", "proven_stages") $requiredStageFields = @("stage_key", "status", "artifact", "runtime_effect") $expectedStageKeys = @( "c19z54_handoff_v4", "c19z55_mode_matrix_v3", "c19z56_mode_matrix_v3_compatibility", "c19z57_readiness_handoff_summary", "c19z58_readiness_handoff_summary_compatibility", "c19z59_operator_action_map", "c19z60_operator_action_map_compatibility", "c19z61_admin_handoff_bundle", "c19z62_admin_handoff_bundle_compatibility", "c19z63_admin_handoff_digest", "c19z64_admin_handoff_digest_compatibility", "c19z65_admin_handoff_digest_rollup", "c19z66_admin_handoff_digest_rollup_compatibility" ) 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 Get-StageByKey { param([object[]]$Stages, [string]$Key) return @($Stages | Where-Object { [string](Get-PropertyValue -Item $_ -Name "stage_key" -Default "") -eq $Key } | Select-Object -First 1) } function Test-Stage { param([object]$Stage, [string]$Key) if ($null -eq $Stage) { return $false } return ( (Test-ObjectHasFields -Item $Stage -Fields $requiredStageFields) -and [string](Get-PropertyValue -Item $Stage -Name "stage_key" -Default "") -eq $Key -and [string](Get-PropertyValue -Item $Stage -Name "status" -Default "") -eq "passed" -and [string](Get-PropertyValue -Item $Stage -Name "artifact" -Default "") -like "artifacts/c19z*" -and [string](Get-PropertyValue -Item $Stage -Name "runtime_effect" -Default "") -eq "contract_only_no_runtime_enablement" ) } & powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "c19z67-remote-workspace-real-adapter-admin-handoff-full-chain-summary-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 "admin_handoff_full_chain_summary" -Default $null $guardrails = Get-PropertyValue -Item $summary -Name "guardrail_summary" -Default $null $stages = @((Get-PropertyValue -Item $summary -Name "proven_stages" -Default @())) $stageChecks = [ordered]@{} foreach ($key in $expectedStageKeys) { $stageChecks[$key] = Test-Stage -Stage (Get-StageByKey -Stages $stages -Key $key) -Key $key } $summaryFieldsCompatible = Test-ObjectHasFields -Item $summary -Fields $requiredSummaryFields $summaryValuesCompatible = ( [string](Get-PropertyValue -Item $summary -Name "schema_version" -Default "") -eq "rap.remote_workspace_real_adapter_admin_handoff_full_chain_summary.v1" -and [string](Get-PropertyValue -Item $summary -Name "source_rollup_schema" -Default "") -eq "rap.remote_workspace_real_adapter_admin_handoff_digest_rollup.v1" -and [string](Get-PropertyValue -Item $summary -Name "chain_status" -Default "") -eq "complete" -and [int](Get-PropertyValue -Item $summary -Name "proven_stage_count" -Default -1) -eq $expectedStageKeys.Count -and [string](Get-PropertyValue -Item $summary -Name "admin_status" -Default "") -eq "not_ready" -and [string](Get-PropertyValue -Item $summary -Name "primary_action" -Default "") -eq "keep_real_adapter_disabled" -and [string](Get-PropertyValue -Item $summary -Name "runtime_effect" -Default "") -eq "contract_only_no_runtime_enablement" ) $guardrailsCompatible = ( [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) ) $stagesCompatible = ( $stages.Count -eq $expectedStageKeys.Count -and @($stageChecks.GetEnumerator() | Where-Object { -not $_.Value }).Count -eq 0 ) $checks = [ordered]@{ source_smoke_passed = ([bool]$sourceResult.passed) source_schema_expected = ([string]$sourceResult.schema_version -eq "c19z67.remote_workspace_real_adapter_admin_handoff_full_chain_summary_smoke.v1") summary_present = ($null -ne $summary) summary_fields_compatible = $summaryFieldsCompatible summary_values_compatible = $summaryValuesCompatible stages_compatible = $stagesCompatible guardrails_compatible = $guardrailsCompatible } $failed = @($checks.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { $_.Key }) $result = [ordered]@{ schema_version = "c19z68.remote_workspace_real_adapter_admin_handoff_full_chain_summary_compatibility_smoke.v1" source_result_path = $sourceFile cluster_id = $ClusterID required_summary_fields = $requiredSummaryFields required_stage_fields = $requiredStageFields expected_stage_keys = $expectedStageKeys stage_checks = $stageChecks admin_handoff_full_chain_summary = $summary 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 "C19Z68 remote workspace real-adapter admin handoff full-chain summary compatibility smoke failed. Result: $fullResultPath Failed: $($failed -join ', ')" } Write-Host "C19Z68 remote workspace real-adapter admin handoff full-chain summary compatibility smoke passed. Result: $fullResultPath" $result