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: MemoryKindRetention domain for the memory.
memory_type: MemoryTypeTyped classification of the memory entry.
scope: MemoryScopeRetrieval scope for the memory entry.
session_id: StringSession 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: u16Count of positive downstream outcomes associated with the reflection.
failure_count: u16Count 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: MemoryGovernanceStateGeneral 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 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: f32Confidence score for retrieval/ranking.
summary: StringBrief summary of the conversation (used for search and display)
content: StringFull 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
impl MemoryBankEntry
Sourcepub fn new(session_id: String, summary: String, content: String) -> Self
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 entrysummary- 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(),
);Sourcepub fn with_memory_type(self, memory_type: MemoryType) -> Self
pub fn with_memory_type(self, memory_type: MemoryType) -> Self
Override the memory type for this entry.
Sourcepub fn with_scope(self, scope: MemoryScope) -> Self
pub fn with_scope(self, scope: MemoryScope) -> Self
Override the memory scope for this entry.
Sourcepub fn with_category(self, category: impl Into<String>) -> Self
pub fn with_category(self, category: impl Into<String>) -> Self
Attach a category to the entry.
Sourcepub fn with_provenance(
self,
task_id: Option<String>,
directive_id: Option<String>,
agent_id: Option<String>,
) -> Self
pub fn with_provenance( self, task_id: Option<String>, directive_id: Option<String>, agent_id: Option<String>, ) -> Self
Attach provenance identifiers to the entry.
Sourcepub fn with_reflection_id(self, reflection_id: impl Into<String>) -> Self
pub fn with_reflection_id(self, reflection_id: impl Into<String>) -> Self
Attach a stable reflection identifier to the entry.
Sourcepub fn with_reflection_learning(
self,
strategy_key: impl Into<String>,
reflection_state: ReflectionMemoryState,
success_count: u16,
failure_count: u16,
) -> Self
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.
Attach retrieval tags to the entry.
Sourcepub fn with_governance_state(self, state: MemoryGovernanceState) -> Self
pub fn with_governance_state(self, state: MemoryGovernanceState) -> Self
Set the general governance state.
Sourcepub fn with_governance_note(self, note: impl Into<String>) -> Self
pub fn with_governance_note(self, note: impl Into<String>) -> Self
Attach an operator note describing memory curation context.
Sourcepub fn with_governance_suggestions(
self,
suggestions: Vec<MemoryGovernanceSuggestion>,
) -> Self
pub fn with_governance_suggestions( self, suggestions: Vec<MemoryGovernanceSuggestion>, ) -> Self
Replace automated governance suggestions.
Sourcepub fn with_promotion(
self,
promoted_from_session_id: impl Into<String>,
promotion_reason: impl Into<String>,
) -> Self
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.
Sourcepub fn with_outcome_provenance(
self,
outcome_summary: Option<String>,
outcome_labels: Vec<String>,
) -> Self
pub fn with_outcome_provenance( self, outcome_summary: Option<String>, outcome_labels: Vec<String>, ) -> Self
Attach durable outcome provenance to the entry.
Sourcepub fn with_confidence(self, confidence: f32) -> Self
pub fn with_confidence(self, confidence: f32) -> Self
Override the retrieval confidence for this entry.
Sourcepub fn is_archived(&self) -> bool
pub fn is_archived(&self) -> bool
Returns true when the memory has been archived from retrieval.
Sourcepub fn is_prompt_eligible_reflection(&self) -> bool
pub fn is_prompt_eligible_reflection(&self) -> bool
Returns true when the reflection can safely be injected into prompts.
Sourcepub fn to_markdown(&self) -> String
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]Sourcepub fn from_markdown(
markdown: &str,
file_path: Option<PathBuf>,
) -> Result<Self, MemoryBankError>
pub fn from_markdown( markdown: &str, file_path: Option<PathBuf>, ) -> Result<Self, MemoryBankError>
Sourcepub fn generate_filename(&self) -> String
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"));Sourcepub fn matches_query(&self, query: &MemoryBankQuery) -> bool
pub fn matches_query(&self, query: &MemoryBankQuery) -> bool
Return true when the entry satisfies the supplied filter.
Sourcepub fn score_against_query(&self, query: &MemoryBankQuery) -> MemorySearchResult
pub fn score_against_query(&self, query: &MemoryBankQuery) -> MemorySearchResult
Rank the entry against a targeted query.
Sourcepub fn to_prompt_section(&self, preview_chars: usize) -> String
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
impl Clone for MemoryBankEntry
Source§fn clone(&self) -> MemoryBankEntry
fn clone(&self) -> MemoryBankEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more