Skip to main content

sochdb_memory/
fact.rs

1use serde::{Deserialize, Serialize};
2use sochdb_core::knowledge_object::BitemporalCoord;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub struct FactId(pub u64);
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
8pub enum FactKind {
9    Extracted,
10    Inferred,
11    UserAsserted,
12}
13
14/// Fact edge with bi-temporal coordinates. Invalidation closes `valid_to`.
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct FactEdge {
17    pub id: FactId,
18    pub episode_id: u64,
19    pub subject: String,
20    pub predicate: String,
21    pub object: String,
22    pub kind: FactKind,
23    pub temporal: BitemporalCoord,
24}
25
26impl FactEdge {
27    pub fn is_valid_at(&self, tau: u64) -> bool {
28        self.temporal.valid_at(tau)
29    }
30
31    pub fn invalidate(&mut self, t_invalid: u64) {
32        self.temporal.close_valid_time(t_invalid);
33    }
34}