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) -> Self

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) -> Self

Override the memory type for this entry.

Source

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

Override the memory scope for this entry.

Source

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

Attach a category to the entry.

Source

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

Attach provenance identifiers to the entry.

Source

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

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, ) -> Self

Attach reflection-learning metadata used for ranking and governance.

Source

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

Attach retrieval tags to the entry.

Source

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

Set the general governance state.

Source

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

Attach an operator note describing memory curation context.

Source

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

Replace automated governance suggestions.

Source

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

Mark the entry as promoted from short-term memory.

Source

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

Attach durable outcome provenance to the entry.

Source

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

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<Self, 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

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

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

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 PartialEq for MemoryBankEntry

Source§

fn eq(&self, other: &Self) -> 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::Ok, __S::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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

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>,