using DeepDrftModels.Enums;

namespace DeepDrftModels.Entities;

/// <summary>
/// Append-only log row for one recorded play (Phase 16 §4.2). Written once at session close, after the
/// engagement floor is crossed; never updated or deleted. Deliberately NOT a <c>BaseEntity</c>: events
/// have no soft-delete lifecycle, no <c>UpdatedAt</c> — they are immutable facts. The release link is
/// resolved server-side from the track key at write time (§2.3 / D4) and stored here so release-total
/// plays are a cheap sum over this column.
/// </summary>
public class PlayEvent
{
    public long Id { get; set; }

    /// <summary>The played track's vault entry key (the only target the client sends).</summary>
    public required string TrackEntryKey { get; set; }

    /// <summary>
    /// The owning release's SQL id, resolved from <see cref="TrackEntryKey"/> at write time. Null when
    /// the track is loose (no release) or the key did not resolve to a live track at write time.
    /// </summary>
    public long? ReleaseId { get; set; }

    /// <summary>The completion bucket computed client-side from the high-water fraction (§1a / D1).</summary>
    public PlayBucket Bucket { get; set; }

    /// <summary>
    /// Anonymous listener token (Phase 16 §3, wave 16.3). Reserved nullable; nothing writes it in wave
    /// 16.1 — the client sends none and the column stays NULL. Wave 16.3 lights it up for the
    /// distinct-listener count.
    /// </summary>
    public string? AnonId { get; set; }

    public DateTime CreatedAt { get; set; }
}
