pub struct TrajectoryTracker {
pub transitions: TransitionMap,
/* private fields */
}Fields§
§transitions: TransitionMapImplementations§
Source§impl TrajectoryTracker
impl TrajectoryTracker
pub fn new(max_turns: usize) -> Self
pub fn record_turn(&mut self, turn: TrajectoryNode)
Sourcepub fn pending_canonicalization(&self, limit: usize) -> Vec<String>
pub fn pending_canonicalization(&self, limit: usize) -> Vec<String>
Recent distinct topic labels that have no learned canonical mapping yet, most recent first. The async canonicalization pass uses this to decide which topics still need an LLM label, so the sync recording path stays fast and no LLM call ever happens per turn.
Sourcepub fn known_topics(&self) -> Vec<String>
pub fn known_topics(&self) -> Vec<String>
The set of learned canonical topic labels, for seeding LLM prompts so it reuses existing labels instead of inventing near-duplicates.
Sourcepub fn learn_canonical(&mut self, raw: &str, canonical: &str)
pub fn learn_canonical(&mut self, raw: &str, canonical: &str)
Store a learned raw -> canonical mapping. Called by the async canonicalization pass after it gets labels from the LLM.
Sourcepub async fn record_turn_with_llm<J: LlmJudge>(
&mut self,
turn: TrajectoryNode,
llm: &CognitiveLlmService<J>,
)
pub async fn record_turn_with_llm<J: LlmJudge>( &mut self, turn: TrajectoryNode, llm: &CognitiveLlmService<J>, )
Record a turn with LLM-powered topic canonicalization.
Checks the learned topic cache first (no LLM call needed for known patterns). On cache miss, asks the LLM for a canonical label and stores it for future use. Falls back to the heuristic path on any LLM error.
pub fn get_trajectory(&self) -> &[TrajectoryNode]
pub fn get_resume_context(&self) -> Option<String>
pub fn predict_next_topics(&self) -> Vec<String>
Sourcepub fn reinforce_transition(&mut self, hit_topic: &str)
pub fn reinforce_transition(&mut self, hit_topic: &str)
Called when the speculative cache gets a hit. Reinforces the transition from the previous topic to the hit topic.
Sourcepub fn decay_transition(&mut self, predicted_topic: &str)
pub fn decay_transition(&mut self, predicted_topic: &str)
Called when the speculative cache misses. Slightly decays the transition from the previous topic to the predicted topic.