MemoryBankEntry

Struct MemoryBankEntry 

Source
pub struct MemoryBankEntry {
Show 26 fields pub timestamp: DateTime<Utc>, pub memory_kind: MemoryKind, pub memory_type: MemoryType, pub scope: MemoryScope, pub session_id: String, pub category: Option<String>, pub task_id: Option<String>, pub reflection_id: Option<String>, pub strategy_key: Option<String>, pub reflection_state: Option<ReflectionMemoryState>, pub success_count: u16, pub failure_count: u16, pub directive_id: Option<String>, pub agent_id: Option<String>, pub governance_state: MemoryGovernanceState, pub governance_note: Option<String>, pub governance_suggestions: Vec<MemoryGovernanceSuggestion>, pub tags: Vec<String>, pub promoted_from_session_id: Option<String>, pub promotion_reason: Option<String>, pub outcome_summary: Option<String>, pub outcome_labels: Vec<String>, pub confidence: f32, pub summary: String, pub content: String, pub file_path: Option<PathBuf>,
}
Expand description

A single entry in the memory bank representing a saved conversation context

Each entry contains metadata (timestamp, session ID, summary) and the full conversation content. Entries are stored as markdown files in .gestura/memory/ and can be searched and retrieved across sessions.

§Examples

use gestura_core::memory_bank::MemoryBankEntry;

let entry = MemoryBankEntry::new(
    "session-123".to_string(),
    "Implemented user authentication".to_string(),
    "User: How do I add auth?\nAssistant: Here's how...".to_string(),
);

let markdown = entry.to_markdown();
let filename = entry.generate_filename(); // e.g., "memory_20260121_143022_session-1.md"

Fields§

§timestamp: DateTime<Utc>

Timestamp when this entry was created (UTC)

§memory_kind: MemoryKind

Retention domain for the memory.

§memory_type: MemoryType

Typed classification of the memory entry.

§scope: MemoryScope

Retrieval scope for the memory entry.

§session_id: String

Session ID that created this entry (used for grouping related conversations)

§category: Option<String>

Optional category for grouping/filtering entries (e.g., “project”, “personal”, “research”)

§task_id: Option<String>

Optional task identifier associated with the memory.

§reflection_id: Option<String>

Optional stable reflection identifier linked to the memory.

§strategy_key: Option<String>

Optional normalized strategy key for reflection-derived memories.

§reflection_state: Option<ReflectionMemoryState>

Reflection retrieval state derived from downstream outcomes.

§success_count: u16

Count of positive downstream outcomes associated with the reflection.

§failure_count: u16

Count of negative downstream outcomes associated with the reflection.

§directive_id: Option<String>

Optional higher-level directive identifier associated with the memory.

§agent_id: Option<String>

Optional agent identifier that produced or owns the memory.

§governance_state: MemoryGovernanceState

General governance state for the durable memory entry.

§governance_note: Option<String>

Optional operator note describing curation intent.

§governance_suggestions: Vec<MemoryGovernanceSuggestion>

Persisted governance suggestions produced by automated analysis.

§tags: Vec<String>

Tags used for targeted retrieval.

§promoted_from_session_id: Option<String>

Optional originating short-term session when this record was promoted.

§promotion_reason: Option<String>

Optional explanation of why the record was promoted.

§outcome_summary: Option<String>

Optional human-readable outcome summary linked to this memory’s provenance.

§outcome_labels: Vec<String>

Stable outcome labels linked to this memory’s provenance.

§confidence: f32

Confidence score for retrieval/ranking.

§summary: String

Brief summary of the conversation (used for search and display)

§content: String

Full conversation context in markdown format

§file_path: Option<PathBuf>

File path where this entry is stored (not serialized, populated on load)

Implementations§

Source§

impl MemoryBankEntry

Source

pub fn new( session_id: String, summary: String, content: String, ) -> MemoryBankEntry

Create a new memory bank entry with the current timestamp

§Arguments
  • session_id - Unique identifier for the session that created this entry
  • summary - Brief description of the conversation (used for search)
  • content - Full conversation context in markdown format
§Examples
use gestura_core::memory_bank::MemoryBankEntry;

let entry = MemoryBankEntry::new(
    "session-abc123".to_string(),
    "Fixed authentication bug".to_string(),
    "User: Auth is broken\nAssistant: Here's the fix...".to_string(),
);
Source

pub fn with_memory_type(self, memory_type: MemoryType) -> MemoryBankEntry

Override the memory type for this entry.

Source

pub fn with_scope(self, scope: MemoryScope) -> MemoryBankEntry

Override the memory scope for this entry.

Source

pub fn with_category(self, category: impl Into<String>) -> MemoryBankEntry

Attach a category to the entry.

Source

pub fn with_provenance( self, task_id: Option<String>, directive_id: Option<String>, agent_id: Option<String>, ) -> MemoryBankEntry

Attach provenance identifiers to the entry.

Source

pub fn with_reflection_id( self, reflection_id: impl Into<String>, ) -> MemoryBankEntry

Attach a stable reflection identifier to the entry.

Source

pub fn with_reflection_learning( self, strategy_key: impl Into<String>, reflection_state: ReflectionMemoryState, success_count: u16, failure_count: u16, ) -> MemoryBankEntry

Attach reflection-learning metadata used for ranking and governance.

Source

pub fn with_tags(self, tags: Vec<String>) -> MemoryBankEntry

Attach retrieval tags to the entry.

Source

pub fn with_governance_state( self, state: MemoryGovernanceState, ) -> MemoryBankEntry

Set the general governance state.

Source

pub fn with_governance_note(self, note: impl Into<String>) -> MemoryBankEntry

Attach an operator note describing memory curation context.

Source

pub fn with_governance_suggestions( self, suggestions: Vec<MemoryGovernanceSuggestion>, ) -> MemoryBankEntry

Replace automated governance suggestions.

Source

pub fn with_promotion( self, promoted_from_session_id: impl Into<String>, promotion_reason: impl Into<String>, ) -> MemoryBankEntry

Mark the entry as promoted from short-term memory.

Source

pub fn with_outcome_provenance( self, outcome_summary: Option<String>, outcome_labels: Vec<String>, ) -> MemoryBankEntry

Attach durable outcome provenance to the entry.

Source

pub fn with_confidence(self, confidence: f32) -> MemoryBankEntry

Override the retrieval confidence for this entry.

Source

pub fn is_archived(&self) -> bool

Returns true when the memory has been archived from retrieval.

Source

pub fn is_prompt_eligible_reflection(&self) -> bool

Returns true when the reflection can safely be injected into prompts.

Source

pub fn to_markdown(&self) -> String

Convert entry to markdown format for file storage

The markdown format includes metadata headers and the full context:

# Memory Bank Entry

**Timestamp**: 2026-01-21 14:30:22 UTC
**Session ID**: session-abc123
**Category**: engineering   # optional
**Summary**: Fixed authentication bug

## Context

[conversation content here]
Source

pub fn from_markdown( markdown: &str, file_path: Option<PathBuf>, ) -> Result<MemoryBankEntry, MemoryBankError>

Parse entry from markdown format

§Arguments
  • markdown - Markdown content to parse
  • file_path - Optional path to the source file (stored in the entry)
§Returns

Parsed memory bank entry

§Errors

Returns MemoryBankError::Parse if required fields are missing or invalid

Source

pub fn generate_filename(&self) -> String

Generate a unique filename for this entry

Format: memory_YYYYMMDD_HHMMSS_<session-prefix>.md

§Examples
use gestura_core::memory_bank::MemoryBankEntry;

let entry = MemoryBankEntry::new(
    "session-abc123".to_string(),
    "Summary".to_string(),
    "Content".to_string(),
);

let filename = entry.generate_filename();
// e.g., "memory_20260121_143022_session-a.md"
assert!(filename.starts_with("memory_"));
assert!(filename.ends_with(".md"));
Source

pub fn matches_query(&self, query: &MemoryBankQuery) -> bool

Return true when the entry satisfies the supplied filter.

Source

pub fn score_against_query(&self, query: &MemoryBankQuery) -> MemorySearchResult

Rank the entry against a targeted query.

Source

pub fn to_prompt_section(&self, preview_chars: usize) -> String

Render a compact section suitable for prompt context.

Trait Implementations§

Source§

impl Clone for MemoryBankEntry

Source§

fn clone(&self) -> MemoryBankEntry

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryBankEntry

Source§

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

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

impl<'de> Deserialize<'de> for MemoryBankEntry

Source§

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

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

impl PartialEq for MemoryBankEntry

Source§

fn eq(&self, other: &MemoryBankEntry) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for MemoryBankEntry

Source§

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

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for MemoryBankEntry

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

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

§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,