using KArtSell.BuildingBlocks.Versioning;
namespace KArtSell.BuildingBlocks.Execution;
public sealed record ExecutionEnvelope(
    DateTimeOffset AsOf,
    DateTimeOffset PublishedAtCutoff,
    string ScopeKey,
    string IdempotencyKey,
    string CorrelationId,
    VersionSet VersionSet,
    string ContentHash)
{
    public void EnsureValid()
    {
        if (PublishedAtCutoff > AsOf) throw new InvalidOperationException("PublishedAtCutoff cannot be after AsOf.");
        if (string.IsNullOrWhiteSpace(ScopeKey) || string.IsNullOrWhiteSpace(IdempotencyKey) || string.IsNullOrWhiteSpace(CorrelationId) || string.IsNullOrWhiteSpace(ContentHash))
            throw new InvalidOperationException("Execution envelope identifiers are required.");
        VersionSet.EnsureValid();
    }
}
