// File: purge-demo.ts // Path: apps/worker/src/scripts/purge-demo.ts // Project: AI Risk Index — airiskindex.io // Author: Simon-Pierre Boucher // Contact: contact@spboucher.ai // Copyright © 2026 Simon-Pierre Boucher. All rights reserved. // // Description: Removes the demonstration dataset once real ratings exist. import { prisma } from "@airiskindex/db"; // Removes the demonstration dataset (synthetic tasks "XX-XXXX.00-Tn", demo // panel ratings, and score runs computed from demo raters) once real ratings // exist. Demo runs are preview artifacts, not published index history — the // immutability rule (CLAUDE.md §9) applies to real runs. async function main(): Promise { const demoRuns = await prisma.scoreRun.findMany({ where: { raterModels: { hasSome: ["demo-panel-a", "demo-panel-b"] } }, select: { id: true }, }); const runIds = demoRuns.map((run) => run.id); const [taskScores, occScores, runs] = await prisma.$transaction([ prisma.taskScore.deleteMany({ where: { runId: { in: runIds } } }), prisma.occupationScore.deleteMany({ where: { runId: { in: runIds } } }), prisma.scoreRun.deleteMany({ where: { id: { in: runIds } } }), ]); const ratings = await prisma.taskRating.deleteMany({ where: { model: { startsWith: "demo-" } }, }); const tasks = await prisma.task.deleteMany({ where: { id: { contains: "-T" } } }); const occupations = await prisma.occupation.deleteMany({ where: { code: "99-9999.00" } }); console.log( `purged demo artifacts: ${runs.count} runs, ${occScores.count} occupation scores, ${taskScores.count} task scores, ${ratings.count} ratings, ${tasks.count} synthetic tasks, ${occupations.count} synthetic occupations`, ); } main() .catch((error) => { console.error(error); process.exitCode = 1; }) .finally(() => prisma.$disconnect());