Class: OllamaAgent::Topology::StagedGraph

Inherits:
SymbolGraph
  • Object
show all
Includes:
SymbolIds
Defined in:
lib/ollama_agent/topology/staged_graph.rb,
lib/ollama_agent/topology/staged_graph/symbol_ids.rb

Overview

Reopened from staged_graph.rb to mix in SymbolIds.

Defined Under Namespace

Modules: SymbolIds

Instance Method Summary collapse

Methods inherited from SymbolGraph

#add_origin, #origins_for, #reset_file, #symbols

Constructor Details

#initializeStagedGraph

Returns a new instance of StagedGraph.



11
12
13
14
15
16
# File 'lib/ollama_agent/topology/staged_graph.rb', line 11

def initialize
  super
  @staged = {}
  @staged_by_file = Hash.new { |h, k| h[k] = [] }
  @promotion_blockers = {}
end

Instance Method Details

#committed_origins_for(symbol_id:) ⇒ Object



49
50
51
# File 'lib/ollama_agent/topology/staged_graph.rb', line 49

def committed_origins_for(symbol_id:)
  origins_for(symbol_id: symbol_id)
end

#committed_symbols_with_originsObject

Yields committed @origins bundles only (never staged). ir_node_aggregate merges same-FQCN class shards.



58
59
60
61
62
63
64
65
66
# File 'lib/ollama_agent/topology/staged_graph.rb', line 58

def committed_symbols_with_origins
  return enum_for(:committed_symbols_with_origins) unless block_given?

  @origins.each do |symbol_id, list|
    origins_dup = list.map(&:dup)
    aggregate = aggregate_ir_for_origins(origins_dup)
    yield({ symbol_id: symbol_id, origins: origins_dup, ir_node_aggregate: aggregate })
  end
end

#note_parse_failure(file_path:) ⇒ Object



23
24
25
# File 'lib/ollama_agent/topology/staged_graph.rb', line 23

def note_parse_failure(file_path:)
  @promotion_blockers[file_path.to_s] = :parse_error
end

#note_validation_failure(file_path:) ⇒ Object



27
28
29
# File 'lib/ollama_agent/topology/staged_graph.rb', line 27

def note_validation_failure(file_path:)
  @promotion_blockers[file_path.to_s] = :validation
end

#promote(file_path:) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ollama_agent/topology/staged_graph.rb', line 31

def promote(file_path:)
  fp = file_path.to_s
  blocker = @promotion_blockers[fp]
  return :rejected_parse_error if blocker == :parse_error
  return :rejected_validation if blocker == :validation

  entries = Array(@staged_by_file[fp]).dup
  entries.each { |entry| commit_entry(entry) }
  remove_staged_entries_for_file_path(fp)
  @promotion_blockers.delete(fp)
  :promoted
end

#reject(file_path:, reason:) ⇒ Object



44
45
46
47
# File 'lib/ollama_agent/topology/staged_graph.rb', line 44

def reject(file_path:, reason:)
  remove_staged_entries_for_file_path(file_path.to_s)
  reason
end

#stage(file_path:, ir_nodes:) ⇒ Object



18
19
20
21
# File 'lib/ollama_agent/topology/staged_graph.rb', line 18

def stage(file_path:, ir_nodes:)
  fp = file_path.to_s
  Array(ir_nodes).each { |node| stage_node(fp, node) }
end

#staged_origins_for(symbol_id:) ⇒ Object



53
54
55
# File 'lib/ollama_agent/topology/staged_graph.rb', line 53

def staged_origins_for(symbol_id:)
  Array(@staged[symbol_id.to_s]).map(&:dup)
end