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.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 25 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.
22 23 24 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 22 def action @action end |
#agent_id ⇒ Object (readonly)
Returns the value of attribute agent_id.
22 23 24 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 22 def agent_id @agent_id end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
22 23 24 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 22 def context @context end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
22 23 24 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 22 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
22 23 24 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 22 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
22 23 24 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 22 def id @id end |
#observation_count ⇒ Object
Returns the value of attribute observation_count.
23 24 25 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 23 def observation_count @observation_count end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
22 23 24 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 22 def outcome @outcome end |
#resonance ⇒ Object
Returns the value of attribute resonance.
23 24 25 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 23 def resonance @resonance end |
Instance Method Details
#boost_familiarity ⇒ Object
42 43 44 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 42 def boost_familiarity @resonance = [@resonance + Constants::FAMILIARITY_BOOST, Constants::MAX_RESONANCE].min end |
#decay ⇒ Object
46 47 48 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 46 def decay @resonance = [@resonance - Constants::RESONANCE_DECAY, Constants::RESONANCE_FLOOR].max end |
#faded? ⇒ Boolean
50 51 52 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 50 def faded? @resonance <= Constants::RESONANCE_FLOOR end |
#label ⇒ Object
54 55 56 57 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 54 def label Constants::RESONANCE_LABELS.each { |range, lbl| return lbl if range.cover?(@resonance) } :silent end |
#observe_again ⇒ Object
37 38 39 40 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 37 def observe_again @observation_count += 1 @resonance = [@resonance + Constants::REPETITION_BOOST, Constants::MAX_RESONANCE].min end |
#to_h ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/legion/extensions/agentic/social/mirror_system/helpers/observed_behavior.rb', line 59 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 |