Class ResilienceConfigValidator

java.lang.Object
com.tnsai.agents.validation.validators.ResilienceConfigValidator
All Implemented Interfaces:
Validator

public final class ResilienceConfigValidator extends Object implements Validator
AGENT-V009 — Catches malformed Resilience configurations at build time. Today these silently misbehave at runtime: a maxAttempts=0 retry policy "succeeds" without ever retrying, an enabled=true circuit breaker with a non-positive failureThreshold never trips, a rate limiter with maxRequests=0 blocks every call.

Negative numeric fields are surfaced as ERROR — they are unambiguously invalid (no resilience subsystem treats a negative threshold or backoff as legitimate). Misconfigurations that produce a logically-disabled subsystem are surfaced as WARNING — the operator may have intentionally disabled retry while leaving stale config for future tuning, but the more common case is "I forgot to set maxAttempts."

Scope: walks every Role attached to the agent, checks the type-level @Resilience (if any) and every method-level @Resilience on declared methods. Methods inherited from Object or framework-supplied superclasses are excluded (only role.getClass().getDeclaredMethods() is scanned).

Out of scope:

  • timeout=0 — Javadoc explicitly says "0 means no timeout (use default)". Emitting ERROR for it would conflict with documented intent.
  • Speculative thresholds (e.g. "failureThreshold > maxAttempts*10 means breaker effectively never opens") — too noisy without per-deployment context.
  • Live policy verification — the resilience executor at runtime is the authority on policy semantics.

Suppress with AgentBuilder.relaxValidation("AGENT-V009").

Since:
0.5.0 (issue #85 slice)
  • Constructor Details

    • ResilienceConfigValidator

      public ResilienceConfigValidator()
  • Method Details

    • id

      public String id()
      Description copied from interface: Validator
      Short, stable id for logging and test assertions (e.g. "llm-presence").
      Specified by:
      id in interface Validator
    • validate

      public List<ValidationIssue> validate(ValidationContext ctx)
      Description copied from interface: Validator
      Inspect the agent configuration and return any issues detected. Returning an empty list means "no problems found by this validator".
      Specified by:
      validate in interface Validator
      Parameters:
      ctx - frozen view of the agent under construction
      Returns:
      zero-or-more issues; never null