Class: Legion::Extensions::Agentic::Learning::EpistemicCuriosity::Helpers::KnowledgeGap

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, question:, domain:, gap_type:, urgency: Constants::DEFAULT_URGENCY) ⇒ KnowledgeGap

Returns a new instance of KnowledgeGap.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 13

def initialize(id:, question:, domain:, gap_type:, urgency: Constants::DEFAULT_URGENCY)
  @id           = id
  @question     = question
  @domain       = domain
  @gap_type     = gap_type
  @urgency      = urgency.clamp(0.0, 1.0)
  @satisfaction = 0.0
  @explorations = 0
  @created_at   = Time.now.utc
  @resolved_at  = nil
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



10
11
12
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 10

def created_at
  @created_at
end

#domainObject (readonly)

Returns the value of attribute domain.



10
11
12
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 10

def domain
  @domain
end

#explorationsObject (readonly)

Returns the value of attribute explorations.



10
11
12
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 10

def explorations
  @explorations
end

#gap_typeObject (readonly)

Returns the value of attribute gap_type.



10
11
12
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 10

def gap_type
  @gap_type
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 10

def id
  @id
end

#questionObject (readonly)

Returns the value of attribute question.



10
11
12
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 10

def question
  @question
end

#resolved_atObject

Returns the value of attribute resolved_at.



11
12
13
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 11

def resolved_at
  @resolved_at
end

#satisfactionObject

Returns the value of attribute satisfaction.



11
12
13
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 11

def satisfaction
  @satisfaction
end

#urgencyObject

Returns the value of attribute urgency.



11
12
13
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 11

def urgency
  @urgency
end

Instance Method Details

#decay!Object



44
45
46
47
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 44

def decay!
  @urgency = (@urgency - Constants::URGENCY_DECAY).clamp(0.0, 1.0)
  self
end

#explore!Object



25
26
27
28
29
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 25

def explore!
  @explorations += 1
  @urgency = (@urgency + Constants::URGENCY_BOOST).clamp(0.0, 1.0)
  self
end

#resolved?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 36

def resolved?
  @satisfaction >= Constants::SATISFACTION_THRESHOLD
end

#satisfy!(amount: 0.3) ⇒ Object



31
32
33
34
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 31

def satisfy!(amount: 0.3)
  @satisfaction = (@satisfaction + amount).clamp(0.0, 1.0)
  self
end

#to_hObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 49

def to_h
  {
    id:            @id,
    question:      @question,
    domain:        @domain,
    gap_type:      @gap_type,
    urgency:       @urgency.round(4),
    urgency_label: urgency_label,
    satisfaction:  @satisfaction.round(4),
    explorations:  @explorations,
    resolved:      resolved?,
    created_at:    @created_at,
    resolved_at:   @resolved_at
  }
end

#urgency_labelObject



40
41
42
# File 'lib/legion/extensions/agentic/learning/epistemic_curiosity/helpers/knowledge_gap.rb', line 40

def urgency_label
  Constants::URGENCY_LABELS.find { |entry| entry[:range].cover?(@urgency) }&.fetch(:label, :mild) || :mild
end