/**
 * Contract between `apps/api`'s `/internal/tech-steps/*` routes
 * (`modules/internal/tech-step-worker.routes.ts`) and
 * `services/tech-step-llm-worker` — a process outside this monorepo with no
 * Prisma access of its own (see that service's own README). Deliberately
 * kept separate from `types/recipe.ts`/`schemas/recipe.ts`: this is an
 * internal machine-to-machine protocol, not part of the `apps/web` API
 * contract those files describe, even though it references the same
 * `TechStep` catalog.
 */

/** One low-confidence clause `GET /internal/tech-steps/audit-batch` found by re-running `techStepClassifier.classifyClauses` against a sample of existing `Step`s — see `TechStepClauseClassification` in `tech-step-matcher.ts` for what "low-confidence" means here. */
export interface TechStepAuditClauseView {
  stepId: number;
  recipeId: number;
  clauseText: string;
  /** The NER anchor's own implied technique key, if the clause had one — `null` means the clause matched no known technique's vocabulary at all, yet still scored high enough elsewhere to be worth a second opinion. */
  anchorKey: string | null;
  /** The classifier's own top guess for this clause's technique, `null` if it found none. */
  intentKey: string | null;
  score: number;
  locale: string;
}

/** One not-yet-processed correction `GET /internal/tech-steps/pending-corrections` returns — the worker's raw material for its "transform corrections into training suggestions" job. `clauseText` is the corrected span's own text (`Step.description.slice(start, end)`), resolved server-side since the worker never reads `Step` rows directly. */
export interface PendingTechStepCorrectionView {
  id: number;
  stepId: number;
  recipeId: number;
  clauseText: string;
  start: number;
  end: number;
  previousTechStepKey: string | null;
  correctedTechStepKey: string | null;
}

/** Where a `TechStepTrainingSuggestion` came from — mirrors the `sourceType` column in schema.prisma (kept as a plain string column there, not a Prisma enum, so a future source doesn't need a migration to add). */
export type TrainingSuggestionSourceType = "correction" | "llm_audit";
