Class: Legion::Extensions::Agentic::Executive::Control::Helpers::Goal

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/legion/extensions/agentic/executive/control/helpers/goal.rb

Constant Summary

Constants included from Constants

Constants::ADAPTATION_ALPHA, Constants::AUTOMATIC_THRESHOLD, Constants::CONFLICT_BOOST, Constants::CONTROLLED_THRESHOLD, Constants::CONTROL_MODES, Constants::DEFAULT_EFFORT, Constants::EFFORT_CEILING, Constants::EFFORT_DECAY, Constants::EFFORT_FLOOR, Constants::EFFORT_LABELS, Constants::EFFORT_RECOVERY, Constants::ERROR_BOOST, Constants::GOAL_STATES, Constants::MAX_GOALS, Constants::MAX_HISTORY, Constants::MAX_POLICIES, Constants::NOVELTY_BOOST, Constants::OVERRIDE_THRESHOLD

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, description:, domain: :general, priority: 0.5) ⇒ Goal

Returns a new instance of Goal.



14
15
16
17
18
19
20
21
22
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 14

def initialize(id:, description:, domain: :general, priority: 0.5)
  @id          = id
  @description = description
  @domain      = domain
  @priority    = priority.to_f.clamp(0.0, 1.0)
  @state       = :active
  @progress    = 0.0
  @created_at  = Time.now.utc
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.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/executive/control/helpers/goal.rb', line 12

def description
  @description
end

#domainObject (readonly)

Returns the value of attribute domain.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 12

def domain
  @domain
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 12

def id
  @id
end

#priorityObject (readonly)

Returns the value of attribute priority.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 12

def priority
  @priority
end

#progressObject (readonly)

Returns the value of attribute progress.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 12

def progress
  @progress
end

#stateObject (readonly)

Returns the value of attribute state.



12
13
14
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 12

def state
  @state
end

Instance Method Details

#abandon!Object



44
45
46
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 44

def abandon!
  @state = :abandoned unless @state == :completed
end

#active?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 48

def active?
  @state == :active
end

#advance(amount: 0.1) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 24

def advance(amount: 0.1)
  return nil unless @state == :active

  @progress = [@progress + amount, 1.0].min
  complete! if @progress >= 1.0
  @progress
end

#complete!Object



32
33
34
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 32

def complete!
  @state = :completed
end

#completed?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 52

def completed?
  @state == :completed
end

#resume!Object



40
41
42
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 40

def resume!
  @state = :active if @state == :suspended
end

#suspend!Object



36
37
38
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 36

def suspend!
  @state = :suspended if @state == :active
end

#to_hObject



56
57
58
59
60
61
62
63
64
65
# File 'lib/legion/extensions/agentic/executive/control/helpers/goal.rb', line 56

def to_h
  {
    id:          @id,
    description: @description,
    domain:      @domain,
    priority:    @priority.round(4),
    state:       @state,
    progress:    @progress.round(4)
  }
end