Module: Legion::Extensions::Agentic::Memory::Hologram::Runners::CognitiveHologram
- Includes:
- Helpers::Lex
- Included in:
- Client
- Defined in:
- lib/legion/extensions/agentic/memory/hologram/runners/cognitive_hologram.rb
Instance Method Summary collapse
- #create(domain: :general, content: '', engine: nil) ⇒ Object
- #fragment(hologram_id:, count: 4, engine: nil) ⇒ Object
- #hologram_status(engine: nil) ⇒ Object
- #interference_check(hologram_id_a:, hologram_id_b:, engine: nil) ⇒ Object
- #list_holograms(limit: 20, engine: nil) ⇒ Object
- #reconstruct(hologram_id:, fragment_ids: [], engine: nil) ⇒ Object
Instance Method Details
#create(domain: :general, content: '', engine: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/agentic/memory/hologram/runners/cognitive_hologram.rb', line 13 def create(domain: :general, content: '', engine: nil, **) raise ArgumentError, 'content cannot be empty' if content.to_s.strip.empty? target_engine = engine || default_engine hologram = target_engine.create_hologram(domain: domain, content: content) log.debug("[cognitive_hologram] created hologram: domain=#{domain} id=#{hologram.id}") { success: true, hologram: hologram.to_h } rescue StandardError => e log.error("[cognitive_hologram] create failed: #{e.}") { success: false, error: e. } end |
#fragment(hologram_id:, count: 4, engine: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/legion/extensions/agentic/memory/hologram/runners/cognitive_hologram.rb', line 27 def fragment(hologram_id:, count: 4, engine: nil, **) target_engine = engine || default_engine fragments = target_engine.fragment_hologram(hologram_id: hologram_id, count: count) unless fragments log.warn("[cognitive_hologram] fragment: hologram not found id=#{hologram_id}") return { success: false, reason: :hologram_not_found } end log.debug("[cognitive_hologram] fragmented hologram id=#{hologram_id} count=#{fragments.size}") { success: true, fragment_count: fragments.size, fragments: fragments.map(&:to_h) } rescue StandardError => e log.error("[cognitive_hologram] fragment failed: #{e.}") { success: false, error: e. } end |
#hologram_status(engine: nil) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/legion/extensions/agentic/memory/hologram/runners/cognitive_hologram.rb', line 86 def hologram_status(engine: nil, **) target_engine = engine || default_engine report = target_engine.hologram_report log.debug("[cognitive_hologram] status: total=#{report[:total_holograms]} " \ "avg_resolution=#{report[:average_resolution].round(2)}") { success: true, report: report } rescue StandardError => e log.error("[cognitive_hologram] hologram_status failed: #{e.}") { success: false, error: e. } end |
#interference_check(hologram_id_a:, hologram_id_b:, engine: nil) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/legion/extensions/agentic/memory/hologram/runners/cognitive_hologram.rb', line 70 def interference_check(hologram_id_a:, hologram_id_b:, engine: nil, **) target_engine = engine || default_engine result = target_engine.measure_interference( hologram_id_a: hologram_id_a, hologram_id_b: hologram_id_b ) log.debug('[cognitive_hologram] interference_check: ' \ "a=#{hologram_id_a} b=#{hologram_id_b} score=#{result[:interference]}") result.merge(success: true) rescue StandardError => e log.error("[cognitive_hologram] interference_check failed: #{e.}") { success: false, error: e. } end |
#list_holograms(limit: 20, engine: nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/legion/extensions/agentic/memory/hologram/runners/cognitive_hologram.rb', line 59 def list_holograms(limit: 20, engine: nil, **) target_engine = engine || default_engine holograms = target_engine.holograms.first(limit) log.debug("[cognitive_hologram] list_holograms: count=#{holograms.size} limit=#{limit}") { success: true, holograms: holograms.map(&:to_h), count: holograms.size } rescue StandardError => e log.error("[cognitive_hologram] list_holograms failed: #{e.}") { success: false, error: e. } end |
#reconstruct(hologram_id:, fragment_ids: [], engine: nil) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/legion/extensions/agentic/memory/hologram/runners/cognitive_hologram.rb', line 43 def reconstruct(hologram_id:, fragment_ids: [], engine: nil, **) target_engine = engine || default_engine result = target_engine.reconstruct_from_fragments( hologram_id: hologram_id, fragment_ids: fragment_ids ) log.debug("[cognitive_hologram] reconstruct hologram=#{hologram_id} " \ "fragments=#{fragment_ids.size} success=#{result[:success]}") result.merge(success: result[:success]) rescue StandardError => e log.error("[cognitive_hologram] reconstruct failed: #{e.}") { success: false, error: e. } end |