Class: Legion::LLM::Routing::Outcome::Action
- Inherits:
-
Object
- Object
- Legion::LLM::Routing::Outcome::Action
- Defined in:
- lib/legion/llm/routing/outcome.rb
Overview
Immutable classified action. outcome preserves the originating
ProviderOutcome for emission/diagnostics (never re-classified downstream).
Instance Attribute Summary collapse
-
#disposition ⇒ Object
readonly
Returns the value of attribute disposition.
-
#exclusions ⇒ Object
readonly
Returns the value of attribute exclusions.
-
#global_transition ⇒ Object
readonly
Returns the value of attribute global_transition.
-
#outcome ⇒ Object
readonly
Returns the value of attribute outcome.
-
#rejection ⇒ Object
readonly
Returns the value of attribute rejection.
Class Method Summary collapse
- .retry(exclusions:, outcome:, global_transition: nil) ⇒ Object
- .success(outcome:) ⇒ Object
- .terminal(rejection:, outcome:) ⇒ Object
Instance Method Summary collapse
-
#initialize(disposition:, outcome:, exclusions: [], global_transition: nil, rejection: nil) ⇒ Action
constructor
A new instance of Action.
- #retry? ⇒ Boolean
- #success? ⇒ Boolean
- #terminal? ⇒ Boolean
Constructor Details
#initialize(disposition:, outcome:, exclusions: [], global_transition: nil, rejection: nil) ⇒ Action
Returns a new instance of Action.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/legion/llm/routing/outcome.rb', line 51 def initialize(disposition:, outcome:, exclusions: [], global_transition: nil, rejection: nil, **) case disposition when :success raise ArgumentError, 'success carries no rejection/transition' if rejection || global_transition when :retry raise ArgumentError, 'retry carries no rejection' if rejection when :terminal raise ArgumentError, 'terminal requires a rejection' if rejection.nil? raise ArgumentError, 'terminal carries no global transition' if global_transition else raise ArgumentError, "unknown disposition: #{disposition.inspect}" end @disposition = disposition @outcome = outcome @exclusions = exclusions.freeze @global_transition = global_transition @rejection = rejection freeze end |
Instance Attribute Details
#disposition ⇒ Object (readonly)
Returns the value of attribute disposition.
37 38 39 |
# File 'lib/legion/llm/routing/outcome.rb', line 37 def disposition @disposition end |
#exclusions ⇒ Object (readonly)
Returns the value of attribute exclusions.
37 38 39 |
# File 'lib/legion/llm/routing/outcome.rb', line 37 def exclusions @exclusions end |
#global_transition ⇒ Object (readonly)
Returns the value of attribute global_transition.
37 38 39 |
# File 'lib/legion/llm/routing/outcome.rb', line 37 def global_transition @global_transition end |
#outcome ⇒ Object (readonly)
Returns the value of attribute outcome.
37 38 39 |
# File 'lib/legion/llm/routing/outcome.rb', line 37 def outcome @outcome end |
#rejection ⇒ Object (readonly)
Returns the value of attribute rejection.
37 38 39 |
# File 'lib/legion/llm/routing/outcome.rb', line 37 def rejection @rejection end |
Class Method Details
.retry(exclusions:, outcome:, global_transition: nil) ⇒ Object
43 44 45 |
# File 'lib/legion/llm/routing/outcome.rb', line 43 def self.retry(exclusions:, outcome:, global_transition: nil, **) new(disposition: :retry, exclusions: exclusions, global_transition: global_transition, outcome: outcome) end |
.success(outcome:) ⇒ Object
39 40 41 |
# File 'lib/legion/llm/routing/outcome.rb', line 39 def self.success(outcome:, **) new(disposition: :success, outcome: outcome) end |
.terminal(rejection:, outcome:) ⇒ Object
47 48 49 |
# File 'lib/legion/llm/routing/outcome.rb', line 47 def self.terminal(rejection:, outcome:, **) new(disposition: :terminal, rejection: rejection, outcome: outcome) end |
Instance Method Details
#retry? ⇒ Boolean
73 |
# File 'lib/legion/llm/routing/outcome.rb', line 73 def retry?(**) = @disposition == :retry |
#success? ⇒ Boolean
72 |
# File 'lib/legion/llm/routing/outcome.rb', line 72 def success?(**) = @disposition == :success |
#terminal? ⇒ Boolean
74 |
# File 'lib/legion/llm/routing/outcome.rb', line 74 def terminal?(**) = @disposition == :terminal |