Class: Legion::Extensions::Agentic::Social::MirrorSystem::Helpers::ObservedBehavior
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Social::MirrorSystem::Helpers::ObservedBehavior
- Defined in:
- lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#agent_id ⇒ Object
readonly
Returns the value of attribute agent_id.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#observation_count ⇒ Object
Returns the value of attribute observation_count.
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
-
#resonance ⇒ Object
Returns the value of attribute resonance.
Instance Method Summary collapse
- #boost_familiarity ⇒ Object
- #decay ⇒ Object
- #faded? ⇒ Boolean
-
#initialize(agent_id:, action:, domain:, context: nil, outcome: nil, resonance: nil) ⇒ ObservedBehavior
constructor
A new instance of ObservedBehavior.
- #label ⇒ Object
- #observe_again ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(agent_id:, action:, domain:, context: nil, outcome: nil, resonance: nil) ⇒ ObservedBehavior
Returns a new instance of ObservedBehavior.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 13 def initialize(agent_id:, action:, domain:, context: nil, outcome: nil, resonance: nil) @id = SecureRandom.uuid @agent_id = agent_id @action = action @domain = domain @context = context @outcome = outcome @resonance = (resonance || Constants::DEFAULT_RESONANCE).clamp(0.0, Constants::MAX_RESONANCE) @observation_count = 1 @created_at = Time.now.utc end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 10 def action @action end |
#agent_id ⇒ Object (readonly)
Returns the value of attribute agent_id.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 10 def agent_id @agent_id end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 10 def context @context end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 10 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 10 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 10 def id @id end |
#observation_count ⇒ Object
Returns the value of attribute observation_count.
11 12 13 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 11 def observation_count @observation_count end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
10 11 12 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 10 def outcome @outcome end |
#resonance ⇒ Object
Returns the value of attribute resonance.
11 12 13 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 11 def resonance @resonance end |
Instance Method Details
#boost_familiarity ⇒ Object
30 31 32 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 30 def boost_familiarity @resonance = [@resonance + Constants::FAMILIARITY_BOOST, Constants::MAX_RESONANCE].min end |
#decay ⇒ Object
34 35 36 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 34 def decay @resonance = [@resonance - Constants::RESONANCE_DECAY, Constants::RESONANCE_FLOOR].max end |
#faded? ⇒ Boolean
38 39 40 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 38 def faded? @resonance <= Constants::RESONANCE_FLOOR end |
#label ⇒ Object
42 43 44 45 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 42 def label Constants::RESONANCE_LABELS.each { |range, lbl| return lbl if range.cover?(@resonance) } :silent end |
#observe_again ⇒ Object
25 26 27 28 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 25 def observe_again @observation_count += 1 @resonance = [@resonance + Constants::REPETITION_BOOST, Constants::MAX_RESONANCE].min end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 47 def to_h { id: @id, agent_id: @agent_id, action: @action, domain: @domain, context: @context, outcome: @outcome, resonance: @resonance, observation_count: @observation_count, label: label, created_at: @created_at } end |