Class: Legion::Extensions::Agentic::Memory::Archaeology::Helpers::ExcavationSite

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb

Constant Summary

Constants included from Constants

Constants::ARTIFACT_TYPES, Constants::DEFAULT_PRESERVATION, Constants::DENSITY_LABELS, Constants::DEPTH_LABELS, Constants::DEPTH_PRESERVATION_MODIFIER, Constants::DEPTH_RARITY_WEIGHTS, Constants::DOMAIN_TYPES, Constants::EPOCH_NAMES, Constants::EXCAVATION_DEPTH_LEVELS, Constants::INTEGRITY_LABELS, Constants::MAX_ARTIFACTS, Constants::MAX_SITES, Constants::PRESERVATION_DECAY, Constants::PRESERVATION_LABELS, Constants::SEDIMENT_DENSITY_DEFAULT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Constants

label_for

Constructor Details

#initialize(domain:) ⇒ ExcavationSite

Returns a new instance of ExcavationSite.



16
17
18
19
20
21
22
23
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 16

def initialize(domain:)
  validate_domain!(domain)
  @id              = SecureRandom.uuid
  @domain          = domain.to_sym
  @current_depth   = :surface
  @artifacts_found = []
  @created_at      = Time.now.utc
end

Instance Attribute Details

#artifacts_foundObject (readonly)

Returns the value of attribute artifacts_found.



12
13
14
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 12

def artifacts_found
  @artifacts_found
end

#created_atObject (readonly) Also known as: started_at

Returns the value of attribute created_at.



12
13
14
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 12

def created_at
  @created_at
end

#current_depthObject (readonly)

Returns the value of attribute current_depth.



12
13
14
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 12

def current_depth
  @current_depth
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 12

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 12

def id
  @id
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 33

def complete?
  @current_depth == EXCAVATION_DEPTH_LEVELS.last
end

#dig_deeper!Object



25
26
27
28
29
30
31
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 25

def dig_deeper!
  idx = EXCAVATION_DEPTH_LEVELS.index(@current_depth) || 0
  return false if idx >= EXCAVATION_DEPTH_LEVELS.size - 1

  @current_depth = EXCAVATION_DEPTH_LEVELS[idx + 1]
  true
end

#excavate!Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 37

def excavate!
  weights  = DEPTH_RARITY_WEIGHTS.fetch(@current_depth, {})
  art_type = weighted_pick(weights)
  artifact = Artifact.new(type: art_type, domain: @domain,
                          content: "#{art_type} from #{@current_depth}",
                          depth_level: @current_depth,
                          preservation: compute_base_preservation)
  @artifacts_found << artifact
  artifact
end

#surveyObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 48

def survey
  {
    id:              @id,
    domain:          @domain,
    current_depth:   @current_depth,
    depth_label:     DEPTH_LABELS.fetch(@current_depth, 'Unknown'),
    artifacts_count: @artifacts_found.size,
    complete:        complete?,
    started_at:      @created_at.iso8601
  }
end

#to_hObject



60
61
62
# File 'lib/legion/extensions/agentic/memory/archaeology/helpers/excavation_site.rb', line 60

def to_h
  survey.merge(artifacts: @artifacts_found.map(&:to_h))
end