Class: RosettAi::Workflow::Steps::RaiStep

Inherits:
Object
  • Object
show all
Defined in:
lib/rosett_ai/workflow/steps/rai_step.rb

Overview

Executes an internal rai CLI subcommand.

Resolves the rai binary via PATH lookup, falling back to the development tree's bin/raictl.

Author:

  • hugo

  • claude

Instance Method Summary collapse

Constructor Details

#initialize(definition) ⇒ RaiStep

Returns a new instance of RaiStep.

Parameters:

  • definition (Hash)

    step definition from workflow YAML



18
19
20
21
22
# File 'lib/rosett_ai/workflow/steps/rai_step.rb', line 18

def initialize(definition)
  @definition = definition
  @command = definition.fetch('command')
  validate!
end

Instance Method Details

#describeString

Returns step description for dry-run.

Returns:

  • (String)

    step description for dry-run



25
26
27
# File 'lib/rosett_ai/workflow/steps/rai_step.rb', line 25

def describe
  "[raictl] #{@definition['name']}#{@command}"
end

#executeHash

Executes the rai subcommand.

Returns:

  • (Hash)

    execution result with :status and :message



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rosett_ai/workflow/steps/rai_step.rb', line 32

def execute
  argv = @command.split
  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  success = system(resolve_rai_binary, *argv)
  elapsed = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).round(1)

  if success
    { status: 'pass', message: "Completed: raictl #{@command}", duration_ms: elapsed }
  else
    { status: 'fail', message: "Failed: raictl #{@command} (exit #{$CHILD_STATUS&.exitstatus})",
      duration_ms: elapsed }
  end
end