Skip to main content

CoherenceField

Struct CoherenceField 

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

Source

pub fn new() -> Self

Construct a fresh field with no accumulated coherence.

Source

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

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.

Source

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.

Source

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.

Source

pub fn context_interaction_count(&self, key: &ContextKey<V, N>) -> u32

Number of positive interactions recorded for a context (0 if unseen).

Source

pub fn decay_all(&mut self, elapsed_ticks: u64)

Apply time-based decay to all accumulators.

Source

pub fn context_count(&self) -> usize

Number of tracked contexts.

Source

pub fn iter( &self, ) -> impl Iterator<Item = (&ContextKey<V, N>, &CoherenceAccumulator)>

Iterate over all (context key, accumulator) pairs.

Source

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).

Source

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.

Trait Implementations§

Source§

impl<V: SensorVocabulary<N>, const N: usize> Debug for CoherenceField<V, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: SensorVocabulary<N>, const N: usize> Default for CoherenceField<V, N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<V, const N: usize> Freeze for CoherenceField<V, N>

§

impl<V, const N: usize> RefUnwindSafe for CoherenceField<V, N>
where V: RefUnwindSafe,

§

impl<V, const N: usize> Send for CoherenceField<V, N>
where V: Send,

§

impl<V, const N: usize> Sync for CoherenceField<V, N>
where V: Sync,

§

impl<V, const N: usize> Unpin for CoherenceField<V, N>
where V: Unpin,

§

impl<V, const N: usize> UnsafeUnpin for CoherenceField<V, N>

§

impl<V, const N: usize> UnwindSafe for CoherenceField<V, N>
where V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.