Skip to main content

Module error_signatures

Module error_signatures 

Source
Expand description

Per-provider stderr classification into throttle / flake / unknown.

Complements crate::agent_run_record::ExitClassifier: the classifier here consumes configurable per-provider regex lists so operators can tune detection per CLI (claude-code, opencode-go, kimi-for-coding, …) without code changes. Matches feed the existing terraphim_spawner::health::CircuitBreaker (via crate::provider_probe::ProviderHealthMap) and the crate::provider_budget::ProviderBudgetTracker – nothing new is invented here.

Classification outcomes:

  • Throttle – provider quota / rate-limit hit. Trip the breaker and force the hour+day budget windows past their caps so the routing filter drops the provider until the next window rolls.
  • Flake – transient failure (timeout, EOF, connection reset). Do NOT trip the breaker; the dispatch layer retries with the next entry in the pool.
  • Unknown – neither list matched. Escalate (fleet-meta issue) so a human can classify the pattern. Unknown is also counted as a soft failure so a pathological provider that repeatedly emits unclassified errors still eventually opens the breaker.

Structs§

CompileError
Compile error building per-provider regex patterns.
CompiledSignatures
Runtime-compiled signatures for a single provider.
ProviderErrorSignatures
Serialised form of per-provider error signatures (matches the TOML layout under [[providers]].error_signatures).

Enums§

ErrorKind
Classifier verdict returned by classify.

Functions§

build_signature_map
Build a signature map from the raw config list. Invalid regexes surface as CompileError so misconfiguration fails loud at startup rather than silently disabling classification at runtime.
classify
Classify a stderr snippet against the provider’s compiled signatures.
classify_lines
Classify a list of stderr lines by joining them (newline-separated) and running classify. Convenience wrapper for the spawn-exit path where stderr is captured line-by-line.
unknown_dedupe_key
Build a stable dedupe key for an unknown-error escalation: provider plus the leading 20 chars of the stderr (both-ends trimmed + lowercased). The short prefix + lowercase normalisation means minor suffix variance (trailing newlines, mixed case, extra detail) dedupes to one key so we don’t spam fleet-meta with duplicate issues for the same stderr shape.

Type Aliases§

ProviderSignatureMap
Map of compiled signatures keyed by provider id.