feat(graph): complete stategraph cleanup and acceptance

This commit is contained in:
zhuyongxin
2026-07-20 10:23:27 +08:00
parent 208a231113
commit 190013c901
46 changed files with 1223 additions and 1211 deletions
+66 -1
View File
@@ -79,6 +79,15 @@ $chatPath = Join-Path $OutputDir "chat-response.json"
$chat | ConvertTo-Json -Depth 30 | Set-Content -Encoding UTF8 -Path $chatPath
$runId = $chat.data.runId
if ($chat.data.success -ne $true) {
throw "Chat response was not successful."
}
if ([string]::IsNullOrWhiteSpace([string]$chat.data.answer)) {
throw "Chat response did not include a non-empty answer."
}
if ($chat.data.sessionId -ne $SessionId) {
throw "Chat response sessionId '$($chat.data.sessionId)' did not match requested sessionId '$SessionId'."
}
if (-not $runId) {
throw "Chat response did not include runId; exact trace verification cannot continue."
}
@@ -92,6 +101,51 @@ $trace = Invoke-RestMethod @traceRequest
$tracePath = Join-Path $OutputDir "trace-response.json"
$trace | ConvertTo-Json -Depth 80 | Set-Content -Encoding UTF8 -Path $tracePath
$traceData = Get-TraceData -TraceResponse $trace
if ($null -eq $traceData -or $null -eq $traceData.run) {
throw "Exact Trace response did not include data.run."
}
if ($traceData.runId -ne $runId -or $traceData.run.runId -ne $runId) {
throw "Exact Trace runId did not match Chat runId '$runId'."
}
if ($traceData.run.sessionId -ne $SessionId) {
throw "Exact Trace run did not belong to requested sessionId '$SessionId'."
}
$orchestrationTrace = $traceData.run.orchestrationTrace
if ($null -eq $orchestrationTrace) {
throw "Exact Trace data.run.orchestrationTrace is missing."
}
foreach ($field in @("version", "final_node", "termination_reason")) {
if (-not ($orchestrationTrace.PSObject.Properties.Name -contains $field) -or
[string]::IsNullOrWhiteSpace([string]$orchestrationTrace.$field)) {
throw "Exact Trace data.run.orchestrationTrace.$field is missing."
}
}
foreach ($field in @("transitions", "degraded", "evidence_retry_count")) {
if (-not ($orchestrationTrace.PSObject.Properties.Name -contains $field)) {
throw "Exact Trace data.run.orchestrationTrace.$field is missing."
}
}
if ($null -eq $orchestrationTrace.transitions) {
throw "Exact Trace data.run.orchestrationTrace.transitions must be an array."
}
if ([int]$orchestrationTrace.evidence_retry_count -lt 0) {
throw "Exact Trace data.run.orchestrationTrace.evidence_retry_count must not be negative."
}
if ($traceData.run.status -ne "SUCCESS" -or $traceData.run.agentFlow -ne "CHAT") {
throw "Exact Trace run must be CHAT/SUCCESS."
}
if ([string]::IsNullOrWhiteSpace([string]$traceData.run.answer)) {
throw "Exact Trace run did not include a non-empty answer."
}
if (@($traceData.steps).Count -eq 0 -or @($traceData.toolInvocations).Count -eq 0) {
throw "Exact Trace did not include both Agent steps and tool invocation evidence."
}
if ($null -eq $traceData.run.selfEvaluation) {
throw "Exact Trace run did not include selfEvaluation."
}
$feedbackBody = @{
sessionId = $SessionId
runId = $runId
@@ -105,11 +159,13 @@ $feedbackRequest = @{
Body = $feedbackBody
}
$feedback = Invoke-RestMethod @feedbackRequest
if ($feedback.success -ne $true) {
throw "Feedback request was not successful for runId '$runId'."
}
$feedbackPath = Join-Path $OutputDir "feedback-response.json"
$feedback | ConvertTo-Json -Depth 30 | Set-Content -Encoding UTF8 -Path $feedbackPath
$traceData = Get-TraceData -TraceResponse $trace
$selfEvaluation = Get-SelfEvaluation -TraceData $traceData
$verifierEvaluation = $null
if ($null -ne $selfEvaluation) {
@@ -138,6 +194,7 @@ if ($null -ne $promptAudit) {
$promptAuditVersion = $promptAudit.version
}
$toolNames = Get-ToolNames -TraceData $traceData
$transitionCount = @($orchestrationTrace.transitions).Count
$summaryPath = Join-Path $OutputDir "interview-demo-summary.json"
$summary = [ordered]@{
@@ -149,6 +206,12 @@ $summary = [ordered]@{
gatekeeperStatus = $gatekeeperStatus
gatekeeperRuleSetVersion = $gatekeeperRuleSetVersion
promptAuditVersion = $promptAuditVersion
orchestrationVersion = $orchestrationTrace.version
finalNode = $orchestrationTrace.final_node
terminationReason = $orchestrationTrace.termination_reason
degraded = [bool]$orchestrationTrace.degraded
transitionCount = $transitionCount
evidenceRetryCount = [int]$orchestrationTrace.evidence_retry_count
toolNames = $toolNames
paths = [ordered]@{
chat = $chatPath
@@ -165,4 +228,6 @@ Write-Host "Interview demo preflight completed."
Write-Host "Verdict: $($summary.verdict)"
Write-Host "Gatekeeper rules: $($summary.gatekeeperRuleSetVersion)"
Write-Host "Prompt audit: $($summary.promptAuditVersion)"
Write-Host "Graph final node: $($summary.finalNode)"
Write-Host "Graph termination: $($summary.terminationReason)"
Write-Host "Summary: $summaryPath"