-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAddAuditTrailPolicy.cs
More file actions
56 lines (51 loc) · 2.08 KB
/
Copy pathAddAuditTrailPolicy.cs
File metadata and controls
56 lines (51 loc) · 2.08 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
48
49
50
51
52
53
54
55
56
using ModularityKit.Mutator.Abstractions.Effects;
using ModularityKit.Mutator.Abstractions.Engine;
using ModularityKit.Mutator.Abstractions.Policies;
using PolicyComposition.State;
namespace PolicyComposition.Policies.Approval;
/// <summary>
/// Appends audit trail information to an already allowed approval gate decision.
/// </summary>
/// <remarks>
/// This policy does not block or change the release state. It exists to show how
/// composed policies can contribute side effects and metadata independently of
/// the policy that made the main business decision.
/// </remarks>
internal sealed class AddAuditTrailPolicy : IMutationPolicy<ReleaseGateState>
{
/// <summary>
/// Stable policy identifier used in composition metadata and diagnostics.
/// </summary>
public string Name => "AddAuditTrail";
/// <summary>
/// Medium priority so this policy can be grouped with the approval gate it decorates.
/// </summary>
public int Priority => 200;
/// <summary>
/// Describes the audit trail side effect this policy adds to the composed result.
/// </summary>
public string Description => "Adds audit metadata and a notification side effect.";
/// <summary>
/// Emits one audit side effect and a simple metadata flag.
/// </summary>
/// <param name="mutation">The mutation being evaluated.</param>
/// <param name="state">The current release state.</param>
/// <returns>An allowed decision with audit metadata and a single side effect.</returns>
public PolicyDecision Evaluate(IMutation<ReleaseGateState> mutation, ReleaseGateState state)
=> new()
{
IsAllowed = true,
PolicyName = Name,
Modifications = new Dictionary<string, object>
{
["SideEffects"] = new[]
{
SideEffect.Create("audit", $"Release {state.ReleaseName} passed the composed approval gate.")
}
},
Metadata = new Dictionary<string, object>
{
["auditTrail"] = "enabled"
}
};
}