import { NextResponse } from "next/server"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { VERDICT_REVIEW_BODY_KEYS, reviewProposal } from "yt-dlp-transcript-common/controller/reportVerdicts"; import { VerdictProposalsError } from "yt-dlp-transcript-common/lib/report/verdictProposals"; import { ArticleRegistryError } from "yt-dlp-transcript-common/lib/report/registry"; import { opsFail, ops } from "../_lib"; export const dynamic = "force-dynamic"; // POST { article, claim, decision: "approve" | "reject", verdict, at, note? } // -> { ok: true, proposal: {claim, verdict, reason, model, promptVersion, at, status, note?, reviewedAt} } // // The operator's review of one verdict PROPOSAL (release 29 M8): a model's // proposed verdict for an unruled fact-check claim, kept in // `reports/
/verdicts.proposed.json` (never report.json). A // COMPARE-AND-SET: `verdict` and `at` are the proposal the operator was shown; // one replaced since, reviewed already, or whose claim changed (its // fingerprint) or was ruled meanwhile is refused 409. Approve // sets the claim's `verdict` to the proposal's through the registry's // patchArticle, then marks the proposal approved; reject marks it rejected // and leaves the claim unruled. Synchronous. 404 no such proposal; 409 one // reviewed already, a claim ruled meanwhile, or a sidecar that does not read. // // AN ADAPTER: the rules are the controller's (controller/reportVerdicts.ts, // lib/report/verdictProposals.ts). export async function POST(request: Request) { return ops(request, VERDICT_REVIEW_BODY_KEYS, async (body) => { try { const proposal = await reviewProposal(body, { paths: getPaths() }); return NextResponse.json({ ok: true, proposal }); } catch (e) { if (e instanceof VerdictProposalsError) return opsFail(e.message, e.status); if (e instanceof ArticleRegistryError) return opsFail(e.message, 409); throw e; } }); }