Skip to main content

detect_conversation_cycle

Function detect_conversation_cycle 

Source
pub fn detect_conversation_cycle(
    coherence_history: &[f64],
    window: usize,
    threshold: f64,
) -> ConversationState
Expand description

Detect if coherence changes indicate a circular/stuck conversation.

Examines the last window entries of the coherence history and classifies the trajectory as converging, diverging, stuck, or oscillating.

§Arguments

  • coherence_history: Full history of coherence values (one per tick).
  • window: Number of recent entries to examine.
  • threshold: Minimum meaningful change (below this = stuck).

§Implementation

Dispatches through clawft_treecalc::triage_trajectory first (Finding #8 in docs/eml-treecalc-swap-sites.md): the trajectory is classified as Atom (flat), Sequence (monotone), or Branch (oscillating) by its sign-of-difference pattern. The treecalc form then drives which ConversationState is returned, and the per-state metrics (rate, net_change, max_swing) are computed from the same recent window. This replaces the nested threshold arithmetic with a structural dispatch that’s easier to extend (e.g. a future Atom sub-classifier distinguishing “never-started” from “plateaued”).