Class: Aidp::Execute::DeterministicUnits::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/aidp/execute/deterministic_unit.rb

Overview

Represents a deterministic unit configured in aidp.yml. Definitions are immutable and provide helper accessors used by the scheduler.

Constant Summary collapse

VALID_TYPES =
[:command, :wait].freeze
NEXT_KEY_ALIASES =
{
  if_pass: :success,
  if_success: :success,
  if_fail: :failure,
  if_failure: :failure,
  if_error: :failure,
  if_timeout: :timeout,
  if_wait: :waiting,
  if_new_item: :event,
  if_event: :event
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Definition

Returns a new instance of Definition.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/aidp/execute/deterministic_unit.rb', line 31

def initialize(config)
  @name = config.fetch(:name)
  @type = normalize_type(config[:type]) || default_type_for(config)
  validate_type!

  @command = config[:command]
  @output_file = config[:output_file]
  @next_map = normalize_next_config(config[:next] || {})
  @min_interval_seconds = config.fetch(:min_interval_seconds, 60)
  @max_backoff_seconds = config.fetch(:max_backoff_seconds, 900)
  @backoff_multiplier = config.fetch(:backoff_multiplier, 2.0)
  @enabled = config.fetch(:enabled, true)
   = config.fetch(:metadata, {}).dup
end

Instance Attribute Details

#backoff_multiplierObject (readonly)

Returns the value of attribute backoff_multiplier.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def backoff_multiplier
  @backoff_multiplier
end

#commandObject (readonly)

Returns the value of attribute command.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def command
  @command
end

#enabledObject (readonly)

Returns the value of attribute enabled.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def enabled
  @enabled
end

#max_backoff_secondsObject (readonly)

Returns the value of attribute max_backoff_seconds.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def max_backoff_seconds
  @max_backoff_seconds
end

#metadataObject (readonly)

Returns the value of attribute metadata.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def 
  
end

#min_interval_secondsObject (readonly)

Returns the value of attribute min_interval_seconds.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def min_interval_seconds
  @min_interval_seconds
end

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def name
  @name
end

#next_mapObject (readonly)

Returns the value of attribute next_map.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def next_map
  @next_map
end

#output_fileObject (readonly)

Returns the value of attribute output_file.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def output_file
  @output_file
end

#typeObject (readonly)

Returns the value of attribute type.



27
28
29
# File 'lib/aidp/execute/deterministic_unit.rb', line 27

def type
  @type
end

Instance Method Details

#command?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/aidp/execute/deterministic_unit.rb', line 46

def command?
  type == :command
end

#next_for(result_status, default: nil) ⇒ Object



54
55
56
# File 'lib/aidp/execute/deterministic_unit.rb', line 54

def next_for(result_status, default: nil)
  next_map[result_status.to_sym] || default || next_map[:else]
end

#wait?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/aidp/execute/deterministic_unit.rb', line 50

def wait?
  type == :wait
end