1use urge_core::engine::{ContextValue, EvalContext};
12use urge_meta::{GovernancePipeline, PipelineConfig};
13
14struct AgentAction {
16 agent_id: &'static str,
17 action: &'static str,
18 is_authorized: bool,
19 audit_running: bool,
20 governance_expr: &'static str,
22}
23
24fn main() {
25 println!("=== URGE Agent Governance Gate Demo ===\n");
26
27 let pipeline = GovernancePipeline::new(PipelineConfig::healthcare());
28
29 let actions = &[
30 AgentAction {
31 agent_id: "billing-agent",
32 action: "submit_claim",
33 is_authorized: true,
34 audit_running: true,
35 governance_expr: "must authorized and always audit_running",
36 },
37 AgentAction {
38 agent_id: "rx-agent",
39 action: "prescribe_medication",
40 is_authorized: false, audit_running: true,
42 governance_expr: "must authorized and must verified_order",
43 },
44 AgentAction {
45 agent_id: "intake-agent",
46 action: "access_phi",
47 is_authorized: true,
48 audit_running: false, governance_expr: "must authorized and always audit_running",
50 },
51 AgentAction {
52 agent_id: "scheduler-agent",
53 action: "book_appointment",
54 is_authorized: true,
55 audit_running: true,
56 governance_expr: "must authorized",
57 },
58 ];
59
60 println!("{:<20} {:<25} {:<12}", "Agent", "Action", "Decision");
61 println!("{}", "-".repeat(60));
62
63 for action in actions {
64 let slots: &[(&'static str, ContextValue)] = &[
65 ("authorized", ContextValue::Bool(action.is_authorized)),
66 ("audit_running", ContextValue::Bool(action.audit_running)),
67 ("verified_order", ContextValue::Bool(false)), ];
69
70 let ctx = EvalContext {
71 slots,
72 logical_time: 0,
73 depth_limit: 16,
74 };
75
76 let verdict = pipeline.evaluate_str(action.governance_expr, &ctx);
77
78 println!(
79 "{:<20} {:<25} {}",
80 action.agent_id,
81 action.action,
82 if verdict.valid {
83 "PERMITTED ✓"
84 } else {
85 "DENIED ✗"
86 },
87 );
88
89 if !verdict.valid {
90 println!(
91 " Confidence: {:.0}% | Conflicts: {} | Paradigms: {}",
92 verdict.confidence.as_f32() * 100.0,
93 verdict.cross_validation.conflicts_detected,
94 verdict.paradigms_evaluated.iter().count(),
95 );
96 println!(" Formal: {}", verdict.formal_notation);
97 println!(" Trace ({} steps):", verdict.trace.len());
98 for entry in verdict.trace.entries.iter().take(3) {
99 println!(" [{:?}] {:?}", entry.stage, entry.description);
100 }
101 }
102 }
103
104 println!("\n=== Agent governance summary ===");
105 println!(" Every agent action is gated by formal logic, not behavioral alignment.");
106 println!(" The governance layer is: deterministic, auditable, sub-millisecond.");
107 println!(" No LLM inference involved in permit/deny decisions.");
108 println!(" This is the URGE architecture operating as designed.");
109}