Skip to content
1 min read · 141 words

Function: orderingGuardDispatchMiddleware()

ts
function orderingGuardDispatchMiddleware(
  options: OrderingGuardOptions,
): DispatchPipelineMiddlewareFn;

Defined in: src/batteries/validation/middleware.ts:410

Builds a @nhtio/adk!DispatchPipelineMiddlewareFn that validates (and, in 'mutate' mode, best-effort repairs) turn-state primitive ordering against options.profiles before every executor call.

Parameters

ParameterTypeDescription
optionsOrderingGuardOptionsValidated via validateOptions at call time; throws E_INVALID_ORDERING_GUARD_OPTIONS synchronously on malformed input.

Returns

DispatchPipelineMiddlewareFn

A middleware function following the (ctx, next) => void | Promise<void> idiom — nacks via ctx.nack(error) (or throws, per options.onViolation) without calling next() on an unrepaired blocking violation.

Remarks

Runs on every dispatchInputPipeline iteration, since that is the point where a caught ordering bug is cheapest to fix — before the wire payload is ever built. See the plan's "Middleware — dispatchInputPipeline/turnInputPipeline integration" section for why this insertion point was chosen over a one-shot turn-level check alone.