Class: Aidp::Temporal::Workflows::SubIssueWorkflow

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

Overview

Child workflow for handling decomposed sub-tasks Supports recursive decomposition when a task is too large

Used by IssueToPrWorkflow to break down complex issues into smaller, manageable sub-tasks executed in parallel

Constant Summary collapse

MAX_RECURSION_DEPTH =

Maximum depth for recursive decomposition

3

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



20
21
22
# File 'lib/aidp/temporal/workflows/sub_issue_workflow.rb', line 20

def current_state
  @state
end

#execute(input) ⇒ Object

Main workflow execution



50
51
52
53
54
55
56
57
58
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
# File 'lib/aidp/temporal/workflows/sub_issue_workflow.rb', line 50

def execute(input)
  initialize_state(input)
  log_workflow("started",
    sub_issue_id: @sub_issue_id,
    depth: @depth,
    parent: @parent_workflow_id)

  # Check recursion depth limit
  if @depth >= MAX_RECURSION_DEPTH
    log_workflow("max_depth_reached", depth: @depth)
    return build_error_result("Maximum recursion depth reached")
  end

  begin
    # Analyze the sub-task
    transition_to(:analyzing)
    analysis = analyze_sub_task

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

    # Check if further decomposition needed
    if needs_decomposition?(analysis)
      transition_to(:decomposing)
      result = execute_child_workflows(analysis)
    else
      # Execute directly
      transition_to(:implementing)
      result = execute_implementation(analysis)
    end

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

#pauseObject



38
39
40
41
# File 'lib/aidp/temporal/workflows/sub_issue_workflow.rb', line 38

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

#progressObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/aidp/temporal/workflows/sub_issue_workflow.rb', line 25

def progress
  {
    state: @state,
    sub_issue_id: @sub_issue_id,
    parent_workflow_id: @parent_workflow_id,
    depth: @depth,
    iteration: @iteration,
    started_at: @started_at
  }
end

#resumeObject



44
45
46
47
# File 'lib/aidp/temporal/workflows/sub_issue_workflow.rb', line 44

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