pub struct Context { /* private fields */ }Expand description
The shared context for a Converge job.
Agents receive &Context (immutable) during execution.
Only the engine holds &mut Context during the merge phase.
Implementations§
Source§impl Context
impl Context
Sourcepub fn get(&self, key: ContextKey) -> &[Fact]
pub fn get(&self, key: ContextKey) -> &[Fact]
Returns all facts for a given key.
Sourcepub fn has(&self, key: ContextKey) -> bool
pub fn has(&self, key: ContextKey) -> bool
Returns true if there are any facts for the given key.
Sourcepub fn dirty_keys(&self) -> &[ContextKey]
pub fn dirty_keys(&self) -> &[ContextKey]
Returns keys that changed in the last merge cycle.
Sourcepub fn all_keys(&self) -> Vec<ContextKey>
pub fn all_keys(&self) -> Vec<ContextKey>
Returns all keys that currently have facts in the context.
Sourcepub fn clear_dirty(&mut self)
pub fn clear_dirty(&mut self)
Clears the dirty key tracker (called at start of each cycle).
Sourcepub fn add_fact(&mut self, fact: Fact) -> Result<bool, ConvergeError>
pub fn add_fact(&mut self, fact: Fact) -> Result<bool, ConvergeError>
Adds a fact to the context (engine-only, during merge phase).
Returns Ok(true) if the fact was new (context changed).
Returns Ok(false) if the fact was already present and identical.
§Errors
Returns Err(ConvergeError::Conflict) if a fact with the same ID but
different content already exists. This indicates non-deterministic behavior
from agents producing conflicting outputs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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