|
| 1 | +namespace sigtran.net.Core.Utilities; |
| 2 | + |
| 3 | +/// <summary> |
| 4 | +/// Describes the package-neutral commercial roadmap realignment result. |
| 5 | +/// </summary> |
| 6 | +public sealed class SigtranCommercialRoadmapRealignmentReport |
| 7 | +{ |
| 8 | + /// <summary>Creates a commercial roadmap realignment report.</summary> |
| 9 | + /// <param name="completedUnitCount">The completed work unit count.</param> |
| 10 | + /// <param name="capabilities">The completed capability ids.</param> |
| 11 | + /// <param name="packageNeutralNamingReady">Whether public contract names are package-neutral.</param> |
| 12 | + /// <param name="maintainedPeerPolicyReady">Whether the maintained peer policy is available.</param> |
| 13 | + /// <param name="externalPeerExecutionFoundationReady">Whether external peer execution foundation is ready.</param> |
| 14 | + /// <param name="commercialGateAligned">Whether commercial gates use external peer terminology.</param> |
| 15 | + /// <param name="externalPeerCommercialInteropReady">Whether current external peer commercial interop evidence is ready.</param> |
| 16 | + /// <param name="blockers">The current blocker identifiers.</param> |
| 17 | + public SigtranCommercialRoadmapRealignmentReport( |
| 18 | + int completedUnitCount, |
| 19 | + IReadOnlyList<string> capabilities, |
| 20 | + bool packageNeutralNamingReady, |
| 21 | + bool maintainedPeerPolicyReady, |
| 22 | + bool externalPeerExecutionFoundationReady, |
| 23 | + bool commercialGateAligned, |
| 24 | + bool externalPeerCommercialInteropReady, |
| 25 | + IReadOnlyList<string> blockers) |
| 26 | + { |
| 27 | + ArgumentNullException.ThrowIfNull(capabilities); |
| 28 | + ArgumentNullException.ThrowIfNull(blockers); |
| 29 | + |
| 30 | + CompletedUnitCount = completedUnitCount; |
| 31 | + Capabilities = capabilities.ToArray(); |
| 32 | + PackageNeutralNamingReady = packageNeutralNamingReady; |
| 33 | + MaintainedPeerPolicyReady = maintainedPeerPolicyReady; |
| 34 | + ExternalPeerExecutionFoundationReady = externalPeerExecutionFoundationReady; |
| 35 | + CommercialGateAligned = commercialGateAligned; |
| 36 | + ExternalPeerCommercialInteropReady = externalPeerCommercialInteropReady; |
| 37 | + Blockers = blockers.ToArray(); |
| 38 | + } |
| 39 | + |
| 40 | + /// <summary>The completed work unit count.</summary> |
| 41 | + public int CompletedUnitCount { get; } |
| 42 | + |
| 43 | + /// <summary>The completed capability ids.</summary> |
| 44 | + public IReadOnlyList<string> Capabilities { get; } |
| 45 | + |
| 46 | + /// <summary>Whether public contract names are package-neutral.</summary> |
| 47 | + public bool PackageNeutralNamingReady { get; } |
| 48 | + |
| 49 | + /// <summary>Whether the maintained peer policy is available.</summary> |
| 50 | + public bool MaintainedPeerPolicyReady { get; } |
| 51 | + |
| 52 | + /// <summary>Whether external peer execution foundation is ready.</summary> |
| 53 | + public bool ExternalPeerExecutionFoundationReady { get; } |
| 54 | + |
| 55 | + /// <summary>Whether commercial gates use external peer terminology.</summary> |
| 56 | + public bool CommercialGateAligned { get; } |
| 57 | + |
| 58 | + /// <summary>Whether current external peer commercial interop evidence is ready.</summary> |
| 59 | + public bool ExternalPeerCommercialInteropReady { get; } |
| 60 | + |
| 61 | + /// <summary>The current blocker identifiers.</summary> |
| 62 | + public IReadOnlyList<string> Blockers { get; } |
| 63 | + |
| 64 | + /// <summary>Whether the package-neutral roadmap realignment foundation is complete.</summary> |
| 65 | + public bool FoundationReady => Capabilities.Count == CompletedUnitCount |
| 66 | + && PackageNeutralNamingReady |
| 67 | + && MaintainedPeerPolicyReady |
| 68 | + && ExternalPeerExecutionFoundationReady |
| 69 | + && CommercialGateAligned; |
| 70 | + |
| 71 | + /// <summary>Whether the realigned commercial release gate can pass today.</summary> |
| 72 | + public bool CommercialReleaseReady => FoundationReady |
| 73 | + && ExternalPeerCommercialInteropReady |
| 74 | + && Blockers.Count == 0; |
| 75 | + |
| 76 | + /// <summary>Formats a compact realignment status summary.</summary> |
| 77 | + /// <returns>The realignment status summary.</returns> |
| 78 | + public string Describe() |
| 79 | + { |
| 80 | + return $"commercialRoadmapRealignmentReady={FoundationReady} commercialReleaseReady={CommercialReleaseReady} blockers={Blockers.Count}"; |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +/// <summary> |
| 85 | +/// Provides package-neutral commercial roadmap realignment status. |
| 86 | +/// </summary> |
| 87 | +public static class SigtranCommercialRoadmapRealignmentStatus |
| 88 | +{ |
| 89 | + private static readonly string[] Capabilities = |
| 90 | + [ |
| 91 | + "package-neutral-source-contracts", |
| 92 | + "external-peer-profile-model", |
| 93 | + "maintained-peer-selection-policy", |
| 94 | + "external-peer-lab-environment-contract", |
| 95 | + "digest-covered-external-peer-artifacts", |
| 96 | + "external-peer-run-commands", |
| 97 | + "external-peer-commercial-readiness", |
| 98 | + "commercial-release-gate-alignment", |
| 99 | + "public-label-migration", |
| 100 | + "documentation" |
| 101 | + ]; |
| 102 | + |
| 103 | + private static readonly string[] PublicContractNames = |
| 104 | + [ |
| 105 | + nameof(SigtranExternalPeerInteropStatus), |
| 106 | + nameof(SigtranExternalPeerCommercialReadiness), |
| 107 | + nameof(SigtranMaintainedPeerSelectionPolicy), |
| 108 | + nameof(SigtranCommercialReleaseExecutionReadiness), |
| 109 | + nameof(SigtranCommercialEvidenceGate), |
| 110 | + StatusLabel, |
| 111 | + SigtranExternalPeerInteropStatus.StatusLabel |
| 112 | + ]; |
| 113 | + |
| 114 | + private static readonly string[] PackageSpecificNameGuardCategories = |
| 115 | + [ |
| 116 | + "peer-product-type-name", |
| 117 | + "peer-product-label", |
| 118 | + "peer-product-ci-variable" |
| 119 | + ]; |
| 120 | + |
| 121 | + /// <summary>The status label.</summary> |
| 122 | + public const string StatusLabel = "Commercial Roadmap Realignment"; |
| 123 | + |
| 124 | + /// <summary>The number of completed realignment work units.</summary> |
| 125 | + public const int CompletedUnitCount = 10; |
| 126 | + |
| 127 | + /// <summary>Returns the completed realignment capability names.</summary> |
| 128 | + /// <returns>The completed capability names.</returns> |
| 129 | + public static IReadOnlyList<string> GetCompletedCapabilities() |
| 130 | + { |
| 131 | + return Capabilities.ToArray(); |
| 132 | + } |
| 133 | + |
| 134 | + /// <summary>Returns the public contract names checked by the package-neutral naming guard.</summary> |
| 135 | + /// <returns>The public contract names checked by the naming guard.</returns> |
| 136 | + public static IReadOnlyList<string> GetPublicContractNames() |
| 137 | + { |
| 138 | + return [.. PublicContractNames, .. Capabilities]; |
| 139 | + } |
| 140 | + |
| 141 | + /// <summary>Returns the package-specific naming categories guarded by the realignment status.</summary> |
| 142 | + /// <returns>The guarded package-specific naming categories.</returns> |
| 143 | + public static IReadOnlyList<string> GetPackageSpecificNameGuardCategories() |
| 144 | + { |
| 145 | + return PackageSpecificNameGuardCategories.ToArray(); |
| 146 | + } |
| 147 | + |
| 148 | + /// <summary>Whether the realignment public names are package-neutral.</summary> |
| 149 | + public static bool PackageNeutralNamingReady => GetPublicContractNames() |
| 150 | + .All(static name => name.Contains("external", StringComparison.OrdinalIgnoreCase) |
| 151 | + || name.Contains("commercial", StringComparison.OrdinalIgnoreCase) |
| 152 | + || name.Contains("maintained", StringComparison.OrdinalIgnoreCase) |
| 153 | + || name.Contains("evidence", StringComparison.OrdinalIgnoreCase) |
| 154 | + || name.Contains("package-neutral", StringComparison.OrdinalIgnoreCase) |
| 155 | + || name.Contains("public-label", StringComparison.OrdinalIgnoreCase) |
| 156 | + || string.Equals(name, "documentation", StringComparison.OrdinalIgnoreCase)); |
| 157 | + |
| 158 | + /// <summary>Creates the current package-neutral commercial roadmap realignment report.</summary> |
| 159 | + /// <returns>The current realignment report.</returns> |
| 160 | + public static SigtranCommercialRoadmapRealignmentReport GetReport() |
| 161 | + { |
| 162 | + SigtranExternalPeerCommercialReadinessReport commercialPeer = SigtranExternalPeerCommercialReadiness.CreateCurrent(); |
| 163 | + SigtranCommercialReleaseExecutionReadinessReport release = SigtranCommercialReleaseExecutionReadiness.CreateCurrent(); |
| 164 | + |
| 165 | + bool maintainedPeerPolicyReady = SigtranMaintainedPeerSelectionPolicy.CreateDefault().GetCriteria().Count == 6 |
| 166 | + && SigtranInteropPeerProfiles.CreateExternalPeerSignallingGateway().IsMaintainedCommercialCandidate; |
| 167 | + bool commercialGateAligned = release.Items.Any(static item => item.Name == "external-peer-interop") |
| 168 | + && release.Items.All(static item => !item.Name.Contains("openss7", StringComparison.OrdinalIgnoreCase)) |
| 169 | + && release.Items.All(static item => !item.Name.Contains("ipss7", StringComparison.OrdinalIgnoreCase)); |
| 170 | + |
| 171 | + List<string> blockers = []; |
| 172 | + if (!PackageNeutralNamingReady) |
| 173 | + { |
| 174 | + blockers.Add("package-neutral-naming-required"); |
| 175 | + } |
| 176 | + |
| 177 | + if (!maintainedPeerPolicyReady) |
| 178 | + { |
| 179 | + blockers.Add("maintained-peer-policy-required"); |
| 180 | + } |
| 181 | + |
| 182 | + if (!SigtranExternalPeerInteropStatus.FoundationReady) |
| 183 | + { |
| 184 | + blockers.Add("external-peer-execution-foundation-required"); |
| 185 | + } |
| 186 | + |
| 187 | + if (!commercialGateAligned) |
| 188 | + { |
| 189 | + blockers.Add("commercial-gate-alignment-required"); |
| 190 | + } |
| 191 | + |
| 192 | + blockers.AddRange(commercialPeer.Blockers); |
| 193 | + |
| 194 | + return new( |
| 195 | + CompletedUnitCount, |
| 196 | + Capabilities, |
| 197 | + PackageNeutralNamingReady, |
| 198 | + maintainedPeerPolicyReady, |
| 199 | + SigtranExternalPeerInteropStatus.FoundationReady, |
| 200 | + commercialGateAligned, |
| 201 | + commercialPeer.CommercialInteropReady, |
| 202 | + blockers); |
| 203 | + } |
| 204 | + |
| 205 | + /// <summary>Formats a compact realignment status summary.</summary> |
| 206 | + /// <returns>The realignment status summary.</returns> |
| 207 | + public static string Describe() |
| 208 | + { |
| 209 | + SigtranCommercialRoadmapRealignmentReport report = GetReport(); |
| 210 | + return $"{StatusLabel}: completedUnits={CompletedUnitCount} capabilities={Capabilities.Length} foundationReady={report.FoundationReady} commercialReleaseReady={report.CommercialReleaseReady}"; |
| 211 | + } |
| 212 | +} |
0 commit comments