pub struct Memory {Show 13 fields
pub id: Ulid,
pub memory_type: MemoryType,
pub vector: Vec<f32>,
pub content: String,
pub metadata: Map<String, Value>,
pub agent_id: String,
pub session_id: Option<String>,
pub scope: Scope,
pub created_at: i64,
pub accessed_at: i64,
pub access_count: u32,
pub importance: f32,
pub ttl_secs: Option<i64>,
}Expand description
A single memory entry.
Fields§
§id: UlidTime-sortable unique ID.
memory_type: MemoryTypeCognitive category of this memory.
vector: Vec<f32>Embedding of content.
content: StringThe actual text/data of the memory.
metadata: Map<String, Value>Free-form structured metadata.
agent_id: StringWhich agent created this memory.
session_id: Option<String>Which session produced it (relevant for episodic memory).
scope: ScopeVisibility scope (private to its agent, or shared).
created_at: i64Unix seconds at creation.
accessed_at: i64Unix seconds of the most recent retrieval. Updated by recall.
access_count: u32How many times this memory has been retrieved.
importance: f32Importance in [0.0, 1.0]; higher importance resists decay.
ttl_secs: Option<i64>Optional lifetime in seconds. After expiry the memory is skipped by
recall and removed by compact.
Implementations§
Source§impl Memory
impl Memory
Sourcepub fn new(
content: impl Into<String>,
memory_type: MemoryType,
vector: Vec<f32>,
) -> Self
pub fn new( content: impl Into<String>, memory_type: MemoryType, vector: Vec<f32>, ) -> Self
Create a new memory with sensible defaults. The ID and timestamps are
assigned now; tune the rest with the with_* builders.
Sourcepub fn with_agent(self, agent_id: impl Into<String>) -> Self
pub fn with_agent(self, agent_id: impl Into<String>) -> Self
Set the owning agent.
Sourcepub fn with_session(self, session_id: impl Into<String>) -> Self
pub fn with_session(self, session_id: impl Into<String>) -> Self
Set the session ID.
Sourcepub fn with_importance(self, importance: f32) -> Self
pub fn with_importance(self, importance: f32) -> Self
Set the importance score (clamped to [0,1]).
Sourcepub fn with_scope(self, scope: Scope) -> Self
pub fn with_scope(self, scope: Scope) -> Self
Set the visibility scope.
Sourcepub fn with_meta(self, key: impl Into<String>, value: Value) -> Self
pub fn with_meta(self, key: impl Into<String>, value: Value) -> Self
Attach a metadata key/value pair.
Sourcepub fn is_expired(&self, now: i64) -> bool
pub fn is_expired(&self, now: i64) -> bool
True if the memory’s TTL has elapsed as of now.
Sourcepub fn scaffold_manifest(dimensions: usize) -> Self
pub fn scaffold_manifest(dimensions: usize) -> Self
Build the canonical scaffold manifest for a freshly-initialised
database. This is the default “I am a brand-new MNemo file” memory
inserted by mnemo init (and surfaced by mnemo about) so every new
database is self-describing from birth — no opt-in step required.
The scaffold is a placeholder: the vector is all-zeros (it doesn’t
pretend to carry semantic content), and metadata.scaffold = true
marks it as auto-generated so tooling and humans can tell it apart
from a hand-written manifest. The expected workflow is for the file’s
author to replace this memory with one that records the project’s
actual embedder, agent_id default, and conventions.
See crate::Mnemo::about for the rest of the convention.