33namespace ModularityKit . Mutator . Abstractions . Policies ;
44
55/// <summary>
6- /// Represents a policy that decides whether a mutation can be applied.
7- /// Policies are a FIRST- CLASS governance mechanism in the mutation framework.
6+ /// Represents policy that decides whether a mutation can be applied.
7+ /// Policies are FIRST CLASS governance mechanism in the mutation framework.
88/// </summary>
99/// <typeparam name="TState">Type of the state the mutation operates on.</typeparam>
1010public interface IMutationPolicy < TState >
@@ -31,5 +31,19 @@ public interface IMutationPolicy<TState>
3131 /// <param name="mutation">The mutation to evaluate.</param>
3232 /// <param name="state">The current state before applying the mutation.</param>
3333 /// <returns>A <see cref="PolicyDecision"/> representing the result of the evaluation.</returns>
34- PolicyDecision Evaluate ( IMutation < TState > mutation , TState state ) ;
34+ PolicyDecision Evaluate ( IMutation < TState > mutation , TState state )
35+ => throw new NotSupportedException ( "This policy does not implement synchronous evaluation." ) ;
36+
37+ /// <summary>
38+ /// Evaluates whether the given mutation is allowed on the current state asynchronously.
39+ /// </summary>
40+ /// <param name="mutation">The mutation to evaluate.</param>
41+ /// <param name="state">The current state before applying the mutation.</param>
42+ /// <param name="cancellationToken">Token used to cancel the policy evaluation.</param>
43+ /// <returns>A <see cref="PolicyDecision"/> representing the result of the evaluation.</returns>
44+ Task < PolicyDecision > EvaluateAsync (
45+ IMutation < TState > mutation ,
46+ TState state ,
47+ CancellationToken cancellationToken = default )
48+ => Task . FromResult ( Evaluate ( mutation , state ) ) ;
3549}
0 commit comments