Skip to content

InboundTriggerDispatcher

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Validates and dispatches inbound trigger requests: HMAC signature and timestamp window, replay protection, payload extraction, and queuing.

public sealed class InboundTriggerDispatcher

objectInboundTriggerDispatcher

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Host-agnostic by design: this type has no dependency on ASP.NET Core. The HTTP layer (TriggerEndpoints) owns request body size bounding and the quota check (QuotaGate) — both are naturally HTTP-shaped concerns (a 413/429 response with specific headers) and sit BETWEEN InboundTriggerDispatcher.ValidateAsync and InboundTriggerDispatcher.EnqueueAsync.

Replay protection reuses IIdempotencyStore keyed by the request’s own signature, not a client-supplied Idempotency-Key. The reservation is deliberately never completed on success: leaving it IdempotencyState.Reserved forever makes every later replay of the same signature report IdempotencyState.InProgress, which this type maps to InboundTriggerOutcome.Replayed — simpler than tracking and replaying a stored response, and correct here because a replayed webhook delivery must always be rejected, never re-served (unlike the general idempotency-key contract, which intentionally replays the original response).

InboundTriggerDispatcher(IInboundTriggerStore, InboundTriggerSecretResolver, InboundTriggerRateLimiter, IIdempotencyStore, IJobStore, IRunStore, IOptionsMonitor<AgentPrismInboundTriggerOptions>, TimeProvider?)

Section titled “ InboundTriggerDispatcher(IInboundTriggerStore, InboundTriggerSecretResolver, InboundTriggerRateLimiter, IIdempotencyStore, IJobStore, IRunStore, IOptionsMonitor<AgentPrismInboundTriggerOptions>, TimeProvider?)”

Creates a new dispatcher.

public InboundTriggerDispatcher(IInboundTriggerStore triggerStore, InboundTriggerSecretResolver secretResolver, InboundTriggerRateLimiter rateLimiter, IIdempotencyStore idempotencyStore, IJobStore jobStore, IRunStore runStore, IOptionsMonitor<AgentPrismInboundTriggerOptions> options, TimeProvider? timeProvider = null)

triggerStore IInboundTriggerStore

secretResolver InboundTriggerSecretResolver

rateLimiter InboundTriggerRateLimiter

idempotencyStore IIdempotencyStore

jobStore IJobStore

runStore IRunStore

options IOptionsMonitor<AgentPrismInboundTriggerOptions>

timeProvider TimeProvider?

EnqueueAsync(InboundTriggerValidatedRequest, CancellationToken)

Section titled “ EnqueueAsync(InboundTriggerValidatedRequest, CancellationToken)”

Queues the validated request’s run.

public ValueTask<InboundTriggerDispatchResult> EnqueueAsync(InboundTriggerValidatedRequest validated, CancellationToken cancellationToken = default)

validated InboundTriggerValidatedRequest

The result of a successful InboundTriggerDispatcher.ValidateAsync call.

cancellationToken CancellationToken

The cancellation token.

ValueTask<InboundTriggerDispatchResult>

The identifiers of the queued work.

ReleaseAsync(InboundTriggerValidatedRequest, CancellationToken)

Section titled “ ReleaseAsync(InboundTriggerValidatedRequest, CancellationToken)”

Releases a reservation made by InboundTriggerDispatcher.ValidateAsync when a later, HTTP-layer check (the quota gate) rejects the request — so a legitimate retry is not permanently mistaken for a replay.

public ValueTask ReleaseAsync(InboundTriggerValidatedRequest validated, CancellationToken cancellationToken = default)

validated InboundTriggerValidatedRequest

The result of a successful InboundTriggerDispatcher.ValidateAsync call.

cancellationToken CancellationToken

The cancellation token.

ValueTask

ValidateAsync(string, string, string, string?, string?, CancellationToken)

Section titled “ ValidateAsync(string, string, string, string?, string?, CancellationToken)”

Validates a request: trigger lookup, signature and timestamp, rate limit, replay protection, and payload extraction — in that order.

public ValueTask<InboundTriggerValidationResult> ValidateAsync(string tenantId, string name, string rawBody, string? timestampHeader, string? signatureHeader, CancellationToken cancellationToken = default)

tenantId string

The tenant identifier, from the route.

name string

The trigger name, from the route.

rawBody string

The raw, already size-bounded request body.

timestampHeader string?

The X-AgentPrism-Timestamp header value.

signatureHeader string?

The X-AgentPrism-Signature header value.

cancellationToken CancellationToken

The cancellation token.

ValueTask<InboundTriggerValidationResult>

The validation result.