Module: ClaudeMemory::Index::IndexQueryLogic
- Defined in:
- lib/claude_memory/index/index_query_logic.rb
Class Method Summary collapse
-
.collect_fact_ids(provenance_by_content, content_ids, limit) ⇒ Array<Integer>
Pure function: collects fact IDs from provenance records No I/O, no side effects - fully testable.
Class Method Details
.collect_fact_ids(provenance_by_content, content_ids, limit) ⇒ Array<Integer>
Pure function: collects fact IDs from provenance records No I/O, no side effects - fully testable
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/claude_memory/index/index_query_logic.rb', line 13 def self.collect_fact_ids(provenance_by_content, content_ids, limit) return [] if limit <= 0 return [] if content_ids.empty? seen_fact_ids = Set.new ordered_fact_ids = [] content_ids.each do |content_id| provenance_records = provenance_by_content[content_id] next unless provenance_records provenance_records.each do |prov| fact_id = prov[:fact_id] next if seen_fact_ids.include?(fact_id) seen_fact_ids.add(fact_id) ordered_fact_ids << fact_id break if ordered_fact_ids.size >= limit end break if ordered_fact_ids.size >= limit end ordered_fact_ids end |