Class: Legion::Extensions::Agentic::Attention::Blindspot::Helpers::KnowledgeBoundary

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb

Constant Summary

Constants included from Constants

Constants::AWARENESS_LABELS, Constants::AWARENESS_THRESHOLD, Constants::COVERAGE_LABELS, Constants::DEFAULT_SEVERITY, Constants::DISCOVERY_METHODS, Constants::MAX_BLINDSPOTS, Constants::MAX_BOUNDARIES, Constants::SEVERITY_BOOST, Constants::SEVERITY_LABELS, Constants::STATUS_LABELS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Constants

label_for

Constructor Details

#initialize(domain:, confidence: 0.5, coverage_estimate: 0.5) ⇒ KnowledgeBoundary

Returns a new instance of KnowledgeBoundary.



16
17
18
19
20
21
22
23
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 16

def initialize(domain:, confidence: 0.5, coverage_estimate: 0.5)
  @id               = SecureRandom.uuid
  @domain           = domain.to_sym
  @confidence       = confidence.to_f.clamp(0.0, 1.0)
  @coverage_estimate = coverage_estimate.to_f.clamp(0.0, 1.0)
  @created_at       = Time.now.utc
  @updated_at       = Time.now.utc
end

Instance Attribute Details

#confidenceObject (readonly)

Returns the value of attribute confidence.



14
15
16
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 14

def confidence
  @confidence
end

#coverage_estimateObject (readonly)

Returns the value of attribute coverage_estimate.



14
15
16
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 14

def coverage_estimate
  @coverage_estimate
end

#created_atObject (readonly)

Returns the value of attribute created_at.



14
15
16
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 14

def created_at
  @created_at
end

#domainObject (readonly)

Returns the value of attribute domain.



14
15
16
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 14

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 14

def id
  @id
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



14
15
16
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 14

def updated_at
  @updated_at
end

Instance Method Details

#coverage_labelObject



25
26
27
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 25

def coverage_label
  Constants.label_for(COVERAGE_LABELS, @coverage_estimate) || :minimal
end

#gap_detected?(error_occurred: false) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 29

def gap_detected?(error_occurred: false)
  error_occurred && @confidence >= AWARENESS_THRESHOLD
end

#to_hObject



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 45

def to_h
  {
    id:                @id,
    domain:            @domain,
    confidence:        @confidence,
    coverage_estimate: @coverage_estimate,
    coverage_label:    coverage_label,
    created_at:        @created_at,
    updated_at:        @updated_at
  }
end

#update_confidence!(new_confidence) ⇒ Object



33
34
35
36
37
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 33

def update_confidence!(new_confidence)
  @confidence  = new_confidence.to_f.clamp(0.0, 1.0)
  @updated_at  = Time.now.utc
  self
end

#update_coverage!(new_coverage) ⇒ Object



39
40
41
42
43
# File 'lib/legion/extensions/agentic/attention/blindspot/helpers/knowledge_boundary.rb', line 39

def update_coverage!(new_coverage)
  @coverage_estimate = new_coverage.to_f.clamp(0.0, 1.0)
  @updated_at        = Time.now.utc
  self
end