pub struct CoherenceTracker { /* private fields */ }Expand description
Tracks coherence state for a collection of entries.
Implementations§
Source§impl CoherenceTracker
impl CoherenceTracker
Sourcepub const fn new(config: CoherenceConfig) -> Self
pub const fn new(config: CoherenceConfig) -> Self
Creates a new coherence tracker with the given configuration.
Sourcepub const fn current_epoch(&self) -> u64
pub const fn current_epoch(&self) -> u64
Returns the current epoch.
Sourcepub fn advance_epoch(&mut self) -> u64
pub fn advance_epoch(&mut self) -> u64
Advances the epoch and returns the new value.
Sourcepub const fn config(&self) -> &CoherenceConfig
pub const fn config(&self) -> &CoherenceConfig
Returns the configuration.
Sourcepub fn create_initial_meta(
&mut self,
proof_attestation_hash: [u8; 32],
) -> CoherenceMeta
pub fn create_initial_meta( &mut self, proof_attestation_hash: [u8; 32], ) -> CoherenceMeta
Creates initial coherence metadata for a new entry.
Note: Uses current_epoch + 1 to ensure new entries always have a non-zero mutation_epoch, signifying they’ve been mutated at least once.
Sourcepub fn on_entry_added(&mut self, coherence_score: u16)
pub fn on_entry_added(&mut self, coherence_score: u16)
Updates coherence tracking when an entry is added.
Sourcepub fn on_entry_removed(&mut self, coherence_score: u16)
pub fn on_entry_removed(&mut self, coherence_score: u16)
Updates coherence tracking when an entry is removed.
Sourcepub fn on_entry_mutated(
&mut self,
old_meta: &CoherenceMeta,
new_coherence: u16,
proof_attestation_hash: [u8; 32],
) -> CoherenceMeta
pub fn on_entry_mutated( &mut self, old_meta: &CoherenceMeta, new_coherence: u16, proof_attestation_hash: [u8; 32], ) -> CoherenceMeta
Updates coherence tracking when an entry is mutated.
Returns the new coherence metadata for the entry.
Sourcepub fn would_violate_threshold(&self, proposed_coherence: u16) -> bool
pub fn would_violate_threshold(&self, proposed_coherence: u16) -> bool
Checks if a proposed coherence change would violate constraints.
Sourcepub fn average_coherence_f32(&self) -> f32
pub fn average_coherence_f32(&self) -> f32
Returns the average coherence score as a float.
Sourcepub const fn entry_count(&self) -> u32
pub const fn entry_count(&self) -> u32
Returns the number of entries tracked.
Sourcepub const fn low_coherence_mutations(&self) -> u32
pub const fn low_coherence_mutations(&self) -> u32
Returns the number of low-coherence mutations.
Sourcepub fn apply_decay(&mut self, epochs_elapsed: u64)
pub fn apply_decay(&mut self, epochs_elapsed: u64)
Applies coherence decay based on elapsed epochs.
This is called periodically to age coherence scores.
Trait Implementations§
Source§impl Clone for CoherenceTracker
impl Clone for CoherenceTracker
Source§fn clone(&self) -> CoherenceTracker
fn clone(&self) -> CoherenceTracker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more