lex-agentic-memory 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +13 -0
- data/lex-agentic-memory.gemspec +30 -0
- data/lib/legion/extensions/agentic/memory/archaeology/client.rb +19 -0
- data/lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb +184 -0
- data/lib/legion/extensions/agentic/memory/archaeology/helpers/artifact.rb +146 -0
- data/lib/legion/extensions/agentic/memory/archaeology/helpers/constants.rb +95 -0
- data/lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb +97 -0
- data/lib/legion/extensions/agentic/memory/archaeology/runners/cognitive_archaeology.rb +86 -0
- data/lib/legion/extensions/agentic/memory/archaeology/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/archaeology.rb +22 -0
- data/lib/legion/extensions/agentic/memory/compression/client.rb +15 -0
- data/lib/legion/extensions/agentic/memory/compression/helpers/compression_engine.rb +145 -0
- data/lib/legion/extensions/agentic/memory/compression/helpers/constants.rb +44 -0
- data/lib/legion/extensions/agentic/memory/compression/helpers/information_chunk.rb +81 -0
- data/lib/legion/extensions/agentic/memory/compression/runners/cognitive_compression.rb +76 -0
- data/lib/legion/extensions/agentic/memory/compression/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/compression.rb +19 -0
- data/lib/legion/extensions/agentic/memory/echo/client.rb +19 -0
- data/lib/legion/extensions/agentic/memory/echo/helpers/constants.rb +57 -0
- data/lib/legion/extensions/agentic/memory/echo/helpers/echo.rb +95 -0
- data/lib/legion/extensions/agentic/memory/echo/helpers/echo_engine.rb +136 -0
- data/lib/legion/extensions/agentic/memory/echo/runners/cognitive_echo.rb +81 -0
- data/lib/legion/extensions/agentic/memory/echo/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/echo.rb +19 -0
- data/lib/legion/extensions/agentic/memory/echo_chamber/client.rb +19 -0
- data/lib/legion/extensions/agentic/memory/echo_chamber/helpers/chamber.rb +134 -0
- data/lib/legion/extensions/agentic/memory/echo_chamber/helpers/chamber_engine.rb +156 -0
- data/lib/legion/extensions/agentic/memory/echo_chamber/helpers/constants.rb +60 -0
- data/lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb +96 -0
- data/lib/legion/extensions/agentic/memory/echo_chamber/runners/cognitive_echo_chamber.rb +84 -0
- data/lib/legion/extensions/agentic/memory/echo_chamber/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/echo_chamber.rb +21 -0
- data/lib/legion/extensions/agentic/memory/episodic/actors/decay.rb +45 -0
- data/lib/legion/extensions/agentic/memory/episodic/client.rb +25 -0
- data/lib/legion/extensions/agentic/memory/episodic/helpers/constants.rb +36 -0
- data/lib/legion/extensions/agentic/memory/episodic/helpers/episode.rb +104 -0
- data/lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb +57 -0
- data/lib/legion/extensions/agentic/memory/episodic/helpers/episodic_store.rb +141 -0
- data/lib/legion/extensions/agentic/memory/episodic/runners/episodic_buffer.rb +108 -0
- data/lib/legion/extensions/agentic/memory/episodic/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/episodic.rb +20 -0
- data/lib/legion/extensions/agentic/memory/hologram/client.rb +23 -0
- data/lib/legion/extensions/agentic/memory/hologram/helpers/constants.rb +67 -0
- data/lib/legion/extensions/agentic/memory/hologram/helpers/hologram.rb +118 -0
- data/lib/legion/extensions/agentic/memory/hologram/helpers/hologram_engine.rb +117 -0
- data/lib/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment.rb +70 -0
- data/lib/legion/extensions/agentic/memory/hologram/runners/cognitive_hologram.rb +110 -0
- data/lib/legion/extensions/agentic/memory/hologram/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/hologram.rb +22 -0
- data/lib/legion/extensions/agentic/memory/immune_memory/client.rb +19 -0
- data/lib/legion/extensions/agentic/memory/immune_memory/helpers/constants.rb +84 -0
- data/lib/legion/extensions/agentic/memory/immune_memory/helpers/encounter.rb +54 -0
- data/lib/legion/extensions/agentic/memory/immune_memory/helpers/immune_memory_engine.rb +171 -0
- data/lib/legion/extensions/agentic/memory/immune_memory/helpers/memory_cell.rb +97 -0
- data/lib/legion/extensions/agentic/memory/immune_memory/runners/cognitive_immune_memory.rb +76 -0
- data/lib/legion/extensions/agentic/memory/immune_memory/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/immune_memory.rb +20 -0
- data/lib/legion/extensions/agentic/memory/nostalgia/client.rb +31 -0
- data/lib/legion/extensions/agentic/memory/nostalgia/helpers/constants.rb +68 -0
- data/lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_engine.rb +148 -0
- data/lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event.rb +44 -0
- data/lib/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory.rb +97 -0
- data/lib/legion/extensions/agentic/memory/nostalgia/runners/analysis.rb +61 -0
- data/lib/legion/extensions/agentic/memory/nostalgia/runners/recall.rb +60 -0
- data/lib/legion/extensions/agentic/memory/nostalgia/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/nostalgia.rb +21 -0
- data/lib/legion/extensions/agentic/memory/offloading/client.rb +29 -0
- data/lib/legion/extensions/agentic/memory/offloading/helpers/constants.rb +55 -0
- data/lib/legion/extensions/agentic/memory/offloading/helpers/external_store.rb +82 -0
- data/lib/legion/extensions/agentic/memory/offloading/helpers/offloaded_item.rb +65 -0
- data/lib/legion/extensions/agentic/memory/offloading/helpers/offloading_engine.rb +138 -0
- data/lib/legion/extensions/agentic/memory/offloading/runners/cognitive_offloading.rb +102 -0
- data/lib/legion/extensions/agentic/memory/offloading/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/offloading.rb +20 -0
- data/lib/legion/extensions/agentic/memory/paleontology/client.rb +19 -0
- data/lib/legion/extensions/agentic/memory/paleontology/helpers/constants.rb +69 -0
- data/lib/legion/extensions/agentic/memory/paleontology/helpers/excavation.rb +62 -0
- data/lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb +125 -0
- data/lib/legion/extensions/agentic/memory/paleontology/helpers/paleontology_engine.rb +170 -0
- data/lib/legion/extensions/agentic/memory/paleontology/runners/cognitive_paleontology.rb +93 -0
- data/lib/legion/extensions/agentic/memory/paleontology/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/paleontology.rb +22 -0
- data/lib/legion/extensions/agentic/memory/palimpsest/client.rb +19 -0
- data/lib/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer.rb +81 -0
- data/lib/legion/extensions/agentic/memory/palimpsest/helpers/constants.rb +56 -0
- data/lib/legion/extensions/agentic/memory/palimpsest/helpers/palimpsest.rb +124 -0
- data/lib/legion/extensions/agentic/memory/palimpsest/helpers/palimpsest_engine.rb +117 -0
- data/lib/legion/extensions/agentic/memory/palimpsest/runners/cognitive_palimpsest.rb +105 -0
- data/lib/legion/extensions/agentic/memory/palimpsest/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/palimpsest.rb +21 -0
- data/lib/legion/extensions/agentic/memory/reserve/client.rb +19 -0
- data/lib/legion/extensions/agentic/memory/reserve/helpers/constants.rb +58 -0
- data/lib/legion/extensions/agentic/memory/reserve/helpers/pathway.rb +112 -0
- data/lib/legion/extensions/agentic/memory/reserve/helpers/reserve_engine.rb +163 -0
- data/lib/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve.rb +92 -0
- data/lib/legion/extensions/agentic/memory/reserve/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/reserve.rb +19 -0
- data/lib/legion/extensions/agentic/memory/semantic/actors/decay.rb +45 -0
- data/lib/legion/extensions/agentic/memory/semantic/client.rb +28 -0
- data/lib/legion/extensions/agentic/memory/semantic/helpers/concept.rb +101 -0
- data/lib/legion/extensions/agentic/memory/semantic/helpers/constants.rb +51 -0
- data/lib/legion/extensions/agentic/memory/semantic/helpers/knowledge_store.rb +145 -0
- data/lib/legion/extensions/agentic/memory/semantic/runners/semantic_memory.rb +94 -0
- data/lib/legion/extensions/agentic/memory/semantic/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/semantic.rb +20 -0
- data/lib/legion/extensions/agentic/memory/semantic_priming/client.rb +19 -0
- data/lib/legion/extensions/agentic/memory/semantic_priming/helpers/connection.rb +77 -0
- data/lib/legion/extensions/agentic/memory/semantic_priming/helpers/constants.rb +68 -0
- data/lib/legion/extensions/agentic/memory/semantic_priming/helpers/priming_network.rb +206 -0
- data/lib/legion/extensions/agentic/memory/semantic_priming/helpers/semantic_node.rb +81 -0
- data/lib/legion/extensions/agentic/memory/semantic_priming/runners/semantic_priming.rb +120 -0
- data/lib/legion/extensions/agentic/memory/semantic_priming/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/semantic_priming.rb +20 -0
- data/lib/legion/extensions/agentic/memory/semantic_satiation/client.rb +28 -0
- data/lib/legion/extensions/agentic/memory/semantic_satiation/helpers/concept.rb +82 -0
- data/lib/legion/extensions/agentic/memory/semantic_satiation/helpers/constants.rb +37 -0
- data/lib/legion/extensions/agentic/memory/semantic_satiation/helpers/satiation_engine.rb +103 -0
- data/lib/legion/extensions/agentic/memory/semantic_satiation/runners/semantic_satiation.rb +92 -0
- data/lib/legion/extensions/agentic/memory/semantic_satiation/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/semantic_satiation.rb +19 -0
- data/lib/legion/extensions/agentic/memory/source_monitoring/actors/decay.rb +31 -0
- data/lib/legion/extensions/agentic/memory/source_monitoring/client.rb +28 -0
- data/lib/legion/extensions/agentic/memory/source_monitoring/helpers/constants.rb +66 -0
- data/lib/legion/extensions/agentic/memory/source_monitoring/helpers/source_record.rb +94 -0
- data/lib/legion/extensions/agentic/memory/source_monitoring/helpers/source_tracker.rb +119 -0
- data/lib/legion/extensions/agentic/memory/source_monitoring/runners/source_monitoring.rb +95 -0
- data/lib/legion/extensions/agentic/memory/source_monitoring/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/source_monitoring.rb +19 -0
- data/lib/legion/extensions/agentic/memory/trace/actors/decay.rb +45 -0
- data/lib/legion/extensions/agentic/memory/trace/actors/tier_migration.rb +45 -0
- data/lib/legion/extensions/agentic/memory/trace/batch_decay.rb +44 -0
- data/lib/legion/extensions/agentic/memory/trace/client.rb +32 -0
- data/lib/legion/extensions/agentic/memory/trace/helpers/cache_store.rb +167 -0
- data/lib/legion/extensions/agentic/memory/trace/helpers/decay.rb +68 -0
- data/lib/legion/extensions/agentic/memory/trace/helpers/error_tracer.rb +94 -0
- data/lib/legion/extensions/agentic/memory/trace/helpers/store.rb +260 -0
- data/lib/legion/extensions/agentic/memory/trace/helpers/trace.rb +106 -0
- data/lib/legion/extensions/agentic/memory/trace/local_migrations/20260316000001_create_memory_traces.rb +31 -0
- data/lib/legion/extensions/agentic/memory/trace/local_migrations/20260316000002_create_memory_associations.rb +13 -0
- data/lib/legion/extensions/agentic/memory/trace/persistent_store.rb +94 -0
- data/lib/legion/extensions/agentic/memory/trace/quota.rb +55 -0
- data/lib/legion/extensions/agentic/memory/trace/runners/consolidation.rb +121 -0
- data/lib/legion/extensions/agentic/memory/trace/runners/traces.rb +105 -0
- data/lib/legion/extensions/agentic/memory/trace/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/trace.rb +54 -0
- data/lib/legion/extensions/agentic/memory/transfer/client.rb +28 -0
- data/lib/legion/extensions/agentic/memory/transfer/helpers/constants.rb +34 -0
- data/lib/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge.rb +74 -0
- data/lib/legion/extensions/agentic/memory/transfer/helpers/transfer_engine.rb +188 -0
- data/lib/legion/extensions/agentic/memory/transfer/runners/transfer_learning.rb +77 -0
- data/lib/legion/extensions/agentic/memory/transfer/version.rb +13 -0
- data/lib/legion/extensions/agentic/memory/transfer.rb +19 -0
- data/lib/legion/extensions/agentic/memory/version.rb +11 -0
- data/lib/legion/extensions/agentic/memory.rb +35 -0
- data/spec/legion/extensions/agentic/memory/archaeology/client_spec.rb +38 -0
- data/spec/legion/extensions/agentic/memory/archaeology/cognitive_archaeology_spec.rb +7 -0
- data/spec/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine_spec.rb +165 -0
- data/spec/legion/extensions/agentic/memory/archaeology/helpers/artifact_spec.rb +196 -0
- data/spec/legion/extensions/agentic/memory/archaeology/helpers/constants_spec.rb +42 -0
- data/spec/legion/extensions/agentic/memory/archaeology/helpers/excavation_site_spec.rb +115 -0
- data/spec/legion/extensions/agentic/memory/archaeology/runners/cognitive_archaeology_spec.rb +96 -0
- data/spec/legion/extensions/agentic/memory/compression/helpers/compression_engine_spec.rb +138 -0
- data/spec/legion/extensions/agentic/memory/compression/helpers/constants_spec.rb +50 -0
- data/spec/legion/extensions/agentic/memory/compression/helpers/information_chunk_spec.rb +123 -0
- data/spec/legion/extensions/agentic/memory/compression/runners/cognitive_compression_spec.rb +80 -0
- data/spec/legion/extensions/agentic/memory/echo/client_spec.rb +20 -0
- data/spec/legion/extensions/agentic/memory/echo/cognitive_echo_spec.rb +7 -0
- data/spec/legion/extensions/agentic/memory/echo/helpers/echo_engine_spec.rb +152 -0
- data/spec/legion/extensions/agentic/memory/echo/helpers/echo_spec.rb +128 -0
- data/spec/legion/extensions/agentic/memory/echo/runners_spec.rb +80 -0
- data/spec/legion/extensions/agentic/memory/echo_chamber/client_spec.rb +84 -0
- data/spec/legion/extensions/agentic/memory/echo_chamber/helpers/chamber_engine_spec.rb +266 -0
- data/spec/legion/extensions/agentic/memory/echo_chamber/helpers/chamber_spec.rb +249 -0
- data/spec/legion/extensions/agentic/memory/echo_chamber/helpers/constants_spec.rb +130 -0
- data/spec/legion/extensions/agentic/memory/echo_chamber/helpers/echo_spec.rb +252 -0
- data/spec/legion/extensions/agentic/memory/echo_chamber/runners/cognitive_echo_chamber_spec.rb +185 -0
- data/spec/legion/extensions/agentic/memory/episodic/client_spec.rb +80 -0
- data/spec/legion/extensions/agentic/memory/episodic/episodic_buffer_spec.rb +15 -0
- data/spec/legion/extensions/agentic/memory/episodic/helpers/constants_spec.rb +86 -0
- data/spec/legion/extensions/agentic/memory/episodic/helpers/episode_spec.rb +188 -0
- data/spec/legion/extensions/agentic/memory/episodic/helpers/episodic_binding_spec.rb +114 -0
- data/spec/legion/extensions/agentic/memory/episodic/helpers/episodic_store_spec.rb +201 -0
- data/spec/legion/extensions/agentic/memory/episodic/runners/episodic_buffer_spec.rb +208 -0
- data/spec/legion/extensions/agentic/memory/hologram/client_spec.rb +89 -0
- data/spec/legion/extensions/agentic/memory/hologram/cognitive_hologram_spec.rb +39 -0
- data/spec/legion/extensions/agentic/memory/hologram/helpers/constants_spec.rb +143 -0
- data/spec/legion/extensions/agentic/memory/hologram/helpers/hologram_engine_spec.rb +268 -0
- data/spec/legion/extensions/agentic/memory/hologram/helpers/hologram_spec.rb +256 -0
- data/spec/legion/extensions/agentic/memory/hologram/helpers/holographic_fragment_spec.rb +213 -0
- data/spec/legion/extensions/agentic/memory/hologram/runners/cognitive_hologram_spec.rb +239 -0
- data/spec/legion/extensions/agentic/memory/immune_memory/client_spec.rb +18 -0
- data/spec/legion/extensions/agentic/memory/immune_memory/cognitive_immune_memory_spec.rb +7 -0
- data/spec/legion/extensions/agentic/memory/immune_memory/helpers/encounter_spec.rb +85 -0
- data/spec/legion/extensions/agentic/memory/immune_memory/helpers/immune_memory_engine_spec.rb +203 -0
- data/spec/legion/extensions/agentic/memory/immune_memory/helpers/memory_cell_spec.rb +190 -0
- data/spec/legion/extensions/agentic/memory/immune_memory/runners_spec.rb +83 -0
- data/spec/legion/extensions/agentic/memory/nostalgia/client_spec.rb +71 -0
- data/spec/legion/extensions/agentic/memory/nostalgia/helpers/constants_spec.rb +65 -0
- data/spec/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_engine_spec.rb +191 -0
- data/spec/legion/extensions/agentic/memory/nostalgia/helpers/nostalgia_event_spec.rb +59 -0
- data/spec/legion/extensions/agentic/memory/nostalgia/helpers/nostalgic_memory_spec.rb +134 -0
- data/spec/legion/extensions/agentic/memory/nostalgia/runners/analysis_spec.rb +97 -0
- data/spec/legion/extensions/agentic/memory/nostalgia/runners/recall_spec.rb +81 -0
- data/spec/legion/extensions/agentic/memory/offloading/client_spec.rb +30 -0
- data/spec/legion/extensions/agentic/memory/offloading/helpers/constants_spec.rb +71 -0
- data/spec/legion/extensions/agentic/memory/offloading/helpers/external_store_spec.rb +158 -0
- data/spec/legion/extensions/agentic/memory/offloading/helpers/offloaded_item_spec.rb +123 -0
- data/spec/legion/extensions/agentic/memory/offloading/helpers/offloading_engine_spec.rb +250 -0
- data/spec/legion/extensions/agentic/memory/offloading/runners/cognitive_offloading_spec.rb +194 -0
- data/spec/legion/extensions/agentic/memory/paleontology/client_spec.rb +27 -0
- data/spec/legion/extensions/agentic/memory/paleontology/cognitive_paleontology_spec.rb +7 -0
- data/spec/legion/extensions/agentic/memory/paleontology/helpers/constants_spec.rb +33 -0
- data/spec/legion/extensions/agentic/memory/paleontology/helpers/excavation_spec.rb +71 -0
- data/spec/legion/extensions/agentic/memory/paleontology/helpers/fossil_spec.rb +134 -0
- data/spec/legion/extensions/agentic/memory/paleontology/helpers/paleontology_engine_spec.rb +148 -0
- data/spec/legion/extensions/agentic/memory/paleontology/runners/cognitive_paleontology_spec.rb +89 -0
- data/spec/legion/extensions/agentic/memory/palimpsest/client_spec.rb +58 -0
- data/spec/legion/extensions/agentic/memory/palimpsest/helpers/belief_layer_spec.rb +150 -0
- data/spec/legion/extensions/agentic/memory/palimpsest/helpers/constants_spec.rb +63 -0
- data/spec/legion/extensions/agentic/memory/palimpsest/helpers/palimpsest_engine_spec.rb +164 -0
- data/spec/legion/extensions/agentic/memory/palimpsest/helpers/palimpsest_spec.rb +172 -0
- data/spec/legion/extensions/agentic/memory/palimpsest/runners/cognitive_palimpsest_spec.rb +165 -0
- data/spec/legion/extensions/agentic/memory/reserve/client_spec.rb +37 -0
- data/spec/legion/extensions/agentic/memory/reserve/helpers/pathway_spec.rb +165 -0
- data/spec/legion/extensions/agentic/memory/reserve/helpers/reserve_engine_spec.rb +196 -0
- data/spec/legion/extensions/agentic/memory/reserve/runners/cognitive_reserve_spec.rb +96 -0
- data/spec/legion/extensions/agentic/memory/semantic/client_spec.rb +35 -0
- data/spec/legion/extensions/agentic/memory/semantic/helpers/concept_spec.rb +119 -0
- data/spec/legion/extensions/agentic/memory/semantic/helpers/knowledge_store_spec.rb +140 -0
- data/spec/legion/extensions/agentic/memory/semantic/runners/semantic_memory_spec.rb +103 -0
- data/spec/legion/extensions/agentic/memory/semantic_priming/helpers/connection_spec.rb +98 -0
- data/spec/legion/extensions/agentic/memory/semantic_priming/helpers/priming_network_spec.rb +208 -0
- data/spec/legion/extensions/agentic/memory/semantic_priming/helpers/semantic_node_spec.rb +125 -0
- data/spec/legion/extensions/agentic/memory/semantic_priming/semantic_priming_spec.rb +7 -0
- data/spec/legion/extensions/agentic/memory/semantic_satiation/client_spec.rb +19 -0
- data/spec/legion/extensions/agentic/memory/semantic_satiation/helpers/concept_spec.rb +167 -0
- data/spec/legion/extensions/agentic/memory/semantic_satiation/helpers/constants_spec.rb +81 -0
- data/spec/legion/extensions/agentic/memory/semantic_satiation/helpers/satiation_engine_spec.rb +189 -0
- data/spec/legion/extensions/agentic/memory/semantic_satiation/runners/semantic_satiation_spec.rb +176 -0
- data/spec/legion/extensions/agentic/memory/source_monitoring/client_spec.rb +25 -0
- data/spec/legion/extensions/agentic/memory/source_monitoring/helpers/source_record_spec.rb +152 -0
- data/spec/legion/extensions/agentic/memory/source_monitoring/helpers/source_tracker_spec.rb +139 -0
- data/spec/legion/extensions/agentic/memory/source_monitoring/runners/source_monitoring_spec.rb +102 -0
- data/spec/legion/extensions/agentic/memory/trace/actors/decay_spec.rb +62 -0
- data/spec/legion/extensions/agentic/memory/trace/actors/tier_migration_spec.rb +62 -0
- data/spec/legion/extensions/agentic/memory/trace/batch_decay_spec.rb +26 -0
- data/spec/legion/extensions/agentic/memory/trace/client_spec.rb +62 -0
- data/spec/legion/extensions/agentic/memory/trace/helpers/decay_spec.rb +134 -0
- data/spec/legion/extensions/agentic/memory/trace/helpers/store_spec.rb +217 -0
- data/spec/legion/extensions/agentic/memory/trace/helpers/trace_spec.rb +120 -0
- data/spec/legion/extensions/agentic/memory/trace/local_persistence_spec.rb +255 -0
- data/spec/legion/extensions/agentic/memory/trace/memory_spec.rb +11 -0
- data/spec/legion/extensions/agentic/memory/trace/persistent_store_spec.rb +50 -0
- data/spec/legion/extensions/agentic/memory/trace/quota_spec.rb +56 -0
- data/spec/legion/extensions/agentic/memory/trace/runners/consolidation_spec.rb +118 -0
- data/spec/legion/extensions/agentic/memory/trace/runners/traces_spec.rb +69 -0
- data/spec/legion/extensions/agentic/memory/transfer/client_spec.rb +18 -0
- data/spec/legion/extensions/agentic/memory/transfer/helpers/constants_spec.rb +41 -0
- data/spec/legion/extensions/agentic/memory/transfer/helpers/domain_knowledge_spec.rb +134 -0
- data/spec/legion/extensions/agentic/memory/transfer/helpers/transfer_engine_spec.rb +299 -0
- data/spec/legion/extensions/agentic/memory/transfer/runners/transfer_learning_spec.rb +144 -0
- data/spec/spec_helper.rb +46 -0
- metadata +351 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Memory
|
|
7
|
+
module SemanticSatiation
|
|
8
|
+
module Runners
|
|
9
|
+
module SemanticSatiation
|
|
10
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
11
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
12
|
+
|
|
13
|
+
def expose(label:, domain: :general, **)
|
|
14
|
+
result = satiation_engine.expose_by_label(label: label, domain: domain)
|
|
15
|
+
Legion::Logging.debug "[semantic_satiation] expose: label=#{label} domain=#{domain} " \
|
|
16
|
+
"fluency=#{result[:fluency]&.round(2)} satiated=#{result[:satiated]}"
|
|
17
|
+
result
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def register(label:, domain: :general, **)
|
|
21
|
+
concept = satiation_engine.register_concept(label: label, domain: domain)
|
|
22
|
+
Legion::Logging.debug "[semantic_satiation] register: label=#{label} domain=#{domain} id=#{concept.id[0..7]}"
|
|
23
|
+
concept.to_h
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def expose_by_id(concept_id:, **)
|
|
27
|
+
result = satiation_engine.expose_concept(concept_id: concept_id)
|
|
28
|
+
if result[:error]
|
|
29
|
+
Legion::Logging.debug "[semantic_satiation] expose_by_id: not found id=#{concept_id[0..7]}"
|
|
30
|
+
else
|
|
31
|
+
Legion::Logging.debug "[semantic_satiation] expose_by_id: id=#{concept_id[0..7]} " \
|
|
32
|
+
"fluency=#{result[:fluency]&.round(2)}"
|
|
33
|
+
end
|
|
34
|
+
result
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def recover(amount: Helpers::Constants::RECOVERY_RATE, **)
|
|
38
|
+
result = satiation_engine.recover_all
|
|
39
|
+
Legion::Logging.debug "[semantic_satiation] recover: amount=#{amount} recovered=#{result[:recovered]}"
|
|
40
|
+
result
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def satiation_status(**)
|
|
44
|
+
summary = satiation_engine.to_h
|
|
45
|
+
Legion::Logging.debug "[semantic_satiation] status: concepts=#{summary[:concept_count]} " \
|
|
46
|
+
"satiated=#{summary[:satiated_count]}"
|
|
47
|
+
summary
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def domain_satiation(domain:, **)
|
|
51
|
+
avg_fluency = satiation_engine.domain_satiation(domain: domain)
|
|
52
|
+
Legion::Logging.debug "[semantic_satiation] domain_satiation: domain=#{domain} avg_fluency=#{avg_fluency.round(2)}"
|
|
53
|
+
{ domain: domain, avg_fluency: avg_fluency }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def most_exposed(limit: 5, **)
|
|
57
|
+
concepts = satiation_engine.most_exposed(limit: limit)
|
|
58
|
+
Legion::Logging.debug "[semantic_satiation] most_exposed: limit=#{limit} found=#{concepts.size}"
|
|
59
|
+
{ concepts: concepts.map(&:to_h), count: concepts.size }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def freshest_concepts(limit: 5, **)
|
|
63
|
+
concepts = satiation_engine.freshest(limit: limit)
|
|
64
|
+
Legion::Logging.debug "[semantic_satiation] freshest: limit=#{limit} found=#{concepts.size}"
|
|
65
|
+
{ concepts: concepts.map(&:to_h), count: concepts.size }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def novelty_report(**)
|
|
69
|
+
report = satiation_engine.novelty_report
|
|
70
|
+
total = satiation_engine.concepts.size
|
|
71
|
+
Legion::Logging.debug "[semantic_satiation] novelty_report: total=#{total}"
|
|
72
|
+
{ distribution: report, total: total }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def prune_saturated(**)
|
|
76
|
+
removed = satiation_engine.prune_saturated
|
|
77
|
+
Legion::Logging.debug "[semantic_satiation] prune_saturated: removed=#{removed}"
|
|
78
|
+
{ removed: removed }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
def satiation_engine
|
|
84
|
+
@satiation_engine ||= Helpers::SatiationEngine.new
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/memory/semantic_satiation/version'
|
|
4
|
+
require 'legion/extensions/agentic/memory/semantic_satiation/helpers/constants'
|
|
5
|
+
require 'legion/extensions/agentic/memory/semantic_satiation/helpers/concept'
|
|
6
|
+
require 'legion/extensions/agentic/memory/semantic_satiation/helpers/satiation_engine'
|
|
7
|
+
require 'legion/extensions/agentic/memory/semantic_satiation/runners/semantic_satiation'
|
|
8
|
+
require 'legion/extensions/agentic/memory/semantic_satiation/client'
|
|
9
|
+
|
|
10
|
+
module Legion
|
|
11
|
+
module Extensions
|
|
12
|
+
module Agentic
|
|
13
|
+
module Memory
|
|
14
|
+
module SemanticSatiation
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Memory
|
|
7
|
+
module SourceMonitoring
|
|
8
|
+
module Actors
|
|
9
|
+
class Decay < Legion::Extensions::Actors::Every
|
|
10
|
+
def time
|
|
11
|
+
60
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def use_runner?
|
|
15
|
+
false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def runner_function
|
|
19
|
+
:update_source_monitoring
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def runner_class
|
|
23
|
+
Legion::Extensions::Agentic::Memory::SourceMonitoring::Runners::SourceMonitoring
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/memory/source_monitoring/helpers/constants'
|
|
4
|
+
require 'legion/extensions/agentic/memory/source_monitoring/helpers/source_record'
|
|
5
|
+
require 'legion/extensions/agentic/memory/source_monitoring/helpers/source_tracker'
|
|
6
|
+
require 'legion/extensions/agentic/memory/source_monitoring/runners/source_monitoring'
|
|
7
|
+
|
|
8
|
+
module Legion
|
|
9
|
+
module Extensions
|
|
10
|
+
module Agentic
|
|
11
|
+
module Memory
|
|
12
|
+
module SourceMonitoring
|
|
13
|
+
class Client
|
|
14
|
+
include Runners::SourceMonitoring
|
|
15
|
+
|
|
16
|
+
def initialize(tracker: nil, **)
|
|
17
|
+
@tracker = tracker || Helpers::SourceTracker.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
attr_reader :tracker
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Memory
|
|
7
|
+
module SourceMonitoring
|
|
8
|
+
module Helpers
|
|
9
|
+
module Constants
|
|
10
|
+
MAX_RECORDS = 500
|
|
11
|
+
MAX_HISTORY = 200
|
|
12
|
+
MAX_ATTRIBUTIONS = 100
|
|
13
|
+
|
|
14
|
+
CONFIDENCE_FLOOR = 0.1
|
|
15
|
+
CONFIDENCE_DECAY = 0.01
|
|
16
|
+
CONFIDENCE_ALPHA = 0.12
|
|
17
|
+
|
|
18
|
+
DEFAULT_CONFIDENCE = 0.6
|
|
19
|
+
|
|
20
|
+
# Source categories (Johnson & Raye reality monitoring)
|
|
21
|
+
SOURCES = %i[
|
|
22
|
+
external_perception
|
|
23
|
+
internal_generation
|
|
24
|
+
memory_retrieval
|
|
25
|
+
imagination
|
|
26
|
+
inference
|
|
27
|
+
instruction
|
|
28
|
+
dream
|
|
29
|
+
unknown
|
|
30
|
+
].freeze
|
|
31
|
+
|
|
32
|
+
# Reality status — is this from the real world or internally generated?
|
|
33
|
+
REALITY_STATUS = {
|
|
34
|
+
external_perception: :real,
|
|
35
|
+
internal_generation: :constructed,
|
|
36
|
+
memory_retrieval: :recalled,
|
|
37
|
+
imagination: :imagined,
|
|
38
|
+
inference: :derived,
|
|
39
|
+
instruction: :received,
|
|
40
|
+
dream: :dreamed,
|
|
41
|
+
unknown: :uncertain
|
|
42
|
+
}.freeze
|
|
43
|
+
|
|
44
|
+
# Confusion pairs — common source monitoring errors
|
|
45
|
+
CONFUSION_PAIRS = [
|
|
46
|
+
%i[external_perception memory_retrieval],
|
|
47
|
+
%i[internal_generation memory_retrieval],
|
|
48
|
+
%i[imagination external_perception],
|
|
49
|
+
%i[inference external_perception],
|
|
50
|
+
%i[dream memory_retrieval]
|
|
51
|
+
].freeze
|
|
52
|
+
|
|
53
|
+
CONFIDENCE_LABELS = {
|
|
54
|
+
(0.8..) => :certain,
|
|
55
|
+
(0.6...0.8) => :confident,
|
|
56
|
+
(0.4...0.6) => :uncertain,
|
|
57
|
+
(0.2...0.4) => :doubtful,
|
|
58
|
+
(..0.2) => :guessing
|
|
59
|
+
}.freeze
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Memory
|
|
7
|
+
module SourceMonitoring
|
|
8
|
+
module Helpers
|
|
9
|
+
class SourceRecord
|
|
10
|
+
include Constants
|
|
11
|
+
|
|
12
|
+
attr_reader :id, :content_id, :source, :domain, :context, :recorded_at
|
|
13
|
+
attr_accessor :confidence, :verified
|
|
14
|
+
|
|
15
|
+
def initialize(id:, content_id:, source:, domain: :general, confidence: DEFAULT_CONFIDENCE, context: {})
|
|
16
|
+
@id = id
|
|
17
|
+
@content_id = content_id
|
|
18
|
+
@source = source
|
|
19
|
+
@domain = domain
|
|
20
|
+
@confidence = confidence.to_f.clamp(0.0, 1.0)
|
|
21
|
+
@context = context
|
|
22
|
+
@verified = false
|
|
23
|
+
@recorded_at = Time.now.utc
|
|
24
|
+
@corrections = []
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def reality_status
|
|
28
|
+
REALITY_STATUS.fetch(@source, :uncertain)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def external?
|
|
32
|
+
@source == :external_perception
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def internal?
|
|
36
|
+
%i[internal_generation imagination dream].include?(@source)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def verify
|
|
40
|
+
@verified = true
|
|
41
|
+
@confidence = [@confidence + 0.15, 1.0].min
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def correct(new_source:)
|
|
45
|
+
@corrections << { from: @source, to: new_source, at: Time.now.utc }
|
|
46
|
+
@source = new_source
|
|
47
|
+
@confidence = [@confidence * 0.8, CONFIDENCE_FLOOR].max
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def correction_count
|
|
51
|
+
@corrections.size
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def confused?
|
|
55
|
+
CONFUSION_PAIRS.any? { |pair| pair.include?(@source) } && @confidence < 0.5
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def decay
|
|
59
|
+
@confidence = [@confidence - CONFIDENCE_DECAY, CONFIDENCE_FLOOR].max
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def faded?
|
|
63
|
+
@confidence <= CONFIDENCE_FLOOR && !@verified
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def confidence_label
|
|
67
|
+
CONFIDENCE_LABELS.each { |range, lbl| return lbl if range.cover?(@confidence) }
|
|
68
|
+
:guessing
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def to_h
|
|
72
|
+
{
|
|
73
|
+
id: @id,
|
|
74
|
+
content_id: @content_id,
|
|
75
|
+
source: @source,
|
|
76
|
+
domain: @domain,
|
|
77
|
+
reality_status: reality_status,
|
|
78
|
+
confidence: @confidence.round(4),
|
|
79
|
+
confidence_label: confidence_label,
|
|
80
|
+
verified: @verified,
|
|
81
|
+
external: external?,
|
|
82
|
+
internal: internal?,
|
|
83
|
+
confused: confused?,
|
|
84
|
+
corrections: correction_count,
|
|
85
|
+
recorded_at: @recorded_at
|
|
86
|
+
}
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Memory
|
|
7
|
+
module SourceMonitoring
|
|
8
|
+
module Helpers
|
|
9
|
+
class SourceTracker
|
|
10
|
+
include Constants
|
|
11
|
+
|
|
12
|
+
attr_reader :records, :attribution_log
|
|
13
|
+
|
|
14
|
+
def initialize
|
|
15
|
+
@records = {}
|
|
16
|
+
@attribution_log = []
|
|
17
|
+
@record_counter = 0
|
|
18
|
+
@accuracy_hits = 0
|
|
19
|
+
@accuracy_total = 0
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def record_source(content_id:, source:, domain: :general, confidence: DEFAULT_CONFIDENCE, context: {})
|
|
23
|
+
return nil unless SOURCES.include?(source)
|
|
24
|
+
return nil if @records.size >= MAX_RECORDS
|
|
25
|
+
|
|
26
|
+
@record_counter += 1
|
|
27
|
+
rec_id = :"src_#{@record_counter}"
|
|
28
|
+
rec = SourceRecord.new(
|
|
29
|
+
id: rec_id, content_id: content_id, source: source,
|
|
30
|
+
domain: domain, confidence: confidence, context: context
|
|
31
|
+
)
|
|
32
|
+
@records[rec_id] = rec
|
|
33
|
+
rec
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def attribute(content_id:)
|
|
37
|
+
@records.values.select { |r| r.content_id == content_id }.sort_by { |r| -r.confidence }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def verify_source(record_id:)
|
|
41
|
+
rec = @records[record_id]
|
|
42
|
+
return nil unless rec
|
|
43
|
+
|
|
44
|
+
rec.verify
|
|
45
|
+
@accuracy_hits += 1
|
|
46
|
+
@accuracy_total += 1
|
|
47
|
+
log_attribution(record_id, :verified)
|
|
48
|
+
rec
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def correct_source(record_id:, new_source:)
|
|
52
|
+
rec = @records[record_id]
|
|
53
|
+
return nil unless rec
|
|
54
|
+
return nil unless SOURCES.include?(new_source)
|
|
55
|
+
|
|
56
|
+
old = rec.source
|
|
57
|
+
rec.correct(new_source: new_source)
|
|
58
|
+
@accuracy_total += 1
|
|
59
|
+
log_attribution(record_id, :corrected, from: old, to: new_source)
|
|
60
|
+
rec
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def reality_check(content_id:)
|
|
64
|
+
records = attribute(content_id: content_id)
|
|
65
|
+
return { status: :unknown, confidence: 0.0 } if records.empty?
|
|
66
|
+
|
|
67
|
+
best = records.first
|
|
68
|
+
{ status: best.reality_status, confidence: best.confidence, source: best.source, verified: best.verified }
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def confused_records
|
|
72
|
+
@records.values.select(&:confused?).map(&:to_h)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def records_by_source(source:)
|
|
76
|
+
@records.values.select { |r| r.source == source }.map(&:to_h)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def records_in_domain(domain:)
|
|
80
|
+
@records.values.select { |r| r.domain == domain }.map(&:to_h)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def attribution_accuracy
|
|
84
|
+
return 0.0 if @accuracy_total.zero?
|
|
85
|
+
|
|
86
|
+
@accuracy_hits.to_f / @accuracy_total
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def decay_all
|
|
90
|
+
@records.each_value(&:decay)
|
|
91
|
+
@records.reject! { |_, r| r.faded? }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def to_h
|
|
95
|
+
source_dist = SOURCES.to_h { |s| [s, @records.values.count { |r| r.source == s }] }
|
|
96
|
+
{
|
|
97
|
+
total_records: @records.size,
|
|
98
|
+
verified_count: @records.values.count(&:verified),
|
|
99
|
+
confused_count: @records.values.count(&:confused?),
|
|
100
|
+
accuracy: attribution_accuracy.round(4),
|
|
101
|
+
source_distribution: source_dist,
|
|
102
|
+
attribution_log_size: @attribution_log.size
|
|
103
|
+
}
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
private
|
|
107
|
+
|
|
108
|
+
def log_attribution(record_id, action, **extra)
|
|
109
|
+
entry = { record_id: record_id, action: action, at: Time.now.utc }.merge(extra)
|
|
110
|
+
@attribution_log << entry
|
|
111
|
+
@attribution_log.shift while @attribution_log.size > MAX_ATTRIBUTIONS
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Legion
|
|
4
|
+
module Extensions
|
|
5
|
+
module Agentic
|
|
6
|
+
module Memory
|
|
7
|
+
module SourceMonitoring
|
|
8
|
+
module Runners
|
|
9
|
+
module SourceMonitoring
|
|
10
|
+
include Legion::Extensions::Helpers::Lex if Legion::Extensions.const_defined?(:Helpers) &&
|
|
11
|
+
Legion::Extensions::Helpers.const_defined?(:Lex)
|
|
12
|
+
|
|
13
|
+
def record_source(content_id:, source:, domain: :general, confidence: nil, context: {}, **)
|
|
14
|
+
conf = confidence || Helpers::Constants::DEFAULT_CONFIDENCE
|
|
15
|
+
Legion::Logging.debug "[source_monitoring] record: content=#{content_id} source=#{source}"
|
|
16
|
+
rec = tracker.record_source(
|
|
17
|
+
content_id: content_id, source: source.to_sym,
|
|
18
|
+
domain: domain, confidence: conf, context: context
|
|
19
|
+
)
|
|
20
|
+
if rec
|
|
21
|
+
{ success: true, record: rec.to_h }
|
|
22
|
+
else
|
|
23
|
+
{ success: false, reason: :invalid_or_full }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def attribute_source(content_id:, **)
|
|
28
|
+
records = tracker.attribute(content_id: content_id)
|
|
29
|
+
Legion::Logging.debug "[source_monitoring] attribute: content=#{content_id} found=#{records.size}"
|
|
30
|
+
{ success: true, records: records.map(&:to_h), count: records.size }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def verify_source(record_id:, **)
|
|
34
|
+
Legion::Logging.debug "[source_monitoring] verify: #{record_id}"
|
|
35
|
+
rec = tracker.verify_source(record_id: record_id.to_sym)
|
|
36
|
+
if rec
|
|
37
|
+
{ success: true, record: rec.to_h }
|
|
38
|
+
else
|
|
39
|
+
{ success: false, reason: :not_found }
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def correct_source(record_id:, new_source:, **)
|
|
44
|
+
Legion::Logging.debug "[source_monitoring] correct: #{record_id} -> #{new_source}"
|
|
45
|
+
rec = tracker.correct_source(record_id: record_id.to_sym, new_source: new_source.to_sym)
|
|
46
|
+
if rec
|
|
47
|
+
{ success: true, record: rec.to_h }
|
|
48
|
+
else
|
|
49
|
+
{ success: false, reason: :not_found_or_invalid }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def reality_check(content_id:, **)
|
|
54
|
+
result = tracker.reality_check(content_id: content_id)
|
|
55
|
+
Legion::Logging.debug "[source_monitoring] reality_check: #{content_id} => #{result[:status]}"
|
|
56
|
+
{ success: true, **result }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def confused_sources(**)
|
|
60
|
+
confused = tracker.confused_records
|
|
61
|
+
{ success: true, confused: confused, count: confused.size }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def sources_by_type(source:, **)
|
|
65
|
+
records = tracker.records_by_source(source: source.to_sym)
|
|
66
|
+
{ success: true, records: records, count: records.size }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def attribution_accuracy(**)
|
|
70
|
+
{ success: true, accuracy: tracker.attribution_accuracy.round(4) }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def update_source_monitoring(**)
|
|
74
|
+
Legion::Logging.debug '[source_monitoring] tick'
|
|
75
|
+
tracker.decay_all
|
|
76
|
+
{ success: true, records: tracker.records.size }
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def source_monitoring_stats(**)
|
|
80
|
+
Legion::Logging.debug '[source_monitoring] stats'
|
|
81
|
+
{ success: true, stats: tracker.to_h }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
private
|
|
85
|
+
|
|
86
|
+
def tracker
|
|
87
|
+
@tracker ||= Helpers::SourceTracker.new
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/agentic/memory/source_monitoring/version'
|
|
4
|
+
require 'legion/extensions/agentic/memory/source_monitoring/helpers/constants'
|
|
5
|
+
require 'legion/extensions/agentic/memory/source_monitoring/helpers/source_record'
|
|
6
|
+
require 'legion/extensions/agentic/memory/source_monitoring/helpers/source_tracker'
|
|
7
|
+
require 'legion/extensions/agentic/memory/source_monitoring/runners/source_monitoring'
|
|
8
|
+
require 'legion/extensions/agentic/memory/source_monitoring/client'
|
|
9
|
+
|
|
10
|
+
module Legion
|
|
11
|
+
module Extensions
|
|
12
|
+
module Agentic
|
|
13
|
+
module Memory
|
|
14
|
+
module SourceMonitoring
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/actors/every'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Agentic
|
|
8
|
+
module Memory
|
|
9
|
+
module Trace
|
|
10
|
+
module Actor
|
|
11
|
+
class Decay < Legion::Extensions::Actors::Every
|
|
12
|
+
def runner_class
|
|
13
|
+
Legion::Extensions::Agentic::Memory::Trace::Runners::Consolidation
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def runner_function
|
|
17
|
+
'decay_cycle'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def time
|
|
21
|
+
60
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def run_now?
|
|
25
|
+
false
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def use_runner?
|
|
29
|
+
false
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def check_subtask?
|
|
33
|
+
false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def generate_task?
|
|
37
|
+
false
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'legion/extensions/actors/every'
|
|
4
|
+
|
|
5
|
+
module Legion
|
|
6
|
+
module Extensions
|
|
7
|
+
module Agentic
|
|
8
|
+
module Memory
|
|
9
|
+
module Trace
|
|
10
|
+
module Actor
|
|
11
|
+
class TierMigration < Legion::Extensions::Actors::Every
|
|
12
|
+
def runner_class
|
|
13
|
+
Legion::Extensions::Agentic::Memory::Trace::Runners::Consolidation
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def runner_function
|
|
17
|
+
'migrate_tier'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def time
|
|
21
|
+
300
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def run_now?
|
|
25
|
+
false
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def use_runner?
|
|
29
|
+
false
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def check_subtask?
|
|
33
|
+
false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def generate_task?
|
|
37
|
+
false
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|