namespace ZB.MOM.WW.ScadaBridge.SiteCallAudit;

/// <summary>
/// Configuration options for the Site Call Audit (#22) read-side: stuck-call
/// detection and KPI windowing. Mirrors the KPI-relevant subset of
/// <c>NotificationOutboxOptions</c> — the reconciliation, purge and dispatch
/// cadence options the Notification Outbox carries are not part of the Site
/// Call Audit read-side backend and are deliberately omitted here.
/// </summary>
public class SiteCallAuditOptions
{
    /// <summary>
    /// Age past which a non-terminal cached call (<c>Pending</c>/<c>Retrying</c>)
    /// is considered stuck. Display-only — surfaced as the Stuck KPI and a row
    /// badge, with no escalation. Default 10 minutes, matching
    /// <c>NotificationOutboxOptions.StuckAgeThreshold</c>.
    /// </summary>
    public TimeSpan StuckAgeThreshold { get; set; } = TimeSpan.FromMinutes(10);

    /// <summary>
    /// Trailing window used to compute the delivered- and failed-last-interval
    /// throughput KPIs. Default 1 minute, matching
    /// <c>NotificationOutboxOptions.DeliveredKpiWindow</c>.
    /// </summary>
    public TimeSpan KpiInterval { get; set; } = TimeSpan.FromMinutes(1);

    /// <summary>
    /// Task 5 (#22): Ask timeout for the central→site Retry/Discard relay. When
    /// the owning site does not ack a <c>RetryParkedOperation</c> /
    /// <c>DiscardParkedOperation</c> within this window — site offline, no
    /// ClusterClient route, or central buffering deliberately absent — the relay
    /// reports a <c>SiteUnreachable</c> outcome. Default 10 seconds: long enough
    /// to absorb a healthy cross-cluster round-trip, short enough that an
    /// operator clicking Retry on an offline site gets a fast, honest answer.
    /// <para>
    /// <b>Ordering invariant:</b> <c>RelayTimeout</c> must stay below
    /// <c>CommunicationOptions.QueryTimeout</c> (default 30s), the timeout the
    /// outer <c>CommunicationService.RetrySiteCallAsync</c>/<c>DiscardSiteCallAsync</c>
    /// Ask of the <c>SiteCallAuditActor</c> uses. The outer Ask must outlive this
    /// inner site relay Ask so the inner relay times out first and yields the
    /// distinct <c>SiteUnreachable</c> outcome; if the outer Ask expired first,
    /// that outcome would be lost to a generic Ask-timeout exception. The
    /// defaults (10s &lt; 30s) satisfy this — keep the gap when tuning either.
    /// </para>
    /// </summary>
    public TimeSpan RelayTimeout { get; set; } = TimeSpan.FromSeconds(10);
}
