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