phago_core/primitives/wire.rs
1//! WIRE — Hebbian Learning + Synaptic Pruning
2//!
3//! "Neurons that fire together, wire together." Synaptic connections that
4//! are frequently used grow stronger (long-term potentiation). Connections
5//! that are rarely used weaken and are pruned (synaptic pruning).
6//!
7//! The critical insight: **the structure IS the memory**. The network
8//! doesn't store knowledge in nodes and query through edges. The edges
9//! themselves — their weights, their topology — encode what the system
10//! has learned. Topology is knowledge.
11
12use crate::topology::TopologyGraph;
13use crate::types::*;
14
15/// Strengthen used connections and prune unused ones.
16///
17/// Wire operates on the shared topology graph in the substrate.
18/// Multiple agents read and modify the same graph — wiring is a
19/// collective activity, like neural plasticity across a brain region.
20pub trait Wire {
21 /// Strengthen the connection between two nodes.
22 ///
23 /// Called when two concepts are observed together (co-activation).
24 /// The weight increase is proportional to the strength parameter.
25 fn strengthen(&self, from: NodeId, to: NodeId, weight: f64, graph: &mut dyn TopologyGraph);
26
27 /// Record a co-activation event for a set of nodes.
28 ///
29 /// When multiple concepts appear together (e.g., in the same document),
30 /// all pairwise connections are strengthened. This is Hebbian learning:
31 /// nodes that activate together wire together.
32 fn co_activate(&self, nodes: &[NodeId], graph: &mut dyn TopologyGraph);
33
34 /// Prune connections below a weight threshold.
35 ///
36 /// Weak connections are removed — synaptic pruning. This prevents
37 /// the graph from growing without bound and ensures that only
38 /// genuinely related concepts remain connected.
39 fn prune(&self, threshold: f64, graph: &mut dyn TopologyGraph) -> Vec<PrunedConnection>;
40
41 /// Decay all connection weights.
42 ///
43 /// Time-based weakening: all connections lose strength unless
44 /// they are re-activated. This ensures the graph reflects recent
45 /// relevance, not just historical co-occurrence.
46 fn decay(&self, rate: f64, graph: &mut dyn TopologyGraph);
47}