Class: ClaudeMemory::Resolve::Resolver
- Inherits:
-
Object
- Object
- ClaudeMemory::Resolve::Resolver
- Defined in:
- lib/claude_memory/resolve/resolver.rb
Overview
Truth maintenance engine that processes distilled extractions into stored facts. Wraps entity resolution, fact insertion, supersession, and conflict detection in a single database transaction.
Instance Method Summary collapse
-
#apply(extraction, content_item_id: nil, occurred_at: nil, project_path: nil, scope: "project") ⇒ Hash
Apply a distilled extraction, resolving each fact against existing knowledge.
-
#initialize(store) ⇒ Resolver
constructor
A new instance of Resolver.
Constructor Details
#initialize(store) ⇒ Resolver
Returns a new instance of Resolver.
16 17 18 |
# File 'lib/claude_memory/resolve/resolver.rb', line 16 def initialize(store) @store = store end |
Instance Method Details
#apply(extraction, content_item_id: nil, occurred_at: nil, project_path: nil, scope: "project") ⇒ Hash
Apply a distilled extraction, resolving each fact against existing knowledge. Facts may be inserted, reinforce an existing fact, supersede old facts, or create a conflict when the resolution is ambiguous.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/claude_memory/resolve/resolver.rb', line 31 def apply(extraction, content_item_id: nil, occurred_at: nil, project_path: nil, scope: "project") occurred_at ||= Time.now.utc.iso8601 result = { entities_created: 0, facts_created: 0, facts_superseded: 0, conflicts_created: 0, provenance_created: 0 } # Wrap entire extraction in a single transaction for better concurrency # This reduces database lock time compared to per-fact transactions @store.db.transaction do entity_ids = resolve_entities(extraction.entities) result[:entities_created] = entity_ids.size extraction.facts.each do |fact_data| outcome = resolve_fact(fact_data, entity_ids, content_item_id, occurred_at, project_path: project_path, scope: scope) result[:facts_created] += outcome[:created] result[:facts_superseded] += outcome[:superseded] result[:conflicts_created] += outcome[:conflicts] result[:provenance_created] += outcome[:provenance] end end result end |