Class: Legion::Extensions::Agentic::Memory::EchoChamber::Helpers::Echo

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

Constant Summary

Constants included from Constants

Constants::AMPLIFICATION_LABELS, Constants::AMPLIFICATION_RATE, Constants::BREAKTHROUGH_BONUS, Constants::CHAMBER_STATES, Constants::CHAMBER_STATE_LABELS, Constants::DECAY_RATE, Constants::DEFAULT_AMPLITUDE, Constants::DEFAULT_WALL_THICKNESS, Constants::DISRUPTION_THRESHOLD, Constants::ECHO_TYPES, Constants::MAX_CHAMBERS, Constants::MAX_ECHOES, Constants::POROUS_THRESHOLD, Constants::RESONANCE_LABELS, Constants::SEALED_THRESHOLD, Constants::SILENT_THRESHOLD

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Constants

label_for

Constructor Details

#initialize(content:, echo_type: :belief, domain: :general, source_agent: nil, amplitude: DEFAULT_AMPLITUDE) ⇒ Echo

Returns a new instance of Echo.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 17

def initialize(content:, echo_type: :belief, domain: :general,
               source_agent: nil, amplitude: DEFAULT_AMPLITUDE)
  @id               = SecureRandom.uuid
  @content          = content
  @echo_type        = validate_type(echo_type)
  @domain           = domain.to_sym
  @source_agent     = source_agent
  @amplitude        = amplitude.to_f.clamp(0.0, 1.0).round(10)
  @original_amplitude = @amplitude
  @frequency        = 1
  @created_at       = Time.now.utc
end

Instance Attribute Details

#amplitudeObject (readonly)

Returns the value of attribute amplitude.



14
15
16
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14

def amplitude
  @amplitude
end

#contentObject (readonly)

Returns the value of attribute content.



14
15
16
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14

def content
  @content
end

#created_atObject (readonly)

Returns the value of attribute created_at.



14
15
16
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14

def created_at
  @created_at
end

#domainObject (readonly)

Returns the value of attribute domain.



14
15
16
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14

def domain
  @domain
end

#echo_typeObject (readonly)

Returns the value of attribute echo_type.



14
15
16
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14

def echo_type
  @echo_type
end

#frequencyObject (readonly)

Returns the value of attribute frequency.



14
15
16
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14

def frequency
  @frequency
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14

def id
  @id
end

#original_amplitudeObject (readonly)

Returns the value of attribute original_amplitude.



14
15
16
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14

def original_amplitude
  @original_amplitude
end

#source_agentObject (readonly)

Returns the value of attribute source_agent.



14
15
16
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 14

def source_agent
  @source_agent
end

Instance Method Details

#amplify!(rate = AMPLIFICATION_RATE) ⇒ Object



30
31
32
33
34
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 30

def amplify!(rate = AMPLIFICATION_RATE)
  @frequency += 1
  @amplitude = (@amplitude + rate).clamp(0.0, 1.0).round(10)
  self
end

#amplitude_labelObject



57
58
59
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 57

def amplitude_label
  Constants.label_for(AMPLIFICATION_LABELS, @amplitude)
end

#dampen!(rate = DECAY_RATE) ⇒ Object



36
37
38
39
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 36

def dampen!(rate = DECAY_RATE)
  @amplitude = (@amplitude - rate).clamp(0.0, 1.0).round(10)
  self
end

#fading?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 45

def fading?
  @amplitude <= POROUS_THRESHOLD
end

#frequency_labelObject



53
54
55
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 53

def frequency_label
  Constants.label_for(RESONANCE_LABELS, frequency_score)
end

#resonate?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 41

def resonate?
  @amplitude >= DISRUPTION_THRESHOLD
end

#silent?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/legion/extensions/agentic/memory/echo_chamber/helpers/echo.rb', line 49

def silent?
  @amplitude <= SILENT_THRESHOLD
end

#to_hObject



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

def to_h
  {
    id:                 @id,
    content:            @content,
    echo_type:          @echo_type,
    domain:             @domain,
    source_agent:       @source_agent,
    amplitude:          @amplitude,
    original_amplitude: @original_amplitude,
    frequency:          @frequency,
    frequency_label:    frequency_label,
    amplitude_label:    amplitude_label,
    resonate:           resonate?,
    fading:             fading?,
    silent:             silent?,
    created_at:         @created_at
  }
end