Module: Smith::Errors
- Defined in:
- lib/smith/errors.rb
Overview
Classification surface for host retry policies. Smith owns the answer to "should the workflow attempt be retried?" so consumers don't reimplement the case statement in every Execution / Job.
Class Method Summary collapse
- .retry_forbidden?(error) ⇒ Boolean
- .retry_forbidden_class?(error_class) ⇒ Boolean
- .retry_forbidden_classes ⇒ Object
-
.retryable?(error) ⇒ Boolean
Returns true when the host should retry the workflow attempt.
-
.retryable_classes ⇒ Object
Always-retryable error classes for explicit ActiveJob retry_on allow-lists.
Class Method Details
.retry_forbidden?(error) ⇒ Boolean
41 42 43 44 45 |
# File 'lib/smith/errors.rb', line 41 def self.retry_forbidden?(error) return false if error.nil? retry_forbidden_classes.any? { |error_class| MODULE_MATCH.bind_call(error_class, error) } end |
.retry_forbidden_class?(error_class) ⇒ Boolean
47 48 49 |
# File 'lib/smith/errors.rb', line 47 def self.retry_forbidden_class?(error_class) retry_forbidden_classes.any? { |forbidden| error_class <= forbidden } end |
.retry_forbidden_classes ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/smith/errors.rb', line 51 def self.retry_forbidden_classes @retry_forbidden_classes ||= [ Smith::ToolCaptureFailed, Smith::ToolOutcomeUncertain, Smith::ToolExecutionNotAdmitted, Smith::ToolFailureNotificationFailed, Smith::BoundedCompletionError, Smith::PersistedFailureInvalid ].freeze end |
.retryable?(error) ⇒ Boolean
Returns true when the host should retry the workflow attempt.
AgentError + DeadlineExceeded are always retryable.
DeterministicStepFailure + ToolGuardrailFailed honor their
retryable attribute (opt-in at the raise site).
All other Smith errors and non-Smith errors return false.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/smith/errors.rb', line 24 def self.retryable?(error) return false if error.nil? composite_failure = defined?(Smith::Workflow::Composite::BranchFailure) && MODULE_MATCH.bind_call(Smith::Workflow::Composite::BranchFailure, error) return false if composite_failure case error when Smith::DeterministicStepFailure, Smith::ToolGuardrailFailed error.retryable == true when Smith::AgentError, Smith::DeadlineExceeded true else false end end |
.retryable_classes ⇒ Object
Always-retryable error classes for explicit ActiveJob retry_on allow-lists. Excludes the retryable-bearing families because their retryability is per-raise, not per-class.
65 66 67 |
# File 'lib/smith/errors.rb', line 65 def self.retryable_classes [Smith::AgentError, Smith::DeadlineExceeded].freeze end |