pub struct DriftMeter {
pub agent_a: AgentId,
pub agent_b: AgentId,
pub state_divergence: f64,
pub causal_divergence: f64,
pub context_divergence: f64,
pub composite_score: f64,
pub threshold: f64,
pub is_drifting: bool,
pub computed_at: Timestamp,
}Expand description
Composite divergence metric between two agents.
All scores are in [0, 1]: 0.0 = identical, 1.0 = fully diverged.
Fields§
§agent_a: AgentIdFirst agent in the comparison.
agent_b: AgentIdSecond agent in the comparison.
state_divergence: f64State-level divergence (0 = same state, 1 = fully different).
causal_divergence: f64Causal divergence from DAG lane comparison.
context_divergence: f64Context overlap divergence (1 - Jaccard similarity of scored items).
composite_score: f64Weighted composite score.
threshold: f64Threshold from IntentDef.drift_threshold (default 0.85).
Drift is detected when 1.0 - composite_score < threshold,
i.e. when composite divergence is high enough.
is_drifting: boolWhether the agents are considered to be drifting apart.
computed_at: TimestampWhen this measurement was taken.
Implementations§
Source§impl DriftMeter
impl DriftMeter
Sourcepub fn compute(input: DriftInput<'_>) -> Self
pub fn compute(input: DriftInput<'_>) -> Self
Compute the drift between two agents from their event streams.
This is a pure function — no I/O.
Sourcefn compute_state_divergence(a: &AgentState, b: &AgentState) -> f64
fn compute_state_divergence(a: &AgentState, b: &AgentState) -> f64
Compare two AgentState values for divergence.
Returns 0.0 if identical variant, 0.5 if same category but different details, 1.0 if completely different states.
Sourcefn compute_causal_divergence(
events_a: &[Event<Value>],
events_b: &[Event<Value>],
decay: &DecayParams,
) -> f64
fn compute_causal_divergence( events_a: &[Event<Value>], events_b: &[Event<Value>], decay: &DecayParams, ) -> f64
Compare DAG lane sequences between two agents.
Uses the ratio of shared event kinds in recent history as a proxy for causal alignment. Apply Weibull decay to weight recent events more.
Sourcefn decay_weighted_kind_histogram(
events: &[Event<Value>],
decay: &DecayParams,
) -> HashMap<u16, f32>
fn decay_weighted_kind_histogram( events: &[Event<Value>], decay: &DecayParams, ) -> HashMap<u16, f32>
Build a decay-weighted histogram of event kinds.
Sourcefn compute_context_divergence(items_a: &[Uuid], items_b: &[Uuid]) -> f64
fn compute_context_divergence(items_a: &[Uuid], items_b: &[Uuid]) -> f64
Compute context divergence as 1 - Jaccard similarity.
Trait Implementations§
Source§impl Clone for DriftMeter
impl Clone for DriftMeter
Source§fn clone(&self) -> DriftMeter
fn clone(&self) -> DriftMeter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more