/**
 * BullMQ 队列名常量 — 单一真理源。
 *
 * 命名规则:`<domain>-<verb>`,小写连字符。
 *   - persona-recompute:   重算单 patient persona 版本(jobName = patientId 串行)
 *   - plan-recompute:      重算单 patient followup plans(jobName = patientId 串行)
 *   - plan-asset-generate: 生成 PlanScript + PlanSummary(jobName = planId 串行)
 *
 * 三个队列各自 jobName 锁 per-queue,跨队列允许并发(数据依赖天然)。
 * 详见 docs/three-layer-model.md "事件驱动主路径"。
 */
export const QueueName = {
  PERSONA_RECOMPUTE: 'persona-recompute',
  PLAN_RECOMPUTE: 'plan-recompute',
  PLAN_ASSET_GENERATE: 'plan-asset-generate',
} as const;
export type QueueName = (typeof QueueName)[keyof typeof QueueName];

/**
 * 各队列默认重试 / 退避策略。
 */
export const QueueDefaults = {
  [QueueName.PERSONA_RECOMPUTE]: {
    attempts: 3,
    backoff: { type: 'exponential', delay: 1_000 }, // 1s / 5s / 25s
    removeOnComplete: { count: 200 },
    removeOnFail: { count: 1_000 },
  },
  [QueueName.PLAN_RECOMPUTE]: {
    attempts: 3,
    backoff: { type: 'exponential', delay: 1_000 },
    removeOnComplete: { count: 200 },
    removeOnFail: { count: 1_000 },
  },
  [QueueName.PLAN_ASSET_GENERATE]: {
    /**
     * AI 调用贵,只重试 2 次;还失败则 fallback 到模板兜底(processor 内部处理)
     */
    attempts: 2,
    backoff: { type: 'exponential', delay: 5_000 }, // 5s / 25s
    removeOnComplete: { count: 200 },
    removeOnFail: { count: 1_000 },
  },
} as const;
