Class: Legion::Extensions::Agentic::Self::NarrativeSelf::Helpers::NarrativeThread
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::NarrativeSelf::Helpers::NarrativeThread
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb
Constant Summary
Constants included from Constants
Constants::DEFAULT_SIGNIFICANCE, Constants::EMOTIONAL_BOOST, Constants::EPISODE_DECAY, Constants::EPISODE_TYPES, Constants::MAX_CHAPTER_SIZE, Constants::MAX_EPISODES, Constants::MAX_SELF_CONCEPT_TRAITS, Constants::MAX_THREADS, Constants::MAX_TIMELINE_WINDOW, Constants::SIGNIFICANCE_ALPHA, Constants::SIGNIFICANCE_FLOOR, Constants::SIGNIFICANCE_LABELS, Constants::THREAD_DECAY, Constants::THREAD_MATCH_THRESHOLD, Constants::TRAIT_ALPHA
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#episode_ids ⇒ Object
readonly
Returns the value of attribute episode_ids.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#strength ⇒ Object
readonly
Returns the value of attribute strength.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
- #add_episode(episode_id) ⇒ Object
- #decay ⇒ Object
-
#initialize(theme:, domain: :general) ⇒ NarrativeThread
constructor
A new instance of NarrativeThread.
- #reinforce ⇒ Object
- #size ⇒ Object
- #to_h ⇒ Object
- #weak? ⇒ Boolean
Constructor Details
#initialize(theme:, domain: :general) ⇒ NarrativeThread
Returns a new instance of NarrativeThread.
16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 16 def initialize(theme:, domain: :general) @id = SecureRandom.uuid @theme = theme @domain = domain @strength = 0.5 @episode_ids = [] @created_at = Time.now.utc end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 14 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
14 15 16 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 14 def domain @domain end |
#episode_ids ⇒ Object (readonly)
Returns the value of attribute episode_ids.
14 15 16 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 14 def episode_ids @episode_ids end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 14 def id @id end |
#strength ⇒ Object (readonly)
Returns the value of attribute strength.
14 15 16 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 14 def strength @strength end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
14 15 16 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 14 def theme @theme end |
Instance Method Details
#add_episode(episode_id) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 25 def add_episode(episode_id) return if @episode_ids.include?(episode_id) @episode_ids << episode_id @episode_ids.shift if @episode_ids.size > MAX_CHAPTER_SIZE reinforce end |
#decay ⇒ Object
37 38 39 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 37 def decay @strength = [(@strength - THREAD_DECAY), 0.0].max end |
#reinforce ⇒ Object
33 34 35 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 33 def reinforce @strength = [@strength + 0.1, 1.0].min end |
#size ⇒ Object
45 46 47 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 45 def size @episode_ids.size end |
#to_h ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 49 def to_h { id: @id, theme: @theme, domain: @domain, strength: @strength, episodes: @episode_ids.size, created_at: @created_at } end |
#weak? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/agentic/self/narrative_self/helpers/narrative_thread.rb', line 41 def weak? @strength < SIGNIFICANCE_FLOOR end |