Skip to main content

RelationshipEdge

Struct RelationshipEdge 

Source
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: Uuid

Unique identifier for this edge

§from_entity: Uuid

Source entity UUID

§to_entity: Uuid

Target entity UUID

§relation_type: RelationType

Type of relationship

§strength: f32

Confidence/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: String

Additional 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: u32

Number of times both entities were co-accessed (Hebbian co-activation) Higher count = stronger learned association

§ltp_status: LtpStatus

Long-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: EdgeTier

Memory 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

Source

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.

Source

pub fn activations_in_window( &self, start: DateTime<Utc>, end: DateTime<Utc>, ) -> usize

Get activation count within a time window (for temporal retrieval scoring)

Source

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)

Source

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)

Source

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

Source

pub fn is_potentiated(&self) -> bool

Check if this edge has any LTP protection (for backward compatibility)

Source

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]

Source

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

Source

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

Source§

fn clone(&self) -> RelationshipEdge

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 RelationshipEdge

Source§

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

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

impl<'de> Deserialize<'de> for RelationshipEdge

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 Serialize for RelationshipEdge

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

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> Downcast for T
where T: Any,

Source§

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

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

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

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

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

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

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

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

Source§

impl<T> Fruit for T
where T: Send + Downcast,