pub struct MemoryNode {Show 17 fields
pub id: MemoryId,
pub agent_id: AgentId,
pub user_id: UserId,
pub memory_type: MemoryType,
pub embedding: Embedding,
pub content: String,
pub created_at: Timestamp,
pub accessed_at: Timestamp,
pub access_count: u32,
pub salience: Salience,
pub confidence: Confidence,
pub space_id: SpaceId,
pub attributes: HashMap<String, AttributeValue>,
pub tags: Vec<String>,
pub valid_from: Option<Timestamp>,
pub valid_until: Option<Timestamp>,
pub context: Option<String>,
}Expand description
A memory node: the atomic unit of knowledge in MenteDB.
Combines vector embeddings, graph connections, temporal properties, and flexible attributes in a single primitive.
Fields§
§id: MemoryIdUnique identifier.
agent_id: AgentIdThe agent that owns this memory.
user_id: UserIdThe end user that owns this memory (orthogonal to agent_id).
A memory belongs to both a user and an agent; a scoped query sees it
only when it is visible on both axes. Defaults to the nil (shared)
user, both for new() and for data written before this field existed.
memory_type: MemoryTypeMemory type classification.
embedding: EmbeddingEmbedding vector for semantic similarity search.
content: StringHuman-readable content.
created_at: TimestampWhen this memory was created.
accessed_at: TimestampWhen this memory was last accessed.
access_count: u32How many times this memory has been accessed.
salience: SalienceCurrent salience score (decays over time).
confidence: ConfidenceConfidence in this memory’s accuracy.
space_id: SpaceIdThe memory space this belongs to.
attributes: HashMap<String, AttributeValue>Flexible key-value attributes.
Tags for bitmap indexing.
valid_from: Option<Timestamp>When this fact became true in the real world. None means valid since creation.
valid_until: Option<Timestamp>When this fact stopped being true. None means still valid.
context: Option<String>Optional retrieval context, prepended to the content when the memory is indexed (BM25) and embedded, but NOT stored as part of the content the caller reads back. This is the contextual-retrieval hook: a short situating blurb the caller generates (for example “From a thread about the billing migration”) that makes an otherwise-ambiguous memory findable by terms it never literally contains. None indexes the content as-is.
Implementations§
Source§impl MemoryNode
impl MemoryNode
Sourcepub fn new(
agent_id: AgentId,
memory_type: MemoryType,
content: String,
embedding: Embedding,
) -> Self
pub fn new( agent_id: AgentId, memory_type: MemoryType, content: String, embedding: Embedding, ) -> Self
Create a new memory node with the given content and embedding.
Sourcepub fn with_user_id(self, user_id: UserId) -> Self
pub fn with_user_id(self, user_id: UserId) -> Self
Set the owning end user, returning the node (builder style).
Parallels the agent_id constructor argument on the orthogonal user
axis. Leave unset (nil) for shared/global memories.
Sourcepub fn with_context(self, context: impl Into<String>) -> Self
pub fn with_context(self, context: impl Into<String>) -> Self
Attach retrieval context (builder style). See MemoryNode::context.
Sourcepub fn indexed_text(&self) -> Cow<'_, str>
pub fn indexed_text(&self) -> Cow<'_, str>
The text to index and embed: the context (when present) prefixed to the
content, so retrieval matches on both while the stored content stays
exactly what the caller wrote.
Source§impl MemoryNode
impl MemoryNode
Sourcepub fn is_valid_at(&self, at: Timestamp) -> bool
pub fn is_valid_at(&self, at: Timestamp) -> bool
Returns true if this memory is temporally valid at the given timestamp.
Sourcepub fn invalidate(&mut self, at: Timestamp)
pub fn invalidate(&mut self, at: Timestamp)
Mark this memory as no longer valid.
Sourcepub fn is_invalidated(&self) -> bool
pub fn is_invalidated(&self) -> bool
Returns true if this memory has been invalidated.
Trait Implementations§
Source§impl Clone for MemoryNode
impl Clone for MemoryNode
Source§fn clone(&self) -> MemoryNode
fn clone(&self) -> MemoryNode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more