Class: Aidp::Temporal::Workflows::WorkLoopWorkflow

Inherits:
BaseWorkflow
  • Object
show all
Defined in:
lib/aidp/temporal/workflows/work_loop_workflow.rb

Overview

Workflow that implements the fix-forward work loop pattern Handles iterative implementation with test validation

State machine: READY → APPLY_PATCH → TEST → → DONE | FAIL → DIAGNOSE → NEXT_PATCH → READY

Constant Summary

Constants inherited from BaseWorkflow

BaseWorkflow::DEFAULT_ACTIVITY_OPTIONS

Instance Method Summary collapse

Methods inherited from BaseWorkflow

activity_options, workflow_name

Instance Method Details

#current_stateObject



17
18
19
# File 'lib/aidp/temporal/workflows/work_loop_workflow.rb', line 17

def current_state
  @state
end

#escalate_modelObject



68
69
70
71
# File 'lib/aidp/temporal/workflows/work_loop_workflow.rb', line 68

def escalate_model
  @escalate_requested = true
  log_workflow("escalation_requested", current_iteration: @iteration)
end

#execute(input) ⇒ Object

Main workflow execution



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/aidp/temporal/workflows/work_loop_workflow.rb', line 74

def execute(input)
  initialize_state(input)
  log_workflow("started",
    step_name: @step_name,
    max_iterations: @max_iterations,
    project_dir: @project_dir)

  begin
    result = run_work_loop
    build_result(result)
  rescue Temporalio::Error::CanceledError
    log_workflow("canceled", state: @state, iteration: @iteration)
    build_canceled_result
  end
end

#inject_instruction(instruction) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/aidp/temporal/workflows/work_loop_workflow.rb', line 57

def inject_instruction(instruction)
  @instruction_queue ||= []
  @instruction_queue << {
    content: instruction,
    type: :user_input,
    queued_at: Time.now.iso8601
  }
  log_workflow("instruction_queued", queue_size: @instruction_queue.length)
end

#iteration_countObject



22
23
24
# File 'lib/aidp/temporal/workflows/work_loop_workflow.rb', line 22

def iteration_count
  @iteration
end

#pauseObject



45
46
47
48
# File 'lib/aidp/temporal/workflows/work_loop_workflow.rb', line 45

def pause
  @paused = true
  log_workflow("paused", iteration: @iteration)
end

#progressObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/aidp/temporal/workflows/work_loop_workflow.rb', line 32

def progress
  {
    state: @state,
    iteration: @iteration,
    max_iterations: @max_iterations,
    step_name: @step_name,
    consecutive_failures: @consecutive_failures,
    started_at: @started_at
  }
end

#resumeObject



51
52
53
54
# File 'lib/aidp/temporal/workflows/work_loop_workflow.rb', line 51

def resume
  @paused = false
  log_workflow("resumed", iteration: @iteration)
end

#test_resultsObject



27
28
29
# File 'lib/aidp/temporal/workflows/work_loop_workflow.rb', line 27

def test_results
  @last_test_results
end