import type { TurnPipelineMiddlewareFn, DispatchPipelineMiddlewareFn } from "../../types"; import type { OrderingGuardOptions } from "./types"; /** `ctx.stash` key under which the prior-iteration primitive snapshot is kept for * {@link @nhtio/adk!PreservationRule} statefulness — see the plan's "Statefulness for * `PreservationRule`" section. Exported (as `ORDERING_GUARD_SNAPSHOT_STASH_KEY`) so a caller * can pass a custom `options.snapshotStashKey` without guessing the default's exact string. */ declare const SNAPSHOT = "__orderingGuardSnapshot"; /** `ctx.stash` key under which the most recent {@link OrderingGuardResult} (repaired + * unrepaired + advisories) is recorded, so a caller or a later pipeline stage can inspect * exactly what this middleware did on the current iteration without parsing the nack error. */ declare const RESULT = "__orderingGuardLastResult"; /** `ctx.stash` key under which the post-repair "effective timeline" (the in-memory, * already-ordered copy `repairViolations` produced, with any inserted alternation fillers) * is recorded for the current iteration, so repairs can be re-evaluated against it. */ declare const EFFECTIVE_TIMELINE = "__orderingGuardEffectiveTimeline"; /** * Builds a {@link @nhtio/adk!DispatchPipelineMiddlewareFn} that validates (and, in `'mutate'` * mode, best-effort repairs) turn-state primitive ordering against `options.profiles` before * every executor call. * * @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. * * @param options - Validated via {@link validateOptions} at call time; throws * `E_INVALID_ORDERING_GUARD_OPTIONS` synchronously on malformed input. * @returns A middleware function following the `(ctx, next) => void | Promise` idiom — * nacks via `ctx.nack(error)` (or throws, per `options.onViolation`) without calling `next()` * on an unrepaired blocking violation. */ export declare const orderingGuardDispatchMiddleware: (options: OrderingGuardOptions) => DispatchPipelineMiddlewareFn; /** * Builds a {@link @nhtio/adk!TurnPipelineMiddlewareFn} running the same ordering-guard core as * {@link orderingGuardDispatchMiddleware}, once per turn before the first executor call. * * @remarks * `TurnContext` has no `nack()` — only `abort()` — so the default `onViolation: 'nack'` * behavior maps to `ctx.abort(error)` here rather than a dispatch-style nack; `onViolation: * 'throw'` still throws in both middleware. This asymmetry is a real, documented difference * between the two contexts, not an inconsistency. * * @param options - Same shape and validation as {@link orderingGuardDispatchMiddleware}. * @returns A turn-pipeline middleware function with the same enforce/mutate semantics. */ export declare const orderingGuardTurnMiddleware: (options: OrderingGuardOptions) => TurnPipelineMiddlewareFn; export { SNAPSHOT as ORDERING_GUARD_SNAPSHOT_STASH_KEY, RESULT as ORDERING_GUARD_RESULT_STASH_KEY, EFFECTIVE_TIMELINE as ORDERING_GUARD_EFFECTIVE_TIMELINE_STASH_KEY, };