import type { JobDefinition } from './job-definition.types';

/**
 * M-AI-04-02: Active Recall Job Definition（冻结）
 *
 * 对应迁移契约 docs/architecture/m-ai-04-active-recall-migration-contract.md
 *
 * 字段取值来源：
 * - promptKey/promptVersion: 复用现有 active-recall-analysis prompt
 * - model: deepseek-v4-pro, primary tier（与当前 AiGateway 一致）
 * - input.schemaVersion: active-recall-v1（契约 §3）
 * - output.schemaVersion: active-recall-v1（契约 §4）
 * - timeoutMs: 120000（2min，与旧 ai-analysis 链路 DefaultJobOptions 一致）
 * - maxRetries: 3（与旧链路一致）
 * - cancellable: true（支持用户取消进行中的分析）
 */

export const ACTIVE_RECALL_JOB_DEFINITION: JobDefinition = {
  jobType: 'active_recall',

  metadata: {
    label: 'Active Recall Analysis',
    description:
      'Analyze user\'s active recall answer against the original knowledge point. ' +
      'Generates score, mastery level, strengths, weaknesses, focus items, and review suggestions.',
    domain: 'analysis',
    version: '1.0.0',
  },

  queue: {
    queueName: 'ai-interactive',
    defaultPriority: 0,
  },

  execution: {
    timeoutMs: 120_000,       // 2 min — AI analysis + validation + projection
    maxRetries: 3,            // Match legacy ai-analysis queue default
    retryBackoff: { type: 'exponential', delay: 1000 },
    cancellable: true,
    abortStrategy: 'fail',    // Fail the job on timeout; retry logic handles retry
  },

  input: {
    schemaVersion: 'active-recall-v1',
  },

  output: {
    schemaVersion: 'active-recall-v1',
  },

  prompt: {
    promptKey: 'active-recall-analysis',
    promptVersion: '1.0.0',
  },

  model: {
    modelTier: 'primary',
    modelProvider: 'deepseek',
    modelName: 'deepseek-v4-pro',
    maxTokens: 4096,
  },

  credential: {
    allowedModes: ['platform_key'],
    defaultMode: 'platform_key',
  },

  projectorKey: 'active_recall_projector',

  security: {
    contentSafetyCheck: true,
    outputRedaction: false,
  },
};
