Add fuzzy key match, pattern mining (P#) and IDF ranking to document … - #30
Conversation
…graph Phase 3 of the structured document graph: fuzzy retrieval, cross-document pattern mining and rarity-based ranking (rare structure = high information, IDF-style scoring). - Fuzzy key match: search_key_fuzzy scores distinct keys by exact/prefix/ contains/Levenshtein similarity with an IDF bonus (rarer keys score higher). `doc_search` accepts `~segment` to force fuzzy and falls back exact-substring -> fuzzy when the full-path trie misses. - Pattern mining: mine_patterns() counts kind chains (wildcard FIELD/IDX payloads) ending at scalar leaves over a max_depth window, assigns stable pattern ids (P#, registry persisted in storage and restored on open) and indexes chains into the previously dead pattern_trie. Results carry node_count / doc_count / doc_freq, sorted by document frequency ascending so characteristic patterns surface first and background (~1.0) sinks. - Structural search: search_kind_chain() matches nodes whose ancestor kind window ends with the query chain (e.g. "MAP, FIELD, NUMBER"); results are ranked by pattern uniqueness IDF. search_path_scan() complements the radix trie whose leaf holds a single record per chain, returning all nodes with the same key path across documents (spec.replicas: 97 hits on the infra repo instead of 1). - Depth semantics fixed in doc_search: depth counts extra levels BELOW the pattern, so the radix key-length filter gets pattern_len + depth. - New MCP tools: doc_mine_patterns, doc_list_patterns, doc_search_struct. New CLI commands: `codegraph doc patterns`, `codegraph doc struct`.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (54.75%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #30 +/- ##
==========================================
- Coverage 73.84% 73.32% -0.53%
==========================================
Files 87 87
Lines 19286 19915 +629
==========================================
+ Hits 14242 14602 +360
- Misses 5044 5313 +269 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…graph
Phase 3 of the structured document graph: fuzzy retrieval, cross-document pattern mining and rarity-based ranking (rare structure = high information, IDF-style scoring).
doc_searchaccepts~segmentto force fuzzy and falls back exact-substring -> fuzzy when the full-path trie misses.codegraph doc patterns,codegraph doc struct.