Class: ClaudeMemory::Recall
- Inherits:
-
Object
- Object
- ClaudeMemory::Recall
- Defined in:
- lib/claude_memory/recall.rb,
lib/claude_memory/recall/query_core.rb,
lib/claude_memory/recall/dual_engine.rb,
lib/claude_memory/recall/legacy_engine.rb,
lib/claude_memory/recall/expansion_detector.rb,
lib/claude_memory/recall/dual_query_template.rb
Overview
Query interface for facts across dual databases (global + project). Delegates to DualEngine or LegacyEngine depending on the store type.
Defined Under Namespace
Modules: ExpansionDetector, QueryCore Classes: DualEngine, DualQueryTemplate, LegacyEngine
Constant Summary collapse
- SCOPE_PROJECT =
Returns query only project-scoped facts.
"project"- SCOPE_GLOBAL =
Returns query only global-scoped facts.
"global"- SCOPE_ALL =
Returns query both project and global facts (default).
"all"
Class Method Summary collapse
-
.architecture_choices(manager, limit: 10) ⇒ Array<Hash>
Architecture-related facts.
-
.conventions(manager, limit: 20) ⇒ Array<Hash>
Convention facts.
-
.project_config(manager, limit: 10) ⇒ Array<Hash>
Project configuration facts.
-
.recent_decisions(manager, limit: 10) ⇒ Array<Hash>
Recent decision facts.
Instance Method Summary collapse
-
#changes(since:, limit: 50, scope: SCOPE_ALL) ⇒ Array<Hash>
List facts created or modified since a given time.
-
#conflicts(scope: SCOPE_ALL) ⇒ Array<Hash>
List open fact conflicts.
-
#explain(fact_id_or_docid, scope: nil) ⇒ Hash
Show provenance chain for a fact.
-
#fact_graph(fact_id, depth: 2, scope: nil) ⇒ Hash
Traverse fact relationships (supersessions, conflicts) as a graph.
-
#facts_by_branch(branch_name, limit: 20, scope: SCOPE_ALL) ⇒ Array<Hash>
Find facts associated with a git branch.
-
#facts_by_directory(cwd, limit: 20, scope: SCOPE_ALL) ⇒ Array<Hash>
Find facts associated with a working directory.
-
#facts_by_tool(tool_name, limit: 20, scope: SCOPE_ALL) ⇒ Array<Hash>
Find facts associated with a specific tool.
-
#initialize(store_or_manager, fts: nil, project_path: nil, env: ENV, embedding_generator: nil) ⇒ Recall
constructor
A new instance of Recall.
-
#query(query_text, limit: 10, scope: SCOPE_ALL, include_raw_text: false, intent: nil) ⇒ Array<Hash>
Search facts by text query using FTS5.
-
#query_concepts(concepts, limit: 10, scope: SCOPE_ALL) ⇒ Array<Hash>
Find facts at the intersection of multiple concepts.
-
#query_index(query_text, limit: 20, scope: SCOPE_ALL, intent: nil) ⇒ Array<Hash>
Search content items (not facts) via FTS5 index.
-
#query_semantic(text, limit: 10, scope: SCOPE_ALL, mode: :both, explain: false, intent: nil) ⇒ Array<Hash>
Search facts using vector embeddings (semantic similarity).
Constructor Details
#initialize(store_or_manager, fts: nil, project_path: nil, env: ENV, embedding_generator: nil) ⇒ Recall
Returns a new instance of Recall.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/claude_memory/recall.rb', line 49 def initialize(store_or_manager, fts: nil, project_path: nil, env: ENV, embedding_generator: nil) config = Configuration.new(env) resolved_project_path = project_path || config.project_dir resolved_generator = || Embeddings.resolve(env: env) @engine = if store_or_manager.is_a?(Store::StoreManager) DualEngine.new( store_or_manager, embedding_generator: resolved_generator, project_path: resolved_project_path ) else LegacyEngine.new( store_or_manager, fts: fts || Index::LexicalFTS.new(store_or_manager), embedding_generator: resolved_generator, project_path: resolved_project_path ) end end |
Class Method Details
.architecture_choices(manager, limit: 10) ⇒ Array<Hash>
Returns architecture-related facts.
25 26 27 |
# File 'lib/claude_memory/recall.rb', line 25 def architecture_choices(manager, limit: 10) Shortcuts.for(:architecture, manager, limit: limit) end |
.conventions(manager, limit: 20) ⇒ Array<Hash>
Returns convention facts.
32 33 34 |
# File 'lib/claude_memory/recall.rb', line 32 def conventions(manager, limit: 20) Shortcuts.for(:conventions, manager, limit: limit) end |
Instance Method Details
#changes(since:, limit: 50, scope: SCOPE_ALL) ⇒ Array<Hash>
List facts created or modified since a given time
113 114 115 |
# File 'lib/claude_memory/recall.rb', line 113 def changes(since:, limit: 50, scope: SCOPE_ALL) @engine.changes(since: since, limit: limit, scope: scope) end |
#conflicts(scope: SCOPE_ALL) ⇒ Array<Hash>
List open fact conflicts
120 121 122 |
# File 'lib/claude_memory/recall.rb', line 120 def conflicts(scope: SCOPE_ALL) @engine.conflicts(scope: scope) end |
#explain(fact_id_or_docid, scope: nil) ⇒ Hash
Show provenance chain for a fact
104 105 106 |
# File 'lib/claude_memory/recall.rb', line 104 def explain(fact_id_or_docid, scope: nil) @engine.explain(fact_id_or_docid, scope: scope) end |
#fact_graph(fact_id, depth: 2, scope: nil) ⇒ Hash
Traverse fact relationships (supersessions, conflicts) as a graph
96 97 98 |
# File 'lib/claude_memory/recall.rb', line 96 def fact_graph(fact_id, depth: 2, scope: nil) @engine.fact_graph(fact_id, depth: depth, scope: scope) end |
#facts_by_branch(branch_name, limit: 20, scope: SCOPE_ALL) ⇒ Array<Hash>
Find facts associated with a git branch
129 130 131 |
# File 'lib/claude_memory/recall.rb', line 129 def facts_by_branch(branch_name, limit: 20, scope: SCOPE_ALL) @engine.facts_by_branch(branch_name, limit: limit, scope: scope) end |
#facts_by_directory(cwd, limit: 20, scope: SCOPE_ALL) ⇒ Array<Hash>
Find facts associated with a working directory
138 139 140 |
# File 'lib/claude_memory/recall.rb', line 138 def facts_by_directory(cwd, limit: 20, scope: SCOPE_ALL) @engine.facts_by_directory(cwd, limit: limit, scope: scope) end |
#facts_by_tool(tool_name, limit: 20, scope: SCOPE_ALL) ⇒ Array<Hash>
Find facts associated with a specific tool
147 148 149 |
# File 'lib/claude_memory/recall.rb', line 147 def facts_by_tool(tool_name, limit: 20, scope: SCOPE_ALL) @engine.facts_by_tool(tool_name, limit: limit, scope: scope) end |
#query(query_text, limit: 10, scope: SCOPE_ALL, include_raw_text: false, intent: nil) ⇒ Array<Hash>
Search facts by text query using FTS5
77 78 79 |
# File 'lib/claude_memory/recall.rb', line 77 def query(query_text, limit: 10, scope: SCOPE_ALL, include_raw_text: false, intent: nil) @engine.query(query_text, limit: limit, scope: scope, include_raw_text: include_raw_text, intent: intent) end |
#query_concepts(concepts, limit: 10, scope: SCOPE_ALL) ⇒ Array<Hash>
Find facts at the intersection of multiple concepts
169 170 171 172 173 |
# File 'lib/claude_memory/recall.rb', line 169 def query_concepts(concepts, limit: 10, scope: SCOPE_ALL) raise ArgumentError, "Must provide 2-5 concepts" unless (2..5).cover?(concepts.size) @engine.query_concepts(concepts, limit: limit, scope: scope) end |
#query_index(query_text, limit: 20, scope: SCOPE_ALL, intent: nil) ⇒ Array<Hash>
Search content items (not facts) via FTS5 index
87 88 89 |
# File 'lib/claude_memory/recall.rb', line 87 def query_index(query_text, limit: 20, scope: SCOPE_ALL, intent: nil) @engine.query_index(query_text, limit: limit, scope: scope, intent: intent) end |
#query_semantic(text, limit: 10, scope: SCOPE_ALL, mode: :both, explain: false, intent: nil) ⇒ Array<Hash>
Search facts using vector embeddings (semantic similarity)
159 160 161 |
# File 'lib/claude_memory/recall.rb', line 159 def query_semantic(text, limit: 10, scope: SCOPE_ALL, mode: :both, explain: false, intent: nil) @engine.query_semantic(text, limit: limit, scope: scope, mode: mode, explain: explain, intent: intent) end |