@@ -20,6 +20,8 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtrip.Receipt do
2020 :model_receipt_ref ,
2121 :appkit_projection_refs ,
2222 :scanner_receipts ,
23+ :failure_receipts ,
24+ :failure_projection_refs ,
2325 :aitrace_facts ,
2426 :trace_refs ,
2527 :does_not_prove
@@ -35,6 +37,7 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtrip do
3537
3638 alias AITrace.AIPlatform
3739 alias AppKit.ContextSurface
40+ alias AppKit.EvalSurface
3841 alias Citadel.ContextAuthority
3942 alias Citadel.ContextAuthority.AuthorityRequest
4043 alias Jido.Integration.InferenceRuntime
@@ -43,6 +46,7 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtrip do
4346 alias Mezzanine.AIExecution
4447 alias Mezzanine.AIExecution.RuntimeDeps
4548 alias Mezzanine.ContextPacketEngine
49+ alias Mezzanine.EvalEngine
4650 alias OuterBrain.ContextABI
4751 alias StackLab.ContextABIScanner
4852 alias StackLab.CoordinationFabricScanner
@@ -76,19 +80,21 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtrip do
7680 appkit_projections ( packet , admission_receipt , grant , route_decision , model_receipt ) ,
7781 { :ok , aitrace_facts } <-
7882 aitrace_facts ( packet , grant , route_decision , model_receipt , projections ) ,
83+ { :ok , failure_fixtures } <- failure_fixtures ( packet ) ,
7984 { :ok , scanner_receipts } <-
80- scanner_receipts (
81- packet ,
82- compile_receipt ,
83- grant ,
84- admission_receipt ,
85- route_request ,
86- route_decision ,
87- render_result ,
88- model_receipt ,
89- projections ,
90- aitrace_facts
91- ) do
85+ scanner_receipts ( % {
86+ packet: packet ,
87+ compile_receipt: compile_receipt ,
88+ grant: grant ,
89+ admission_receipt: admission_receipt ,
90+ route_request: route_request ,
91+ route_decision: route_decision ,
92+ render_result: render_result ,
93+ model_receipt: model_receipt ,
94+ projections: projections ,
95+ failure_fixtures: failure_fixtures ,
96+ aitrace_facts: aitrace_facts
97+ } ) do
9298 { :ok ,
9399 % Receipt {
94100 receipt_ref: receipt_ref ( packet , route_decision ) ,
@@ -110,6 +116,8 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtrip do
110116 model_receipt_ref: model_receipt . receipt_ref ,
111117 appkit_projection_refs: appkit_projection_refs ( projections ) ,
112118 scanner_receipts: scanner_receipts ,
119+ failure_receipts: [ failure_fixtures . failure_receipt ] ,
120+ failure_projection_refs: [ failure_fixtures . failure_projection . failure_ref ] ,
113121 aitrace_facts: aitrace_facts ,
114122 trace_refs: [ @ trace_ref , model_receipt . trace_ref ] ,
115123 does_not_prove: [
@@ -370,18 +378,40 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtrip do
370378 end
371379 end
372380
373- defp scanner_receipts (
374- packet ,
375- compile_receipt ,
376- grant ,
377- admission_receipt ,
378- route_request ,
379- route_decision ,
380- render_result ,
381- model_receipt ,
382- projections ,
383- aitrace_facts
384- ) do
381+ defp failure_fixtures ( packet ) do
382+ with { :ok , failure } <-
383+ EvalEngine . failure_from_reason ( :eval_parent_budget_exceeded ,
384+ trace_ref: "trace://router-fabric/demo/eval-failure"
385+ ) ,
386+ { :ok , failure_receipt } <-
387+ AIExecution . failure_receipt ( failure ,
388+ tenant_ref: packet . tenant_ref ,
389+ workflow_ref: @ workflow_ref ,
390+ stage: :eval ,
391+ trace_ref: "trace://router-fabric/demo/eval-failure"
392+ ) ,
393+ { :ok , failure_projection } <- EvalSurface . failure_projection ( failure ) do
394+ { :ok ,
395+ % {
396+ failure_receipt: failure_receipt ,
397+ failure_projection: failure_projection
398+ } }
399+ end
400+ end
401+
402+ defp scanner_receipts ( % {
403+ packet: packet ,
404+ compile_receipt: compile_receipt ,
405+ grant: grant ,
406+ admission_receipt: admission_receipt ,
407+ route_request: route_request ,
408+ route_decision: route_decision ,
409+ render_result: render_result ,
410+ model_receipt: model_receipt ,
411+ projections: projections ,
412+ failure_fixtures: failure_fixtures ,
413+ aitrace_facts: aitrace_facts
414+ } ) do
385415 with { :ok , context_scan } <-
386416 ContextABIScanner . scan ( % {
387417 owner_repo: "stack_lab" ,
@@ -393,7 +423,8 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtrip do
393423 route_decisions: [ route_decision ] ,
394424 render_results: [ render_result ] ,
395425 model_invocation_receipts: [ model_receipt ] ,
396- appkit_projections: Map . values ( projections ) ,
426+ failure_receipts: [ failure_fixtures . failure_receipt ] ,
427+ appkit_projections: Map . values ( projections ) ++ [ failure_fixtures . failure_projection ] ,
397428 aitrace_facts: aitrace_facts
398429 } ) ,
399430 { :ok , router_scan } <-
@@ -534,6 +565,7 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtrip do
534565 do: Map . new ( value , fn { k , v } -> { to_string ( k ) , json_safe ( v ) } end )
535566
536567 defp json_safe ( values ) when is_list ( values ) , do: Enum . map ( values , & json_safe / 1 )
568+ defp json_safe ( value ) when is_boolean ( value ) , do: value
537569 defp json_safe ( value ) when is_atom ( value ) , do: Atom . to_string ( value )
538570 defp json_safe ( value ) , do: value
539571end
0 commit comments