pub struct ContextState { /* private fields */ }Expand description
The shared context for a Converge job.
Agents receive &dyn converge_pack::Context (immutable) during execution.
Only the engine holds &mut Context during the merge phase.
Implementations§
Source§impl ContextState
impl ContextState
Sourcepub fn snapshot(&self) -> ContextSnapshot
pub fn snapshot(&self) -> ContextSnapshot
Captures a durable storage snapshot for later rehydration.
Sourcepub fn from_snapshot(snapshot: ContextSnapshot) -> Result<Self, ConvergeError>
pub fn from_snapshot(snapshot: ContextSnapshot) -> Result<Self, ConvergeError>
Rehydrates a context from a verified storage snapshot.
This restores previously promoted context state. It is not a promotion API: malformed snapshots, key mismatches, duplicate IDs, and Merkle mismatches are rejected before the context is returned.
Sourcepub fn get(&self, key: ContextKey) -> &[ContextFact]
pub fn get(&self, key: ContextKey) -> &[ContextFact]
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 has_pending_proposals(&self) -> bool
pub fn has_pending_proposals(&self) -> bool
Returns true if any staged proposals are pending promotion.
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_proposal(
&mut self,
proposal: ProposedFact,
) -> Result<bool, ConvergeError>
pub fn add_proposal( &mut self, proposal: ProposedFact, ) -> Result<bool, ConvergeError>
Stages a proposal for engine validation/promotion.
Returns Ok(true) if the proposal was new.
Returns Ok(false) if an identical proposal is already pending.
Sourcepub fn add_input(
&mut self,
key: ContextKey,
id: impl Into<ProposalId>,
content: impl Into<String>,
) -> Result<bool, ConvergeError>
pub fn add_input( &mut self, key: ContextKey, id: impl Into<ProposalId>, content: impl Into<String>, ) -> Result<bool, ConvergeError>
Stages external input as a proposal to be governed by the engine.
Sourcepub fn add_input_with_provenance(
&mut self,
key: ContextKey,
id: impl Into<ProposalId>,
content: impl Into<String>,
provenance: impl Into<String>,
) -> Result<bool, ConvergeError>
pub fn add_input_with_provenance( &mut self, key: ContextKey, id: impl Into<ProposalId>, content: impl Into<String>, provenance: impl Into<String>, ) -> Result<bool, ConvergeError>
Stages external input with explicit provenance.
Sourcepub fn submit_observation(
&mut self,
request: AdmissionRequest,
) -> Result<AdmissionReceipt, ConvergeError>
pub fn submit_observation( &mut self, request: AdmissionRequest, ) -> Result<AdmissionReceipt, ConvergeError>
Stages a typed external observation as a proposal.
This is the preferred boundary for systems such as Organism. It records actor and source provenance, but it does not create authoritative facts.
Trait Implementations§
Source§impl Clone for ContextState
impl Clone for ContextState
Source§fn clone(&self) -> ContextState
fn clone(&self) -> ContextState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Context for ContextState
Implement the converge-pack Context trait for the concrete Context struct.
This allows agents to use &dyn converge_pack::Context.
impl Context for ContextState
Implement the converge-pack Context trait for the concrete Context struct.
This allows agents to use &dyn converge_pack::Context.
Source§fn has(&self, key: ContextKey) -> bool
fn has(&self, key: ContextKey) -> bool
Source§fn get(&self, key: ContextKey) -> &[ContextFact]
fn get(&self, key: ContextKey) -> &[ContextFact]
Source§fn get_proposals(&self, key: ContextKey) -> &[ProposedFact]
fn get_proposals(&self, key: ContextKey) -> &[ProposedFact]
Source§fn count(&self, key: ContextKey) -> usize
fn count(&self, key: ContextKey) -> usize
Source§fn formation_kind(&self) -> Option<FormationKind>
fn formation_kind(&self) -> Option<FormationKind>
None means the suggestor is running outside
a formation harness (e.g., the engine’s default registration
path); fall back to standalone behavior. Read more