Class: Legion::Extensions::Llm::Routing::ProviderOutcome
- Inherits:
-
Data
- Object
- Data
- Legion::Extensions::Llm::Routing::ProviderOutcome
- Defined in:
- lib/legion/extensions/llm/routing/provider_outcome.rb
Overview
A provider-neutral normalized outcome. Adapters translate wire errors into one of these kinds; the common classifier branches only on kind, never on provider identity. The value contains no provider object, callable, response body, routing weight, or health-mutation instruction. HTTP 503/529 alone is not an input and cannot manufacture instance_unavailable. See phase-1-lex-llm-additive.md section 14.2.
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#quota_domain ⇒ Object
readonly
Returns the value of attribute quota_domain.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
Instance Method Summary collapse
-
#initialize(kind:, reason:, quota_domain: nil, retry_after: nil, metadata: {}) ⇒ ProviderOutcome
constructor
A new instance of ProviderOutcome.
- #validate_quota_domain!(kind, quota_domain) ⇒ Object
- #validate_retry_after!(retry_after) ⇒ Object
Constructor Details
#initialize(kind:, reason:, quota_domain: nil, retry_after: nil, metadata: {}) ⇒ ProviderOutcome
Returns a new instance of ProviderOutcome.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/legion/extensions/llm/routing/provider_outcome.rb', line 20 def initialize(kind:, reason:, quota_domain: nil, retry_after: nil, metadata: {}) support = Legion::Extensions::Llm::Inventory::RecordSupport errors = Legion::Extensions::Llm::Inventory::Errors raise errors::ValidationError, 'kind must be a Taxonomies::PROVIDER_OUTCOMES value' unless Legion::Extensions::Llm::Taxonomies::PROVIDER_OUTCOMES.include?(kind) super( kind: kind, reason: support.sanitized_reason(value: reason, field: :reason), quota_domain: validate_quota_domain!(kind, quota_domain), retry_after: validate_retry_after!(retry_after), metadata: support.(value: ) ) end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind
19 20 21 |
# File 'lib/legion/extensions/llm/routing/provider_outcome.rb', line 19 def kind @kind end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
19 20 21 |
# File 'lib/legion/extensions/llm/routing/provider_outcome.rb', line 19 def @metadata end |
#quota_domain ⇒ Object (readonly)
Returns the value of attribute quota_domain
19 20 21 |
# File 'lib/legion/extensions/llm/routing/provider_outcome.rb', line 19 def quota_domain @quota_domain end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason
19 20 21 |
# File 'lib/legion/extensions/llm/routing/provider_outcome.rb', line 19 def reason @reason end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after
19 20 21 |
# File 'lib/legion/extensions/llm/routing/provider_outcome.rb', line 19 def retry_after @retry_after end |
Instance Method Details
#validate_quota_domain!(kind, quota_domain) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/legion/extensions/llm/routing/provider_outcome.rb', line 34 def validate_quota_domain!(kind, quota_domain) errors = Legion::Extensions::Llm::Inventory::Errors return nil if quota_domain.nil? raise errors::ValidationError, 'quota_domain must be a Routing::QuotaDomainKey' unless quota_domain.is_a?(QuotaDomainKey) raise errors::ValidationError, 'quota_domain is allowed only for rate_limited' unless kind == :rate_limited quota_domain end |
#validate_retry_after!(retry_after) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/legion/extensions/llm/routing/provider_outcome.rb', line 43 def validate_retry_after!(retry_after) return nil if retry_after.nil? return retry_after if retry_after.is_a?(::Numeric) && retry_after.finite? && !retry_after.negative? raise Legion::Extensions::Llm::Inventory::Errors::ValidationError, 'retry_after must be nil or a finite nonnegative Numeric' end |