Class: Aidp::Temporal::Workflows::IssueToPrWorkflow

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

Overview

Workflow that orchestrates the full issue-to-PR pipeline Handles: issue analysis, planning, implementation, testing, and PR creation

State machine: INIT → ANALYZE → PLAN → IMPLEMENT → TEST → → CREATE_PR | FAIL → IMPLEMENT → COMPLETE

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/issue_to_pr_workflow.rb', line 17

def current_state
  @state
end

#execute(input) ⇒ Object

Main workflow execution



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/aidp/temporal/workflows/issue_to_pr_workflow.rb', line 59

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

  begin
    # Phase 1: Analyze the issue
    transition_to(:analyzing)
    analysis = run_analysis_phase

    return build_error_result("Analysis failed") unless analysis[:success]

    # Phase 2: Create implementation plan
    transition_to(:planning)
    plan = run_planning_phase(analysis)

    return build_error_result("Planning failed") unless plan[:success]

    # Phase 3: Implementation loop (fix-forward pattern)
    transition_to(:implementing)
    implementation = run_implementation_loop(plan)

    return build_error_result("Implementation failed: max iterations reached") unless implementation[:success]

    # Phase 4: Create PR
    transition_to(:creating_pr)
    pr_result = run_create_pr_phase(implementation)

    transition_to(:completed)
    build_success_result(pr_result)
  rescue Temporalio::Error::CanceledError
    log_workflow("canceled", state: @state, iteration: @iteration)
    transition_to(:canceled)
    build_canceled_result
  end
end

#inject_instruction(instruction) ⇒ Object



52
53
54
55
56
# File 'lib/aidp/temporal/workflows/issue_to_pr_workflow.rb', line 52

def inject_instruction(instruction)
  @injected_instructions ||= []
  @injected_instructions << instruction
  log_workflow("instruction_injected", instruction_length: instruction.length)
end

#iteration_countObject



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

def iteration_count
  @iteration
end

#pauseObject



40
41
42
43
# File 'lib/aidp/temporal/workflows/issue_to_pr_workflow.rb', line 40

def pause
  @paused = true
  log_workflow("paused")
end

#progressObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/aidp/temporal/workflows/issue_to_pr_workflow.rb', line 27

def progress
  {
    state: @state,
    iteration: @iteration,
    max_iterations: @max_iterations,
    issue_number: @issue_number,
    started_at: @started_at,
    last_activity: @last_activity
  }
end

#resumeObject



46
47
48
49
# File 'lib/aidp/temporal/workflows/issue_to_pr_workflow.rb', line 46

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