Class: RosettAi::Workflow::Steps::RaiStep
- Inherits:
-
Object
- Object
- RosettAi::Workflow::Steps::RaiStep
- 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.
Instance Method Summary collapse
-
#describe ⇒ String
Step description for dry-run.
-
#execute ⇒ Hash
Executes the rai subcommand.
-
#initialize(definition) ⇒ RaiStep
constructor
A new instance of RaiStep.
Constructor Details
#initialize(definition) ⇒ RaiStep
Returns a new instance of RaiStep.
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
#describe ⇒ String
Returns 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 |
#execute ⇒ Hash
Executes the rai subcommand.
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 |