Class: Legion::Extensions::Agentic::Learning::Procedural::Helpers::Production

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/learning/procedural/helpers/production.rb

Constant Summary

Constants included from Constants

Constants::AUTOMATION_THRESHOLD, Constants::COMPILATION_THRESHOLD, Constants::DECAY_RATE, Constants::DEFAULT_PROFICIENCY, Constants::MAX_HISTORY, Constants::MAX_PRODUCTIONS, Constants::MAX_SKILLS, Constants::PRACTICE_GAIN, Constants::PROFICIENCY_CEILING, Constants::PROFICIENCY_FLOOR, Constants::PROFICIENCY_LABELS, Constants::SKILL_STAGES, Constants::STAGE_LABELS, Constants::STALE_THRESHOLD

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(condition:, action:, domain:, skill_id:) ⇒ Production

Returns a new instance of Production.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 17

def initialize(condition:, action:, domain:, skill_id:)
  @id               = SecureRandom.uuid
  @condition        = condition
  @action           = action
  @domain           = domain
  @skill_id         = skill_id
  @execution_count  = 0
  @success_count    = 0
  @created_at       = Time.now.utc
  @last_executed_at = @created_at
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



14
15
16
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 14

def action
  @action
end

#conditionObject (readonly)

Returns the value of attribute condition.



14
15
16
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 14

def condition
  @condition
end

#created_atObject (readonly)

Returns the value of attribute created_at.



14
15
16
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.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/learning/procedural/helpers/production.rb', line 14

def domain
  @domain
end

#execution_countObject (readonly)

Returns the value of attribute execution_count.



14
15
16
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 14

def execution_count
  @execution_count
end

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 14

def id
  @id
end

#last_executed_atObject (readonly)

Returns the value of attribute last_executed_at.



14
15
16
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 14

def last_executed_at
  @last_executed_at
end

#skill_idObject (readonly)

Returns the value of attribute skill_id.



14
15
16
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 14

def skill_id
  @skill_id
end

#success_countObject (readonly)

Returns the value of attribute success_count.



14
15
16
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 14

def success_count
  @success_count
end

Instance Method Details

#execute!(success:) ⇒ Object



29
30
31
32
33
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 29

def execute!(success:)
  @execution_count  += 1
  @success_count    += 1 if success
  @last_executed_at  = Time.now.utc
end

#reliable?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 41

def reliable?
  success_rate >= 0.7 && @execution_count >= 3
end

#success_rateObject



35
36
37
38
39
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 35

def success_rate
  return 0.0 if @execution_count.zero?

  @success_count.to_f / @execution_count
end

#to_hObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/legion/extensions/agentic/learning/procedural/helpers/production.rb', line 45

def to_h
  {
    id:               @id,
    condition:        @condition,
    action:           @action,
    domain:           @domain,
    skill_id:         @skill_id,
    execution_count:  @execution_count,
    success_count:    @success_count,
    success_rate:     success_rate,
    reliable:         reliable?,
    created_at:       @created_at,
    last_executed_at: @last_executed_at
  }
end