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.