Class: ClaudeMemory::Core::FactCollector
- Inherits:
-
Object
- Object
- ClaudeMemory::Core::FactCollector
- Defined in:
- lib/claude_memory/core/fact_collector.rb
Overview
Pure logic for collecting and ordering fact IDs from provenance records Follows Functional Core pattern - no I/O, just transformations
Class Method Summary collapse
-
.collect_ordered_fact_ids(provenance_by_content, content_ids, limit) ⇒ Array<Integer>
Collect fact IDs from provenance records, maintaining content order and deduplicating.
-
.extract_content_ids(provenance_records) ⇒ Array<Integer>
Extract unique content IDs from array of provenance records.
-
.extract_fact_ids(provenance_records) ⇒ Array<Integer>
Extract unique fact IDs from array of provenance records.
Class Method Details
.collect_ordered_fact_ids(provenance_by_content, content_ids, limit) ⇒ Array<Integer>
Collect fact IDs from provenance records, maintaining content order and deduplicating
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/claude_memory/core/fact_collector.rb', line 13 def self.collect_ordered_fact_ids(provenance_by_content, content_ids, limit) return [] if limit <= 0 seen_fact_ids = Set.new ordered_fact_ids = [] content_ids.each do |content_id| provenance_records = provenance_by_content[content_id] || [] 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 |
.extract_content_ids(provenance_records) ⇒ Array<Integer>
Extract unique content IDs from array of provenance records
46 47 48 |
# File 'lib/claude_memory/core/fact_collector.rb', line 46 def self.extract_content_ids(provenance_records) provenance_records.map { |p| p[:content_item_id] }.uniq end |
.extract_fact_ids(provenance_records) ⇒ Array<Integer>
Extract unique fact IDs from array of provenance records
39 40 41 |
# File 'lib/claude_memory/core/fact_collector.rb', line 39 def self.extract_fact_ids(provenance_records) provenance_records.map { |p| p[:fact_id] }.uniq end |