Class: Legion::Extensions::Agentic::Inference::Debugging::Helpers::ReasoningError

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_type:, description:, severity:, source_phase:, confidence_at_detection:) ⇒ ReasoningError

Returns a new instance of ReasoningError.



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 16

def initialize(error_type:, description:, severity:, source_phase:, confidence_at_detection:)
  @id                       = SecureRandom.uuid
  @error_type               = error_type
  @description              = description
  @severity                 = severity.clamp(0.0, 1.0).round(10)
  @source_phase             = source_phase
  @confidence_at_detection  = confidence_at_detection.clamp(0.0, 1.0).round(10)
  @status                   = :detected
  @trace_ids                = []
  @correction_ids           = []
  @created_at               = Time.now.utc
  @resolved_at              = nil
end

Instance Attribute Details

#confidence_at_detectionObject (readonly)

Returns the value of attribute confidence_at_detection.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def confidence_at_detection
  @confidence_at_detection
end

#correction_idsObject (readonly)

Returns the value of attribute correction_ids.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def correction_ids
  @correction_ids
end

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def description
  @description
end

#error_typeObject (readonly)

Returns the value of attribute error_type.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def error_type
  @error_type
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def id
  @id
end

#resolved_atObject (readonly)

Returns the value of attribute resolved_at.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def resolved_at
  @resolved_at
end

#severityObject (readonly)

Returns the value of attribute severity.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def severity
  @severity
end

#source_phaseObject (readonly)

Returns the value of attribute source_phase.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def source_phase
  @source_phase
end

#statusObject (readonly)

Returns the value of attribute status.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def status
  @status
end

#trace_idsObject (readonly)

Returns the value of attribute trace_ids.



12
13
14
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 12

def trace_ids
  @trace_ids
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 67

def active?
  !%i[resolved unresolvable].include?(@status)
end

#correct!(correction_id) ⇒ Object



41
42
43
44
45
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 41

def correct!(correction_id)
  @correction_ids << correction_id
  @status = :correcting
  self
end

#detect!Object



30
31
32
33
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 30

def detect!
  @status = :detected
  self
end

#mark_unresolvable!Object



53
54
55
56
57
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 53

def mark_unresolvable!
  @status      = :unresolvable
  @resolved_at = Time.now.utc
  self
end

#resolve!Object



47
48
49
50
51
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 47

def resolve!
  @status      = :resolved
  @resolved_at = Time.now.utc
  self
end

#resolved?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 63

def resolved?
  @status == :resolved
end

#severe?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 59

def severe?
  @severity >= 0.7
end

#severity_labelObject



71
72
73
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 71

def severity_label
  Constants.severity_label(@severity)
end

#to_hObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 75

def to_h
  {
    id:                      @id,
    error_type:              @error_type,
    description:             @description,
    severity:                @severity,
    severity_label:          severity_label,
    source_phase:            @source_phase,
    confidence_at_detection: @confidence_at_detection,
    status:                  @status,
    trace_ids:               @trace_ids.dup,
    correction_ids:          @correction_ids.dup,
    created_at:              @created_at,
    resolved_at:             @resolved_at
  }
end

#trace!(trace_id) ⇒ Object



35
36
37
38
39
# File 'lib/legion/extensions/agentic/inference/debugging/helpers/reasoning_error.rb', line 35

def trace!(trace_id)
  @trace_ids << trace_id
  @status = :traced
  self
end