Class: Legion::Extensions::Agentic::Self::Agency::Helpers::OutcomeEvent
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::Agency::Helpers::OutcomeEvent
- Defined in:
- lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb
Instance Attribute Summary collapse
-
#attribution ⇒ Object
readonly
Returns the value of attribute attribution.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#magnitude ⇒ Object
readonly
Returns the value of attribute magnitude.
-
#outcome_type ⇒ Object
readonly
Returns the value of attribute outcome_type.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #attributed_magnitude ⇒ Object
-
#initialize(domain:, outcome_type:, source: :mastery, magnitude: 1.0, attribution: :full_agency) ⇒ OutcomeEvent
constructor
A new instance of OutcomeEvent.
- #success? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(domain:, outcome_type:, source: :mastery, magnitude: 1.0, attribution: :full_agency) ⇒ OutcomeEvent
Returns a new instance of OutcomeEvent.
14 15 16 17 18 19 20 21 22 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 14 def initialize(domain:, outcome_type:, source: :mastery, magnitude: 1.0, attribution: :full_agency) @id = SecureRandom.uuid @domain = domain @outcome_type = outcome_type @source = source @magnitude = magnitude.clamp(0.0, 1.0) @attribution = attribution @timestamp = Time.now.utc end |
Instance Attribute Details
#attribution ⇒ Object (readonly)
Returns the value of attribute attribution.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 12 def attribution @attribution end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 12 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 12 def id @id end |
#magnitude ⇒ Object (readonly)
Returns the value of attribute magnitude.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 12 def magnitude @magnitude end |
#outcome_type ⇒ Object (readonly)
Returns the value of attribute outcome_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 12 def outcome_type @outcome_type end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 12 def source @source end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 12 def @timestamp end |
Instance Method Details
#attributed_magnitude ⇒ Object
28 29 30 31 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 28 def attributed_magnitude level = Constants::ATTRIBUTION_LEVELS[@attribution] || 0.5 @magnitude * level end |
#success? ⇒ Boolean
24 25 26 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 24 def success? %i[success partial_success].include?(@outcome_type) end |
#to_h ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/legion/extensions/agentic/self/agency/helpers/outcome_event.rb', line 33 def to_h { id: @id, domain: @domain, outcome_type: @outcome_type, source: @source, magnitude: @magnitude, attribution: @attribution, success: success?, attributed_magnitude: attributed_magnitude.round(4), timestamp: @timestamp } end |