Class: Legion::Extensions::Agentic::Self::DefaultModeNetwork::Helpers::WanderingThought

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb

Constant Summary

Constants included from Constants

Constants::ACTIVITY_LABELS, Constants::DEEP_IDLE_THRESHOLD, Constants::DEFAULT_SALIENCE, Constants::IDLE_THRESHOLD, Constants::MAX_ASSOCIATION_CHAIN, Constants::MAX_THOUGHT_HISTORY, Constants::MAX_WANDERING_THOUGHTS, Constants::PLANNING_PROBABILITY, Constants::SALIENCE_ALPHA, Constants::SALIENCE_LABELS, Constants::SELF_REFERENTIAL_PROBABILITY, Constants::SOCIAL_REPLAY_PROBABILITY, Constants::THOUGHT_DECAY, Constants::THOUGHT_SALIENCE_FLOOR, Constants::WANDERING_PROBABILITY

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seed:, association_chain:, domain:, thought_type:, salience: Constants::DEFAULT_SALIENCE) ⇒ WanderingThought

Returns a new instance of WanderingThought.



15
16
17
18
19
20
21
22
23
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 15

def initialize(seed:, association_chain:, domain:, thought_type:, salience: Constants::DEFAULT_SALIENCE)
  @id               = SecureRandom.uuid
  @seed             = seed
  @association_chain = Array(association_chain)
  @domain           = domain
  @thought_type     = thought_type.to_sym
  @salience         = salience.to_f.clamp(0.0, 1.0)
  @created_at       = Time.now.utc
end

Instance Attribute Details

#association_chainObject (readonly)

Returns the value of attribute association_chain.



12
13
14
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12

def association_chain
  @association_chain
end

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12

def created_at
  @created_at
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12

def id
  @id
end

#salienceObject

Returns the value of attribute salience.



13
14
15
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 13

def salience
  @salience
end

#seedObject (readonly)

Returns the value of attribute seed.



12
13
14
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12

def seed
  @seed
end

#thought_typeObject (readonly)

Returns the value of attribute thought_type.



12
13
14
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 12

def thought_type
  @thought_type
end

Instance Method Details

#boost_salience(amount = Constants::SALIENCE_ALPHA) ⇒ Object



25
26
27
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 25

def boost_salience(amount = Constants::SALIENCE_ALPHA)
  @salience = [@salience + amount.to_f, 1.0].min
end

#decayObject



29
30
31
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 29

def decay
  @salience = [@salience - Constants::THOUGHT_DECAY, Constants::THOUGHT_SALIENCE_FLOOR].max
end

#faded?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 33

def faded?
  @salience <= Constants::THOUGHT_SALIENCE_FLOOR
end

#labelObject



37
38
39
40
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 37

def label
  Constants::SALIENCE_LABELS.each { |range, lbl| return lbl if range.cover?(@salience) }
  :fleeting
end

#to_hObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/legion/extensions/agentic/self/default_mode_network/helpers/wandering_thought.rb', line 42

def to_h
  {
    id:                @id,
    seed:              @seed,
    association_chain: @association_chain,
    domain:            @domain,
    thought_type:      @thought_type,
    salience:          @salience.round(4),
    label:             label,
    created_at:        @created_at
  }
end