pub struct RelationshipEdge {Show 16 fields
pub uuid: Uuid,
pub from_entity: Uuid,
pub to_entity: Uuid,
pub relation_type: RelationType,
pub strength: f32,
pub created_at: DateTime<Utc>,
pub valid_at: DateTime<Utc>,
pub invalidated_at: Option<DateTime<Utc>>,
pub source_episode_id: Option<Uuid>,
pub context: String,
pub last_activated: DateTime<Utc>,
pub activation_count: u32,
pub ltp_status: LtpStatus,
pub tier: EdgeTier,
pub activation_timestamps: Option<VecDeque<DateTime<Utc>>>,
pub entity_confidence: Option<f32>,
}Expand description
Relationship edge between entities
Implements Hebbian synaptic plasticity: “Neurons that fire together, wire together”
- Strength increases with co-activation (strengthen method)
- Strength decays over time without use (decay method)
- Long-Term Potentiation (LTP): After threshold activations, becomes permanent
Fields§
§uuid: UuidUnique identifier for this edge
from_entity: UuidSource entity UUID
to_entity: UuidTarget entity UUID
relation_type: RelationTypeType of relationship
strength: f32Confidence/strength of this relationship (0.0 to 1.0) Dynamic: increases with co-activation, decays without use
created_at: DateTime<Utc>When this relationship was created
valid_at: DateTime<Utc>When this relationship was last observed (temporal tracking)
invalidated_at: Option<DateTime<Utc>>Whether this relationship has been invalidated (temporal edge invalidation)
source_episode_id: Option<Uuid>Source episode that created this relationship
context: StringAdditional context about the relationship
last_activated: DateTime<Utc>When this synapse was last activated (used in retrieval/traversal) Used to calculate time-based decay
activation_count: u32Number of times both entities were co-accessed (Hebbian co-activation) Higher count = stronger learned association
ltp_status: LtpStatusLong-Term Potentiation status (PIPE-4: multi-scale LTP) Replaces simple bool with tiered protection levels:
- None: Normal decay
- Burst: Temporary 2x protection (5+ activations in 24h)
- Weekly: Moderate 3x protection (3+/week for 2 weeks)
- Full: Maximum 10x protection (10+ activations or 5+ over 30 days)
tier: EdgeTierMemory tier for consolidation (L1→L2→L3) Edges start in L1 (working memory) and promote based on Hebbian strength
activation_timestamps: Option<VecDeque<DateTime<Utc>>>Activation timestamp history for temporal pattern detection (PIPE-4) Only populated for L2+ edges (L1 edges die too quickly to need history) Capacity: L2 = 20 timestamps, L3 = 50 timestamps Enables: burst detection, weekly patterns, temporal query relevance
entity_confidence: Option<f32>Entity extraction confidence (PIPE-5: Unified LTP Readiness) Average confidence of the entities connected by this edge. Affects LTP threshold: high confidence → faster LTP (7 activations) Low confidence → slower LTP (13 activations). Based on synaptic tagging: behaviorally relevant synapses consolidate faster.
Implementations§
Source§impl RelationshipEdge
impl RelationshipEdge
Sourcepub fn strengthen(&mut self) -> Option<(String, String)>
pub fn strengthen(&mut self) -> Option<(String, String)>
Strengthen this synapse (Hebbian learning)
Called when both connected entities are accessed together. Formula: w_new = w_old + η × (1 - w_old) × co_activation_boost
PIPE-4: Multi-scale LTP detection
- Records activation timestamps for L2+ edges
- Detects burst patterns (5+ in 24h) → temporary protection
- Detects weekly patterns (3+/week for 2 weeks) → moderate protection
- Detects sustained patterns (10+ total or 5+ over 30 days) → full protection
Also handles tier promotion (L1→L2→L3) when strength exceeds tier threshold.
Returns Some((old_tier_name, new_tier_name)) if a tier promotion occurred,
None otherwise. This enables the memory-edge coupling: edge promotions
can signal the memory layer to boost the associated memory’s importance.
Sourcepub fn activations_in_window(
&self,
start: DateTime<Utc>,
end: DateTime<Utc>,
) -> usize
pub fn activations_in_window( &self, start: DateTime<Utc>, end: DateTime<Utc>, ) -> usize
Get activation count within a time window (for temporal retrieval scoring)
Sourcepub fn time_of_day_match(&self, target_hour: u32, window_hours: u32) -> usize
pub fn time_of_day_match(&self, target_hour: u32, window_hours: u32) -> usize
Check if edge was active at similar time of day (for temporal retrieval)
Sourcepub fn decay(&mut self) -> bool
pub fn decay(&mut self) -> bool
Apply time-based decay to this synapse
Uses tier-aware decay model (3-tier memory consolidation):
- L1 (Working): ~2.9%/hour decay (λ=0.029), max 48 hours before prune
- L2 (Episodic): ~3.1%/day decay (λ=0.031), max 30 days before prune
- L3 (Semantic): ~2%/month decay (λ=0.02/720h), near-permanent
PIPE-4: Multi-scale LTP protection
- Burst: 2x slower decay (temporary, 48h)
- Weekly: 3x slower decay (habit protection)
- Full: 10x slower decay (permanent protection)
Important: Updates last_activated to prevent double-decay on
repeated calls.
Returns true if synapse should be pruned (below tier’s threshold)
Sourcepub fn effective_strength(&self) -> f32
pub fn effective_strength(&self) -> f32
Get the effective strength considering recency
This is a read-only version that calculates what the strength would be after decay, without modifying the edge. Uses tier-aware decay (L1/L2/L3 have different decay rates).
Sourcepub fn is_potentiated(&self) -> bool
pub fn is_potentiated(&self) -> bool
Check if this edge has any LTP protection (for backward compatibility)
Sourcepub fn adjusted_threshold(&self) -> u32
pub fn adjusted_threshold(&self) -> u32
Get confidence-adjusted LTP threshold (PIPE-5)
High-confidence edges (strong entity extraction) need fewer activations. Low-confidence edges need more activations to prove value.
Returns: threshold in range [LTP_THRESHOLD_MIN, LTP_THRESHOLD_MAX]
Sourcepub fn strength_floor(&self) -> f32
pub fn strength_floor(&self) -> f32
Get tier-specific strength floor for Full LTP (PIPE-5)
L2 edges have lower floor (still proving themselves). L3 edges have higher floor (must demonstrate durability). L1 edges return 1.0 (effectively impossible to reach Full LTP).
Sourcepub fn ltp_readiness(&self) -> f32
pub fn ltp_readiness(&self) -> f32
Calculate LTP readiness score (PIPE-5)
Unified formula combining activation count, strength, and entity confidence:
- count_score = activation_count / adjusted_threshold
- strength_score = strength / strength_floor
- tag_bonus = entity_confidence * TAG_WEIGHT
readiness = count_score * COUNT_WEIGHT + strength_score * STRENGTH_WEIGHT + tag_bonus
Full LTP when readiness >= 1.0
This allows multiple paths to LTP:
- Repetition-dominant: 15 activations can compensate for lower strength
- Intensity-dominant: 0.95 strength can compensate for fewer activations
- Balanced: 10 activations + 0.75 strength + moderate confidence
- Tagged boost: high-confidence edges reach LTP ~30% faster
Trait Implementations§
Source§impl Clone for RelationshipEdge
impl Clone for RelationshipEdge
Source§fn clone(&self) -> RelationshipEdge
fn clone(&self) -> RelationshipEdge
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RelationshipEdge
impl Debug for RelationshipEdge
Source§impl<'de> Deserialize<'de> for RelationshipEdge
impl<'de> Deserialize<'de> for RelationshipEdge
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 RelationshipEdge
impl RefUnwindSafe for RelationshipEdge
impl Send for RelationshipEdge
impl Sync for RelationshipEdge
impl Unpin for RelationshipEdge
impl UnsafeUnpin for RelationshipEdge
impl UnwindSafe for RelationshipEdge
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
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