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

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

export const FEYNMAN_JOB_DEFINITION: JobDefinition = {
  jobType: 'feynman_evaluation',

  metadata: {
    label: 'Feynman Evaluation',
    description:
      'Evaluate a user\'s Feynman explanation of a knowledge item. ' +
      'Analyzes the explanation quality across 6 dimensions: simplicity, analogies, ' +
      'terminology, beginner-friendliness, blind spots, and completeness. ' +
      'Generates score, strengths, weaknesses, suggestions, and focus items.',
    domain: 'analysis',
    version: '1.0.0',
  },

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

  execution: {
    timeoutMs: 180_000,       // 3 min — matches legacy ai-analysis task-type config
    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: 'feynman-evaluation-v1',
  },

  output: {
    schemaVersion: 'feynman-evaluation-v1',
  },

  prompt: {
    promptKey: 'feynman-evaluation',
    promptVersion: '1.0.0',
  },

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

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

  projectorKey: 'feynman_evaluation_projector',

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