import { i as JobRun } from '../../../job-orchestrator.protocol-ZuJ3ow-O.js';
import '../events/event-bus.protocol.js';
import '../../types/drizzle.js';
import 'drizzle-orm/node-postgres';
import './job-orchestration.schema.js';
import 'drizzle-orm/pg-core';
import 'drizzle-orm';
import '@nestjs/common';
import '../events/event-registry.js';

/**
 * Typed errors for the job orchestration domain (ADR-022, JOB-3).
 *
 * All thrown by the Drizzle orchestrator (and mirrored by the Memory
 * backend in JOB-4). They exist as classes so consumers can `instanceof`
 * them in catch blocks and exception filters can map them to HTTP codes.
 */

/**
 * `start(type, …)` was called for a job type that has no row in the `job`
 * table. At runtime this usually means the handler was not decorated or the
 * boot validator (JOB-5) has not registered it yet.
 */
declare class JobTypeNotFoundError extends Error {
    readonly jobType: string;
    readonly name = "JobTypeNotFoundError";
    constructor(jobType: string);
}
/**
 * Thrown by `start` when `collision_mode === 'reject'` and a non-terminal
 * run with the same `concurrency_key` already exists. Carries the incumbent
 * so callers can surface its id or subscribe to its completion event.
 */
declare class JobCollisionError extends Error {
    readonly jobType: string;
    readonly concurrencyKey: string;
    readonly incumbent: JobRun;
    readonly name = "JobCollisionError";
    constructor(jobType: string, concurrencyKey: string, incumbent: JobRun);
}
/**
 * `replay` was called on a run that is not in a replayable terminal state
 * (i.e. still `pending` / `running` / `waiting`). Replay always spawns
 * fresh execution and therefore requires the source run to be settled.
 */
declare class JobNotReplayableError extends Error {
    readonly runId: string;
    readonly currentStatus: string;
    readonly name = "JobNotReplayableError";
    constructor(runId: string, currentStatus: string);
}
/**
 * A `concurrency_key_template` or `dedupe_key_template` referenced a field
 * that is not present on the input payload. Caught at `start` time so the
 * caller sees the misconfiguration synchronously rather than at claim time.
 */
declare class JobTemplateFieldMissingError extends Error {
    readonly template: string;
    readonly field: string;
    readonly name = "JobTemplateFieldMissingError";
    constructor(template: string, field: string);
}
/**
 * Thrown by the four multi-tenant-aware service-layer backends (JOB-8)
 * when `JobsDomainModule` was configured with `multiTenant: true` but the
 * caller did not pass a `tenantId` in the relevant options object.
 *
 * **Strict enforcement rationale (resolved 2026-04-18).** Cross-tenant data
 * leakage is the worst class of bug a multi-tenant system can ship; surfacing
 * the misuse loudly at the call site (rather than silently defaulting to
 * `null` or to the "last tenant seen") prevents both accidental global
 * writes and sneaky reads that return a union of tenants.
 *
 * - `undefined` `tenantId` → throw this error.
 * - Explicit `null` `tenantId` → passes; opts the call into cross-tenant
 *   background work (e.g. a nightly housekeeping job that must scan all
 *   tenants). The row is persisted with `tenant_id = NULL`.
 */
declare class MissingTenantIdError extends Error {
    readonly method: string;
    readonly name = "MissingTenantIdError";
    constructor(method: string);
}
/**
 * Thrown by `JobWorkerModule.onModuleInit` (Drizzle backend only) when the
 * `job` table contains type rows for which no `@JobHandler` is registered
 * in the running process. Surfaces every orphaned type at once so a single
 * boot tells the operator everything to clean up.
 *
 * Skipped entirely in memory mode (Q4 resolution 2026-04-19) — the memory
 * backend has no DB rows to validate; `MemoryJobOrchestrator.start()`
 * throws `JobTypeNotFoundError` synchronously for unknown types instead.
 */
declare class BootValidationError extends Error {
    readonly missingHandlers: string[];
    readonly name = "BootValidationError";
    constructor(missingHandlers: string[]);
}
/**
 * Thrown by `JobWorkerModule.onModuleInit` when one or more `@JobHandler`
 * classes target a `reserved: true` pool from the resolved pool config
 * (the three `events_*` pools are reserved for the events subsystem
 * outbox drain). Listing every offender on a single boot avoids the
 * fix-one-restart-fix-next loop.
 */
declare class ReservedPoolViolationError extends Error {
    readonly offenders: ReadonlyArray<{
        handlerClass: string;
        pool: string;
    }>;
    readonly name = "ReservedPoolViolationError";
    constructor(offenders: ReadonlyArray<{
        handlerClass: string;
        pool: string;
    }>);
}

export { BootValidationError, JobCollisionError, JobNotReplayableError, JobTemplateFieldMissingError, JobTypeNotFoundError, MissingTenantIdError, ReservedPoolViolationError };
