namespace KArtSell.Modules.ModelOperations.ShadowRun.Events;

/// <summary>
/// Published when a shadow run completes evaluation.
/// Idempotent: same RunId + attempt always produces same event.
/// Used by downstream consumers: approval workflows, notifications, reporting.
/// </summary>
public sealed record ShadowRunCompletedEvent(
    Guid RunId,
    Guid ModelId,
    Guid CorrelationId,
    DateOnly WindowStartDate,
    DateOnly WindowEndDate,
    bool AllGatesPassed,
    decimal TotalReturn,
    decimal SharpeRatio,
    decimal ProbOfBacktestOverfit,
    decimal DailySharePercentile,
    string? ErrorMessage,
    DateTime CompletedAt)
{
    /// <summary>
    /// Idempotency key ensures duplicate events are silently ignored.
    /// Format: {RunId}#{Attempt}
    /// </summary>
    public string IdempotencyKey => $"{RunId}#1";
}
