Skip to content

Commit 50b5b18

Browse files
committed
Feat: PolicyCompositionMode enum and exception
1 parent 1fe5584 commit 50b5b18

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace ModularityKit.Mutator.Abstractions.Exceptions;
2+
3+
/// <summary>
4+
/// Exception thrown when composed policies attempt to produce incompatible outputs.
5+
/// </summary>
6+
/// <remarks>
7+
/// Initializes a new instance of the <see cref="PolicyCompositionConflictException"/> class.
8+
/// </remarks>
9+
/// <param name="compositionName">Name of the composed policy set.</param>
10+
/// <param name="conflictKey">Key or field that conflicted.</param>
11+
/// <param name="policyNames">Policy names that contributed to the conflict.</param>
12+
public sealed class PolicyCompositionConflictException(
13+
string compositionName,
14+
string conflictKey,
15+
IReadOnlyList<string> policyNames) : MutationException(
16+
$"Policy composition '{compositionName}' has a conflict for '{conflictKey}' between policies {string.Join(", ", policyNames)}.")
17+
{
18+
/// <summary>
19+
/// Name of the composed policy set that detected the conflict.
20+
/// </summary>
21+
public string CompositionName { get; } = compositionName;
22+
23+
/// <summary>
24+
/// Key or field that conflicted during composition.
25+
/// </summary>
26+
public string ConflictKey { get; } = conflictKey;
27+
28+
/// <summary>
29+
/// Policy names that contributed to the conflicting value.
30+
/// </summary>
31+
public IReadOnlyList<string> PolicyNames { get; } = policyNames;
32+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace ModularityKit.Mutator.Abstractions.Policies;
2+
3+
/// <summary>
4+
/// Defines how composed policy set combines child policy decisions.
5+
/// </summary>
6+
public enum PolicyCompositionMode
7+
{
8+
/// <summary>
9+
/// All composed policies are evaluated and their outputs are merged.
10+
/// Any blocking decision blocks the composition.
11+
/// </summary>
12+
AllOf = 0,
13+
14+
/// <summary>
15+
/// All composed policies are evaluated and at least one allowed branch must succeed.
16+
/// Outputs from the allowed branches are merged.
17+
/// </summary>
18+
AnyOf = 1,
19+
20+
/// <summary>
21+
/// Policies are evaluated in priority order and the first decisive policy wins.
22+
/// </summary>
23+
Priority = 2
24+
}

0 commit comments

Comments
 (0)