Skip to main content

AuditLog

Struct AuditLog 

Source
pub struct AuditLog { /* private fields */ }
Expand description

Append-only governance audit log.

Implementations§

Source§

impl AuditLog

Source

pub fn new() -> Self

Source

pub fn record( &mut self, expression: &str, verdict: &Verdict, timestamp_ns: u64, correlation_id: Option<&str>, ) -> u64

Record a governance decision.

Source

pub fn entries_since(&self, after_seq: u64) -> &[AuditEntry]

Returns all entries since after_seq (exclusive).

Source

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}
Source

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}
Source

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§

Source§

impl Default for AuditLog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.