Class: Legion::Extensions::Agentic::Executive::Planning::Helpers::PlanStep
- Inherits:
-
Object
- Object
- Legion::Extensions::Agentic::Executive::Planning::Helpers::PlanStep
- Defined in:
- lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#actual_effort ⇒ Object
Returns the value of attribute actual_effort.
-
#completed_at ⇒ Object
readonly
Returns the value of attribute completed_at.
-
#depends_on ⇒ Object
readonly
Returns the value of attribute depends_on.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#estimated_effort ⇒ Object
readonly
Returns the value of attribute estimated_effort.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #blocked? ⇒ Boolean
- #complete!(result: nil) ⇒ Object
- #duration ⇒ Object
- #fail!(reason: nil) ⇒ Object
-
#initialize(action:, description: nil, depends_on: [], estimated_effort: 1) ⇒ PlanStep
constructor
A new instance of PlanStep.
- #ready?(completed_step_ids) ⇒ Boolean
- #start! ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(action:, description: nil, depends_on: [], estimated_effort: 1) ⇒ PlanStep
Returns a new instance of PlanStep.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 16 def initialize(action:, description: nil, depends_on: [], estimated_effort: 1, **) @id = SecureRandom.uuid @action = action @description = description @status = :pending @depends_on = Array(depends_on).dup @estimated_effort = estimated_effort @actual_effort = nil @result = nil @started_at = nil @completed_at = nil end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 12 def action @action end |
#actual_effort ⇒ Object
Returns the value of attribute actual_effort.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 14 def actual_effort @actual_effort end |
#completed_at ⇒ Object (readonly)
Returns the value of attribute completed_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 12 def completed_at @completed_at end |
#depends_on ⇒ Object (readonly)
Returns the value of attribute depends_on.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 12 def depends_on @depends_on end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 12 def description @description end |
#estimated_effort ⇒ Object (readonly)
Returns the value of attribute estimated_effort.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 12 def estimated_effort @estimated_effort end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 12 def id @id end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 12 def result @result end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
12 13 14 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 12 def started_at @started_at end |
#status ⇒ Object
Returns the value of attribute status.
14 15 16 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 14 def status @status end |
Instance Method Details
#blocked? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 41 def blocked? @status == :blocked end |
#complete!(result: nil) ⇒ Object
45 46 47 48 49 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 45 def complete!(result: nil) @status = :completed @result = result @completed_at = Time.now.utc end |
#duration ⇒ Object
35 36 37 38 39 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 35 def duration return nil unless @started_at && @completed_at @completed_at - @started_at end |
#fail!(reason: nil) ⇒ Object
51 52 53 54 55 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 51 def fail!(reason: nil) @status = :failed @result = { reason: reason } @completed_at = Time.now.utc end |
#ready?(completed_step_ids) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 29 def ready?(completed_step_ids) return false if %i[completed failed skipped].include?(@status) @depends_on.all? { |dep_id| completed_step_ids.include?(dep_id) } end |
#start! ⇒ Object
57 58 59 60 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 57 def start! @status = :active @started_at = Time.now.utc end |
#to_h ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/legion/extensions/agentic/executive/planning/helpers/plan_step.rb', line 62 def to_h { id: @id, action: @action, description: @description, status: @status, depends_on: @depends_on, estimated_effort: @estimated_effort, actual_effort: @actual_effort, result: @result, started_at: @started_at, completed_at: @completed_at } end |