27 lines
1.3 KiB
C#
27 lines
1.3 KiB
C#
using Ludarium.Domain;
|
|
|
|
namespace Ludarium.Application;
|
|
|
|
public sealed record HealthRuleResult(string Category, Severity Severity, string Message);
|
|
|
|
public static class HealthRules
|
|
{
|
|
public static HealthRuleResult? EvaluateRoot(LibraryRoot root) =>
|
|
!root.IsAvailable ? new("Availability", Severity.Critical, "The library root could not be read; existing artifacts were preserved.") :
|
|
root.IsReadOnly != true ? new("Availability", Severity.Warning, "The library root is readable but a read-only mount could not be confirmed.") : null;
|
|
|
|
public static HealthRuleResult? EvaluateArtifact(Artifact artifact) => artifact.MediaType switch
|
|
{
|
|
MediaType.Unknown => new("Identity", Severity.Notice, "Content type is unknown and remains available for review."),
|
|
_ when artifact.State == ArtifactState.Missing => new("Availability", Severity.Warning, "The artifact was not observed during a successful root traversal."),
|
|
_ => null
|
|
};
|
|
|
|
public static HealthRuleResult? EvaluateBundle(Bundle bundle) => bundle.State switch
|
|
{
|
|
BundleState.Incomplete => new("BundleCompleteness", Severity.Warning, "One or more required bundle members are missing."),
|
|
BundleState.Ambiguous => new("BundleCompleteness", Severity.Notice, "Bundle membership requires an operator decision."),
|
|
_ => null
|
|
};
|
|
}
|