| | | 1 | | using System.Collections.ObjectModel; |
| | | 2 | | |
| | | 3 | | namespace AsiBackbone.Core.Emissions; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Provider-neutral no-op governance emitter for tests, samples, local validation, and outbox proof-of-composition flow |
| | | 7 | | /// </summary> |
| | | 8 | | /// <remarks> |
| | | 9 | | /// This emitter does not send data to an external provider. It acknowledges the envelope as delivered so hosts can vali |
| | | 10 | | /// </remarks> |
| | | 11 | | public sealed class NoOpGovernanceEmitter : IAsiBackboneGovernanceEmitter |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets the provider name used by the no-op emitter. |
| | | 15 | | /// </summary> |
| | | 16 | | public const string ProviderName = "noop"; |
| | | 17 | | |
| | 2 | 18 | | private static readonly IReadOnlyDictionary<string, string> DeliveredMetadata = new ReadOnlyDictionary<string, strin |
| | 2 | 19 | | new Dictionary<string, string>(StringComparer.Ordinal) |
| | 2 | 20 | | { |
| | 2 | 21 | | ["emitter.kind"] = "noop", |
| | 2 | 22 | | ["emitter.purpose"] = "outbox-drain-validation" |
| | 2 | 23 | | }); |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Gets a reusable no-op governance emitter instance. |
| | | 27 | | /// </summary> |
| | 10 | 28 | | public static NoOpGovernanceEmitter Instance { get; } = new(); |
| | | 29 | | |
| | | 30 | | /// <inheritdoc /> |
| | | 31 | | public ValueTask<GovernanceEmissionResult> EmitAsync( |
| | | 32 | | GovernanceEmissionEnvelope envelope, |
| | | 33 | | CancellationToken cancellationToken = default) |
| | | 34 | | { |
| | 4 | 35 | | ArgumentNullException.ThrowIfNull(envelope); |
| | 4 | 36 | | cancellationToken.ThrowIfCancellationRequested(); |
| | | 37 | | |
| | 4 | 38 | | var result = GovernanceEmissionResult.DeliveredFromNormalizedMetadata( |
| | 4 | 39 | | ProviderName, |
| | 4 | 40 | | providerRecordId: envelope.EnvelopeId, |
| | 4 | 41 | | DeliveredMetadata); |
| | | 42 | | |
| | 4 | 43 | | return ValueTask.FromResult(result); |
| | | 44 | | } |
| | | 45 | | } |