Skip to content

Commit 4db8576

Browse files
committed
Add failure gate fixtures to router proof
1 parent 2c9b939 commit 4db8576

13 files changed

Lines changed: 350 additions & 141 deletions

File tree

contract_artifacts.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ artifacts:
99
producer_repo_ref: repo://nshkrdotcom/ground_plane
1010
producer_path: /home/home/p/g/n/ground_plane
1111
source_ref: main
12-
source_sha: aab153c1b48b06281d5f13487cdcb3dac39e5cb8
12+
source_sha: e47d4b47c711f5196303dc0e98e40162098bb63d
1313
build_command: mix ci
1414
status: deprecated
1515
successor: ground_plane_contracts
@@ -37,7 +37,7 @@ artifacts:
3737
producer_repo_ref: repo://nshkrdotcom/ground_plane
3838
producer_path: /home/home/p/g/n/ground_plane
3939
source_ref: main
40-
source_sha: aab153c1b48b06281d5f13487cdcb3dac39e5cb8
40+
source_sha: e47d4b47c711f5196303dc0e98e40162098bb63d
4141
build_command: mix ci
4242
status: stable
4343
consumers:

examples/context_abi_roundtrip/lib/stack_lab/examples/context_abi_roundtrip.ex

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,17 @@ defmodule StackLab.Examples.ContextABIRoundtrip do
8585
{:ok, aitrace_facts} <-
8686
aitrace_facts(packet, grant, route_decision, model_receipt, projections),
8787
{:ok, scanner_receipts} <-
88-
scanner_receipts(
89-
packet,
90-
compile_receipt,
91-
grant,
92-
admission_receipt,
93-
route_decision,
94-
render_result,
95-
model_receipt,
96-
projections,
97-
aitrace_facts
98-
) do
88+
scanner_receipts(%{
89+
packet: packet,
90+
compile_receipt: compile_receipt,
91+
grant: grant,
92+
admission_receipt: admission_receipt,
93+
route_decision: route_decision,
94+
render_result: render_result,
95+
model_receipt: model_receipt,
96+
projections: projections,
97+
aitrace_facts: aitrace_facts
98+
}) do
9999
{:ok,
100100
%Receipt{
101101
receipt_ref: receipt_ref(packet, model_receipt),
@@ -381,17 +381,17 @@ defmodule StackLab.Examples.ContextABIRoundtrip do
381381
end
382382
end
383383

384-
defp scanner_receipts(
385-
packet,
386-
compile_receipt,
387-
grant,
388-
admission_receipt,
389-
route_decision,
390-
render_result,
391-
model_receipt,
392-
projections,
393-
aitrace_facts
394-
) do
384+
defp scanner_receipts(%{
385+
packet: packet,
386+
compile_receipt: compile_receipt,
387+
grant: grant,
388+
admission_receipt: admission_receipt,
389+
route_decision: route_decision,
390+
render_result: render_result,
391+
model_receipt: model_receipt,
392+
projections: projections,
393+
aitrace_facts: aitrace_facts
394+
}) do
395395
with {:ok, context_scan} <-
396396
ContextABIScanner.scan(%{
397397
owner_repo: "stack_lab",

examples/nshkr_router_fabric_roundtrip/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
`stack_lab_nshkr_router_fabric_roundtrip` proves the first NSHKR router MVP:
44
an admitted Context ABI packet is routed through
55
`Trinity.MezzanineRouterAdapter`, rendered through OuterBrain, invoked through
6-
the Jido fake runtime, recorded in AITrace, and projected through AppKit.
6+
the Jido fake runtime, recorded in AITrace, projected through AppKit, and
7+
checked with a bounded eval-failure receipt fixture.
78

89
The proof is deterministic and provider-free. It does not prove live-provider
910
quality, distributed placement, GEPA optimization, or production persistence.

examples/nshkr_router_fabric_roundtrip/lib/stack_lab/examples/nshkr_router_fabric_roundtrip.ex

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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
539571
end

examples/nshkr_router_fabric_roundtrip/mix.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ defmodule StackLab.NSHKRRouterFabricRoundtrip.MixProject do
2727
defp deps do
2828
[
2929
{:app_kit_context_surface, path: "../../../app_kit/core/context_surface"},
30+
{:app_kit_eval_surface, path: "../../../app_kit/core/eval_surface"},
3031
{:outer_brain_context_abi, path: "../../../outer_brain/core/context_abi", override: true},
3132
{:outer_brain_prompting,
3233
path: "../../../outer_brain/core/outer_brain_prompting", override: true},
@@ -36,6 +37,7 @@ defmodule StackLab.NSHKRRouterFabricRoundtrip.MixProject do
3637
path: "../../../mezzanine/core/context_packet_engine", override: true},
3738
{:mezzanine_ai_execution_engine,
3839
path: "../../../mezzanine/core/ai_execution_engine", override: true},
40+
{:mezzanine_eval_engine, path: "../../../mezzanine/core/eval_engine"},
3941
{:jido_model_invocation_contracts,
4042
path: "../../../jido_integration/core/model_invocation_contracts", override: true},
4143
{:jido_inference_runtime, path: "../../../jido_integration/core/inference_runtime"},

examples/nshkr_router_fabric_roundtrip/test/stack_lab/examples/nshkr_router_fabric_roundtrip_test.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtripTest do
1414
assert receipt.selected_route_kind == :trinity_coordinated
1515
assert receipt.selected_model_profile_ref == "model-profile://fixture/worker"
1616
assert receipt.trinity_selected_role_ref == "role://router-fabric/worker"
17+
18+
assert [%{failure_family: :eval, safe_action: :review_eval_evidence}] =
19+
receipt.failure_receipts
20+
21+
assert ["failure://mezzanine/" <> _] = receipt.failure_projection_refs
1722
assert receipt.scanner_receipts.context_abi.status == :pass
1823
assert receipt.scanner_receipts.router_fabric.status == :pass
1924
assert receipt.scanner_receipts.coordination_fabric.status == :pass
@@ -27,6 +32,9 @@ defmodule StackLab.Examples.NSHKRRouterFabricRoundtripTest do
2732

2833
assert json =~ "\"status\": \"pass\""
2934
assert json =~ "\"selected_route_kind\": \"trinity_coordinated\""
35+
assert json =~ "\"failure_family\": \"eval\""
36+
assert json =~ "\"failure_projection_refs\""
37+
assert json =~ "\"retryable?\": false"
3038
assert json =~ "Trinity.MezzanineRouterAdapter" or json =~ "router_fabric"
3139
refute json =~ "raw_prompt"
3240
refute json =~ "provider_payload\":"

examples/trinity_platform_roundtrip/lib/stack_lab/examples/trinity_platform_roundtrip.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ defmodule StackLab.Examples.TRINITYPlatformRoundtrip do
9696
budget_ref: "budget/role/worker",
9797
context_budget_ref: "context/role/worker",
9898
handoff_policy_ref: "handoff/role/worker",
99-
appkit_projection_ref: "appkit/coordination/worker",
99+
projection_ref: "appkit/coordination/worker",
100100
gepa_target_refs: ["gepa/target/role_prompt"]
101101
}
102102
],

proof_matrix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ proofs:
451451
- admitted Context ABI packet is routed through the concrete TRINITY Mezzanine router adapter
452452
- Mezzanine route decision carries route policy, authority, selected model profile, verifier, fallback plan, and TRINITY route-plan refs
453453
- OuterBrain render refs are carried into Jido Integration fake model invocation without raw prompt or provider payload leakage
454+
- Mezzanine eval failure reasons are mapped to bounded owner-local failure receipts and AppKit safe projections
454455
- AppKit projects context packet, route decision, model invocation, and eval verdict refs through product-safe DTOs
455456
- AITrace emits bounded context, route, model, and eval facts
456457
- StackLab context ABI, router fabric, coordination fabric, and model inference scanners pass on the assembled receipt

support/context_abi_scanner/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
Scanner receipts for the fugu Context ABI path.
44

55
This package validates that context packets, authority grants, Mezzanine
6-
admission receipts, render handoffs, model invocation receipts, AppKit
7-
projections, and AITrace facts stay ref-only and tenant-consistent.
6+
admission receipts, render handoffs, model invocation receipts, optional
7+
owner-local failure receipts, AppKit projections, and AITrace facts stay
8+
ref-only and tenant-consistent.
89

910
It is a StackLab proof package. It does not own Context ABI semantics; those
1011
remain in OuterBrain, Citadel, Mezzanine, Jido Integration, AppKit, and

0 commit comments

Comments
 (0)