Class: Legion::Extensions::Agentic::Defense::ErrorMonitoring::Helpers::ErrorSignal
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Defense::ErrorMonitoring::Helpers::ErrorSignal
- Includes:
- Constants
- Defined in:
- lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb
Constant Summary
Constants included from Constants
Constants::CONFIDENCE_ALPHA, Constants::CONFLICT_ALPHA, Constants::CONFLICT_THRESHOLD, Constants::CORRECTION_BOOST, Constants::DEFAULT_CONFIDENCE, Constants::DEFAULT_CONFLICT_LEVEL, Constants::DEFAULT_ERROR_RATE, Constants::ERROR_RATE_ALPHA, Constants::ERROR_SEVERITY_LABELS, Constants::MAX_CONFLICT_LOG, Constants::MAX_CORRECTIONS, Constants::MAX_ERROR_LOG, Constants::MAX_SLOWDOWN, Constants::MONITORING_STATE_LABELS, Constants::POST_ERROR_SLOWDOWN, Constants::SEVERE_ERROR_THRESHOLD, Constants::SLOWDOWN_DECAY
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#corrected ⇒ Object
readonly
Returns the value of attribute corrected.
-
#detected_at ⇒ Object
readonly
Returns the value of attribute detected_at.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#intended ⇒ Object
readonly
Returns the value of attribute intended.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
Instance Method Summary collapse
- #age ⇒ Object
-
#initialize(action:, domain:, intended:, actual:, severity:) ⇒ ErrorSignal
constructor
A new instance of ErrorSignal.
- #label ⇒ Object
- #mark_corrected ⇒ Object
- #severe? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(action:, domain:, intended:, actual:, severity:) ⇒ ErrorSignal
Returns a new instance of ErrorSignal.
14 15 16 17 18 19 20 21 22 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 14 def initialize(action:, domain:, intended:, actual:, severity:) @action = action @domain = domain @intended = intended @actual = actual @severity = severity.to_f.clamp(0.0, 1.0) @detected_at = Time.now.utc @corrected = false end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 12 def action @action end |
#actual ⇒ Object (readonly)
Returns the value of attribute actual.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 12 def actual @actual end |
#corrected ⇒ Object (readonly)
Returns the value of attribute corrected.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 12 def corrected @corrected end |
#detected_at ⇒ Object (readonly)
Returns the value of attribute detected_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 12 def detected_at @detected_at end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 12 def domain @domain end |
#intended ⇒ Object (readonly)
Returns the value of attribute intended.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 12 def intended @intended end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
12 13 14 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 12 def severity @severity end |
Instance Method Details
#age ⇒ Object
32 33 34 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 32 def age Time.now.utc - @detected_at end |
#label ⇒ Object
36 37 38 39 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 36 def label ERROR_SEVERITY_LABELS.each { |range, lbl| return lbl if range.cover?(@severity) } :trivial end |
#mark_corrected ⇒ Object
24 25 26 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 24 def mark_corrected @corrected = true end |
#severe? ⇒ Boolean
28 29 30 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 28 def severe? @severity >= SEVERE_ERROR_THRESHOLD end |
#to_h ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/legion/extensions/agentic/defense/error_monitoring/helpers/error_signal.rb', line 41 def to_h { action: @action, domain: @domain, intended: @intended, actual: @actual, severity: @severity.round(4), label: label, detected_at: @detected_at, corrected: @corrected, age: age.round(2) } end |