pub struct CoherenceField<V: SensorVocabulary<N>, const N: usize> { /* private fields */ }Expand description
The coherence field: a map of context → CoherenceAccumulator.
Generic over any sensor vocabulary V implementing SensorVocabulary<N>.
Maintains at most [MAX_CONTEXTS] entries with LRU eviction.
Patent Claims 6–7, 13.
Implementations§
Source§impl<V: SensorVocabulary<N>, const N: usize> CoherenceField<V, N>
impl<V: SensorVocabulary<N>, const N: usize> CoherenceField<V, N>
Sourcepub fn effective_coherence(&self, instant: f32, key: &ContextKey<V, N>) -> f32
pub fn effective_coherence(&self, instant: f32, key: &ContextKey<V, N>) -> f32
Compute effective coherence using the asymmetric gate (CCF-001).
- Unfamiliar (ctx < 0.3):
min(instant, ctx)— earn trust first. - Familiar (ctx ≥ 0.3):
0.3 × instant + 0.7 × ctx— history buffers noise.
Sourcepub fn positive_interaction(
&mut self,
key: &ContextKey<V, N>,
personality: &Personality,
tick: u64,
alone: bool,
)
pub fn positive_interaction( &mut self, key: &ContextKey<V, N>, personality: &Personality, tick: u64, alone: bool, )
Record a positive interaction for a context, modulated by personality.
Creates the accumulator at the personality baseline if the context is unseen.
Sourcepub fn negative_interaction(
&mut self,
key: &ContextKey<V, N>,
personality: &Personality,
tick: u64,
)
pub fn negative_interaction( &mut self, key: &ContextKey<V, N>, personality: &Personality, tick: u64, )
Record a negative interaction for a context, modulated by personality.
Creates the accumulator at the personality baseline if the context is unseen.
Sourcepub fn context_coherence(&self, key: &ContextKey<V, N>) -> f32
pub fn context_coherence(&self, key: &ContextKey<V, N>) -> f32
Get the accumulated coherence for a context.
Returns the accumulator value if seen, or the fallback / 0.0 for unseen contexts.
Sourcepub fn context_interaction_count(&self, key: &ContextKey<V, N>) -> u32
pub fn context_interaction_count(&self, key: &ContextKey<V, N>) -> u32
Number of positive interactions recorded for a context (0 if unseen).
Sourcepub fn context_count(&self) -> usize
pub fn context_count(&self) -> usize
Number of tracked contexts.
Sourcepub fn iter(
&self,
) -> impl Iterator<Item = (&ContextKey<V, N>, &CoherenceAccumulator)>
pub fn iter( &self, ) -> impl Iterator<Item = (&ContextKey<V, N>, &CoherenceAccumulator)>
Iterate over all (context key, accumulator) pairs.
Sourcepub fn set_fallback(&mut self, value: Option<f32>)
pub fn set_fallback(&mut self, value: Option<f32>)
Set the fallback coherence returned for unseen contexts in degraded mode.
Pass None to clear the fallback (unseen contexts revert to 0.0).
Sourcepub fn get_or_create(
&mut self,
key: &ContextKey<V, N>,
) -> &mut CoherenceAccumulator
pub fn get_or_create( &mut self, key: &ContextKey<V, N>, ) -> &mut CoherenceAccumulator
Get or create the accumulator for key, initialising at the personality baseline.
Evicts the oldest entry when the field is at [MAX_CONTEXTS] capacity.