// File: job-id.ts // Path: apps/worker/src/raters/job-id.ts // Project: AI Risk Index — airiskindex.io // Author: Simon-Pierre Boucher // Contact: contact@spboucher.ai // Copyright © 2026 Simon-Pierre Boucher. All rights reserved. // // Description: Deterministic rating job/custom IDs (idempotent batches). import { createHash } from "node:crypto"; /** * Deterministic ID used both as the BullMQ job ID and the Message Batches * `custom_id`, so retries and batch reconciliation are idempotent * (CLAUDE.md §6; docs/research/03-llm-rater-api.md). One request rates all * dimensions of one task with one model. */ export function ratingJobId(taskId: string, model: string, promptVersion: string): string { return createHash("sha256") .update(`${taskId}:${model}:${promptVersion}`) .digest("hex") .slice(0, 32); }