Skip to main content

ContextView

Trait ContextView 

Source
pub trait ContextView: Send + Sync {
    // Required methods
    fn has(&self, key: ContextKey) -> bool;
    fn get(&self, key: ContextKey) -> &[Fact];

    // Provided methods
    fn get_proposals(&self, key: ContextKey) -> &[ProposedFact] { ... }
    fn count(&self, key: ContextKey) -> usize { ... }
}
Expand description

Re-export the Context trait from converge-pack. Suggestor and Invariant implementations use &dyn ContextView in their signatures. 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) -> &[Fact]

Get all facts 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.

Implementors§

Source§

impl Context for Context

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