Class: Legion::Extensions::Agentic::Memory::Episodic::Helpers::EpisodicBinding

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

Constant Summary

Constants included from Constants

Constants::ATTENTION_BOOST, Constants::BINDING_DECAY, Constants::BINDING_STRENGTH_FLOOR, Constants::COHERENCE_LABELS, Constants::DEFAULT_BINDING_STRENGTH, Constants::EPISODE_TTL, Constants::INTEGRATION_THRESHOLD, Constants::MAX_BINDINGS_PER_EPISODE, Constants::MAX_EPISODES, Constants::MAX_HISTORY, Constants::MODALITIES, Constants::RECENTLY_ACCESSED_WINDOW, Constants::REHEARSAL_BOOST

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(modality:, content:, source:, strength: DEFAULT_BINDING_STRENGTH) ⇒ EpisodicBinding

Returns a new instance of EpisodicBinding.

Raises:

  • (ArgumentError)


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

def initialize(modality:, content:, source:, strength: DEFAULT_BINDING_STRENGTH)
  raise ArgumentError, "invalid modality: #{modality}" unless MODALITIES.include?(modality.to_sym)

  @id       = SecureRandom.uuid
  @modality = modality.to_sym
  @content  = content
  @source   = source.to_sym
  @strength = strength.to_f.clamp(0.0, 1.0)
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



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

def content
  @content
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#modalityObject (readonly)

Returns the value of attribute modality.



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

def modality
  @modality
end

#sourceObject (readonly)

Returns the value of attribute source.



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

def source
  @source
end

#strengthObject (readonly)

Returns the value of attribute strength.



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

def strength
  @strength
end

Instance Method Details

#decayObject



26
27
28
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 26

def decay
  @strength = [@strength - BINDING_DECAY, 0.0].max
end

#faded?Boolean

Returns:

  • (Boolean)


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

def faded?
  @strength <= BINDING_STRENGTH_FLOOR
end

#integrated?Boolean

Returns:

  • (Boolean)


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

def integrated?
  @strength >= INTEGRATION_THRESHOLD
end

#strengthen(amount) ⇒ Object



30
31
32
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 30

def strengthen(amount)
  @strength = [@strength + amount.to_f, 1.0].min
end

#to_hObject



42
43
44
45
46
47
48
49
50
# File 'lib/legion/extensions/agentic/memory/episodic/helpers/episodic_binding.rb', line 42

def to_h
  {
    id:       @id,
    modality: @modality,
    content:  @content,
    source:   @source,
    strength: @strength
  }
end