pub struct Obligation {
pub id: ObligationId,
pub obligation_type: ObligationType,
pub agent: String<32>,
pub action: String<64>,
pub object: Option<String<64>>,
pub state: ObligationState,
pub created_at: u64,
pub deadline_ns: Option<u64>,
pub last_updated: u64,
pub source: Option<String<128>>,
pub priority: u8,
}Expand description
A tracked obligation in the world state.
Fields§
§id: ObligationId§obligation_type: ObligationTypeSDL modality.
agent: String<32>The agent bearing the obligation.
action: String<64>The action the obligation concerns.
object: Option<String<64>>Optional object/patient of the action.
state: ObligationStateCurrent lifecycle state.
created_at: u64Logical time when obligation was created (nanoseconds or counter).
deadline_ns: Option<u64>Deadline for satisfaction. None = no deadline (permanent).
last_updated: u64Logical time of last state transition.
source: Option<String<128>>Policy source citation.
priority: u8Priority (higher = more urgent). Used for escalation ordering.
Implementations§
Source§impl Obligation
impl Obligation
Sourcepub fn new(
id: &str,
obligation_type: ObligationType,
agent: &str,
action: &str,
deadline_ns: Option<u64>,
created_at: u64,
) -> Obligation
pub fn new( id: &str, obligation_type: ObligationType, agent: &str, action: &str, deadline_ns: Option<u64>, created_at: u64, ) -> Obligation
Examples found in repository?
examples/comparison_opa.rs (lines 73-80)
54fn main() {
55 println!("=== URGE side of the OPA comparison ===\n");
56 println!("policy expression: {POLICY}\n");
57
58 let pipeline = GovernancePipeline::new(PipelineConfig::healthcare());
59
60 // Case 1: everything in order — same PERMIT OPA gives.
61 evaluate(&pipeline, true, true);
62
63 // Case 2: review missing. OPA says deny. URGE says deny AND reports the
64 // cross-paradigm finding: the temporal constraint is violated while the
65 // deontic obligation is active — a contradiction, not just a false.
66 evaluate(&pipeline, true, false);
67
68 // Part 2 — what OPA has no vocabulary for at all: the review is an
69 // obligation with a deadline, tracked across time.
70 println!("=== Obligation lifecycle (no OPA equivalent) ===\n");
71 let mut mgr = ObligationManager::new();
72 mgr.register(
73 Obligation::new(
74 "review-P123",
75 ObligationType::Obligatory,
76 "payment-agent",
77 "complete_review",
78 Some(1000), // deadline at t=1000
79 0,
80 ),
81 0,
82 );
83 println!("t=0 obligation registered: complete_review, deadline t=1000");
84 println!(
85 " active={} violated={}",
86 mgr.active_count(),
87 mgr.violated_count()
88 );
89
90 let violations = mgr.process(ObligationEvent::TimeTick { now: 2000 });
91 println!("t=2000 time tick — deadline exceeded, review never happened");
92 for v in &violations {
93 println!(" VIOLATION EVENT: {v:?}");
94 }
95 println!(
96 " active={} violated={}",
97 mgr.active_count(),
98 mgr.violated_count()
99 );
100}Sourcepub fn check_deadline(&mut self, now: u64) -> bool
pub fn check_deadline(&mut self, now: u64) -> bool
Check deadline and transition to Violated if exceeded. Returns true if a violation was newly detected.
Trait Implementations§
Source§impl Clone for Obligation
impl Clone for Obligation
Source§fn clone(&self) -> Obligation
fn clone(&self) -> Obligation
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Obligation
impl RefUnwindSafe for Obligation
impl Send for Obligation
impl Sync for Obligation
impl Unpin for Obligation
impl UnsafeUnpin for Obligation
impl UnwindSafe for Obligation
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