pub trait Context: Send + Sync {
// Required methods
fn has(&self, key: ContextKey) -> bool;
fn get(&self, key: ContextKey) -> &[ContextFact];
// Provided methods
fn get_proposals(&self, key: ContextKey) -> &[ProposedFact] { ... }
fn version(&self) -> u64 { ... }
fn count(&self, key: ContextKey) -> usize { ... }
fn formation_kind(&self) -> Option<FormationKind> { ... }
}Expand description
Read-only view of the shared context.
Suggestors receive &dyn Context during accepts() and execute().
They cannot mutate it directly — mutations happen through AgentEffect
after the engine collects all effects and merges them deterministically.
Required Methods§
Sourcefn has(&self, key: ContextKey) -> bool
fn has(&self, key: ContextKey) -> bool
Check whether any facts exist under this key.
Sourcefn get(&self, key: ContextKey) -> &[ContextFact]
fn get(&self, key: ContextKey) -> &[ContextFact]
Get all read-only context fact projections under this key.
Provided Methods§
Sourcefn get_proposals(&self, key: ContextKey) -> &[ProposedFact]
fn get_proposals(&self, key: ContextKey) -> &[ProposedFact]
Get all proposed facts (unvalidated).
Sourcefn version(&self) -> u64
fn version(&self) -> u64
Monotonic context version, when the backing implementation tracks one.
Stateless test contexts and simple external implementations can keep the
default 0.
Sourcefn count(&self, key: ContextKey) -> usize
fn count(&self, key: ContextKey) -> usize
Count of facts under a key.
Sourcefn formation_kind(&self) -> Option<FormationKind>
fn formation_kind(&self) -> Option<FormationKind>
The kind of formation orchestrating this suggestor’s current
execution, if any. None means the suggestor is running outside
a formation harness (e.g., the engine’s default registration
path); fall back to standalone behavior.
Formation harnesses that orchestrate inner suggestors override this on the context they pass down. Suggestors that don’t care about formation context can ignore this method entirely.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Context for ContextState
Implement the converge-pack Context trait for the concrete Context struct.
This allows agents to use &dyn converge_pack::Context.