export function triggerReview(params, deps) {
    const { queuePort, reviewRequestTrackingGateway, logger } = deps;
    const jobIdPrefix = params.jobType === 'followup'
        ? `${params.platform}-followup`
        : params.platform;
    const jobId = queuePort.createJobId(jobIdPrefix, params.projectPath, params.reviewRequestNumber);
    if (queuePort.hasActiveJob(jobId)) {
        logger.info({ jobId }, 'Review already in progress, deduplicating');
        return { status: 'deduplicated', reason: 'Review already in progress' };
    }
    const job = {
        id: jobId,
        platform: params.platform,
        projectPath: params.projectPath,
        localPath: params.localPath,
        mrNumber: params.reviewRequestNumber,
        skill: params.skill,
        mrUrl: params.mrUrl,
        sourceBranch: params.sourceBranch,
        targetBranch: params.targetBranch,
        jobType: params.jobType,
        language: params.language,
        title: params.title,
        assignedBy: params.assignedBy,
    };
    const enqueued = queuePort.enqueue(job);
    if (!enqueued) {
        logger.warn({ jobId }, 'Failed to enqueue job');
        return { status: 'failed', reason: 'Queue full or job rejected' };
    }
    reviewRequestTrackingGateway.recordPush(params.localPath, params.reviewRequestNumber, params.platform);
    logger.info({ jobId, reviewRequestNumber: params.reviewRequestNumber, jobType: params.jobType }, 'Review triggered');
    return { status: 'success', jobId };
}
//# sourceMappingURL=triggerReview.usecase.js.map