Skip to main content

MemoryNode

Struct MemoryNode 

Source
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: MemoryId

Unique identifier.

§agent_id: AgentId

The agent that owns this memory.

§user_id: UserId

The 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: MemoryType

Memory type classification.

§embedding: Embedding

Embedding vector for semantic similarity search.

§content: String

Human-readable content.

§created_at: Timestamp

When this memory was created.

§accessed_at: Timestamp

When this memory was last accessed.

§access_count: u32

How many times this memory has been accessed.

§salience: Salience

Current salience score (decays over time).

§confidence: Confidence

Confidence in this memory’s accuracy.

§space_id: SpaceId

The memory space this belongs to.

§attributes: HashMap<String, AttributeValue>

Flexible key-value attributes.

§tags: Vec<String>

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

Source

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.

Source

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.

Source

pub fn with_context(self, context: impl Into<String>) -> Self

Attach retrieval context (builder style). See MemoryNode::context.

Source

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

Source

pub fn is_valid_at(&self, at: Timestamp) -> bool

Returns true if this memory is temporally valid at the given timestamp.

Source

pub fn invalidate(&mut self, at: Timestamp)

Mark this memory as no longer valid.

Source

pub fn is_invalidated(&self) -> bool

Returns true if this memory has been invalidated.

Trait Implementations§

Source§

impl Clone for MemoryNode

Source§

fn clone(&self) -> MemoryNode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MemoryNode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MemoryNode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.