Module knowledge_graph

Module knowledge_graph 

Source
Expand description

Pattern learning infrastructure for dynamically discovering new tool patterns

This module implements a learning system that observes tool usage in Bash commands, identifies patterns, and promotes frequently-seen patterns to learned patterns.

§Architecture

  • PatternLearner: Main learning system with voting-based promotion
  • CandidatePattern: Tracks observations and category votes for unknown tools
  • LearnedPattern: Promoted patterns with confidence scores

§Example

use terraphim_session_analyzer::patterns::knowledge_graph::{PatternLearner, LearnedPattern};
use terraphim_session_analyzer::models::ToolCategory;

let mut learner = PatternLearner::new();

// Observe tool usage
learner.observe(
    "pytest".to_string(),
    "pytest tests/".to_string(),
    ToolCategory::Testing
);

// After multiple observations, promote to learned patterns
let learned = learner.promote_candidates();

Structs§

CandidatePattern
A candidate pattern being observed
LearnedPattern
A learned pattern that has been promoted
PatternLearner
Learn new tool patterns from usage

Functions§

infer_category_from_contexts
Infer category from tool name and command contexts using heuristics