using System.Collections.Immutable; namespace StellaOps.Policy.Licensing; public interface ILicenseComplianceEvaluator { Task EvaluateAsync( IReadOnlyList components, LicensePolicy policy, CancellationToken ct = default); } public sealed record LicenseComponent { public required string Name { get; init; } public string? Version { get; init; } public string? Purl { get; init; } public string? LicenseExpression { get; init; } public ImmutableArray Licenses { get; init; } = []; public ImmutableDictionary Metadata { get; init; } = ImmutableDictionary.Empty; } public sealed record LicenseComplianceReport { public LicenseInventory Inventory { get; init; } = new(); public ImmutableArray Findings { get; init; } = []; public ImmutableArray Conflicts { get; init; } = []; public LicenseComplianceStatus OverallStatus { get; init; } = LicenseComplianceStatus.Pass; public ImmutableArray AttributionRequirements { get; init; } = []; } public sealed record LicenseInventory { public ImmutableArray Licenses { get; init; } = []; public ImmutableDictionary ByCategory { get; init; } = ImmutableDictionary.Empty; public int UnknownLicenseCount { get; init; } public int NoLicenseCount { get; init; } } public sealed record LicenseUsage { public required string LicenseId { get; init; } public string? Expression { get; init; } public LicenseCategory Category { get; init; } public ImmutableArray Components { get; init; } = []; public int Count { get; init; } } public sealed record LicenseFinding { public required LicenseFindingType Type { get; init; } public required string LicenseId { get; init; } public required string ComponentName { get; init; } public string? ComponentPurl { get; init; } public LicenseCategory Category { get; init; } public string? Message { get; init; } } public sealed record LicenseConflict { public required string ComponentName { get; init; } public string? ComponentPurl { get; init; } public ImmutableArray LicenseIds { get; init; } = []; public string? Reason { get; init; } } public sealed record AttributionRequirement { public required string ComponentName { get; init; } public string? ComponentPurl { get; init; } public required string LicenseId { get; init; } public ImmutableArray Notices { get; init; } = []; public bool IncludeLicenseText { get; init; } } public sealed record LicenseObligation { public required LicenseObligationType Type { get; init; } public string? Details { get; init; } } public enum LicenseComplianceStatus { Pass = 0, Warn = 1, Fail = 2 } public enum LicenseFindingType { ProhibitedLicense = 0, CopyleftInProprietaryContext = 1, LicenseConflict = 2, UnknownLicense = 3, MissingLicense = 4, AttributionRequired = 5, SourceDisclosureRequired = 6, PatentClauseRisk = 7, CommercialRestriction = 8, ConditionalLicenseViolation = 9 } public enum LicenseCategory { Unknown = 0, Permissive = 1, WeakCopyleft = 2, StrongCopyleft = 3, Proprietary = 4, PublicDomain = 5 } public enum LicenseObligationType { Attribution = 0, SourceDisclosure = 1, PatentGrant = 2, TrademarkNotice = 3 }