mentedb_core/edge.rs
1//! MemoryEdge — typed, weighted relationships between memories.
2
3use serde::{Deserialize, Serialize};
4
5use crate::types::*;
6
7/// The type of relationship between two memories.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
9pub enum EdgeType {
10 /// Causal: A caused B.
11 Caused,
12 /// Temporal: A happened before B.
13 Before,
14 /// Semantic: A is related to B.
15 Related,
16 /// Contradicts: A conflicts with B.
17 Contradicts,
18 /// Supports: A provides evidence for B.
19 Supports,
20 /// Supersedes: A replaces B (newer information).
21 Supersedes,
22 /// Derived: A was derived/inferred from B.
23 Derived,
24 /// Part of: A is a component of B.
25 PartOf,
26}
27
28/// A directed, typed, weighted edge between two memory nodes.
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct MemoryEdge {
31 /// Source memory ID.
32 pub source: MemoryId,
33 /// Target memory ID.
34 pub target: MemoryId,
35 /// Relationship type.
36 pub edge_type: EdgeType,
37 /// Strength of the relationship (0.0 to 1.0).
38 pub weight: f32,
39 /// When this edge was created.
40 pub created_at: Timestamp,
41}