-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConflictScenario.cs
More file actions
47 lines (44 loc) · 1.73 KB
/
Copy pathConflictScenario.cs
File metadata and controls
47 lines (44 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using ModularityKit.Mutator.Abstractions.Exceptions;
using PolicyComposition.Mutations;
using PolicyComposition.Policies;
using PolicyComposition.State;
namespace PolicyComposition.Scenarios;
/// <summary>
/// Demonstrates explicit conflict detection during composition.
/// </summary>
/// <remarks>
/// This scenario intentionally composes two policies that both write the owner
/// field with different values. The example is useful because it shows that the
/// composition layer does not silently pick one result. Instead, it fails fast
/// with a conflict exception that names the field and the policies involved.
/// </remarks>
internal static class ConflictScenario
{
/// <summary>
/// Evaluates a conflicting policy set and prints the exception details.
/// </summary>
/// <remarks>
/// The exception is caught locally so the example can show the conflict
/// diagnostics without stopping the rest of the console run.
/// </remarks>
public static async Task Run()
{
var state = new ReleaseGateState("release-42", "Draft", "platform");
var mutation = new SubmitReleaseMutation(
releaseName: state.ReleaseName,
approvals: 2,
emergency: false,
environment: "staging");
try
{
await ReleaseGovernancePolicies.ConflictingOwnerGate().EvaluateAsync(mutation, state);
}
catch (PolicyCompositionConflictException exception)
{
Console.WriteLine($" conflict key: {exception.ConflictKey}");
Console.WriteLine($" policies: {string.Join(", ", exception.PolicyNames)}");
Console.WriteLine($" message: {exception.Message}");
Console.WriteLine();
}
}
}