pub struct Memory {
pub metadata: MemoryMetadata,
pub content: String,
pub embedding: Option<Vec<f32>>,
}Expand description
A complete memory entry: metadata + content.
Fields§
§metadata: MemoryMetadataMetadata
content: StringContent (text, JSON, or binary encoded as base64)
embedding: Option<Vec<f32>>Optional embedding vector (stored separately in Embeddings galaxy)
Implementations§
Source§impl Memory
impl Memory
Set tags on this memory.
Sourcepub const fn with_importance(self, importance: f32) -> Self
pub const fn with_importance(self, importance: f32) -> Self
Set importance score (0.0 to 1.0).
Sourcepub const fn with_memory_type(self, memory_type: MemoryType) -> Self
pub const fn with_memory_type(self, memory_type: MemoryType) -> Self
Set memory type.
Sourcepub const fn with_emotional_valence(self, valence: f32, weight: f32) -> Self
pub const fn with_emotional_valence(self, valence: f32, weight: f32) -> Self
Set emotional valence (-1.0 to 1.0) and weight (0.0 to 1.0).
Sourcepub const fn with_protection(self, protected: bool) -> Self
pub const fn with_protection(self, protected: bool) -> Self
Mark this memory as protected from forgetting.
Sourcepub fn with_source(self, source: String, trust: f32) -> Self
pub fn with_source(self, source: String, trust: f32) -> Self
Set provenance source and trust score.
Sourcepub const fn with_half_life_days(self, days: f32) -> Self
pub const fn with_half_life_days(self, days: f32) -> Self
Set per-memory decay half-life in days.
Sourcepub const fn with_neuro_score(self, score: f32) -> Self
pub const fn with_neuro_score(self, score: f32) -> Self
Set initial neuro_score (0.0 to 1.0).
Sourcepub const fn with_novelty_score(self, score: f32) -> Self
pub const fn with_novelty_score(self, score: f32) -> Self
Set initial novelty_score (0.0 to 1.0).
Sourcepub const fn with_privacy(self, is_private: bool, model_exclude: bool) -> Self
pub const fn with_privacy(self, is_private: bool, model_exclude: bool) -> Self
Set privacy flags.
Sourcepub fn transition_tier(&mut self, to: Tier) -> Result<(), CoreError>
pub fn transition_tier(&mut self, to: Tier) -> Result<(), CoreError>
Transition the serving tier (MEMORY_TYPOLOGY_V8.md §6).
The dream cycle is the ONLY legitimate caller — tier moves are a
sleep-time lifecycle decision, never a request-path one (no tool
accepts a tier argument; memory.update whitelists its fields).
Legal moves:
Working → Episodic— age-out of the current-session working setEpisodic → Semantic— consolidation promotionWorking | Episodic | Semantic → Archival— decay-outArchival → Episodic— promotion on read (warm re-serving)
Anything else — demotion out of a consolidated or sealed state, skipping ahead on the ladder — is refused. One move per call: the dream cycle paces the ladder one step per cycle.
Sourcepub fn transition_validity(
&mut self,
transition: MemoryTransition,
) -> Result<(), ValidityTransitionError>
pub fn transition_validity( &mut self, transition: MemoryTransition, ) -> Result<(), ValidityTransitionError>
Transition the lifecycle validity (V8 Slice B, D1+D2).
The dream cycle’s validity_sweep is the ONLY legitimate caller —
validity moves are a sleep-time lifecycle decision, never a
request-path one (no tool accepts a validity argument).
Legality is exactly wm_core::episodic::ValidityState::transition;
this wrapper only supplies the record id so callers cannot
fabricate a mismatched identity.
Sourcepub fn with_agent(self, agent_id: String, version: u64) -> Self
pub fn with_agent(self, agent_id: String, version: u64) -> Self
Set agent identity and version.
Sourcepub fn with_embedding(self, embedding: Vec<f32>) -> Self
pub fn with_embedding(self, embedding: Vec<f32>) -> Self
Attach an embedding vector.
Sourcepub fn record_access(&mut self)
pub fn record_access(&mut self)
Record an access (updates accessed_at and increments access_count).
Sourcepub fn recall(&mut self)
pub fn recall(&mut self)
Record a recall — Hebbian-style strengthening of neuro_score.
Boosts neuro_score by 0.05 * (1.0 - current_neuro_score) (diminishing
returns), increments recall_count, updates accessed_at, and decays
novelty_score (familiarity reduces novelty).
Sourcepub fn decay(&mut self, now: DateTime<Utc>)
pub fn decay(&mut self, now: DateTime<Utc>)
Apply exponential decay to neuro_score based on time since last access
and the memory’s half_life_days.
neuro_score *= 0.5 ^ (days_since_access / half_life_days)
Protected memories are exempt from decay.
Sourcepub fn decay_importance(&mut self, factor: f32)
pub fn decay_importance(&mut self, factor: f32)
Decay importance by a given factor (used by mindful forgetting).
Sourcepub fn should_forget(&self, threshold: f32) -> bool
pub fn should_forget(&self, threshold: f32) -> bool
Whether this memory should be forgotten (importance below threshold). Protected memories are never forgotten.
Sourcepub fn is_telemetry_or_noise(&self) -> bool
pub fn is_telemetry_or_noise(&self) -> bool
Checks whether this memory is operational telemetry, friction logging, or raw noise that should be excluded from dream consolidation, tier promotion, and serendipity association mining (D1/D5/D8 hygiene rules).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Memory
impl<'de> Deserialize<'de> for Memory
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 Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnsafeUnpin for Memory
impl UnwindSafe for Memory
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
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