Class: ClaudeMemory::Recall::DualEngine
- Inherits:
-
Object
- Object
- ClaudeMemory::Recall::DualEngine
- Includes:
- QueryCore
- Defined in:
- lib/claude_memory/recall/dual_engine.rb
Overview
Query engine for dual-database mode (StoreManager with global + project DBs). Wraps DualQueryTemplate around shared QueryCore methods.
Instance Method Summary collapse
- #changes(since:, limit:, scope:) ⇒ Object
- #conflicts(scope:) ⇒ Object
- #explain(fact_id_or_docid, scope:) ⇒ Object
- #fact_graph(fact_id, depth:, scope:) ⇒ Object
- #facts_by_branch(branch_name, limit:, scope:) ⇒ Object
- #facts_by_directory(cwd, limit:, scope:) ⇒ Object
- #facts_by_tool(tool_name, limit:, scope:) ⇒ Object
-
#initialize(manager, embedding_generator:, project_path:) ⇒ DualEngine
constructor
A new instance of DualEngine.
- #query(query_text, limit:, scope:, include_raw_text: false, intent: nil) ⇒ Object
- #query_concepts(concepts, limit:, scope:) ⇒ Object
- #query_index(query_text, limit:, scope:, intent: nil) ⇒ Object
- #query_semantic(text, limit:, scope:, mode:, explain: false, intent: nil) ⇒ Object
Constructor Details
#initialize(manager, embedding_generator:, project_path:) ⇒ DualEngine
Returns a new instance of DualEngine.
10 11 12 13 14 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 10 def initialize(manager, embedding_generator:, project_path:) @manager = manager @embedding_generator = @project_path = project_path end |
Instance Method Details
#changes(since:, limit:, scope:) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 45 def changes(since:, limit:, scope:) results = dual_execute(scope: scope, limit: limit) do |store, source| changes = fetch_changes(store, since, limit) Core::ResultSorter.annotate_source(changes, source) end Core::ResultSorter.(results, limit) end |
#conflicts(scope:) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 53 def conflicts(scope:) dual_execute(scope: scope) do |store, source| conflicts = store.open_conflicts Core::ResultSorter.annotate_source(conflicts, source) end end |
#explain(fact_id_or_docid, scope:) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 38 def explain(fact_id_or_docid, scope:) scope ||= SCOPE_PROJECT store = @manager.store_for_scope(scope) fact_id = resolve_fact_identifier(store, fact_id_or_docid) explain_from_store(store, fact_id) end |
#fact_graph(fact_id, depth:, scope:) ⇒ Object
32 33 34 35 36 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 32 def fact_graph(fact_id, depth:, scope:) scope ||= SCOPE_PROJECT store = @manager.store_for_scope(scope) Core::FactGraph.build(store, fact_id, depth: depth) end |
#facts_by_branch(branch_name, limit:, scope:) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 60 def facts_by_branch(branch_name, limit:, scope:) results = dual_execute(scope: scope, limit: limit) do |store, source| facts_by_context_single(store, :git_branch, branch_name, limit: limit, source: source) end dedupe_and_sort(results, limit) end |
#facts_by_directory(cwd, limit:, scope:) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 67 def facts_by_directory(cwd, limit:, scope:) results = dual_execute(scope: scope, limit: limit) do |store, source| facts_by_context_single(store, :cwd, cwd, limit: limit, source: source) end dedupe_and_sort(results, limit) end |
#facts_by_tool(tool_name, limit:, scope:) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 74 def facts_by_tool(tool_name, limit:, scope:) results = dual_execute(scope: scope, limit: limit) do |store, source| facts_by_tool_single(store, tool_name, limit: limit, source: source) end dedupe_and_sort(results, limit) end |
#query(query_text, limit:, scope:, include_raw_text: false, intent: nil) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 16 def query(query_text, limit:, scope:, include_raw_text: false, intent: nil) effective_query = intent_augmented_query(query_text, intent) results = dual_execute(scope: scope, limit: limit) do |store, source| query_single_store(store, effective_query, limit: limit, source: source, include_raw_text: include_raw_text) end dedupe_and_sort(results, limit) end |
#query_concepts(concepts, limit:, scope:) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 90 def query_concepts(concepts, limit:, scope:) results = dual_execute(scope: scope, limit: limit) do |store, source| query_concepts_single(store, concepts, limit: limit * 2, source: source) end dedupe_by_fact_id(results, limit) end |
#query_index(query_text, limit:, scope:, intent: nil) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 24 def query_index(query_text, limit:, scope:, intent: nil) effective_query = intent_augmented_query(query_text, intent) results = dual_execute(scope: scope, limit: limit) do |store, source| query_index_single_store(store, effective_query, limit: limit, source: source) end dedupe_and_sort_index(results, limit) end |
#query_semantic(text, limit:, scope:, mode:, explain: false, intent: nil) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/claude_memory/recall/dual_engine.rb', line 81 def query_semantic(text, limit:, scope:, mode:, explain: false, intent: nil) effective_text = intent_augmented_query(text, intent) results = dual_execute(scope: scope, limit: limit) do |store, source| query_semantic_single(store, effective_text, limit: limit * 3, mode: mode, source: source, explain: explain, skip_fts_shortcut: !intent.nil?) end dedupe_by_fact_id(results, limit) end |