namespace KArtSell.BuildingBlocks.Versioning;

/// <summary>
/// Immutable identity of the data, model, configuration and code used for a decision.
/// Values are opaque, approved identifiers or SHA-256 digests; they are never inferred from the client.
/// </summary>
public sealed record VersionSet(
    string DatasetId,
    string DataHash,
    string ModelVersion,
    string ConfigVersion,
    string CodeSha,
    string ContractVersion)
{
    public void EnsureValid()
    {
        EnsureNotBlank(DatasetId, nameof(DatasetId));
        EnsureNotBlank(DataHash, nameof(DataHash));
        EnsureNotBlank(ModelVersion, nameof(ModelVersion));
        EnsureNotBlank(ConfigVersion, nameof(ConfigVersion));
        EnsureNotBlank(CodeSha, nameof(CodeSha));
        EnsureNotBlank(ContractVersion, nameof(ContractVersion));
    }

    private static void EnsureNotBlank(string value, string name)
    {
        if (string.IsNullOrWhiteSpace(value))
        {
            throw new ArgumentException($"{name} must be an approved, non-blank identifier.", name);
        }
    }
}
