import PQueue from 'p-queue';
import type { Logger } from 'pino';
import type { ReviewProgress, ProgressEvent } from '../../modules/review-execution/entities/progress/progress.type.js';
import type { Language } from '../../modules/shared-kernel/entities/language/language.schema.js';
import type { ClaudeModelName } from '../../modules/review-execution/entities/modelRouting/modelRouting.schema.js';
export interface ReviewJob {
    id: string;
    platform: 'gitlab' | 'github';
    projectPath: string;
    localPath: string;
    mrNumber: number;
    skill: string;
    mrUrl: string;
    sourceBranch: string;
    targetBranch: string;
    jobType?: 'review' | 'followup';
    language?: Language;
    model?: ClaudeModelName;
    title?: string;
    description?: string;
    assignedBy?: {
        username: string;
        displayName?: string;
    };
    author?: {
        username: string;
        displayName?: string;
    };
    sizeMetrics?: {
        additions: number | null;
        deletions: number | null;
        filesChanged: number | null;
    };
    sourceForkCloneUrl?: string;
}
export interface JobStatus {
    job: ReviewJob;
    status: 'queued' | 'running' | 'completed' | 'failed';
    startedAt?: Date;
    completedAt?: Date;
    error?: string;
    progress?: ReviewProgress;
}
export type ProgressChangeCallback = (jobId: string, progress: ReviewProgress, event?: ProgressEvent) => void;
export type StateChangeCallback = () => void;
export type PersistJobRecordCallback = (jobStatus: JobStatus, abortSignalAborted: boolean) => Promise<void>;
export declare function __getMrChainsSize(): number;
export declare function setProjectConcurrencyCap(projectPath: string, cap: number): void;
export declare function setGlobalConcurrency(value: number): void;
export declare function getRunningCount(): number;
export declare function getTotalCapacity(): number;
export declare function __resetProjectConcurrencyState(): void;
export declare function initQueue(log: Logger): PQueue;
export declare function getQueue(): PQueue;
/**
 * Check if a job should be deduplicated
 */
export declare function shouldDeduplicate(jobId: string): boolean;
/**
 * Mark a job as recently processed
 */
export declare function markJobProcessed(jobId: string): void;
/**
 * Clear deduplication entry for a job (allows retry after failure)
 */
export declare function clearJobDeduplication(jobId: string): void;
/**
 * Create a unique job ID
 */
export declare function createJobId(platform: string, projectPath: string, mrNumber: number): string;
/**
 * Add a review job to the queue
 * @param job - The review job to add
 * @param processor - Function to process the job, receives AbortSignal for cancellation
 */
export declare function enqueueReview(job: ReviewJob, processor: (job: ReviewJob, signal: AbortSignal) => Promise<void>): Promise<boolean>;
/**
 * Get job status by ID
 */
export declare function getJobStatus(jobId: string): 'queued' | 'running' | 'completed' | 'failed' | null;
/**
 * Cancel a running or queued job
 * @returns true if the job was found and cancelled, false otherwise
 */
export declare function cancelJob(jobId: string): boolean;
/**
 * Get queue stats
 */
export declare function getQueueStats(): {
    size: number;
    pending: number;
    recentJobs: number;
};
/**
 * Get detailed status of all jobs
 */
export declare function getJobsStatus(): {
    active: Array<{
        id: string;
        mrNumber: number;
        project: string;
        mrUrl: string;
        status: string;
        startedAt?: string;
        progress?: ReviewProgress;
        title?: string;
        description?: string;
        assignedBy?: {
            username: string;
            displayName?: string;
        };
        author?: {
            username: string;
            displayName?: string;
        };
        sizeMetrics?: {
            additions: number | null;
            deletions: number | null;
            filesChanged: number | null;
        };
        jobType?: 'review' | 'followup';
    }>;
    recent: Array<{
        id: string;
        mrNumber: number;
        project: string;
        mrUrl: string;
        status: string;
        startedAt?: string;
        completedAt?: string;
        error?: string;
        progress?: ReviewProgress;
        title?: string;
        assignedBy?: {
            username: string;
            displayName?: string;
        };
        author?: {
            username: string;
            displayName?: string;
        };
        sizeMetrics?: {
            additions: number | null;
            deletions: number | null;
            filesChanged: number | null;
        };
        jobType?: 'review' | 'followup';
    }>;
};
/**
 * Update job progress
 */
export declare function updateJobProgress(jobId: string, progress: ReviewProgress, event?: ProgressEvent): void;
/**
 * Set the progress change callback
 */
export declare function setProgressChangeCallback(callback: ProgressChangeCallback | null): void;
/**
 * Set the state change callback (called when jobs are added/completed/failed)
 */
export declare function setStateChangeCallback(callback: StateChangeCallback | null): void;
/**
 * Set the persist job record callback (SPEC-176).
 * Fired in the completion finally block; the queue never awaits the returned
 * promise. Implementations must swallow their own errors.
 */
export declare function setPersistJobRecordCallback(callback: PersistJobRecordCallback | null): void;
/**
 * Seed the in-memory completed jobs list at startup (SPEC-176).
 * Records beyond MAX_COMPLETED_JOBS are dropped. Insertion order is preserved.
 */
export declare function replaceCompletedJobs(records: JobStatus[]): void;
/**
 * Get progress for a specific job
 */
export declare function getJobProgress(jobId: string): ReviewProgress | undefined;
//# sourceMappingURL=pQueueAdapter.d.ts.map