Skip to main content

BiosGovernor

Struct BiosGovernor 

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

BIOS-level governance engine.

Designed for no_std + no_alloc contexts. Uses the pipeline in single-engine routing mode with a shallow AST.

Implementations§

Source§

impl BiosGovernor

Source

pub fn new() -> Self

Examples found in repository?
examples/bios_access.rs (line 15)
12fn main() {
13    println!("=== URGE BIOS Access Control Governance Demo ===\n");
14
15    let gov = BiosGovernor::new();
16
17    struct Request {
18        capability: &'static str,
19        app: &'static str,
20        battery: u8,
21        expected: bool,
22    }
23
24    let requests = &[
25        Request {
26            capability: "camera",
27            app: "app.photos",
28            battery: 80,
29            expected: true,
30        },
31        Request {
32            capability: "camera",
33            app: "app.photos",
34            battery: 3,
35            expected: false,
36        }, // critical battery
37        Request {
38            capability: "gps",
39            app: "app.maps",
40            battery: 25,
41            expected: true,
42        },
43        Request {
44            capability: "gps",
45            app: "app.maps",
46            battery: 2,
47            expected: false,
48        }, // critical battery
49        Request {
50            capability: "microphone",
51            app: "app.voice",
52            battery: 50,
53            expected: true,
54        },
55        Request {
56            capability: "nfc",
57            app: "app.pay",
58            battery: 15,
59            expected: false,
60        }, // below 20% threshold
61        Request {
62            capability: "wifi",
63            app: "app.browser",
64            battery: 90,
65            expected: true,
66        },
67    ];
68
69    println!(
70        "{:<15} {:<15} {:<10} {:<10} {:<8}",
71        "Capability", "App", "Battery%", "Permitted", "Correct?"
72    );
73    println!("{}", "-".repeat(63));
74
75    for req in requests {
76        let permitted = gov.check_access(req.capability, req.app, req.battery);
77        let correct = permitted == req.expected;
78        println!(
79            "{:<15} {:<15} {:<10} {:<10} {:<8}",
80            req.capability,
81            req.app,
82            format!("{}%", req.battery),
83            if permitted { "YES ✓" } else { "NO  ✗" },
84            if correct { "✓" } else { "FAIL" },
85        );
86    }
87
88    println!("\n=== Key properties demonstrated ===");
89    println!("  • Deterministic: same inputs → same output, always");
90    println!("  • Auditability: every decision has a logic trace");
91    println!("  • No inference: pure formal logic, no learned weights");
92    println!("  • Embedded-capable: no heap allocation in access-control path");
93    println!("  • <1µs decision time on ARM Cortex-M4 (est.)");
94    println!("\nThis is the 'BIOS governance chip' concept:");
95    println!("  The same engine governs a medical device AND a healthcare ERP.");
96    println!("  Same paradigms. Same Unicode dictionary. Same audit trail format.");
97    println!("  Different policies. Universal governance layer.");
98}
Source

pub fn check_access( &self, capability: &str, _app_id: &str, battery_percent: u8, ) -> bool

Check whether an application is permitted to access a device capability.

Decision factors:

  • User permission granted for this capability
  • Battery level sufficient (some capabilities denied when battery < threshold)
  • Device not in restricted mode
  • Application not on blocklist

Returns true if access is permitted.

Examples found in repository?
examples/bios_access.rs (line 76)
12fn main() {
13    println!("=== URGE BIOS Access Control Governance Demo ===\n");
14
15    let gov = BiosGovernor::new();
16
17    struct Request {
18        capability: &'static str,
19        app: &'static str,
20        battery: u8,
21        expected: bool,
22    }
23
24    let requests = &[
25        Request {
26            capability: "camera",
27            app: "app.photos",
28            battery: 80,
29            expected: true,
30        },
31        Request {
32            capability: "camera",
33            app: "app.photos",
34            battery: 3,
35            expected: false,
36        }, // critical battery
37        Request {
38            capability: "gps",
39            app: "app.maps",
40            battery: 25,
41            expected: true,
42        },
43        Request {
44            capability: "gps",
45            app: "app.maps",
46            battery: 2,
47            expected: false,
48        }, // critical battery
49        Request {
50            capability: "microphone",
51            app: "app.voice",
52            battery: 50,
53            expected: true,
54        },
55        Request {
56            capability: "nfc",
57            app: "app.pay",
58            battery: 15,
59            expected: false,
60        }, // below 20% threshold
61        Request {
62            capability: "wifi",
63            app: "app.browser",
64            battery: 90,
65            expected: true,
66        },
67    ];
68
69    println!(
70        "{:<15} {:<15} {:<10} {:<10} {:<8}",
71        "Capability", "App", "Battery%", "Permitted", "Correct?"
72    );
73    println!("{}", "-".repeat(63));
74
75    for req in requests {
76        let permitted = gov.check_access(req.capability, req.app, req.battery);
77        let correct = permitted == req.expected;
78        println!(
79            "{:<15} {:<15} {:<10} {:<10} {:<8}",
80            req.capability,
81            req.app,
82            format!("{}%", req.battery),
83            if permitted { "YES ✓" } else { "NO  ✗" },
84            if correct { "✓" } else { "FAIL" },
85        );
86    }
87
88    println!("\n=== Key properties demonstrated ===");
89    println!("  • Deterministic: same inputs → same output, always");
90    println!("  • Auditability: every decision has a logic trace");
91    println!("  • No inference: pure formal logic, no learned weights");
92    println!("  • Embedded-capable: no heap allocation in access-control path");
93    println!("  • <1µs decision time on ARM Cortex-M4 (est.)");
94    println!("\nThis is the 'BIOS governance chip' concept:");
95    println!("  The same engine governs a medical device AND a healthcare ERP.");
96    println!("  Same paradigms. Same Unicode dictionary. Same audit trail format.");
97    println!("  Different policies. Universal governance layer.");
98}
Source

pub fn evaluate_simple(&self, _capability: SemanticClass, subject: bool) -> bool

Evaluate a pre-classified governance expression for embedded use.

Returns only the boolean permit/deny — no heap allocation.

Trait Implementations§

Source§

impl Default for BiosGovernor

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.