import { type Diagnostic, type ProcedureManifest } from "@aotter/mantle-spec"; import type { HandlerRegistry } from "../../domain/port/HandlerRegistry.js"; import type { InvokeProcedureRequest, InvokeProcedureResponse } from "../dto/procedure/index.js"; import type { InvokeBuiltinUseCase } from "./InvokeBuiltinUseCase.js"; /** * `InvokeProcedureUseCase` — in-process invocation of a Procedure. * HTTP-agnostic — the adapter's mount layer wraps this to map to/from * `Request` / `Response`. The test harness exercises the same entry * point. * * Order of operations: * 1. Evaluate `requires.auth.all` predicates against `ctx`. Deny ⇒ * `UNAUTHENTICATED` or `AUTH_DENIED`. * 2. Validate `input` against the Procedure's `input` JSON Schema. * Fail ⇒ `INPUT_VALIDATION_FAILED` (first zod issue). * 3. Invoke an optional guard Procedure with validated input and the * same caller context. Any failure denies the target. * 4. Dispatch by `handler.kind`: * - `ref`: resolve in registry, call (`InvokeFailure` → unwrap; * other throws → `INTERNAL_ERROR`). * - `builtin`: delegate to `InvokeBuiltinUseCase` (project + * stamp + chokepoint write per POC ADR-0014). When no builtin * collaborator was injected (test paths, ref-only runtimes) the * use case returns `HANDLER_BUILTIN_NOT_IN_V010`. * 5. Validate the result against the `output` schema. Fail ⇒ * `OUTPUT_VALIDATION_FAILED` (handler / builtin bug). */ /** * Throwable carrier for handlers that want to surface a structured * Diagnostic without going through the generic `INTERNAL_ERROR` * envelope. The use case catches it and converts to an * `{ ok: false, diagnostic }` return. Lives here (not in * `usecase/dto/`) because it's a runtime value, not a DTO type. */ export declare class InvokeFailure extends Error { readonly diagnostic: Diagnostic; constructor(diagnostic: Diagnostic); } export declare class InvokeProcedureUseCase { private readonly registry; private readonly builtin?; private readonly proceduresByName; private readonly inputCache; private readonly outputCache; constructor(registry: HandlerRegistry, builtin?: InvokeBuiltinUseCase | undefined, proceduresByName?: ReadonlyMap); execute(request: InvokeProcedureRequest): Promise>; private executeInternal; private compileInput; private compileOutput; } //# sourceMappingURL=InvokeProcedureUseCase.d.ts.map