Module: OllamaAgent::Runtime::SagaState

Defined in:
lib/ollama_agent/runtime/saga_state.rb

Overview

Finite state labels and legal edges for SagaCoordinator.

Constant Summary collapse

STATES =
%w[
  reserved
  locked
  mutations_applied
  verified
  integration_queued
  committed
  compensated
].freeze
TERMINAL =
%w[committed compensated].freeze
ALLOWED =
{
  "reserved" => %w[locked compensated],
  "locked" => %w[mutations_applied compensated],
  "mutations_applied" => %w[verified compensated],
  "verified" => %w[integration_queued compensated],
  "integration_queued" => %w[committed compensated]
}.freeze

Class Method Summary collapse

Class Method Details

.can_transition?(from, to) ⇒ Boolean

Parameters:

  • from (#to_s)
  • to (#to_s)

Returns:

  • (Boolean)


31
32
33
34
35
36
# File 'lib/ollama_agent/runtime/saga_state.rb', line 31

def can_transition?(from, to)
  key = from.to_s
  return false unless ALLOWED.key?(key)

  ALLOWED[key].include?(to.to_s)
end

.terminal?(state) ⇒ Boolean

Parameters:

  • state (#to_s)

Returns:

  • (Boolean)


39
40
41
# File 'lib/ollama_agent/runtime/saga_state.rb', line 39

def terminal?(state)
  TERMINAL.include?(state.to_s)
end