Skip to content

Commit 5bd106f

Browse files
AlexMikhalevclaude
andcommitted
docs: add design for enhanced terraphim_automata integration
Design document for improving claude-log-analyzer's use of terraphim_automata capabilities including automata caching, dynamic concept learning, and graph connectivity features. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d1cda3b commit 5bd106f

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Design: Enhance claude-log-analyzer with terraphim_automata
2+
3+
## Problem Statement
4+
5+
The claude-log-analyzer crate has terraphim_automata integration behind a feature flag, but underutilizes its capabilities:
6+
- Only uses `find_matches()` for basic pattern matching
7+
- Hardcodes concept definitions instead of dynamic extraction
8+
- Clones thesaurus on every call (inefficient)
9+
- Doesn't use fuzzy matching, autocomplete, or graph connectivity features
10+
11+
## Goals
12+
13+
1. Better text processing using terraphim_automata capabilities
14+
2. Dynamic concept/pattern learning from observed tool usage
15+
3. Efficient thesaurus management with caching
16+
4. Leverage graph connectivity for relationship inference
17+
18+
## Implementation Plan
19+
20+
### Step 1: Improve TerraphimMatcher Pattern Matching
21+
22+
**File**: `src/patterns/matcher.rs`
23+
24+
Current:
25+
```rust
26+
terraphim_find_matches(text, thesaurus.clone(), true)
27+
```
28+
29+
Changes:
30+
- Cache compiled automata instead of rebuilding
31+
- Use fuzzy matching for typo tolerance
32+
- Add context extraction for better pattern understanding
33+
34+
### Step 2: Dynamic Concept Building in KnowledgeGraphBuilder
35+
36+
**File**: `src/kg/builder.rs`
37+
38+
Current: Hardcoded concept lists (BUN, NPM, INSTALL, etc.)
39+
40+
Changes:
41+
- Learn concepts dynamically from observed patterns
42+
- Use terraphim_automata's thesaurus capabilities
43+
- Build hierarchical concept relationships
44+
45+
### Step 3: Enhanced Search with Graph Connectivity
46+
47+
**File**: `src/kg/search.rs`
48+
49+
Current: Manual proximity-based result merging
50+
51+
Changes:
52+
- Use `is_all_terms_connected_by_path()` for semantic relationships
53+
- Improve relevance scoring with concept graph distances
54+
- Cache search results for repeated queries
55+
56+
### Step 4: Integrate Learned Patterns with Terraphim
57+
58+
**File**: `src/patterns/knowledge_graph.rs`
59+
60+
Current: Separate learning system from terraphim
61+
62+
Changes:
63+
- Store learned patterns in terraphim thesaurus
64+
- Use graph structure for relationship inference
65+
- Export/import learned knowledge
66+
67+
## File Changes
68+
69+
| File | Action | Purpose |
70+
|------|--------|---------|
71+
| `src/patterns/matcher.rs:159-290` | Modify | Cache automata, add fuzzy matching |
72+
| `src/kg/builder.rs` | Modify | Dynamic concept learning |
73+
| `src/kg/search.rs` | Modify | Graph connectivity for search |
74+
| `src/patterns/knowledge_graph.rs` | Modify | Integrate with terraphim learning |
75+
76+
## Acceptance Criteria
77+
78+
1. Pattern matching uses cached automata (no clone per call)
79+
2. Concepts learned dynamically from tool observation
80+
3. Fuzzy matching available for typo-tolerant search
81+
4. Tests pass with `--features terraphim`

0 commit comments

Comments
 (0)