Class: Aidp::Temporal::Workflows::StrategyExecutionWorkflow

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

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

#execute(input) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/aidp/temporal/workflows/strategy_execution_workflow.rb', line 24

def execute(input)
  initialize_state(input)
  log_workflow("execute_started",
    strategy: @strategy.name,
    depth: @depth,
    task_id: @task[:id])

  @strategy_record = register_strategy
  log_workflow("strategy_registered", strategy_id: @strategy_record[:id])

  @task_record = ensure_task
  log_workflow("task_ensured", task_id: @task_record[:id])

  @run = start_run
  log_workflow("run_started", run_id: @run[:id])

  transition_to(:fanout)
  branches = launch_branches
  log_workflow("branches_launched", count: branches.length)

  @winning_branch = select_winning_branch(branches)
  log_workflow("winning_branch_selected",
    branch_key: @winning_branch&.fetch(:branch_key, nil),
    aggregate_score: @winning_branch&.fetch(:aggregate_score, nil))

  transition_to(:merge)
  merged_children = execute_subtasks(@winning_branch)
  log_workflow("subtasks_completed", count: merged_children.length)

  result = build_result(branches, merged_children)

  complete_run("completed", result)
  log_workflow("execute_completed", run_id: @run[:id])
  result
rescue Temporalio::Error::CanceledError
  raise
rescue Aidp::StrategyExecution::CliProtocol::ProtocolError,
  Aidp::Database::Error => e
  Aidp.log_error("strategy_execution_workflow", "execute_failed",
    run_id: @run&.fetch(:id, nil),
    depth: @depth,
    error: e.message,
    error_class: e.class.name)
  complete_run("failed", {error: e.message}) if @run
  raise
end

#progressObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/aidp/temporal/workflows/strategy_execution_workflow.rb', line 13

def progress
  {
    state: @state,
    depth: @depth,
    strategy: @strategy&.name,
    task: @task&.fetch(:description, nil),
    run_id: @run&.fetch(:id, nil),
    winning_branch: @winning_branch&.fetch(:branch_key, nil)
  }
end