// WHY A CLIP IS REJECTED ON THE WALK (operator, 2026-10-30: "I tend to want to // reject clips not because they don't match, but are irrelevant ... non-matching // being one reason among others"). // // One vocabulary, read by the writer (manifest.mjs patchClipEntry, rejectClip), // `umtool check`, Play the cut, the clip bench, the CLI and the docs. Two kinds // of reason, stored two ways ON PURPOSE, because they mean different things to // the REPORT: // // FACT reasons -- the report got something wrong. `verdict: "incorrect"`, as // it always was: `correction` says what (`umtool corrections` hands it to the // next report pass), and a clip like that still in the cut BLOCKS `umtool // check` (clip-incorrect). // not-matching what is said does not match the quote or claim. The // `incorrect` verdict with no `reason` -- every manifest // written before this file reads exactly as before. // wrong-speaker somebody else is talking (`reason: "wrong-speaker"`). // // CUT reasons -- the report is RIGHT; the clip just does not belong in this // cut. `verdict: "rejected"` + `reason`, with an optional `rejectNote`. Never // a correction: "irrelevant" must not read as "the report is wrong". Still in // the cut, it is an OPEN (not blocking) check row (clip-rejected). // irrelevant accurate, but not relevant to this cut // repeats covered by an earlier clip (the note: which one) // weak accurate and relevant, not strong enough // privacy holds something that must not be published // other anything else -- the note says what (required) /** * @typedef {{ id: string, label: string, fact: boolean, hint: string, note: "required" | "optional", placeholder: string }} RejectReason */ /** @type {readonly RejectReason[]} In menu order: the digit is the index + 1. */ export const REJECT_REASONS = Object.freeze([ { id: "not-matching", label: "doesn't match", fact: true, note: "required", hint: "what is said doesn't match the quote or claim — a correction for the report", placeholder: "what the report got wrong: wording, addressee, date…" }, { id: "wrong-speaker", label: "wrong speaker", fact: true, note: "optional", hint: "somebody else is talking — a correction for the report", placeholder: "who it is, if you know (optional)" }, { id: "irrelevant", label: "irrelevant", fact: false, note: "optional", hint: "accurate, but not relevant to this cut", placeholder: "why, if it helps (optional)" }, { id: "repeats", label: "repeats", fact: false, note: "optional", hint: "covered by an earlier clip", placeholder: "which clip it repeats, e.g. c07 (optional)" }, { id: "weak", label: "weak", fact: false, note: "optional", hint: "accurate and relevant, but not strong enough", placeholder: "what is missing, if it helps (optional)" }, { id: "privacy", label: "privacy", fact: false, note: "optional", hint: "contains something that must not be published (identifying info)", placeholder: "what, so nobody puts it back (optional)" }, { id: "other", label: "other", fact: false, note: "required", hint: "anything else — say what", placeholder: "why it comes out (required)" }, ]); /** The structured reasons an `incorrect` verdict may carry (`reason`). not-matching is the bare verdict. */ export const FACT_REASONS = Object.freeze(["wrong-speaker"]); /** The reasons a `rejected` verdict carries (`reason`, required). */ export const CUT_REASONS = Object.freeze(REJECT_REASONS.filter((r) => !r.fact).map((r) => r.id)); /** Every reason id, both kinds. */ export const REJECT_REASON_IDS = Object.freeze(REJECT_REASONS.map((r) => r.id)); /** @param {string} id */ export const rejectReasonOf = (id) => REJECT_REASONS.find((r) => r.id === id) ?? null; const flat = (v) => (typeof v === "string" ? v.replace(/\s+/g, " ").trim() : ""); /** * Why this clip is rejected, read off the entry -- null when it is not (unreviewed * or confirmed). A legacy `correction` with no verdict is `incorrect`, as * clipVerdict() reads it. * * @param {any} e a timeline entry * @returns {null | { reason: string, label: string, fact: boolean, note: string, why: string }} */ export function rejectionOf(e) { const v = e?.verdict; const correction = flat(e?.correction); if (v === "rejected") { const r = rejectReasonOf(String(e?.reason ?? "")) ?? rejectReasonOf("other"); const note = flat(e?.rejectNote); return { reason: /** @type {RejectReason} */ (r).id, label: /** @type {RejectReason} */ (r).label, fact: false, note, why: note ? `${r?.label}: ${note}` : String(r?.label) }; } if (v === "incorrect" || (v !== "confirmed" && v !== "rejected" && correction)) { const r = e?.reason === "wrong-speaker" ? rejectReasonOf("wrong-speaker") : rejectReasonOf("not-matching"); const note = correction.replace(/[.\s]+$/, ""); return { reason: /** @type {RejectReason} */ (r).id, label: /** @type {RejectReason} */ (r).label, fact: true, note, why: note ? `${r?.label}: ${note}` : String(r?.label) }; } return null; } /** * The clip-entry patch (manifest.mjs patchClipEntry) that rejects a clip for * `reason`, with `note`: a fact reason writes the `incorrect` verdict and the * note as its `correction`; a cut reason writes `rejected` + `reason` + * `rejectNote` (and leaves any correction alone -- a note on a clip whose * facts are right is still only a note). * * @param {string} reason * @param {string | null | undefined} [note] * @returns {Record} */ export function rejectPatch(reason, note) { const r = rejectReasonOf(String(reason ?? "").trim()); if (!r) throw new Error(`a reject reason is one of ${REJECT_REASON_IDS.join(", ")} (got \`${reason}\`)`); const n = String(note ?? "").trim(); if (r.note === "required" && !n) { throw new Error(r.id === "not-matching" ? "doesn't match needs its note: say what the report got wrong" : `${r.label} needs a note: say why it comes out`); } if (r.id === "not-matching") return { verdict: "incorrect", reason: "", correction: n }; if (r.id === "wrong-speaker") return { verdict: "incorrect", reason: "wrong-speaker", ...(n ? { correction: n } : {}) }; return { verdict: "rejected", reason: r.id, rejectNote: n }; } /** * THE WALK'S VERDICT, written onto a clip entry (manifest.mjs patchClipEntry * calls this after the attribution fields, so `correction` is already the * patched one). Mutates `entry`; throws in a sentence on a bad value. * * verdict: "confirmed" -> the description is accurate * verdict: "incorrect" -> it is not (a FACT reason), and `correction` says how * -- or `reason: "wrong-speaker"` stands for the note * verdict: "rejected" -> accurate, but out of this cut: `reason` is one of * CUT_REASONS, `rejectNote` optional (required for other) * neither -> not yet reviewed * * Shorthands, so a CLI `verdict=` says it in one word: a FACT reason * ("not-matching", "wrong-speaker") is `incorrect` + that reason, a CUT reason * is `rejected` + it. A verdict changed to anything else drops the reason and * the rejectNote (a reason goes only with the verdict it explains). * * LEGACY, and deliberately not migrated: a clip carrying a `correction` and no * `verdict` predates `incorrect` and READS as incorrect (clipVerdict()). The * note requirement is keyed on the explicit value, so those entries can still * be cleared. * * @param {Record} entry * @param {Record} patch */ export function applyVerdictPatch(entry, patch) { let reasonIn = patch.reason; if (patch.verdict !== undefined) { let v = String(patch.verdict ?? "").trim(); if (v === "not-matching") { if (reasonIn === undefined) reasonIn = ""; v = "incorrect"; } else if (FACT_REASONS.includes(v)) { if (reasonIn === undefined) reasonIn = v; v = "incorrect"; } else if (CUT_REASONS.includes(v)) { if (reasonIn === undefined) reasonIn = v; v = "rejected"; } if (!v) delete entry.verdict; else if (v !== "confirmed" && v !== "incorrect" && v !== "rejected") { throw new Error( `verdict must be "confirmed", "incorrect", "rejected" or a reject reason (${REJECT_REASON_IDS.join(", ")}), or empty to clear it (got \`${v}\`)`, ); } else entry.verdict = v; if (entry.verdict !== "incorrect" && entry.verdict !== "rejected" && reasonIn === undefined) delete entry.reason; // A reason belongs to the verdict it explains: a fact reason does not survive a move to rejected, nor the reverse. if (reasonIn === undefined && entry.reason) { const fits = entry.verdict === "rejected" ? CUT_REASONS : FACT_REASONS; if (!fits.includes(entry.reason)) delete entry.reason; } } if (reasonIn !== undefined) { let r = String(reasonIn ?? "").trim(); // not-matching IS the bare incorrect verdict: no reason stored. if (r === "not-matching" && entry.verdict === "incorrect") r = ""; const allowed = entry.verdict === "rejected" ? CUT_REASONS : FACT_REASONS; if (!r) delete entry.reason; else if (!allowed.includes(r)) { if (entry.verdict === "rejected") { throw new Error( `a rejected clip's reason must be ${CUT_REASONS.map((x) => `"${x}"`).join(", ")} (got \`${r}\`)` + (FACT_REASONS.includes(r) || r === "not-matching" ? ` — ${r} is a fact error: its verdict is incorrect` : ""), ); } if (entry.verdict === "incorrect" && CUT_REASONS.includes(r)) { throw new Error(`${r} is not a fact error: reject the clip (verdict=${r}) rather than marking it incorrect`); } throw new Error(`reason must be ${FACT_REASONS.map((x) => `"${x}"`).join(", ")}, or empty to clear it (got \`${r}\`); say anything else in the correction`); } else entry.reason = r; } if (patch.rejectNote !== undefined) { const n = String(patch.rejectNote ?? "").trim(); if (n) entry.rejectNote = n; else delete entry.rejectNote; } if (entry.verdict !== "rejected") { if (patch.rejectNote !== undefined && String(patch.rejectNote ?? "").trim()) { throw new Error("a rejectNote goes with a rejected verdict"); } delete entry.rejectNote; } if (entry.reason && entry.verdict !== "incorrect" && entry.verdict !== "rejected") { throw new Error(`a reason (${entry.reason}) goes with an incorrect verdict`); } if (entry.verdict === "incorrect" && !String(entry.correction ?? "").trim() && !entry.reason) { throw new Error("an incorrect verdict needs its note: say what the report got wrong"); } if (entry.verdict === "rejected") { if (!entry.reason) throw new Error(`a rejected verdict needs its reason: ${CUT_REASONS.join(", ")}`); if (entry.reason === "other" && !entry.rejectNote) throw new Error("rejected as other needs a note (rejectNote): say why it comes out"); } }