|
| 1 | +namespace Sigtran.NET.Core.Utilities; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Describes maintained external peer lab runner readiness status. |
| 5 | +/// </summary> |
| 6 | +public sealed class SigtranMaintainedPeerLabRunnerStatusReport |
| 7 | +{ |
| 8 | + /// <summary>Creates a maintained peer lab runner status report.</summary> |
| 9 | + /// <param name="completedCapabilityCount">The completed runner capability count.</param> |
| 10 | + /// <param name="foundationReady">Whether the runner foundation is ready.</param> |
| 11 | + /// <param name="runnerEvidenceReady">Whether retained runner evidence is ready.</param> |
| 12 | + /// <param name="blockers">The current blocker identifiers.</param> |
| 13 | + public SigtranMaintainedPeerLabRunnerStatusReport( |
| 14 | + int completedCapabilityCount, |
| 15 | + bool foundationReady, |
| 16 | + bool runnerEvidenceReady, |
| 17 | + IReadOnlyList<string> blockers) |
| 18 | + { |
| 19 | + ArgumentNullException.ThrowIfNull(blockers); |
| 20 | + CompletedCapabilityCount = completedCapabilityCount < 0 ? throw new ArgumentOutOfRangeException(nameof(completedCapabilityCount)) : completedCapabilityCount; |
| 21 | + FoundationReady = foundationReady; |
| 22 | + RunnerEvidenceReady = runnerEvidenceReady; |
| 23 | + Blockers = blockers.ToArray(); |
| 24 | + } |
| 25 | + |
| 26 | + /// <summary>The completed runner capability count.</summary> |
| 27 | + public int CompletedCapabilityCount { get; } |
| 28 | + |
| 29 | + /// <summary>Whether the runner foundation is ready.</summary> |
| 30 | + public bool FoundationReady { get; } |
| 31 | + |
| 32 | + /// <summary>Whether retained runner evidence is ready.</summary> |
| 33 | + public bool RunnerEvidenceReady { get; } |
| 34 | + |
| 35 | + /// <summary>The current blocker identifiers.</summary> |
| 36 | + public IReadOnlyList<string> Blockers { get; } |
| 37 | + |
| 38 | + /// <summary>Whether runner evidence can support a commercial readiness claim.</summary> |
| 39 | + public bool CommercialReady => FoundationReady && RunnerEvidenceReady && Blockers.Count == 0; |
| 40 | + |
| 41 | + /// <summary>Formats a compact runner status summary.</summary> |
| 42 | + /// <returns>The runner status summary.</returns> |
| 43 | + public string Describe() |
| 44 | + { |
| 45 | + return $"capabilities={CompletedCapabilityCount} foundation={FoundationReady} evidence={RunnerEvidenceReady} blockers={Blockers.Count} commercial={CommercialReady}"; |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +/// <summary> |
| 50 | +/// Provides maintained external peer lab runner status helpers. |
| 51 | +/// </summary> |
| 52 | +public static class SigtranMaintainedPeerLabRunnerStatus |
| 53 | +{ |
| 54 | + /// <summary>The completed runner unit count.</summary> |
| 55 | + public const int CompletedUnitCount = 10; |
| 56 | + |
| 57 | + /// <summary>Returns the completed maintained peer lab runner capabilities.</summary> |
| 58 | + /// <returns>The completed maintained peer lab runner capabilities.</returns> |
| 59 | + public static IReadOnlyList<string> GetCompletedCapabilities() |
| 60 | + { |
| 61 | + return |
| 62 | + [ |
| 63 | + "runner-workspace-materialization", |
| 64 | + "runner-input-bundle", |
| 65 | + "artifact-output-materialization", |
| 66 | + "runner-preflight", |
| 67 | + "runner-command-manifest", |
| 68 | + "runner-evidence-collection", |
| 69 | + "runner-digest-generation", |
| 70 | + "runner-comparison-handoff", |
| 71 | + "runner-workflow-readiness", |
| 72 | + "runner-status-reporting" |
| 73 | + ]; |
| 74 | + } |
| 75 | + |
| 76 | + /// <summary>Returns maintained peer lab runner foundation status without real retained evidence.</summary> |
| 77 | + /// <returns>The maintained peer lab runner foundation status.</returns> |
| 78 | + public static SigtranMaintainedPeerLabRunnerStatusReport GetFoundationReport() |
| 79 | + { |
| 80 | + SigtranMaintainedPeerLabRunManifest runManifest = SigtranMaintainedPeerLabRunManifests.CreateDefault(); |
| 81 | + SigtranMaintainedPeerLabRunnerInputBundle inputs = SigtranMaintainedPeerLabRunnerInputs.CreateDefault(runManifest); |
| 82 | + SigtranMaintainedPeerLabRunnerArtifactMaterializationPlan artifacts = SigtranMaintainedPeerLabRunnerArtifacts.CreateDefault(inputs.Workspace); |
| 83 | + IReadOnlyList<string> allPrerequisites = SigtranMaintainedPeerLabPrerequisites.GetDefault() |
| 84 | + .Select(static prerequisite => prerequisite.Id) |
| 85 | + .ToArray(); |
| 86 | + SigtranMaintainedPeerLabRunnerPreflightReport preflight = SigtranMaintainedPeerLabRunnerPreflight.Evaluate(inputs, artifacts, allPrerequisites); |
| 87 | + SigtranMaintainedPeerLabRunnerCommandManifest commands = SigtranMaintainedPeerLabRunnerCommandManifests.Create(inputs, artifacts, preflight); |
| 88 | + SigtranMaintainedPeerLabRunnerWorkflowReadinessReport workflow = SigtranMaintainedPeerLabRunnerWorkflowReadiness.Evaluate(commands); |
| 89 | + |
| 90 | + bool foundationReady = workflow.Ready && GetCompletedCapabilities().Count == CompletedUnitCount; |
| 91 | + return new( |
| 92 | + CompletedUnitCount, |
| 93 | + foundationReady, |
| 94 | + runnerEvidenceReady: false, |
| 95 | + ["real-maintained-peer-run-required", "retained-runner-evidence-required"]); |
| 96 | + } |
| 97 | + |
| 98 | + /// <summary>Returns maintained peer lab runner status from a comparison handoff.</summary> |
| 99 | + /// <param name="comparisonHandoff">The runner comparison handoff.</param> |
| 100 | + /// <returns>The maintained peer lab runner status.</returns> |
| 101 | + public static SigtranMaintainedPeerLabRunnerStatusReport FromHandoff(SigtranMaintainedPeerLabRunnerComparisonHandoff comparisonHandoff) |
| 102 | + { |
| 103 | + ArgumentNullException.ThrowIfNull(comparisonHandoff); |
| 104 | + SigtranMaintainedPeerLabCommercialReadinessReport commercial = SigtranMaintainedPeerLabCommercialBridge.Evaluate(comparisonHandoff.ToEvidenceBundle()); |
| 105 | + |
| 106 | + return new( |
| 107 | + CompletedUnitCount, |
| 108 | + foundationReady: true, |
| 109 | + runnerEvidenceReady: comparisonHandoff.IsHandoffReady && commercial.CommercialReady, |
| 110 | + commercial.Blockers); |
| 111 | + } |
| 112 | +} |
0 commit comments