Class: Legion::Extensions::Agentic::Memory::Archaeology::Helpers::ArchaeologyEngine
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Memory::Archaeology::Helpers::ArchaeologyEngine
- Defined in:
- lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb
Instance Method Summary collapse
- #all_artifacts ⇒ Object
- #all_sites ⇒ Object
- #archaeology_report ⇒ Object
- #artifacts_by_depth(depth_level) ⇒ Object
- #artifacts_by_domain(domain) ⇒ Object
- #artifacts_by_type(type) ⇒ Object
- #best_preserved(limit: 10) ⇒ Object
- #create_site(domain:) ⇒ Object
- #decay_all!(rate: Constants::PRESERVATION_DECAY) ⇒ Object
- #dig(site_id:) ⇒ Object
- #excavate(site_id:) ⇒ Object
-
#initialize ⇒ ArchaeologyEngine
constructor
A new instance of ArchaeologyEngine.
- #most_fragile(limit: 10) ⇒ Object
- #restore_artifact(artifact_id:, boost: 0.15) ⇒ Object
- #site_report(site_id:) ⇒ Object
Constructor Details
#initialize ⇒ ArchaeologyEngine
Returns a new instance of ArchaeologyEngine.
10 11 12 13 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 10 def initialize @sites = {} @artifacts = {} end |
Instance Method Details
#all_artifacts ⇒ Object
92 93 94 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 92 def all_artifacts @artifacts.values end |
#all_sites ⇒ Object
96 97 98 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 96 def all_sites @sites.values end |
#archaeology_report ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 77 def archaeology_report { total_artifacts: @artifacts.size, total_sites: @sites.size, type_breakdown: type_breakdown, domain_breakdown: domain_breakdown, depth_breakdown: depth_breakdown, avg_preservation: avg_preservation, avg_integrity: avg_integrity, fragment_count: @artifacts.values.count(&:fragment?), ancient_count: @artifacts.values.count(&:ancient?), sites: @sites.values.map { |s| site_summary(s) } } end |
#artifacts_by_depth(depth_level) ⇒ Object
56 57 58 59 60 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 56 def artifacts_by_depth(depth_level) @artifacts.values.select do |a| a.depth_level == depth_level.to_sym end end |
#artifacts_by_domain(domain) ⇒ Object
52 53 54 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 52 def artifacts_by_domain(domain) @artifacts.values.select { |a| a.domain == domain.to_sym } end |
#artifacts_by_type(type) ⇒ Object
48 49 50 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 48 def artifacts_by_type(type) @artifacts.values.select { |a| a.artifact_type == type.to_sym } end |
#best_preserved(limit: 10) ⇒ Object
62 63 64 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 62 def best_preserved(limit: 10) @artifacts.values.sort_by { |a| -a.preservation }.first(limit) end |
#create_site(domain:) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 15 def create_site(domain:) validate_site_capacity! site = ExcavationSite.new(domain: domain) @sites[site.id] = site site end |
#decay_all!(rate: Constants::PRESERVATION_DECAY) ⇒ Object
42 43 44 45 46 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 42 def decay_all!(rate: Constants::PRESERVATION_DECAY) @artifacts.each_value { |a| a.decay!(rate: rate) } prune_dust! @artifacts.size end |
#dig(site_id:) ⇒ Object
22 23 24 25 26 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 22 def dig(site_id:) site = fetch_site!(site_id) dug = site.dig_deeper! { site: site.survey, dug: dug } end |
#excavate(site_id:) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 28 def excavate(site_id:) site = fetch_site!(site_id) validate_artifact_capacity! artifact = site.excavate! @artifacts[artifact.id] = artifact artifact end |
#most_fragile(limit: 10) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 66 def most_fragile(limit: 10) @artifacts.values .select(&:fragment?) .sort_by(&:preservation) .first(limit) end |
#restore_artifact(artifact_id:, boost: 0.15) ⇒ Object
36 37 38 39 40 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 36 def restore_artifact(artifact_id:, boost: 0.15) artifact = fetch_artifact!(artifact_id) artifact.restore!(boost: boost) artifact end |
#site_report(site_id:) ⇒ Object
73 74 75 |
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/archaeology_engine.rb', line 73 def site_report(site_id:) fetch_site!(site_id).to_h end |