import type { VoyantGraphProvisionedJob } from "./deployment-graph.js"; import { type VoyantGraphRuntimePorts } from "./runtime-composition.js"; import type { VoyantGraphRuntime } from "./runtime-lowering.js"; export declare const VOYANT_PRODUCT_JOB_ROUTE = "/__voyant/jobs"; export declare const VOYANT_PRODUCT_JOB_RELEASE_HEADER = "x-voyant-product-job-release"; export declare const VOYANT_PRODUCT_JOB_EXECUTION_HEADER = "x-voyant-product-job-execution"; export type VoyantNodeJobInvocationSource = "schedule" | "wakeup" | "recovery"; export type VoyantNodeJobHealthStatus = "idle" | "running" | "retrying" | "succeeded" | "failed"; export interface VoyantNodeJobHealth { id: string; status: VoyantNodeJobHealthStatus; attempts: number; retryExhausted: boolean; lastSource?: VoyantNodeJobInvocationSource; lastAttemptAt?: string; lastSuccessAt?: string; lastFailureAt?: string; lastFailure?: string; lastReportFailureAt?: string; lastReportFailure?: string; } export interface VoyantNodeJobExecutionReport { jobId: string; status: "succeeded" | "failed"; attempts: number; retryExhausted: boolean; startedAt?: string; finishedAt: string; error?: string; releaseId?: string; executionToken?: string; } export interface VoyantProductJobExecutionCorrelation { releaseId: string; executionToken: string; } export interface VoyantNodeJobHostRetryOptions { maxAttempts?: number; initialBackoffMs?: number; maxBackoffMs?: number; } export interface CreateVoyantNodeJobHostOptions { runtime: VoyantGraphRuntime; /** Immutable host inventory copied from resolved provisioning.jobs. */ jobs: readonly VoyantGraphProvisionedJob[]; ports?: VoyantGraphRuntimePorts; /** Concrete deployment bindings passed to fixed product-job runtimes. */ bindings?: unknown; retry?: VoyantNodeJobHostRetryOptions; now?: () => Date; sleep?: (milliseconds: number) => Promise; schedulerPollMs?: number; /** Required for the fixed internal HTTP invocation surface. */ originTrustSecret?: string; /** Best-effort terminal execution reporting; failures never repeat domain work. */ reportExecution?: (report: VoyantNodeJobExecutionReport) => Promise | void; /** * Optional deployment-owned cluster lease. Without it, host serialization is * process-local and resident scheduling is supported only for one replica; * domain handlers must still claim their own durable work. */ acquireDistributedLease?: (jobId: string) => Promise<{ release(): Promise | void; } | undefined>; } export interface VoyantNodeJobHost { inventory: readonly VoyantGraphProvisionedJob[]; invoke: (jobId: string, source: VoyantNodeJobInvocationSource, correlation?: VoyantProductJobExecutionCorrelation) => Promise<"started" | "queued" | "skipped">; dispatchSchedule: (event: { scheduleId?: string; cron?: string; }) => Promise; handleRequest: (request: Request, originTrustSecret?: string) => Promise; health: () => readonly VoyantNodeJobHealth[]; /** Resolve after the current invocation and any coalesced follow-up are idle. */ settled: (jobId: string) => Promise; start: () => void; stop: () => void; } /** * Host fixed product jobs selected by the resolved graph. * * The host deliberately retains no run payload or durable work state. Domain * records remain authoritative; this layer provides only delivery, bounded * retry, in-process overlap protection, cadence recovery, and health signals. */ export declare function createVoyantNodeJobHost(options: CreateVoyantNodeJobHostOptions): VoyantNodeJobHost;