namespace ZB.MOM.WW.OtOpcUa.Core.Abstractions;

/// <summary>
///     Legal ranges for per-capability resilience policy values. Single source of truth shared by
///     <c>DriverResilienceOptionsParser</c> (clamp + diagnostic), <c>DriverResiliencePipelineBuilder</c>
///     (last-resort clamp so a pipeline build can never throw Polly's ValidationException), and the
///     AdminUI <c>ResilienceFormModel</c> (authoring-time validation messages). Derived from
///     Polly.Core 8.6.6's option validation: <c>TimeoutStrategyOptions.Timeout</c> ∈ [10 ms, 24 h];
///     <c>CircuitBreakerStrategyOptions.MinimumThroughput</c> ≥ 2.
/// </summary>
public static class ResiliencePolicyRanges
{
    /// <summary>Minimum per-call timeout. Whole-second granularity puts the floor at 1 s (Polly's is 10 ms).</summary>
    public const int MinTimeoutSeconds = 1;

    /// <summary>Maximum per-call timeout — Polly's TimeoutStrategyOptions ceiling (24 h).</summary>
    public const int MaxTimeoutSeconds = 86_400;

    /// <summary>Retry floor; 0 = no retry strategy is added to the pipeline.</summary>
    public const int MinRetryCount = 0;

    /// <summary>Operational retry cap (Polly itself allows int.MaxValue; 100 exponential-backoff attempts ≈ minutes).</summary>
    public const int MaxRetryCount = 100;

    /// <summary>Breaker floor; 0 = no breaker strategy is added (the Tier C posture).</summary>
    public const int MinBreakerFailureThreshold = 0;

    /// <summary>Polly's MinimumThroughput floor — an enabled breaker needs a threshold of at least 2.</summary>
    public const int MinEnabledBreakerFailureThreshold = 2;

    /// <summary>Sanity cap on the breaker threshold (Polly has no ceiling; beyond this it can never trip in the 30 s window).</summary>
    public const int MaxBreakerFailureThreshold = 10_000;
}
