pub struct Fact {Show 17 fields
pub id: FactId,
pub text: String,
pub scope: Scope,
pub tier: MemoryTier,
pub category: Option<String>,
pub source: Option<String>,
pub confidence: Option<f32>,
pub valid_from: DateTime<Utc>,
pub invalid_at: Option<DateTime<Utc>>,
pub created_at: DateTime<Utc>,
pub embedding: Vec<f32>,
pub entity_refs: Vec<EntityId>,
pub supersedes: Option<FactId>,
pub superseded_by: Option<FactId>,
pub access_count: u64,
pub last_accessed: Option<DateTime<Utc>>,
pub metadata: Map<String, Value>,
}Expand description
An atomic unit of agent memory.
A Fact is the fundamental record stored by Engram. It carries free-text
content alongside rich provenance metadata, temporal validity bounds, an
optional embedding vector for semantic search, and a supersession chain for
versioned knowledge updates.
Fields§
§id: FactId§text: StringHuman-readable text content of this fact.
scope: ScopeMemory scope this fact belongs to.
tier: MemoryTierRetention tier.
category: Option<String>Optional free-form category tag (e.g. "preference", "task_result").
source: Option<String>Identifier of the source that produced this fact (agent id, tool name, …).
confidence: Option<f32>Confidence score in [0.0, 1.0]. None means “unrated”.
valid_from: DateTime<Utc>When this fact became valid. Defaults to creation time.
invalid_at: Option<DateTime<Utc>>When this fact stops being valid. None means “still valid”.
created_at: DateTime<Utc>§embedding: Vec<f32>Dense embedding vector (e.g. 1536-dim for text-embedding-3-small).
entity_refs: Vec<EntityId>UUIDs of entities this fact references.
supersedes: Option<FactId>ID of the fact this one supersedes (if this is an update).
superseded_by: Option<FactId>ID of the fact that superseded this one (set when this fact is outdated).
access_count: u64How many times this fact has been retrieved.
last_accessed: Option<DateTime<Utc>>When this fact was last retrieved.
metadata: Map<String, Value>Arbitrary extra metadata.
Implementations§
Source§impl Fact
impl Fact
Sourcepub fn new(text: impl Into<String>, scope: Scope) -> Self
pub fn new(text: impl Into<String>, scope: Scope) -> Self
Create a new fact with required fields; all optional fields default to None/empty.
Sourcepub fn is_valid_at(&self, at: DateTime<Utc>) -> bool
pub fn is_valid_at(&self, at: DateTime<Utc>) -> bool
Returns true if this fact was valid at the given point in time.
pub fn with_tier(self, tier: MemoryTier) -> Self
pub fn with_category(self, category: impl Into<String>) -> Self
pub fn with_confidence(self, confidence: f32) -> Self
pub fn with_source(self, source: impl Into<String>) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Fact
impl<'de> Deserialize<'de> for Fact
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Fact
impl RefUnwindSafe for Fact
impl Send for Fact
impl Sync for Fact
impl Unpin for Fact
impl UnsafeUnpin for Fact
impl UnwindSafe for Fact
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more