import type { NodePgDatabase } from "drizzle-orm/node-postgres"; import type { RunRecord } from "../domain.js"; export type AdmissionTransaction = Parameters[0]>[0]; export interface AdmissionHistory { record: RunRecord; attempt: number; } export declare function hasActiveAttempt(runs: RunRecord[]): boolean; export declare function nextAttempt(history: AdmissionHistory[]): number; /** * Steps shared by every transaction that admits a Run attempt: the project lock * that serializes competing admissions, task history, and redacted persistence * with its events. */ export declare class RunAdmission { private readonly scope; private readonly redact; constructor(scope: string, redact: (text: string) => string); private projectPredicate; /** Lock the project, not just a task: admissions for one project must compete. */ lockProject(tx: AdmissionTransaction, projectId: string): Promise<{ scope: string; id: string; paused: boolean; blocked: string | null; }>; /** Every attempt of a task in attempt order, locked for this admission. */ history(tx: AdmissionTransaction, taskKey: string): Promise; projectRuns(tx: AdmissionTransaction, projectId: string): Promise; /** * Persist a new attempt redacted, optionally lift the project block, and * record its events. A conflict fails admission; it never returns an * unpersisted run. */ insert(tx: AdmissionTransaction, run: RunRecord, options: { unblock: boolean; events?: Array<{ kind: string; payload: unknown; }>; }): Promise; }