Class: Legion::Extensions::Agentic::Inference::Counterfactual::Helpers::Scenario
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Inference::Counterfactual::Helpers::Scenario
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb
Constant Summary
Constants included from Constants
Constants::COUNTERFACTUAL_TYPES, Constants::DEFAULT_REGRET, Constants::DOWNWARD_WEIGHT, Constants::EMOTIONAL_RESPONSES, Constants::MAX_ALTERNATIVES, Constants::MAX_HISTORY, Constants::MAX_SCENARIOS, Constants::MUTATION_TYPES, Constants::PLAUSIBILITY_THRESHOLD, Constants::REGRET_CEILING, Constants::REGRET_DECAY, Constants::REGRET_FLOOR, Constants::RELEVANCE_THRESHOLD, Constants::UPWARD_WEIGHT
Instance Attribute Summary collapse
-
#actual_outcome ⇒ Object
readonly
Returns the value of attribute actual_outcome.
-
#antecedent ⇒ Object
readonly
Returns the value of attribute antecedent.
-
#counterfactual_outcome ⇒ Object
readonly
Returns the value of attribute counterfactual_outcome.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#emotional_valence ⇒ Object
readonly
Returns the value of attribute emotional_valence.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#lesson ⇒ Object
readonly
Returns the value of attribute lesson.
-
#mutation_type ⇒ Object
readonly
Returns the value of attribute mutation_type.
-
#plausibility ⇒ Object
readonly
Returns the value of attribute plausibility.
-
#regret_magnitude ⇒ Object
readonly
Returns the value of attribute regret_magnitude.
-
#resolved ⇒ Object
readonly
Returns the value of attribute resolved.
-
#resolved_at ⇒ Object
readonly
Returns the value of attribute resolved_at.
-
#scenario_type ⇒ Object
readonly
Returns the value of attribute scenario_type.
Instance Method Summary collapse
- #downward? ⇒ Boolean
- #emotional_response ⇒ Object
-
#initialize(scenario_type:, mutation_type:, actual_outcome:, counterfactual_outcome:, antecedent:, domain:, plausibility:, regret_magnitude: 0.5) ⇒ Scenario
constructor
A new instance of Scenario.
- #prefactual? ⇒ Boolean
- #resolve(lesson:) ⇒ Object
- #to_h ⇒ Object
- #upward? ⇒ Boolean
Constructor Details
#initialize(scenario_type:, mutation_type:, actual_outcome:, counterfactual_outcome:, antecedent:, domain:, plausibility:, regret_magnitude: 0.5) ⇒ Scenario
Returns a new instance of Scenario.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 20 def initialize(scenario_type:, mutation_type:, actual_outcome:, counterfactual_outcome:, antecedent:, domain:, plausibility:, regret_magnitude: 0.5) @id = SecureRandom.uuid @scenario_type = scenario_type @mutation_type = mutation_type @actual_outcome = actual_outcome @counterfactual_outcome = counterfactual_outcome @antecedent = antecedent @domain = domain @plausibility = plausibility.to_f.clamp(0.0, 1.0) @regret_magnitude = regret_magnitude.to_f.clamp(0.0, 1.0) @emotional_valence = compute_emotional_valence @lesson = nil @resolved = false @created_at = Time.now.utc @resolved_at = nil end |
Instance Attribute Details
#actual_outcome ⇒ Object (readonly)
Returns the value of attribute actual_outcome.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def actual_outcome @actual_outcome end |
#antecedent ⇒ Object (readonly)
Returns the value of attribute antecedent.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def antecedent @antecedent end |
#counterfactual_outcome ⇒ Object (readonly)
Returns the value of attribute counterfactual_outcome.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def counterfactual_outcome @counterfactual_outcome end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.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/inference/counterfactual/helpers/scenario.rb', line 14 def domain @domain end |
#emotional_valence ⇒ Object (readonly)
Returns the value of attribute emotional_valence.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def emotional_valence @emotional_valence end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def id @id end |
#lesson ⇒ Object (readonly)
Returns the value of attribute lesson.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def lesson @lesson end |
#mutation_type ⇒ Object (readonly)
Returns the value of attribute mutation_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def mutation_type @mutation_type end |
#plausibility ⇒ Object (readonly)
Returns the value of attribute plausibility.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def plausibility @plausibility end |
#regret_magnitude ⇒ Object (readonly)
Returns the value of attribute regret_magnitude.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def regret_magnitude @regret_magnitude end |
#resolved ⇒ Object (readonly)
Returns the value of attribute resolved.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def resolved @resolved end |
#resolved_at ⇒ Object (readonly)
Returns the value of attribute resolved_at.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def resolved_at @resolved_at end |
#scenario_type ⇒ Object (readonly)
Returns the value of attribute scenario_type.
14 15 16 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 14 def scenario_type @scenario_type end |
Instance Method Details
#downward? ⇒ Boolean
43 44 45 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 43 def downward? @scenario_type == :downward end |
#emotional_response ⇒ Object
51 52 53 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 51 def emotional_response EMOTIONAL_RESPONSES.fetch(@scenario_type, :neutral) end |
#prefactual? ⇒ Boolean
47 48 49 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 47 def prefactual? @scenario_type == :prefactual end |
#resolve(lesson:) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 55 def resolve(lesson:) @lesson = lesson @resolved = true @resolved_at = Time.now.utc self end |
#to_h ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 62 def to_h { id: @id, scenario_type: @scenario_type, mutation_type: @mutation_type, actual_outcome: @actual_outcome, counterfactual_outcome: @counterfactual_outcome, antecedent: @antecedent, domain: @domain, plausibility: @plausibility, emotional_valence: @emotional_valence, regret_magnitude: @regret_magnitude, emotional_response: emotional_response, lesson: @lesson, resolved: @resolved, created_at: @created_at, resolved_at: @resolved_at } end |
#upward? ⇒ Boolean
39 40 41 |
# File 'lib/legion/extensions/agentic/inference/counterfactual/helpers/scenario.rb', line 39 def upward? @scenario_type == :upward end |