< Summary

Information
Class: AsiBackbone.Core.Signing.CanonicalEnumWireNames
Assembly: AsiBackbone.Core
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Core/Signing/CanonicalEnumWireNames.cs
Line coverage
89%
Covered lines: 65
Uncovered lines: 8
Coverable lines: 73
Total lines: 124
Line coverage: 89%
Branch coverage
83%
Covered branches: 77
Total branches: 92
Branch coverage: 83.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ForActorType(...)83.33%6688.89%
ForLifecycleStage(...)85.71%282893.33%
ForDecisionOutcome(...)85.71%7790%
ForConstraintOutcome(...)80%5587.5%
ForEmissionEventType(...)81.82%222291.67%
ForEmissionStatus(...)85.71%141490%
ForPersistenceOutcome(...)80%101087.5%
ThrowUndefined(...)100%210%

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.Core/Signing/CanonicalEnumWireNames.cs

#LineLine coverage
 1using AsiBackbone.Core.Actors;
 2using AsiBackbone.Core.Audit;
 3using AsiBackbone.Core.Constraints;
 4using AsiBackbone.Core.Decisions;
 5using AsiBackbone.Core.Emissions;
 6using AsiBackbone.Core.HostIntegration;
 7
 8namespace AsiBackbone.Core.Signing;
 9
 10/// <summary>
 11/// Maps enum values used by canonical signed payloads to their stable v1 wire names.
 12/// </summary>
 13/// <remarks>
 14/// These strings are signature protocol constants. They intentionally do not depend on CLR member names so a source
 15/// rename cannot silently change canonical bytes. Existing values preserve the names emitted by AsiBackbone 6.0.
 16/// </remarks>
 17internal static class CanonicalEnumWireNames
 18{
 19    public static string ForActorType(GovernanceActorType value)
 20    {
 8121        return value switch
 8122        {
 123            GovernanceActorType.Unknown => "Unknown",
 2424            GovernanceActorType.Human => "Human",
 2125            GovernanceActorType.System => "System",
 3426            GovernanceActorType.Service => "Service",
 127            GovernanceActorType.Agent => "Agent",
 028            _ => ThrowUndefined(value)
 8129        };
 30    }
 31
 32    public static string ForLifecycleStage(DecisionReceiptLifecycleStage value)
 33    {
 6334        return value switch
 6335        {
 436            DecisionReceiptLifecycleStage.DecisionEvaluated => "DecisionEvaluated",
 437            DecisionReceiptLifecycleStage.AcknowledgmentRequested => "AcknowledgmentRequested",
 438            DecisionReceiptLifecycleStage.AcknowledgmentCompleted => "AcknowledgmentCompleted",
 439            DecisionReceiptLifecycleStage.CapabilityTokenIssued => "CapabilityTokenIssued",
 440            DecisionReceiptLifecycleStage.GatewayExecutionStarted => "GatewayExecutionStarted",
 841            DecisionReceiptLifecycleStage.GatewayExecutionCompleted => "GatewayExecutionCompleted",
 442            DecisionReceiptLifecycleStage.GatewayExecutionDenied => "GatewayExecutionDenied",
 1843            DecisionReceiptLifecycleStage.ExternalEmissionQueued => "ExternalEmissionQueued",
 444            DecisionReceiptLifecycleStage.ExternalEmissionDelivered => "ExternalEmissionDelivered",
 545            DecisionReceiptLifecycleStage.ExternalEmissionFailed => "ExternalEmissionFailed",
 446            DecisionReceiptLifecycleStage.ExternalEmissionDeadLettered => "ExternalEmissionDeadLettered",
 047            _ => ThrowUndefined(value)
 6348        };
 49    }
 50
 51    public static string ForDecisionOutcome(GovernanceDecisionOutcome value)
 52    {
 3553        return value switch
 3554        {
 955            GovernanceDecisionOutcome.Allowed => "Allowed",
 556            GovernanceDecisionOutcome.Warning => "Warning",
 857            GovernanceDecisionOutcome.Denied => "Denied",
 458            GovernanceDecisionOutcome.Deferred => "Deferred",
 559            GovernanceDecisionOutcome.AcknowledgmentRequired => "AcknowledgmentRequired",
 460            GovernanceDecisionOutcome.EscalationRecommended => "EscalationRecommended",
 061            _ => ThrowUndefined(value)
 3562        };
 63    }
 64
 65    public static string ForConstraintOutcome(ConstraintEvaluationOutcome value)
 66    {
 1667        return value switch
 1668        {
 369            ConstraintEvaluationOutcome.NotApplicable => "NotApplicable",
 370            ConstraintEvaluationOutcome.Allowed => "Allowed",
 671            ConstraintEvaluationOutcome.Warning => "Warning",
 472            ConstraintEvaluationOutcome.Denied => "Denied",
 073            _ => ThrowUndefined(value)
 1674        };
 75    }
 76
 77    public static string ForEmissionEventType(GovernanceEmissionEventType value)
 78    {
 6079        return value switch
 6080        {
 181            GovernanceEmissionEventType.Decision => "Decision",
 182            GovernanceEmissionEventType.Acknowledgment => "Acknowledgment",
 183            GovernanceEmissionEventType.CapabilityToken => "CapabilityToken",
 184            GovernanceEmissionEventType.Gateway => "Gateway",
 2085            GovernanceEmissionEventType.DecisionReceipt => "AuditResidue",
 2886            GovernanceEmissionEventType.AuditLifecycle => "AuditLifecycle",
 787            GovernanceEmissionEventType.Outbox => "Outbox",
 188            GovernanceEmissionEventType.ProviderEmission => "ProviderEmission",
 089            _ => ThrowUndefined(value)
 6090        };
 91    }
 92
 93    public static string ForEmissionStatus(GovernanceEmissionStatus value)
 94    {
 1695        return value switch
 1696        {
 997            GovernanceEmissionStatus.Pending => "Pending",
 198            GovernanceEmissionStatus.Delivered => "Delivered",
 199            GovernanceEmissionStatus.Deferred => "Deferred",
 1100            GovernanceEmissionStatus.Failed => "Failed",
 3101            GovernanceEmissionStatus.RetryableFailure => "RetryableFailure",
 1102            GovernanceEmissionStatus.DeadLettered => "DeadLettered",
 0103            _ => ThrowUndefined(value)
 16104        };
 105    }
 106
 107    public static string ForPersistenceOutcome(GovernedOperationPersistenceOutcome value)
 108    {
 50109        return value switch
 50110        {
 24111            GovernedOperationPersistenceOutcome.Committed => "Committed",
 8112            GovernedOperationPersistenceOutcome.Failed => "Failed",
 8113            GovernedOperationPersistenceOutcome.RolledBack => "RolledBack",
 10114            GovernedOperationPersistenceOutcome.CompletedWithoutMutation => "CompletedWithoutMutation",
 0115            _ => ThrowUndefined(value)
 50116        };
 117    }
 118
 119    private static string ThrowUndefined<TEnum>(TEnum value)
 120        where TEnum : struct, Enum
 121    {
 0122        throw new ArgumentOutOfRangeException(nameof(value), value, "Canonical enum wire values must be explicitly defin
 123    }
 124}