pub struct KnowledgeRelationGraph {
pub project_hash: String,
pub edges: Vec<KnowledgeEdge>,
pub updated_at: DateTime<Utc>,
/* private fields */
}Fields§
§project_hash: String§edges: Vec<KnowledgeEdge>§updated_at: DateTime<Utc>Implementations§
Source§impl KnowledgeRelationGraph
impl KnowledgeRelationGraph
pub fn new(project_hash: &str) -> Self
pub fn path(project_hash: &str) -> Result<PathBuf, String>
pub fn load(project_hash: &str) -> Option<Self>
pub fn load_or_create(project_hash: &str) -> Self
Sourcepub fn mutate_locked<T>(
project_root: &str,
project_hash: &str,
change: impl FnOnce(&mut Self) -> Option<T>,
) -> Result<Option<T>, String>
pub fn mutate_locked<T>( project_root: &str, project_hash: &str, change: impl FnOnce(&mut Self) -> Option<T>, ) -> Result<Option<T>, String>
Load, change and save the graph under the project’s knowledge lock,
the in-process and cross-process lock fact edits and the cognition loop
hold, so a concurrent writer (another process, the dashboard, the
cognition loop) never loses an edge. change returns None when it
changed nothing; the graph is then not written. Must not be called while
that lock is held.
pub fn save(&mut self) -> Result<(), String>
pub fn upsert_edge( &mut self, from: KnowledgeNodeRef, to: KnowledgeNodeRef, kind: KnowledgeEdgeKind, session_id: &str, ) -> bool
pub fn remove_edge( &mut self, from: &KnowledgeNodeRef, to: &KnowledgeNodeRef, kind: Option<KnowledgeEdgeKind>, ) -> usize
pub fn enforce_cap(&mut self, max_edges: usize) -> bool
Sourcepub fn strengthen_edge(
&mut self,
from: &KnowledgeNodeRef,
to: &KnowledgeNodeRef,
amount: f64,
) -> bool
pub fn strengthen_edge( &mut self, from: &KnowledgeNodeRef, to: &KnowledgeNodeRef, amount: f64, ) -> bool
Hebbian strengthening: saturating formula so strength approaches but never exceeds 1.0
Sourcepub fn decay_all_edges(&mut self, days_elapsed: f64)
pub fn decay_all_edges(&mut self, days_elapsed: f64)
Time-based exponential decay on all edge strengths
Sourcepub fn prune_weak_edges(&mut self, threshold: f64) -> usize
pub fn prune_weak_edges(&mut self, threshold: f64) -> usize
Remove edges whose strength has fallen below threshold
Sourcepub fn incident_edges(&self, node: &KnowledgeNodeRef) -> Vec<&KnowledgeEdge>
pub fn incident_edges(&self, node: &KnowledgeNodeRef) -> Vec<&KnowledgeEdge>
Returns only the edges incident to node, using the load-time index.
Trait Implementations§
Source§impl Clone for KnowledgeRelationGraph
impl Clone for KnowledgeRelationGraph
Source§impl Debug for KnowledgeRelationGraph
impl Debug for KnowledgeRelationGraph
Source§impl Default for KnowledgeRelationGraph
impl Default for KnowledgeRelationGraph
Source§impl<'de> Deserialize<'de> for KnowledgeRelationGraphwhere
KnowledgeRelationGraph: Default,
impl<'de> Deserialize<'de> for KnowledgeRelationGraphwhere
KnowledgeRelationGraph: Default,
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Forget for KnowledgeRelationGraph
impl Freeze for KnowledgeRelationGraph
impl Move for KnowledgeRelationGraph
impl RefUnwindSafe for KnowledgeRelationGraph
impl Send for KnowledgeRelationGraph
impl Sync for KnowledgeRelationGraph
impl Unpin for KnowledgeRelationGraph
impl UnsafeUnpin for KnowledgeRelationGraph
impl UnwindSafe for KnowledgeRelationGraph
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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 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> ⓘ
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