pub struct AuditLog { /* private fields */ }Expand description
Append-only governance audit log.
Implementations§
Source§impl AuditLog
impl AuditLog
pub fn new() -> Self
Sourcepub fn record(
&mut self,
expression: &str,
verdict: &Verdict,
timestamp_ns: u64,
correlation_id: Option<&str>,
) -> u64
pub fn record( &mut self, expression: &str, verdict: &Verdict, timestamp_ns: u64, correlation_id: Option<&str>, ) -> u64
Record a governance decision.
Sourcepub fn entries_since(&self, after_seq: u64) -> &[AuditEntry]
pub fn entries_since(&self, after_seq: u64) -> &[AuditEntry]
Returns all entries since after_seq (exclusive).
Sourcepub fn total_entries(&self) -> u64
pub fn total_entries(&self) -> u64
Examples found in repository?
examples/healthcare_consent.rs (line 70)
14fn main() {
15 println!("=== URGE Healthcare Consent Governance Demo ===\n");
16
17 let mut gov = HealthcareGovernor::new();
18
19 // ── Step 1: Patient admission triggers consent obligation ─────────────
20 let _now_ns: u64 = 0; // t = 0
21 let deadline_24h_ns: u64 = 86_400_000_000_000; // 24h in nanoseconds
22
23 println!("[T+0] Patient P123 admitted. Registering consent obligation...");
24 gov.require_consent("P123", "nurse_007", deadline_24h_ns);
25
26 let stats = gov.stats();
27 println!(
28 " Active obligations: {}, Violated: {}",
29 stats.active_obligations, stats.violated_obligations
30 );
31
32 // ── Step 2: PHI access check at T+1h ─────────────────────────────────
33 println!("\n[T+1h] nurse_007 requesting PHI access for P123...");
34 let result = gov.check_phi_access(
35 "nurse_007",
36 "P123",
37 true, // is_authorized
38 true, // is_authenticated
39 true, // audit_active
40 );
41 match result {
42 Ok(_) => println!(" ✓ PHI access PERMITTED"),
43 Err(e) => println!(" ✗ PHI access DENIED: {}", e),
44 }
45
46 // ── Step 3: Advance time past deadline without consent ────────────────
47 let past_deadline_ns: u64 = deadline_24h_ns + 1_000_000_000; // 24h + 1s
48 println!("\n[T+24h+1s] Advancing time past consent deadline...");
49 let violations = gov.tick(past_deadline_ns);
50
51 if violations.is_empty() {
52 println!(" No violations detected.");
53 } else {
54 for v in &violations {
55 println!(" ✗ VIOLATION: {:?}", v);
56 }
57 }
58
59 let stats = gov.stats();
60 println!(
61 " Active obligations: {}, Violated: {}",
62 stats.active_obligations, stats.violated_obligations
63 );
64
65 // ── Step 4: Show audit log ────────────────────────────────────────────
66 println!("\n--- Audit Log Summary ---");
67 let log = gov.audit_log();
68 println!(
69 " Total entries: {}, Permitted: {}, Denied: {}",
70 log.total_entries(),
71 log.permitted_count(),
72 log.denied_count(),
73 );
74
75 println!("\n=== Demo complete ===");
76 println!("\nThis trace is the compliance audit trail. Every decision is");
77 println!("anchored to a formal logic evaluation with a full paradigm trace.");
78 println!("See verdict.formal_notation and verdict.trace for full detail.");
79}Sourcepub fn permitted_count(&self) -> usize
pub fn permitted_count(&self) -> usize
Examples found in repository?
examples/healthcare_consent.rs (line 71)
14fn main() {
15 println!("=== URGE Healthcare Consent Governance Demo ===\n");
16
17 let mut gov = HealthcareGovernor::new();
18
19 // ── Step 1: Patient admission triggers consent obligation ─────────────
20 let _now_ns: u64 = 0; // t = 0
21 let deadline_24h_ns: u64 = 86_400_000_000_000; // 24h in nanoseconds
22
23 println!("[T+0] Patient P123 admitted. Registering consent obligation...");
24 gov.require_consent("P123", "nurse_007", deadline_24h_ns);
25
26 let stats = gov.stats();
27 println!(
28 " Active obligations: {}, Violated: {}",
29 stats.active_obligations, stats.violated_obligations
30 );
31
32 // ── Step 2: PHI access check at T+1h ─────────────────────────────────
33 println!("\n[T+1h] nurse_007 requesting PHI access for P123...");
34 let result = gov.check_phi_access(
35 "nurse_007",
36 "P123",
37 true, // is_authorized
38 true, // is_authenticated
39 true, // audit_active
40 );
41 match result {
42 Ok(_) => println!(" ✓ PHI access PERMITTED"),
43 Err(e) => println!(" ✗ PHI access DENIED: {}", e),
44 }
45
46 // ── Step 3: Advance time past deadline without consent ────────────────
47 let past_deadline_ns: u64 = deadline_24h_ns + 1_000_000_000; // 24h + 1s
48 println!("\n[T+24h+1s] Advancing time past consent deadline...");
49 let violations = gov.tick(past_deadline_ns);
50
51 if violations.is_empty() {
52 println!(" No violations detected.");
53 } else {
54 for v in &violations {
55 println!(" ✗ VIOLATION: {:?}", v);
56 }
57 }
58
59 let stats = gov.stats();
60 println!(
61 " Active obligations: {}, Violated: {}",
62 stats.active_obligations, stats.violated_obligations
63 );
64
65 // ── Step 4: Show audit log ────────────────────────────────────────────
66 println!("\n--- Audit Log Summary ---");
67 let log = gov.audit_log();
68 println!(
69 " Total entries: {}, Permitted: {}, Denied: {}",
70 log.total_entries(),
71 log.permitted_count(),
72 log.denied_count(),
73 );
74
75 println!("\n=== Demo complete ===");
76 println!("\nThis trace is the compliance audit trail. Every decision is");
77 println!("anchored to a formal logic evaluation with a full paradigm trace.");
78 println!("See verdict.formal_notation and verdict.trace for full detail.");
79}Sourcepub fn denied_count(&self) -> usize
pub fn denied_count(&self) -> usize
Examples found in repository?
examples/healthcare_consent.rs (line 72)
14fn main() {
15 println!("=== URGE Healthcare Consent Governance Demo ===\n");
16
17 let mut gov = HealthcareGovernor::new();
18
19 // ── Step 1: Patient admission triggers consent obligation ─────────────
20 let _now_ns: u64 = 0; // t = 0
21 let deadline_24h_ns: u64 = 86_400_000_000_000; // 24h in nanoseconds
22
23 println!("[T+0] Patient P123 admitted. Registering consent obligation...");
24 gov.require_consent("P123", "nurse_007", deadline_24h_ns);
25
26 let stats = gov.stats();
27 println!(
28 " Active obligations: {}, Violated: {}",
29 stats.active_obligations, stats.violated_obligations
30 );
31
32 // ── Step 2: PHI access check at T+1h ─────────────────────────────────
33 println!("\n[T+1h] nurse_007 requesting PHI access for P123...");
34 let result = gov.check_phi_access(
35 "nurse_007",
36 "P123",
37 true, // is_authorized
38 true, // is_authenticated
39 true, // audit_active
40 );
41 match result {
42 Ok(_) => println!(" ✓ PHI access PERMITTED"),
43 Err(e) => println!(" ✗ PHI access DENIED: {}", e),
44 }
45
46 // ── Step 3: Advance time past deadline without consent ────────────────
47 let past_deadline_ns: u64 = deadline_24h_ns + 1_000_000_000; // 24h + 1s
48 println!("\n[T+24h+1s] Advancing time past consent deadline...");
49 let violations = gov.tick(past_deadline_ns);
50
51 if violations.is_empty() {
52 println!(" No violations detected.");
53 } else {
54 for v in &violations {
55 println!(" ✗ VIOLATION: {:?}", v);
56 }
57 }
58
59 let stats = gov.stats();
60 println!(
61 " Active obligations: {}, Violated: {}",
62 stats.active_obligations, stats.violated_obligations
63 );
64
65 // ── Step 4: Show audit log ────────────────────────────────────────────
66 println!("\n--- Audit Log Summary ---");
67 let log = gov.audit_log();
68 println!(
69 " Total entries: {}, Permitted: {}, Denied: {}",
70 log.total_entries(),
71 log.permitted_count(),
72 log.denied_count(),
73 );
74
75 println!("\n=== Demo complete ===");
76 println!("\nThis trace is the compliance audit trail. Every decision is");
77 println!("anchored to a formal logic evaluation with a full paradigm trace.");
78 println!("See verdict.formal_notation and verdict.trace for full detail.");
79}Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuditLog
impl RefUnwindSafe for AuditLog
impl Send for AuditLog
impl Sync for AuditLog
impl Unpin for AuditLog
impl UnsafeUnpin for AuditLog
impl UnwindSafe for AuditLog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more