commit 3bcceb3cb9a04b958a16ea3d82e167900b5c7da9
parent 01bf7a5ca8f6aed8dbc3206b17fd51532f575ab1
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 10 Nov 2026 16:02:37 -0500
umtool: a review-pass mark is of what was reviewed -- each stores its block's signature (a clip's source, played span and gaps; a post's or a card's fields), and one that no longer matches (an edge moved, a post edited, another version opened into the draft, an id reused) reads as unanswered, "changed since reviewed"; the panel reads the marks again when the draft changes; unit-tested and an e2e -- L7b review item 7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat:
6 files changed, 126 insertions(+), 27 deletions(-)
diff --git a/umtool/app/api/report/review-pass/route.ts b/umtool/app/api/report/review-pass/route.ts
@@ -1,6 +1,6 @@
import { projectRef } from "@/lib/projects";
import { readManifest } from "@/lib/projects/report.mjs";
-import { readReviewPass, setReviewMark } from "@/lib/report/reviewPass.mjs";
+import { marksAgainst, readReviewPass, setReviewMark } from "@/lib/report/reviewPass.mjs";
import { refuseCaller } from "@/lib/report/caller";
import { crossSiteRefusal } from "@/lib/report/sameOrigin.mjs";
@@ -17,7 +17,9 @@ export async function GET(request: Request) {
const url = new URL(request.url);
const project = await projectRef(url.searchParams.get("project") ?? "");
if (!project) return Response.json({ error: "no such project" }, { status: 404 });
- return Response.json(await readReviewPass(project.dir), { headers: { "cache-control": "no-store" } });
+ // The marks against the cut as it is now: a block changed since it was reviewed is `stale` (unanswered again).
+ const [doc, manifest] = await Promise.all([readReviewPass(project.dir), readManifest(project.dir).catch(() => null)]);
+ return Response.json({ ...doc, marks: marksAgainst(doc, manifest) }, { headers: { "cache-control": "no-store" } });
}
export async function POST(request: Request) {
@@ -34,7 +36,7 @@ export async function POST(request: Request) {
const mark = body.mark === null || body.mark === undefined || body.mark === "" ? null : body.mark;
try {
const r = await setReviewMark(project.dir, manifest, body.block, mark as "keep" | "fix" | null, { note: typeof body.note === "string" ? body.note : undefined });
- return Response.json({ ok: true, ...r }, { headers: { "cache-control": "no-store" } });
+ return Response.json({ ok: true, mark: r.mark, doc: { ...r.doc, marks: marksAgainst(r.doc, manifest) } }, { headers: { "cache-control": "no-store" } });
} catch (e) {
return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 });
}
diff --git a/umtool/components/projects/workspace/ReviewPass.tsx b/umtool/components/projects/workspace/ReviewPass.tsx
@@ -9,7 +9,7 @@ import { blockAnswer, clipKeepable, clipVerdict, reviewProgress } from "@/lib/re
import AnchoredNotes from "@/components/notes/AnchoredNotes";
import { useSharedNotes } from "@/components/notes/NotesProvider";
import { writeWalkVerdict } from "../bench/walkVerdict";
-import { announceManifestChanged } from "../timelineApi";
+import { MANIFEST_CHANGED, announceManifestChanged } from "../timelineApi";
import VersionVerdict from "../review/VersionVerdict";
import type { PlayEntry } from "../review/PlayCut";
import { READ_ONLY_SAID } from "./readOnly";
@@ -32,7 +32,8 @@ import { aModalIsOpen } from "@/components/ui/modalOpen";
// ---------------------------------------------------------------------------
export type Answer = { mark: "keep" | "fix" | "ruled"; note: string | null; verdict?: string };
-type Mark = { mark: "keep" | "fix"; note?: string; at: string };
+/** A mark as the server reads it against the cut now: `stale` when its block changed since it was reviewed. */
+type Mark = { mark: "keep" | "fix"; note?: string; at: string; stale?: boolean };
/** The pass's state: the marks (review-pass.json), each block's answer, the progress, and the writers. */
export function useReviewPass(project: string, entries: PlayEntry[], on: boolean, readOnly = false) {
@@ -41,21 +42,28 @@ export function useReviewPass(project: string, entries: PlayEntry[], on: boolean
// A clip's answer as just written, until the draft is read again (MANIFEST_CHANGED) and its verdict is in it.
const [written, setWritten] = useState<Record<string, Answer>>({});
useEffect(() => setWritten({}), [entries]);
+ const marksSeq = useRef(0);
+ const readMarks = useCallback(async () => {
+ const mine = ++marksSeq.current;
+ try {
+ const j = (await (await fetch(`/api/report/review-pass?project=${encodeURIComponent(project)}`, { cache: "no-store" })).json()) as { marks?: Record<string, Mark> };
+ if (mine === marksSeq.current) setMarks(j.marks ?? {});
+ } finally {
+ if (mine === marksSeq.current) setLoaded(true);
+ }
+ }, [project]);
+ useEffect(() => {
+ if (on) void readMarks().catch(() => {});
+ }, [on, readMarks]);
+ // The draft changed (a write here or elsewhere): a mark's block may no longer be what was reviewed -- read again.
useEffect(() => {
if (!on) return;
- let live = true;
- void fetch(`/api/report/review-pass?project=${encodeURIComponent(project)}`, { cache: "no-store" })
- .then((r) => r.json())
- .then((j: { marks?: Record<string, Mark> }) => {
- if (!live) return;
- setMarks(j.marks ?? {});
- setLoaded(true);
- })
- .catch(() => live && setLoaded(true));
- return () => {
- live = false;
+ const onChange = (ev: Event) => {
+ if ((ev as CustomEvent).detail?.project === project) void readMarks().catch(() => {});
};
- }, [project, on]);
+ window.addEventListener(MANIFEST_CHANGED, onChange);
+ return () => window.removeEventListener(MANIFEST_CHANGED, onChange);
+ }, [on, project, readMarks]);
const seen = useMemo(
() =>
@@ -231,6 +239,8 @@ export default function ReviewPass({
setFixText("");
}, [id]);
const answer = id ? (rv.answers.get(id) ?? null) : null;
+ // Marked once, but the block is not what was reviewed any more (an edge, a post's words, another version opened).
+ const changed = !!(id && rv.marks[id]?.stale);
// The bench's ruling on a clip (incorrect: a fact error, wrong speaker), shown and left as it is.
const bench =
entry?.type === "clip" && !clipKeepable(entry)
@@ -340,6 +350,11 @@ export default function ReviewPass({
</span>
)}
</div>
+ {changed && !answer && (
+ <p className="m-0 text-[12px] text-muted" data-review-changed="" title={`marked ${rv.marks[id!]?.mark} before the block changed`}>
+ changed since reviewed
+ </p>
+ )}
{/* A clip the bench ruled (a fact error, wrong speaker): the pass shows it and never overwrites it. */}
{bench && (
<p className="m-0 text-[12px] text-doubt-text" data-review-bench={bench.verdict}>
diff --git a/umtool/e2e/review-pass.spec.ts b/umtool/e2e/review-pass.spec.ts
@@ -250,3 +250,15 @@ test("on a phone (390 px) the pass is a sheet under the viewer, its answers in r
expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true);
await shot(page, "ws-review-phone.png");
});
+
+test("a mark is of what was reviewed: c02's edge moved since its Fix -- \"changed since reviewed\", unanswered, the pass resumes there", async ({ page, request }) => {
+ const tok = ((await (await request.get(`/api/report/clip?project=${encodeURIComponent(P)}&clip=c02`)).json()) as { token: string }).token;
+ const w = await request.put("/api/report/window", { data: { project: P, clip: "c02", token: tok, end: 5.3 } });
+ expect(w.ok(), await w.text()).toBe(true);
+ await page.goto(urls.workspaceHref(P, { mode: "review" }));
+ await expect(pass(page)).toHaveAttribute("data-review-current", "c02", { timeout: 20_000 });
+ await expect(page.locator("[data-review-changed]")).toHaveText("changed since reviewed");
+ await expect(page.locator('[data-ws-block="c02"]')).toHaveAttribute("data-ws-block-review", "");
+ // The mark is still on disk, with what it was of: the answer is gone, not the record.
+ expect(json("review-pass.json").marks.c02).toMatchObject({ mark: "fix", note: "trim the tail" });
+});
diff --git a/umtool/lib/report/reviewPass.mjs b/umtool/lib/report/reviewPass.mjs
@@ -19,6 +19,7 @@
// with no answer.
//
// Plain ESM: the CLI runs under bare node; the app reads the same functions.
+import { createHash } from "node:crypto";
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
import path from "node:path";
import { blockAnswer, reviewBlocks, reviewProgress } from "./reviewPassModel.mjs";
@@ -42,7 +43,7 @@ function clean(raw) {
const marks = raw && typeof raw === "object" && raw.marks && typeof raw.marks === "object" ? raw.marks : {};
for (const [id, m] of Object.entries(marks)) {
if (!m || typeof m !== "object" || !REVIEW_MARKS.includes(m.mark)) continue;
- out.marks[id] = { mark: m.mark, ...(typeof m.note === "string" && m.note.trim() ? { note: m.note } : {}), at: typeof m.at === "string" ? m.at : "" };
+ out.marks[id] = { mark: m.mark, ...(typeof m.note === "string" && m.note.trim() ? { note: m.note } : {}), ...(typeof m.sig === "string" ? { sig: m.sig } : {}), at: typeof m.at === "string" ? m.at : "" };
}
return out;
}
@@ -68,6 +69,44 @@ function serial(file, fn) {
});
}
+/** What the walk and the review pass write on an entry: never part of what was reviewed. */
+const REVIEW_KEYS = new Set(["verdict", "correction", "reason", "rejectNote", "walkNote", "star"]);
+const canon = (v) => (Array.isArray(v) ? v.map(canon) : v && typeof v === "object" ? Object.fromEntries(Object.keys(v).sort().map((k) => [k, canon(v[k])])) : v);
+
+/**
+ * WHAT WAS REVIEWED, as a signature stored with each mark: a clip's source, the span it plays and its gaps; a post's
+ * or a card's every field but its id (and the review's own). A mark whose block no longer signs the same -- an edge
+ * moved, a post edited, another version opened into the draft, an id reused -- is "changed since reviewed":
+ * unanswered again.
+ *
+ * @param {Record<string, any>} e a timeline entry
+ */
+export function entrySignature(e) {
+ const what =
+ e?.type === "clip"
+ ? { type: "clip", channel: e.channel ?? null, video: e.video ?? null, src: e.src ?? null, from: e.cutStart ?? e.start ?? null, to: e.cutEnd ?? e.end ?? null, gaps: e.gaps ?? null }
+ : Object.fromEntries(Object.entries(e ?? {}).filter(([k]) => k !== "id" && !REVIEW_KEYS.has(k)));
+ return createHash("sha256").update(JSON.stringify(canon(what))).digest("hex").slice(0, 16);
+}
+
+/**
+ * The marks as they stand against the cut now: each with `stale: true` when its block is gone or no longer signs
+ * what was reviewed (a mark from before signatures is stale too). The model (reviewPassModel.mjs) reads a stale
+ * mark as no answer.
+ *
+ * @param {ReviewPassDoc} doc
+ * @param {{ timeline?: Array<Record<string, any>> } | null} manifest
+ */
+export function marksAgainst(doc, manifest) {
+ const byId = new Map((manifest?.timeline ?? []).filter((e) => e && typeof e.id === "string").map((e) => [e.id, e]));
+ return Object.fromEntries(
+ Object.entries(doc.marks).map(([id, m]) => {
+ const e = byId.get(id);
+ return [id, { ...m, ...(!e || !m.sig || m.sig !== entrySignature(e) ? { stale: true } : {}) }];
+ }),
+ );
+}
+
/** The timeline entry kinds the pass marks here (a clip: its Fix and its clearing; its Keep is its walk verdict). */
const MARKED_HERE = new Set(["clip", "post", "card", "teaser", "video"]);
@@ -96,7 +135,7 @@ export async function setReviewMark(dir, manifest, block, mark, { note, now = ne
return serial(file, async () => {
const doc = await readReviewPass(dir);
if (mark === null) delete doc.marks[block];
- else doc.marks[block] = { mark, ...(text ? { note: text } : {}), at: now.toISOString() };
+ else doc.marks[block] = { mark, ...(text ? { note: text } : {}), sig: entrySignature(e), at: now.toISOString() };
await mkdir(dir, { recursive: true });
const tmp = `${file}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
await writeFile(tmp, JSON.stringify(doc, null, 2) + "\n", "utf8");
@@ -175,8 +214,9 @@ export async function reviewPassCommand(args, { resolve, log = console.log, err
}
const doc = await readReviewPass(p.dir);
const timeline = Array.isArray(manifest.timeline) ? manifest.timeline : [];
- const prog = reviewProgress(timeline, doc.marks);
- const rows = reviewBlocks(timeline).map((e) => ({ id: e.id, type: e.type, answer: blockAnswer(e, doc.marks) }));
+ const marks = marksAgainst(doc, manifest);
+ const prog = reviewProgress(timeline, marks);
+ const rows = reviewBlocks(timeline).map((e) => ({ id: e.id, type: e.type, answer: blockAnswer(e, marks), ...(marks[e.id]?.stale ? { changed: true } : {}) }));
if (json) {
log(JSON.stringify({ project: p.id, done: prog.done, total: prog.total, next: prog.next, blocks: rows }, null, 2));
return 0;
@@ -184,7 +224,7 @@ export async function reviewPassCommand(args, { resolve, log = console.log, err
log(`${p.id}: ${prog.done} / ${prog.total} reviewed${prog.next ? ` · resumes at ${prog.next}` : " · every block answered: the verdict is next"}`);
for (const r of rows) {
const a = r.answer;
- const said = !a ? "—" : a.mark === "fix" ? "needs work" : a.mark === "ruled" ? `${a.verdict} (the bench)` : a.mark;
+ const said = !a ? (r.changed ? "— changed since reviewed" : "—") : a.mark === "fix" ? "needs work" : a.mark === "ruled" ? `${a.verdict} (the bench)` : a.mark;
log(` ${r.id === prog.next ? "→" : " "} ${r.id.padEnd(10)} ${String(r.type).padEnd(6)} ${said}${a?.note ? ` ${a.note}` : ""}`);
}
return 0;
diff --git a/umtool/lib/report/reviewPass.test.mjs b/umtool/lib/report/reviewPass.test.mjs
@@ -6,7 +6,7 @@ import { mkdtempSync, readFileSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";
import { clipKeepable } from "./reviewPassModel.mjs";
-import { blockAnswer, readReviewPass, reviewBlocks, reviewPassCommand, reviewProgress, setReviewMark, REVIEW_PASS_FILE } from "./reviewPass.mjs";
+import { blockAnswer, entrySignature, marksAgainst, readReviewPass, reviewBlocks, reviewPassCommand, reviewProgress, setReviewMark, REVIEW_PASS_FILE } from "./reviewPass.mjs";
const timeline = [
{ type: "clip", id: "c01", verdict: "confirmed" },
@@ -46,14 +46,14 @@ test("the store: a post's mark written and cleared; a clip, an unknown block and
const m = { timeline };
assert.deepEqual((await readReviewPass(dir)).marks, {});
const r = await setReviewMark(dir, m, "p-5", "fix", { note: " the crop cuts his face ", now: new Date("2026-11-10T10:00:00Z") });
- assert.deepEqual(r.mark, { mark: "fix", note: "the crop cuts his face", at: "2026-11-10T10:00:00.000Z" });
+ assert.deepEqual(r.mark, { mark: "fix", note: "the crop cuts his face", sig: entrySignature(timeline[2]), at: "2026-11-10T10:00:00.000Z" });
await setReviewMark(dir, m, "k01", "keep");
assert.deepEqual(Object.keys((await readReviewPass(dir)).marks).sort(), ["k01", "p-5"]);
await setReviewMark(dir, m, "k01", null);
assert.deepEqual(Object.keys(JSON.parse(readFileSync(path.join(dir, REVIEW_PASS_FILE), "utf8")).marks), ["p-5"]);
await assert.rejects(setReviewMark(dir, m, "c04", "keep"), /walk verdict/);
// A clip's Fix and its clearing are marks: its verdict is untouched.
- assert.deepEqual((await setReviewMark(dir, m, "c04", "fix", { note: "trim the tail", now: new Date("2026-11-10T11:00:00Z") })).mark, { mark: "fix", note: "trim the tail", at: "2026-11-10T11:00:00.000Z" });
+ assert.deepEqual((await setReviewMark(dir, m, "c04", "fix", { note: "trim the tail", now: new Date("2026-11-10T11:00:00Z") })).mark, { mark: "fix", note: "trim the tail", sig: entrySignature(timeline[5]), at: "2026-11-10T11:00:00.000Z" });
assert.equal((await setReviewMark(dir, m, "c04", null)).mark, null);
await assert.rejects(setReviewMark(dir, m, "nope", "keep"), /no block/);
await assert.rejects(setReviewMark(dir, m, "k01", "fix"), /what needs work/);
@@ -84,3 +84,32 @@ test("umtool review-pass: ls says where it resumes; mark writes a card's", async
rmSync(dir, { recursive: true, force: true });
}
});
+
+test("a mark is of what was reviewed: an edge moved, a post edited, an id reused -- changed since reviewed, unanswered", async () => {
+ const dir = mkdtempSync(path.join(tmpdir(), "review-pass-sig-"));
+ try {
+ const tl = [
+ { type: "clip", id: "c1", video: "v", start: 1, end: 3, verdict: "confirmed" },
+ { type: "post", id: "p1", post: "x/1", text: "the scale said 291" },
+ { type: "card", id: "k1", heading: "Between", seconds: 1.5 },
+ ];
+ for (const [id, mark] of [["c1", "fix"], ["p1", "keep"], ["k1", "keep"]]) await setReviewMark(dir, { timeline: tl }, id, mark, { note: mark === "fix" ? "trim" : undefined });
+ const doc = await readReviewPass(dir);
+ const same = marksAgainst(doc, { timeline: tl });
+ assert.deepEqual(Object.values(same).map((m) => !!m.stale), [false, false, false]);
+ // The walk's own fields are not what was reviewed: a verdict or a note added since changes nothing.
+ assert.equal(marksAgainst(doc, { timeline: tl.map((e) => ({ ...e, walkNote: "ok", star: true })) }).c1.stale, undefined);
+ const moved = [{ ...tl[0], cutEnd: 2.5 }, { ...tl[1], text: "the scale said 290" }, { type: "teaser", id: "k1", lines: ["reused"] }];
+ const now = marksAgainst(doc, { timeline: moved });
+ assert.deepEqual([now.c1.stale, now.p1.stale, now.k1.stale], [true, true, true]);
+ // Stale is no answer: the clip falls back to its verdict, the post and the card are unanswered.
+ assert.deepEqual(blockAnswer(moved[0], now), { mark: "keep", note: null });
+ assert.equal(blockAnswer(moved[1], now), null);
+ assert.equal(reviewProgress(moved, now).next, "p1");
+ // A block gone: its mark is stale; a mark from before signatures too.
+ assert.equal(marksAgainst(doc, { timeline: [] }).c1.stale, true);
+ assert.equal(marksAgainst({ version: 1, marks: { c1: { mark: "keep", at: "" } } }, { timeline: tl }).c1.stale, true);
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
diff --git a/umtool/lib/report/reviewPassModel.mjs b/umtool/lib/report/reviewPassModel.mjs
@@ -3,7 +3,7 @@
export const REVIEW_MARKS = /** @type {const} */ (["keep", "fix"]);
-/** @typedef {{ mark: "keep" | "fix", note?: string, at: string }} ReviewMark */
+/** @typedef {{ mark: "keep" | "fix", note?: string, sig?: string, at: string, stale?: boolean }} ReviewMark */
/**
* What the pass walks, from either shape of an entry: the play view's (`type`, `review.verdict`) or the
@@ -34,8 +34,9 @@ export function reviewBlocks(entries) {
* @returns {{ mark: "keep" | "fix" | "ruled", note: string | null, verdict?: string } | null}
*/
export function blockAnswer(e, marks) {
+ // A mark whose block changed since it was reviewed (`stale`, reviewPass.mjs marksAgainst) is no answer.
const m = marks?.[e.id];
- if (m) return { mark: m.mark, note: m.note ?? null };
+ if (m && !m.stale) return { mark: m.mark, note: m.note ?? null };
if (e.type !== "clip") return null;
const v = clipVerdict(e);
if (v === "confirmed") return { mark: "keep", note: null };