File tree Expand file tree Collapse file tree
src/Governance/Abstractions/Execution/Model Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace ModularityKit . Mutator . Governance . Abstractions . Execution . Model . Compensation ;
2+
3+ /// <summary>
4+ /// Distinguishes rollback-style restoration from forward corrective compensation.
5+ /// </summary>
6+ public enum GovernedCompensationKind
7+ {
8+ /// <summary>
9+ /// Attempts to restore the prior state or its equivalent.
10+ /// </summary>
11+ Rollback = 0 ,
12+
13+ /// <summary>
14+ /// Applies a forward corrective action instead of restoring prior state.
15+ /// </summary>
16+ ForwardCorrection = 1
17+ }
Original file line number Diff line number Diff line change 1+ namespace ModularityKit . Mutator . Governance . Abstractions . Execution . Model . Compensation ;
2+
3+ /// <summary>
4+ /// Describes how a governed request compensates for a prior execution.
5+ /// </summary>
6+ public sealed record GovernedCompensationPlan
7+ {
8+ /// <summary>
9+ /// Request identifier of the original execution being compensated.
10+ /// </summary>
11+ public string OriginalRequestId { get ; init ; } = string . Empty ;
12+
13+ /// <summary>
14+ /// Compensation style to apply.
15+ /// </summary>
16+ public GovernedCompensationKind Kind { get ; init ; } = GovernedCompensationKind . Rollback ;
17+
18+ /// <summary>
19+ /// Trigger that initiated the compensation.
20+ /// </summary>
21+ public GovernedCompensationTrigger Trigger { get ; init ; } = GovernedCompensationTrigger . OperatorRollback ;
22+
23+ /// <summary>
24+ /// Optional batch identifier for batch-oriented compensation plans.
25+ /// </summary>
26+ public string ? BatchId { get ; init ; }
27+
28+ /// <summary>
29+ /// Optional identifiers of related requests in the same compensation plan.
30+ /// </summary>
31+ public IReadOnlyList < string > RelatedRequestIds { get ; init ; } = [ ] ;
32+
33+ /// <summary>
34+ /// Optional human-readable rationale for the compensation.
35+ /// </summary>
36+ public string ? Reason { get ; init ; }
37+
38+ internal void EnsureValid ( )
39+ {
40+ if ( string . IsNullOrWhiteSpace ( OriginalRequestId ) )
41+ throw new InvalidOperationException ( "Compensation requests require an original request identifier." ) ;
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ namespace ModularityKit . Mutator . Governance . Abstractions . Execution . Model . Compensation ;
2+
3+ /// <summary>
4+ /// Describes what initiated a governed compensation plan.
5+ /// </summary>
6+ public enum GovernedCompensationTrigger
7+ {
8+ /// <summary>
9+ /// A human operator explicitly initiated rollback or correction.
10+ /// </summary>
11+ OperatorRollback = 0 ,
12+
13+ /// <summary>
14+ /// A batch workflow initiated compensation after one or more failures.
15+ /// </summary>
16+ BatchFailure = 1 ,
17+
18+ /// <summary>
19+ /// A failed execution path initiated a compensating follow-up action.
20+ /// </summary>
21+ FailedExecution = 2
22+ }
Original file line number Diff line number Diff line change 1+ namespace ModularityKit . Mutator . Governance . Abstractions . Execution . Model ;
2+
3+ /// <summary>
4+ /// Classifies governed execution as a primary mutation or compensating execution.
5+ /// </summary>
6+ public enum GovernedExecutionKind
7+ {
8+ /// <summary>
9+ /// Standard governed execution for the originally requested mutation.
10+ /// </summary>
11+ Standard = 0 ,
12+
13+ /// <summary>
14+ /// Governed execution intended to compensate for a prior execution.
15+ /// </summary>
16+ Compensation = 1
17+ }
Original file line number Diff line number Diff line change 11using ModularityKit . Mutator . Abstractions . Results ;
2+ using ModularityKit . Mutator . Governance . Abstractions . Execution . Model . Compensation ;
23using ModularityKit . Mutator . Governance . Abstractions . Requests . Model ;
34using ModularityKit . Mutator . Governance . Abstractions . Resolution . Model ;
45
56namespace ModularityKit . Mutator . Governance . Abstractions . Execution . Model ;
67
78/// <summary>
8- /// Captures the outcome of executing a governed mutation request.
9+ /// Captures the outcome of executing governed mutation request.
910/// </summary>
1011public sealed record GovernedExecutionResult < TState >
1112{
@@ -29,6 +30,16 @@ public sealed record GovernedExecutionResult<TState>
2930 /// </summary>
3031 public bool WasExecuted { get ; init ; }
3132
33+ /// <summary>
34+ /// Classifies the execution path represented by this result.
35+ /// </summary>
36+ public GovernedExecutionKind ExecutionKind { get ; init ; } = GovernedExecutionKind . Standard ;
37+
38+ /// <summary>
39+ /// Compensation plan attached to the execution when the request is compensating.
40+ /// </summary>
41+ public GovernedCompensationPlan ? Compensation { get ; init ; }
42+
3243 /// <summary>
3344 /// Resulting state version recorded after a successful execution.
3445 /// </summary>
Original file line number Diff line number Diff line change 1+ using ModularityKit . Mutator . Governance . Abstractions . Execution . Model . Compensation ;
2+
3+ namespace ModularityKit . Mutator . Governance . Abstractions . Execution . Model . Links ;
4+
5+ /// <summary>
6+ /// Represents an explicit relation between governed execution records.
7+ /// </summary>
8+ public sealed record GovernedExecutionLink
9+ {
10+ /// <summary>
11+ /// Linked request identifier.
12+ /// </summary>
13+ public string RequestId { get ; init ; } = string . Empty ;
14+
15+ /// <summary>
16+ /// Relationship to the linked request.
17+ /// </summary>
18+ public GovernedExecutionLinkType Type { get ; init ; }
19+
20+ /// <summary>
21+ /// Execution kind of the linked request.
22+ /// </summary>
23+ public GovernedExecutionKind ExecutionKind { get ; init ; } = GovernedExecutionKind . Standard ;
24+
25+ /// <summary>
26+ /// Compensation style associated with the link when applicable.
27+ /// </summary>
28+ public GovernedCompensationKind ? CompensationKind { get ; init ; }
29+
30+ /// <summary>
31+ /// Trigger that led to the compensating execution when applicable.
32+ /// </summary>
33+ public GovernedCompensationTrigger ? Trigger { get ; init ; }
34+
35+ /// <summary>
36+ /// Optional batch identifier associated with the compensation plan.
37+ /// </summary>
38+ public string ? BatchId { get ; init ; }
39+
40+ /// <summary>
41+ /// Time when the relation was recorded.
42+ /// </summary>
43+ public DateTimeOffset LinkedAt { get ; init ; } = DateTimeOffset . UtcNow ;
44+ }
Original file line number Diff line number Diff line change 1+ namespace ModularityKit . Mutator . Governance . Abstractions . Execution . Model . Links ;
2+
3+ /// <summary>
4+ /// Describes how one governed request relates to another.
5+ /// </summary>
6+ public enum GovernedExecutionLinkType
7+ {
8+ /// <summary>
9+ /// The current request compensates for the linked request.
10+ /// </summary>
11+ Compensates = 0 ,
12+
13+ /// <summary>
14+ /// The current request was compensated by the linked request.
15+ /// </summary>
16+ CompensatedBy = 1
17+ }
You can’t perform that action at this time.
0 commit comments