Files

38 lines
3.4 KiB
PowerShell
Raw Permalink Normal View History

2026-08-26 06:41:07 +08:00
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
$root = Split-Path -Parent $PSScriptRoot
Set-Location -LiteralPath $root
$temporaryRoot = Join-Path ([System.IO.Path]::GetTempPath()) ('rtc-conformance-toolchain-' + [Guid]::NewGuid().ToString('N'))
$capturePath = Join-Path $temporaryRoot 'capture.json'
$reportPath = Join-Path $temporaryRoot 'report.json'
try {
New-Item -ItemType Directory -Path $temporaryRoot | Out-Null
$imageDigest = (docker image inspect data-terminal-cloud-api --format '{{.Id}}').Trim()
if ($imageDigest -notmatch '^sha256:[a-f0-9]{64}$') { throw '无法取得API镜像摘要' }
$startedAt = (Get-Date).ToUniversalTime().AddMinutes(-2)
$endedAt = $startedAt.AddMinutes(1)
$capture = @{
schema_version = 'real-device-rtc-capture-v1'; evidence_source = 'PROTOCOL_SIMULATION'; candidate_version = '0.63.0-rc.local'; build_digest = $imageDigest; environment = 'LOCAL'
rtc_provider_ref = 'mock'; voice_provider_ref = 'mock'; rtc_application_ref = 'local-app'; region_ref = 'local'; change_ticket_ref = 'local-smoke'
executed_by_ref = 'local-toolchain'; attested_by_ref = 'local-toolchain'; attested_at = $endedAt.ToString('o'); collected_at = (Get-Date).ToUniversalTime().ToString('o')
devices = @(@{ device_id = 'sim-device'; hardware_model = 'simulator'; hardware_revision = 'local'; firmware_version = 'simulated'; identity_ref = 'local-device-secret'; audio_profile_ref = 'simulated-audio' })
sessions = @(@{
conversation_id = 'simulated-conversation'; device_id = 'sim-device'; engine_mode = 's2s_hybrid'; scenario = 'NORMAL_COMPLETION'; room_ref = 'local-room'; device_rtc_user_ref = 'local-device-user'; agent_rtc_user_ref = 'local-agent-user'; provider_task_ref = 'local-task'
started_at = $startedAt.ToString('o'); ended_at = $endedAt.ToString('o'); lifecycle = @('ROOM_ISSUED','STARTING_AGENT','ACTIVE','STOPPING','COMPLETED')
rtc_join_succeeded = $true; uplink_succeeded = $true; downlink_succeeded = $true; near_audio_published = $true; far_audio_played = $true; credential_renewed = $false; network_recovered = $false
provider_start_accepted = $true; provider_stop_confirmed = $true; final_transcript_received = $true; usage_recorded = $true; quality_result = 'PASS'; no_duplicate_provider_task = $true; resources_released = $true
cloud_evidence_ref = 'local-schema-smoke'; device_evidence_ref = 'local-schema-smoke'; provider_evidence_ref = 'local-schema-smoke'; quality_evidence_ref = 'local-schema-smoke'; usage_evidence_ref = 'local-schema-smoke'
})
}
[System.IO.File]::WriteAllText($capturePath, ($capture | ConvertTo-Json -Depth 12), [System.Text.UTF8Encoding]::new($false))
go run ./cmd/rtc-conformance -capture $capturePath -candidate-version '0.63.0-rc.local' -build-digest $imageDigest -output $reportPath
$report = Get-Content -Raw -LiteralPath $reportPath | ConvertFrom-Json
if ($report.result -ne 'PASS' -or $report.evidence_scope -ne 'PROTOCOL_SIMULATION' -or -not $report.external_validation_required -or $report.device_count -ne 1 -or $report.session_count -ne 1) { throw 'RTC协议工具链报告边界不正确' }
Write-Host 'RTC证据工具链冒烟通过:1台模拟终端1通结构结果;报告固定为PROTOCOL_SIMULATION,真实RTC门禁继续待验。'
} finally {
if (Test-Path -LiteralPath $temporaryRoot) { Remove-Item -LiteralPath $temporaryRoot -Recurse -Force }
Write-Host '已清理RTC工具链冒烟临时文件。'
}