Skip to main content

Context

Trait Context 

Source
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 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§

Source

fn has(&self, key: ContextKey) -> bool

Check whether any facts exist under this key.

Source

fn get(&self, key: ContextKey) -> &[ContextFact]

Get all read-only context fact projections under this key.

Provided Methods§

Source

fn get_proposals(&self, key: ContextKey) -> &[ProposedFact]

Get all proposed facts (unvalidated).

Source

fn count(&self, key: ContextKey) -> usize

Count of facts under a key.

Source

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.

Implementors§

Source§

impl Context for ContextState

Implement the converge-pack Context trait for the concrete Context struct. This allows agents to use &dyn converge_pack::Context.