Class: Legion::Extensions::Agentic::Memory::Paleontology::Helpers::Fossil

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fossil_type:, domain:, content:, extinction_cause:, era: nil, stratum_depth: 0, preservation: nil, significance: nil) ⇒ Fossil

Returns a new instance of Fossil.



15
16
17
18
19
20
21
22
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 15

def initialize(fossil_type:, domain:, content:, extinction_cause:,
               era: nil, stratum_depth: 0, preservation: nil,
               significance: nil)
  validate_type!(fossil_type)
  validate_cause!(extinction_cause)
  assign_core(fossil_type, domain, content, extinction_cause)
  (era, stratum_depth, preservation, significance)
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def content
  @content
end

#discovered_atObject (readonly)

Returns the value of attribute discovered_at.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def discovered_at
  @discovered_at
end

#domainObject (readonly)

Returns the value of attribute domain.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def domain
  @domain
end

#eraObject (readonly)

Returns the value of attribute era.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def era
  @era
end

#extinct_atObject (readonly)

Returns the value of attribute extinct_at.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def extinct_at
  @extinct_at
end

#extinction_causeObject (readonly)

Returns the value of attribute extinction_cause.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def extinction_cause
  @extinction_cause
end

#fossil_typeObject (readonly)

Returns the value of attribute fossil_type.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def fossil_type
  @fossil_type
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def id
  @id
end

#lineage_idsObject (readonly)

Returns the value of attribute lineage_ids.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def lineage_ids
  @lineage_ids
end

#preservationObject

Returns the value of attribute preservation.



13
14
15
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 13

def preservation
  @preservation
end

#significanceObject

Returns the value of attribute significance.



13
14
15
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 13

def significance
  @significance
end

#stratum_depthObject (readonly)

Returns the value of attribute stratum_depth.



10
11
12
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 10

def stratum_depth
  @stratum_depth
end

Instance Method Details

#ancient?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 42

def ancient?
  (Time.now.utc - @extinct_at) > 5_000_000
end

#erode!(rate: Constants::FOSSILIZATION_RATE) ⇒ Object



24
25
26
27
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 24

def erode!(rate: Constants::FOSSILIZATION_RATE)
  @preservation = (@preservation - rate.abs).clamp(0.0, 1.0).round(10)
  self
end

#imprint?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 34

def imprint?
  @preservation < 0.2
end

#keystone?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 38

def keystone?
  @significance >= 0.8
end


54
55
56
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 54

def link_lineage(other_id)
  @lineage_ids << other_id unless @lineage_ids.include?(other_id)
end

#preservation_labelObject



46
47
48
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 46

def preservation_label
  Constants.label_for(Constants::PRESERVATION_LABELS, @preservation)
end

#reinforce!(boost: 0.1) ⇒ Object



29
30
31
32
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 29

def reinforce!(boost: 0.1)
  @significance = (@significance + boost.abs).clamp(0.0, 1.0).round(10)
  self
end

#significance_labelObject



50
51
52
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 50

def significance_label
  Constants.label_for(Constants::SIGNIFICANCE_LABELS, @significance)
end

#to_hObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/legion/extensions/agentic/memory/paleontology/helpers/fossil.rb', line 58

def to_h
  {
    id:                 @id,
    fossil_type:        @fossil_type,
    domain:             @domain,
    content:            @content,
    extinction_cause:   @extinction_cause,
    era:                @era,
    stratum_depth:      @stratum_depth,
    preservation:       @preservation,
    preservation_label: preservation_label,
    significance:       @significance,
    significance_label: significance_label,
    discovered_at:      @discovered_at,
    extinct_at:         @extinct_at,
    lineage_ids:        @lineage_ids,
    imprint:            imprint?,
    keystone:           keystone?,
    ancient:            ancient?
  }
end