pub struct KnowledgeBridge {
pub project_hash: String,
pub shared_facts: Vec<BridgeEntry>,
pub updated_at: DateTime<Utc>,
}Fields§
§project_hash: String§updated_at: DateTime<Utc>Implementations§
Source§impl KnowledgeBridge
impl KnowledgeBridge
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
pub fn save(&mut self) -> Result<(), String>
Sourcepub fn mutate_locked<T>(
project_hash: &str,
mutate: impl FnOnce(&mut Self) -> T,
) -> Result<T, String>
pub fn mutate_locked<T>( project_hash: &str, mutate: impl FnOnce(&mut Self) -> T, ) -> Result<T, String>
One read-modify-write of a project’s bridge under its cross-process lock: loaded inside the lock, saved before it is released. Parallel publishers therefore never drop each other’s entries.
Sourcepub fn publish(&mut self, agent_id: &str, facts: &[KnowledgeFact]) -> u32
pub fn publish(&mut self, agent_id: &str, facts: &[KnowledgeFact]) -> u32
Publish eligible facts from an agent’s knowledge store. Only publishes facts with sufficient confidence, a publishable archetype, and that haven’t already been published by this agent.
Sourcepub fn pull(&self, requesting_agent: &str) -> Vec<BridgeEntry>
pub fn pull(&self, requesting_agent: &str) -> Vec<BridgeEntry>
Pull facts from the bridge that were published by other agents.
Sourcepub fn entry_to_fact(entry: &BridgeEntry) -> KnowledgeFact
pub fn entry_to_fact(entry: &BridgeEntry) -> KnowledgeFact
Convert a BridgeEntry into a KnowledgeFact for import.
Applies a 10% trust penalty to imported confidence.
Sourcepub fn cleanup(&mut self, max_age_days: i64, min_confidence: f32) -> usize
pub fn cleanup(&mut self, max_age_days: i64, min_confidence: f32) -> usize
Remove entries older than max_age_days or below min_confidence.
pub fn entries_for_agent(&self, agent_id: &str) -> Vec<&BridgeEntry>
pub fn summary(&self) -> String
Trait Implementations§
Source§impl Clone for KnowledgeBridge
impl Clone for KnowledgeBridge
Source§impl Debug for KnowledgeBridge
impl Debug for KnowledgeBridge
Source§impl<'de> Deserialize<'de> for KnowledgeBridge
impl<'de> Deserialize<'de> for KnowledgeBridge
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 KnowledgeBridge
impl Freeze for KnowledgeBridge
impl Move for KnowledgeBridge
impl RefUnwindSafe for KnowledgeBridge
impl Send for KnowledgeBridge
impl Sync for KnowledgeBridge
impl Unpin for KnowledgeBridge
impl UnsafeUnpin for KnowledgeBridge
impl UnwindSafe for KnowledgeBridge
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