pub struct Pattern {Show 15 fields
pub id: String,
pub description: String,
pub instruction: String,
pub confidence: f64,
pub evidence_count: u32,
pub first_observed: DateTime<Utc>,
pub last_updated: DateTime<Utc>,
pub category: String,
pub active: bool,
pub content_hash: String,
pub key: String,
pub value: Value,
pub contradicting_count: u32,
pub last_reinforced: DateTime<Utc>,
pub source_sessions: Vec<Uuid>,
}Expand description
A pattern extracted from multiple observations.
Fields§
§id: StringUnique identifier
description: StringHuman-readable description of the pattern
instruction: StringNatural language instruction to inject into system prompt
confidence: f64Confidence score (0.0 - 1.0)
evidence_count: u32Number of observations supporting this pattern
first_observed: DateTime<Utc>When the pattern was first observed
last_updated: DateTime<Utc>When the pattern was last updated
category: StringCategory of the pattern (e.g., “preference”, “error_avoidance”, “efficiency”)
active: boolWhether this pattern is active (can be injected into prompts)
content_hash: StringNormalized fingerprint for content-based dedup: “{category}|{first 1KB of instruction}”
key: StringStructured key identifying this pattern (e.g., “prefer_functional_style”)
value: ValueStructured value as JSON (replaces free-text instruction at the data level)
contradicting_count: u32Number of contradicting observations
last_reinforced: DateTime<Utc>When this pattern was last reinforced by a matching signal
source_sessions: Vec<Uuid>Session IDs where this pattern was observed (traceability)
Implementations§
Source§impl Pattern
impl Pattern
Sourcepub fn new(description: String, instruction: String, category: String) -> Self
pub fn new(description: String, instruction: String, category: String) -> Self
Create a new pattern with the current timestamp.
Backward-compatible constructor. Derives key and value from
description and instruction for migration purposes.
Sourcepub fn new_with_key(
key: String,
value: Value,
category: String,
source_session: Option<Uuid>,
) -> Self
pub fn new_with_key( key: String, value: Value, category: String, source_session: Option<Uuid>, ) -> Self
Create a pattern with MenteDB-aligned fields.
description and instruction are derived from key + value
rendering, keeping the BehaviorAdapter output format unchanged.
Sourcepub fn decayed_confidence(&self, half_life_days: f64) -> f64
pub fn decayed_confidence(&self, half_life_days: f64) -> f64
Calculate the time-decayed confidence based on evidence and age.