namespace KArtSell.BuildingBlocks.ReadModels;
public enum ProjectionHealth { Current, Stale, Rebuilding, Failed, Quarantined }
public sealed record ProjectionContract(string Name, int Version, string SourceWatermark, DateTimeOffset BuiltAt, TimeSpan StaleAfter, string Owner)
{
    public ProjectionHealth Evaluate(DateTimeOffset now, bool rebuilding = false, bool failed = false, bool quarantined = false)
    {
        if (quarantined) return ProjectionHealth.Quarantined;
        if (failed) return ProjectionHealth.Failed;
        if (rebuilding) return ProjectionHealth.Rebuilding;
        return now - BuiltAt > StaleAfter ? ProjectionHealth.Stale : ProjectionHealth.Current;
    }
}
