Class: OllamaAgent::Topology::SymbolGraph
- Inherits:
-
Object
- Object
- OllamaAgent::Topology::SymbolGraph
- Defined in:
- lib/ollama_agent/topology/symbol_graph.rb
Overview
In-memory multi-origin symbol storage (SQLite in E11b).
Direct Known Subclasses
Instance Method Summary collapse
-
#add_origin(symbol_id:, file_path:, ir_node:) ⇒ Object
rubocop:disable Naming/PredicateMethod – API name; returns whether a new origin was stored.
-
#initialize ⇒ SymbolGraph
constructor
A new instance of SymbolGraph.
-
#origins_for(symbol_id:) ⇒ Object
rubocop:enable Naming/PredicateMethod.
- #reset_file(file_path:) ⇒ Object
- #symbols ⇒ Object
Constructor Details
#initialize ⇒ SymbolGraph
Returns a new instance of SymbolGraph.
7 8 9 |
# File 'lib/ollama_agent/topology/symbol_graph.rb', line 7 def initialize @origins = {} end |
Instance Method Details
#add_origin(symbol_id:, file_path:, ir_node:) ⇒ Object
rubocop:disable Naming/PredicateMethod – API name; returns whether a new origin was stored.
12 13 14 15 16 17 18 19 20 |
# File 'lib/ollama_agent/topology/symbol_graph.rb', line 12 def add_origin(symbol_id:, file_path:, ir_node:) key = symbol_id.to_s entry = { file_path: file_path.to_s, ir_node: ir_node } list = @origins[key] ||= [] return false if list.any? { |o| origin_equal?(o, entry) } list << entry true end |
#origins_for(symbol_id:) ⇒ Object
rubocop:enable Naming/PredicateMethod
23 24 25 |
# File 'lib/ollama_agent/topology/symbol_graph.rb', line 23 def origins_for(symbol_id:) Array(@origins[symbol_id.to_s]).map(&:dup) end |
#reset_file(file_path:) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ollama_agent/topology/symbol_graph.rb', line 31 def reset_file(file_path:) fp = file_path.to_s removed = 0 @origins.each_value do |list| before = list.size list.reject! { |o| o[:file_path] == fp } removed += before - list.size end @origins.reject! { |_k, v| v.empty? } removed end |
#symbols ⇒ Object
27 28 29 |
# File 'lib/ollama_agent/topology/symbol_graph.rb', line 27 def symbols @origins.keys end |