Class: Legion::Extensions::Agentic::Self::MetacognitiveMonitoring::Helpers::MonitoringJudgment
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Self::MetacognitiveMonitoring::Helpers::MonitoringJudgment
- Defined in:
- lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb
Instance Attribute Summary collapse
-
#actual_outcome ⇒ Object
readonly
Returns the value of attribute actual_outcome.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#effort_level ⇒ Object
readonly
Returns the value of attribute effort_level.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#judgment_type ⇒ Object
readonly
Returns the value of attribute judgment_type.
-
#predicted_confidence ⇒ Object
readonly
Returns the value of attribute predicted_confidence.
-
#resolved ⇒ Object
readonly
Returns the value of attribute resolved.
Instance Method Summary collapse
- #calibration_error ⇒ Object
- #confidence_label ⇒ Object
- #effort_label ⇒ Object
-
#initialize(judgment_type:, domain:, predicted_confidence: DEFAULT_CONFIDENCE, effort_level: 0.5) ⇒ MonitoringJudgment
constructor
A new instance of MonitoringJudgment.
- #overconfident? ⇒ Boolean
- #resolve!(actual:) ⇒ Object
- #to_h ⇒ Object
- #underconfident? ⇒ Boolean
Constructor Details
#initialize(judgment_type:, domain:, predicted_confidence: DEFAULT_CONFIDENCE, effort_level: 0.5) ⇒ MonitoringJudgment
Returns a new instance of MonitoringJudgment.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 15 def initialize(judgment_type:, domain:, predicted_confidence: DEFAULT_CONFIDENCE, effort_level: 0.5) @id = SecureRandom.uuid @judgment_type = judgment_type @domain = domain @predicted_confidence = predicted_confidence.clamp(0.0, 1.0) @effort_level = effort_level.clamp(0.0, 1.0) @actual_outcome = nil @resolved = false @created_at = Time.now.utc end |
Instance Attribute Details
#actual_outcome ⇒ Object (readonly)
Returns the value of attribute actual_outcome.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 12 def actual_outcome @actual_outcome end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 12 def created_at @created_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 12 def domain @domain end |
#effort_level ⇒ Object (readonly)
Returns the value of attribute effort_level.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 12 def effort_level @effort_level end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 12 def id @id end |
#judgment_type ⇒ Object (readonly)
Returns the value of attribute judgment_type.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 12 def judgment_type @judgment_type end |
#predicted_confidence ⇒ Object (readonly)
Returns the value of attribute predicted_confidence.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 12 def predicted_confidence @predicted_confidence end |
#resolved ⇒ Object (readonly)
Returns the value of attribute resolved.
12 13 14 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 12 def resolved @resolved end |
Instance Method Details
#calibration_error ⇒ Object
32 33 34 35 36 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 32 def calibration_error return nil unless resolved (predicted_confidence - actual_outcome).round(10) end |
#confidence_label ⇒ Object
50 51 52 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 50 def confidence_label CONFIDENCE_LABELS.find { |range, _| range.cover?(predicted_confidence) }&.last end |
#effort_label ⇒ Object
54 55 56 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 54 def effort_label EFFORT_LABELS.find { |range, _| range.cover?(effort_level) }&.last end |
#overconfident? ⇒ Boolean
38 39 40 41 42 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 38 def overconfident? return false unless resolved calibration_error > OVERCONFIDENCE_THRESHOLD end |
#resolve!(actual:) ⇒ Object
26 27 28 29 30 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 26 def resolve!(actual:) @actual_outcome = actual.clamp(0.0, 1.0) @resolved = true self end |
#to_h ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 58 def to_h { id: id, judgment_type: judgment_type, domain: domain, predicted_confidence: predicted_confidence, actual_outcome: actual_outcome, effort_level: effort_level, resolved: resolved, calibration_error: calibration_error, confidence_label: confidence_label, effort_label: effort_label, created_at: created_at } end |
#underconfident? ⇒ Boolean
44 45 46 47 48 |
# File 'lib/legion/extensions/agentic/self/metacognitive_monitoring/helpers/monitoring_judgment.rb', line 44 def underconfident? return false unless resolved calibration_error < UNDERCONFIDENCE_THRESHOLD end |