Class: Aidp::OrchestrationAdapter

Inherits:
Object
  • Object
show all
Includes:
MessageDisplay
Defined in:
lib/aidp/orchestration_adapter.rb

Overview

Adapter for orchestration execution Routes to Temporal-based or legacy orchestration based on configuration

When Temporal is enabled:

  • Workflows execute through Temporal for durability and observability
  • Activities wrap existing AIDP functionality
  • State is persisted in Temporal's history

When Temporal is disabled (legacy mode):

  • Falls back to existing AsyncWorkLoopRunner and BackgroundRunner
  • State is tracked in file-based storage

Migration strategy:

  1. Enable Temporal in aidp.yml
  2. Start Temporal worker: aidp temporal worker
  3. Use aidp temporal start for new workflows
  4. Existing jobs continue until complete

Constant Summary

Constants included from MessageDisplay

MessageDisplay::COLOR_MAP, MessageDisplay::CRITICAL_TYPES

Instance Method Summary collapse

Methods included from MessageDisplay

#display_message, included, #message_display_prompt, #quiet_mode?

Constructor Details

#initialize(project_dir: Dir.pwd) ⇒ OrchestrationAdapter

Returns a new instance of OrchestrationAdapter.



24
25
26
# File 'lib/aidp/orchestration_adapter.rb', line 24

def initialize(project_dir: Dir.pwd)
  @project_dir = project_dir
end

Instance Method Details

#cancel_workflow(workflow_id) ⇒ Object

Cancel a workflow



72
73
74
75
76
77
78
# File 'lib/aidp/orchestration_adapter.rb', line 72

def cancel_workflow(workflow_id)
  if temporal_enabled?
    cancel_temporal_workflow(workflow_id)
  else
    cancel_legacy_job(workflow_id)
  end
end

#list_workflowsObject

List active workflows



81
82
83
84
85
86
87
# File 'lib/aidp/orchestration_adapter.rb', line 81

def list_workflows
  if temporal_enabled?
    list_temporal_workflows
  else
    list_legacy_jobs
  end
end

#start_issue_workflow(issue_number, options = {}) ⇒ Object

Start an issue-to-PR workflow Routes to Temporal or legacy based on configuration



44
45
46
47
48
49
50
# File 'lib/aidp/orchestration_adapter.rb', line 44

def start_issue_workflow(issue_number, options = {})
  if temporal_enabled?
    start_temporal_issue_workflow(issue_number, options)
  else
    start_legacy_issue_workflow(issue_number, options)
  end
end

#start_work_loop(step_name, step_spec, context = {}, options = {}) ⇒ Object

Start a work loop Routes to Temporal or legacy based on configuration



54
55
56
57
58
59
60
# File 'lib/aidp/orchestration_adapter.rb', line 54

def start_work_loop(step_name, step_spec, context = {}, options = {})
  if temporal_enabled?
    start_temporal_work_loop(step_name, step_spec, context, options)
  else
    start_legacy_work_loop(step_name, step_spec, context, options)
  end
end

#temporal_enabled?Boolean

Check if Temporal orchestration is enabled

Returns:

  • (Boolean)


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/aidp/orchestration_adapter.rb', line 29

def temporal_enabled?
  return @temporal_enabled if defined?(@temporal_enabled)

  begin
    require_relative "temporal"
    @temporal_enabled = Aidp::Temporal.enabled?(@project_dir)
  rescue LoadError
    @temporal_enabled = false
  end

  @temporal_enabled
end

#workflow_status(workflow_id) ⇒ Object

Get workflow status



63
64
65
66
67
68
69
# File 'lib/aidp/orchestration_adapter.rb', line 63

def workflow_status(workflow_id)
  if temporal_enabled?
    temporal_workflow_status(workflow_id)
  else
    legacy_job_status(workflow_id)
  end
end