| | | 1 | | namespace AsiBackbone.Core.Evaluation; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Provides host-configurable options for the default AsiBackbone policy evaluator. |
| | | 5 | | /// </summary> |
| | | 6 | | public sealed class AsiBackbonePolicyEvaluatorOptions |
| | | 7 | | { |
| | | 8 | | private const string DefaultNoConstraintsReasonMessage = |
| | | 9 | | "No policy constraints were registered or supplied for evaluation."; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Gets the default machine-readable reason code used when strict empty-policy evaluation denies execution. |
| | | 13 | | /// </summary> |
| | | 14 | | public const string DefaultNoConstraintsReasonCode = "asibackbone.policy.no_constraints"; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Gets or sets a value indicating whether evaluation should deny when no constraints are registered or supplied. |
| | | 18 | | /// </summary> |
| | | 19 | | /// <remarks> |
| | | 20 | | /// The default value is <see langword="false" /> for backward compatibility with hosts that intentionally run |
| | | 21 | | /// permissive or explicitly unconstrained evaluation flows. |
| | | 22 | | /// </remarks> |
| | 15 | 23 | | public bool DenyWhenNoConstraints { get; set; } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets or sets a value indicating whether evaluation should stop after the first denied constraint result. |
| | | 27 | | /// </summary> |
| | | 28 | | /// <remarks> |
| | | 29 | | /// The default value is <see langword="false" /> so the evaluator continues to collect the complete set of |
| | | 30 | | /// warning and denial reasons for audit visibility. Set this to <see langword="true" /> only when the host |
| | | 31 | | /// intentionally prefers latency-optimized fast-abort behavior over full reason-code aggregation. |
| | | 32 | | /// </remarks> |
| | 42 | 33 | | public bool ShortCircuitOnFirstDenial { get; set; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Gets or sets the machine-readable reason code used when <see cref="DenyWhenNoConstraints" /> denies an empty pol |
| | | 37 | | /// </summary> |
| | 83 | 38 | | public string NoConstraintsReasonCode { get; set; } = DefaultNoConstraintsReasonCode; |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Gets or sets the reason message used when <see cref="DenyWhenNoConstraints" /> denies an empty policy. |
| | | 42 | | /// </summary> |
| | 80 | 43 | | public string NoConstraintsReasonMessage { get; set; } = DefaultNoConstraintsReasonMessage; |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Validates evaluator options. |
| | | 47 | | /// </summary> |
| | | 48 | | public void Validate() |
| | | 49 | | { |
| | 38 | 50 | | if (string.IsNullOrWhiteSpace(NoConstraintsReasonCode)) |
| | | 51 | | { |
| | 3 | 52 | | throw new InvalidOperationException($"{nameof(NoConstraintsReasonCode)} must not be empty."); |
| | | 53 | | } |
| | | 54 | | |
| | 35 | 55 | | if (string.IsNullOrWhiteSpace(NoConstraintsReasonMessage)) |
| | | 56 | | { |
| | 3 | 57 | | throw new InvalidOperationException($"{nameof(NoConstraintsReasonMessage)} must not be empty."); |
| | | 58 | | } |
| | 32 | 59 | | } |
| | | 60 | | } |