Class: Aidp::StrategyExecution::StrategySpec

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/strategy_execution/strategy_spec.rb

Constant Summary collapse

DEFAULT_MAX_DEPTH =
1
DEFAULT_FANOUT =
1
DEFAULT_MERGE_POLICY =
"highest_score"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ StrategySpec

Returns a new instance of StrategySpec.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 16

def initialize(data)
  @name = fetch_name(data)
  @max_depth = positive_integer(data[:max_depth], DEFAULT_MAX_DEPTH)
  @fanout = positive_integer(data[:fanout], DEFAULT_FANOUT)
  @agents = normalize_agents(data[:agents] || {})
  @evaluators = normalize_evaluators(data[:evaluators] || [])
  @merge_policy = (data[:merge_policy] || DEFAULT_MERGE_POLICY).to_s
  @constraints = (data[:constraints] || {}).transform_keys(&:to_sym)
  @timeouts = (data[:timeouts] || {}).transform_keys(&:to_sym)
  ensure_runnable!
end

Instance Attribute Details

#agentsObject (readonly)

Returns the value of attribute agents.



10
11
12
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 10

def agents
  @agents
end

#constraintsObject (readonly)

Returns the value of attribute constraints.



10
11
12
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 10

def constraints
  @constraints
end

#evaluatorsObject (readonly)

Returns the value of attribute evaluators.



10
11
12
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 10

def evaluators
  @evaluators
end

#fanoutObject (readonly)

Returns the value of attribute fanout.



10
11
12
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 10

def fanout
  @fanout
end

#max_depthObject (readonly)

Returns the value of attribute max_depth.



10
11
12
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 10

def max_depth
  @max_depth
end

#merge_policyObject (readonly)

Returns the value of attribute merge_policy.



10
11
12
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 10

def merge_policy
  @merge_policy
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 10

def name
  @name
end

#timeoutsObject (readonly)

Returns the value of attribute timeouts.



10
11
12
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 10

def timeouts
  @timeouts
end

Class Method Details

.from_hash(data) ⇒ Object



12
13
14
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 12

def self.from_hash(data)
  new(data.transform_keys(&:to_sym))
end

Instance Method Details

#branch_commandsObject



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 41

def branch_commands
  commands = candidate_agent_commands
  Array.new(fanout) do |index|
    command = commands[index % commands.length]
    {
      key: "branch_#{index}",
      name: command[:name],
      command: command[:command]
    }
  end
end

#evaluator_definitionsObject



53
54
55
# File 'lib/aidp/strategy_execution/strategy_spec.rb', line 53

def evaluator_definitions
  evaluators
end

#to_hObject



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

def to_h
  {
    name: name,
    max_depth: max_depth,
    fanout: fanout,
    agents: agents,
    evaluators: evaluators,
    merge_policy: merge_policy,
    constraints: constraints,
    timeouts: timeouts
  }
end