commit 8fb03d65dcd8df0dc7b69889b78c19dd0dccfc17
parent aa9f0d4876c40ad822ca64bef60d82c501d4ea9f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sun, 1 Nov 2026 11:52:00 -0500
umtool bench: a window save refused for a stamp's second (claim.at, a mark's at) or the mute mark outside the new window offers the fix -- Move the stamp to <first second / nearest> (its words), Clear the stamp's second -- as the same save again, in one write; umtool window … --move-stamp first|nearest|<s> / --clear-stamp / --move-mute nearest / --clear-mute
The operator shrinking g01: "could not save: the stamp's second (claim.at 5859)
must lie inside the window 5862.94–5872.35 — widen the window, or clear
claim.at" -- "there should probably be a 'clear claim.at' button".
- manifest.mjs: the refusal is a MarksOutside (the sentence as it was) naming
each second and where each fix would put it: the first second that plays
(the cut, else the extent) or the nearest, never inside a gap. `markFix`
(first | nearest | <s> | clear) and `muteFix` (nearest | clear) on the same
patch apply the fix inside the one write.
- PUT /api/report/window: markFix/muteFix whitelisted; the 400 carries
`outside`. The bench keeps the refused patch and shows the fixes beside the
note, each with the words the stamp would land on; the unsaved trim is never
lost ("keep editing").
- The cite and its QR already follow a moved edge (citeFollow.mjs, U1).
- Not covered: an effect's seconds (fx punchIn, zoom.at, speakers' at) refused
by validateFxEntries keep their sentence and no button.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 198 insertions(+), 5 deletions(-)
diff --git a/umtool/app/api/report/window/route.ts b/umtool/app/api/report/window/route.ts
@@ -1,5 +1,5 @@
import { withEditNotes } from "@/lib/report/guard";
-import { StaleToken, updateClip } from "@/lib/report/manifest.mjs";
+import { MarksOutside, StaleToken, updateClip } from "@/lib/report/manifest.mjs";
import { updateTakeClip } from "@/lib/report/takeEdit.mjs";
import { resolveClip } from "@/lib/report/serve.mjs";
import { refuseCaller } from "@/lib/report/caller";
@@ -59,6 +59,12 @@ export async function PUT(request: Request) {
// plays on, in source seconds; empty or null clears it. Checked by the
// writer against the clip's window, like the cut.
"muteFrom",
+ // The fix for a window save refused because a stamp's second (claim.at, a mark's at) or the
+ // mute mark would fall outside the new window, retried in the same write: "first" | "nearest"
+ // | a source second | "clear" (markFix), "nearest" | "clear" (muteFix). The refusal (400)
+ // carries `outside` -- each mark's second and where the fixes would put it.
+ "markFix",
+ "muteFix",
// The clip this one re-plays on purpose (a callback, a flash-forward), so
// their overlap is not flagged or trimmed; empty or null clears it.
"repeatOf",
@@ -124,6 +130,9 @@ export async function PUT(request: Request) {
{ status: 409 },
);
}
+ if (e instanceof MarksOutside) {
+ return Response.json({ error: e.message, outside: { kind: e.kind, window: e.window, marks: e.marks } }, { status: 400 });
+ }
return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 });
}
}
diff --git a/umtool/bin/umtool.mjs b/umtool/bin/umtool.mjs
@@ -796,6 +796,9 @@ function usage() {
" takes it out, on record): not-matching|wrong-speaker (fact errors: incorrect, the note its",
" correction) or irrelevant|repeats|weak|privacy|other (rejected; other needs --note)",
" --cut-start S --cut-end E --lock-cut the cut the video renders",
+ " --move-stamp first|nearest|<s> | --clear-stamp with --start/--end: a stamp's second (claim.at,",
+ " a mark's at) the new window would leave outside moves to the first second that plays, the nearest,",
+ " or <s>, or loses its at -- in the same write; --move-mute nearest | --clear-mute the mute mark's",
" --gap FROM-TO (repeatable) cut those source seconds out of the clip's middle: it plays",
" as ONE segment of jump cuts (gaps.mjs; inside the cut, ≥ 0.2 s, 0.5 s kept between);",
" --gap-remove S the gap holding source second S · --gaps 'A-B,C-D' the whole list ('' clears)",
@@ -1090,6 +1093,24 @@ async function cmdWindow() {
if (has(`--no-${flag.slice(2)}`)) patch[key] = false;
}
if (val("--note") !== undefined) patch.note = val("--note");
+ // A window edit refused because a stamp's second (or the mute mark) would fall outside it:
+ // the fix in the same write (manifest.mjs MarksOutside) -- the stamp to the first second
+ // that plays, the nearest one or a named second, or its `at` cleared; the mute mark to the
+ // nearest second, or cleared.
+ if (val("--move-stamp") !== undefined) {
+ const v = String(val("--move-stamp"));
+ if (!["first", "nearest"].includes(v) && !Number.isFinite(Number(v))) die(`--move-stamp ${v}: first, nearest or a source second`);
+ patch.markFix = v === "first" || v === "nearest" ? v : Number(v);
+ }
+ if (has("--clear-stamp")) {
+ if (patch.markFix !== undefined) die("--move-stamp or --clear-stamp, not both");
+ patch.markFix = "clear";
+ }
+ if (val("--move-mute") !== undefined) {
+ if (String(val("--move-mute")) !== "nearest") die("--move-mute nearest (the mute mark to the nearest second the clip plays)");
+ patch.muteFix = "nearest";
+ }
+ if (has("--clear-mute")) patch.muteFix = "clear";
// Gaps inside the clip (gaps.mjs): seconds taken out of its middle, so it
// renders as one segment of jump cuts. `--gap` adds one (repeatable),
// `--gap-remove S` takes out the gap holding S, `--gaps` sets the list
@@ -1231,9 +1252,17 @@ async function cmdWindow() {
: ` (generated by ${editNotes.generatedBy}; nothing changed)`,
);
}
+ if (patch.markFix !== undefined) console.log(` stamp: ${patch.markFix === "clear" ? "its second cleared" : `moved (${patch.markFix})`} — ${JSON.stringify(res.entry.claims ?? res.entry.claim ?? null)}`);
+ if (patch.muteFix !== undefined) console.log(` mute mark: ${res.entry.muteFrom ?? "cleared"}`);
console.log(`\nRun resolve-windows to see whether the widener agrees:`);
console.log(` node umtool/report-to-video/resolve-windows.mjs ${p.dir}/video.manifest.json`);
} catch (e) {
+ // A stamp (or the mute mark) left outside the new window: say the fixes, in this command's words.
+ if (e?.name === "MarksOutside" && Array.isArray(e.marks)) {
+ const m = e.marks[0];
+ const flag = e.kind === "mute" ? ["--move-mute nearest", "--clear-mute"] : [`--move-stamp first (${m.first})`, `--move-stamp nearest (${m.nearest})`, "--clear-stamp"];
+ die(`${e.message}\n or in the same write: add ${flag.join(", or ")}`);
+ }
die(e?.message ?? String(e));
}
}
diff --git a/umtool/components/projects/ClipBench.tsx b/umtool/components/projects/ClipBench.tsx
@@ -577,6 +577,11 @@ export default function ClipBench({
playheadRef.current = playhead;
}, [playhead]);
const [note, setNote] = useState<string | null>(null);
+ // A window save refused because a stamp's second (or the mute mark) would fall outside the new
+ // window (manifest.mjs MarksOutside): the refused patch, kept to retry with the fix the
+ // operator picks -- the unsaved trim is never lost.
+ type Outside = { kind: "mark" | "mute"; window: { start: number; end: number }; marks: { index: number | null; id: string | null; at: number; first: number; nearest: number }[] };
+ const [fix, setFix] = useState<{ patch: Record<string, unknown>; outside: Outside } | null>(null);
const [busy, setBusy] = useState<string | null>(null);
const [dirty, setDirty] = useState(false);
const [draft, setDraft] = useState<Record<AttribKey, string>>(() => emptyDraft(data.clip));
@@ -1521,6 +1526,7 @@ export default function ClipBench({
lastSaved.current = j;
setBusy(null);
if (wroteNotes(j)) void notes.reload();
+ setFix(!r.ok && j.outside ? { patch, outside: j.outside as Outside } : null);
if (!r.ok) {
setNote(
j.stale
@@ -2872,6 +2878,51 @@ export default function ClipBench({
</ReaderPane>
);
+ // A refused save's one-click fixes: move the stamp (to the first second that plays, or the
+ // nearest), or clear its second -- each the same save again, with the fix, in one write.
+ const wordsAt = (sec: number) => {
+ const c = cues.find((x) => sec >= x.start && sec < x.end) ?? cues.find((x) => x.start >= sec);
+ return c ? c.text.replace(/\s+/g, " ").trim().slice(0, 60) : null;
+ };
+ const fixBox = fix ? (
+ <div role="group" aria-label="fix the refused save" data-bench-fix={fix.outside.kind} className="flex flex-wrap items-center gap-1.5 text-[12px]">
+ <span className="text-text-2">
+ {fix.outside.kind === "mute" ? "The mute mark" : fix.outside.marks.length > 1 ? `${fix.outside.marks.length} stamps` : "The stamp"} at {fix.outside.marks.map((m) => m.at.toFixed(2)).join(", ")} would be outside {fix.outside.window.start.toFixed(2)}–{fix.outside.window.end.toFixed(2)}:
+ </span>
+ {(fix.outside.kind === "mark" ? (["first", "nearest"] as const) : (["nearest"] as const)).map((how) => {
+ const m = fix.outside.marks[0];
+ const at = m[how];
+ if (how === "nearest" && fix.outside.kind === "mark" && Math.abs(m.nearest - m.first) < 0.005) return null;
+ const w = wordsAt(at);
+ return (
+ <button
+ key={how}
+ type="button"
+ data-bench-fix-move={how}
+ disabled={!!busy}
+ className={buttonVariants({ variant: "outline", size: "sm" })}
+ title={w ? `it lands on “${w}”` : undefined}
+ onClick={() => void save({ ...fix.patch, ...(fix.outside.kind === "mute" ? { muteFix: how } : { markFix: how }) })}
+ >
+ Move {fix.outside.kind === "mute" ? "the mark" : "the stamp"} to {at.toFixed(2)} ({how === "first" ? "first second" : "nearest"}){w ? ` — “${w}”` : ""}
+ </button>
+ );
+ })}
+ <button
+ type="button"
+ data-bench-fix-clear=""
+ disabled={!!busy}
+ className={buttonVariants({ variant: "outline", size: "sm" })}
+ onClick={() => void save({ ...fix.patch, ...(fix.outside.kind === "mute" ? { muteFix: "clear" } : { markFix: "clear" }) })}
+ >
+ {fix.outside.kind === "mute" ? "Clear the mute mark" : "Clear the stamp's second (claim.at)"}
+ </button>
+ <button type="button" className="ink-link" onClick={() => setFix(null)}>
+ keep editing
+ </button>
+ </div>
+ ) : null;
+
// ---- the phone's own pieces (see "THE WALK ON A PHONE", above) -------------
// Each is md:hidden; the desk never draws them. Their data attributes are
// their own (`data-walk-*`), so no desk selector ever matches two elements.
@@ -3008,6 +3059,7 @@ export default function ClipBench({
{note}
</span>
)}
+ <span className="md:hidden">{fixBox}</span>
<span data-walk-verdict={verdict} className={cn("ml-auto", verdict === "confirmed" ? "text-kept-text" : verdict === "incorrect" || verdict === "rejected" ? "text-doubt-text" : "text-muted")}>
{verdictLabel(clip)}
</span>
@@ -3586,6 +3638,7 @@ export default function ClipBench({
{note}
</span>
)}
+ {fixBox}
</div>
{/* ---- the instrument ----
diff --git a/umtool/lib/report/knobs.test.mjs b/umtool/lib/report/knobs.test.mjs
@@ -127,6 +127,40 @@ test("updateClip: a window that leaves claim.at outside is refused", async () =>
await updateClip(dir, "c02", { start: 30.5 });
});
+test("updateClip: the refusal carries the fixes, and markFix / muteFix apply one in the same write", async () => {
+ const dir = await project();
+ await updateClaimKnobs(dir, "c02", { at: 31 });
+ // The refusal: a MarksOutside naming the second and where each fix would put it.
+ const err = await updateClip(dir, "c02", { start: 32.5, end: 39 }).catch((e) => e);
+ assert.equal(err.name, "MarksOutside");
+ assert.equal(err.kind, "mark");
+ assert.deepEqual(err.window, { start: 32.5, end: 39 });
+ assert.deepEqual(err.marks, [{ index: null, id: err.marks[0].id, at: 31, first: 32.5, nearest: 32.5 }]);
+ // Moved to the first second that plays, in the one write that also trims.
+ const before = await readRaw(dir);
+ const r = await updateClip(dir, "c02", { start: 32.5, end: 39, markFix: "first" });
+ assert.equal(r.entry.start, 32.5);
+ assert.equal(clip(await read(dir), "c02").claim.at, 32.5);
+ assert.notEqual(await readRaw(dir), before);
+ // A named second; then clear: the stamp keeps its verdict, loses its second.
+ await updateClaimKnobs(dir, "c02", { at: 33 });
+ await updateClip(dir, "c02", { start: 34, markFix: 35.25 });
+ assert.equal(clip(await read(dir), "c02").claim.at, 35.25);
+ await updateClip(dir, "c02", { start: 36, markFix: "clear" });
+ assert.equal("at" in clip(await read(dir), "c02").claim, false);
+ assert.ok(clip(await read(dir), "c02").claim.verdict, "the stamp is still there");
+ // A bad fix is refused in words.
+ await updateClaimKnobs(dir, "c02", { at: 36.5 });
+ await assert.rejects(updateClip(dir, "c02", { start: 37, markFix: "later" }), /markFix is first, nearest, clear or a source second/);
+ // The mute mark: refused with its fixes, then moved to the nearest second the clip plays.
+ await updateClip(dir, "c02", { start: 36, muteFrom: 38.5, markFix: "nearest" });
+ const m = await updateClip(dir, "c02", { end: 37.5 }).catch((e) => e);
+ assert.equal(m.name, "MarksOutside");
+ assert.equal(m.kind, "mute");
+ await updateClip(dir, "c02", { end: 37.5, muteFix: "nearest" });
+ assert.equal(clip(await read(dir), "c02").muteFrom, 37.5);
+});
+
test("updateFactcheck: stamp scale, motion, opacity and a verdict's stampLabel; refused out of range", async () => {
const dir = await project();
const r = await updateFactcheck(dir, { stamp: { scale: 1.4, motion: "pop", opacity: 0.8 }, verdicts: { CONTRADICTED: { label: "Seizures", stampLabel: "SEIZURE" } } }, { token: await manifestToken(dir) });
diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs
@@ -167,6 +167,44 @@ export class StaleToken extends Error {
}
}
+/**
+ * A window save that leaves a second the clip's marks name -- a stamp's
+ * `claim.at` (or a mark's `claims[k].at`), the mute mark -- outside the new
+ * window. The message is the sentence it always was; `marks` says what each
+ * could move to, so a page can offer the fix as one retried write
+ * (`markFix` / `muteFix` on the same patch: updateClip below) and the
+ * operator's unsaved trim is never lost. `umtool window … --move-stamp
+ * first|nearest|<s>` / `--clear-stamp` / `--move-mute nearest` /
+ * `--clear-mute` are the terminal's.
+ */
+export class MarksOutside extends Error {
+ /**
+ * @param {string} message
+ * @param {{ kind: "mark" | "mute", window: { start: number, end: number }, marks: Array<{ index: number | null, id: string | null, at: number, first: number, nearest: number }> }} detail
+ */
+ constructor(message, detail) {
+ super(message);
+ this.name = "MarksOutside";
+ this.kind = detail.kind;
+ this.window = detail.window;
+ this.marks = detail.marks;
+ }
+}
+
+/** The first and the last second a clip plays (its cut, else its extent), and the nearest of them to `at` that is not in a gap. */
+function keptSecondNear(entry, at) {
+ const from = entry.cutStart ?? entry.start;
+ const to = entry.cutEnd ?? entry.end;
+ const gaps = Array.isArray(entry.gaps) ? entry.gaps : [];
+ const out = (v) => {
+ const g = gaps.find((x) => v > x.from && v < x.to);
+ return g ? (v - g.from <= g.to - v ? g.from : g.to) : v;
+ };
+ const first = out(from);
+ const nearest = out(Math.min(to, Math.max(from, at)));
+ return { first: round2(first), nearest: round2(nearest) };
+}
+
const WINDOW_FIELDS = ["start", "end"];
const FLAG_FIELDS = ["lock", "lockStart", "lockEnd", "lockCut"];
@@ -453,6 +491,13 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n
// cut, and checked against the entry AFTER the patch: a window save that
// leaves the mark outside is refused rather than keeping a mark that no
// longer says anything about the clip. Empty or null deletes it.
+ if (patch.muteFix !== undefined && patch.muteFix !== null && patch.muteFrom === undefined && entry.muteFrom != null) {
+ // The refused save's fix (MarksOutside), in the same write: the mark to the nearest kept second, or gone.
+ const fix = String(patch.muteFix);
+ if (fix === "clear") delete entry.muteFrom;
+ else if (fix === "nearest") entry.muteFrom = keptSecondNear(entry, entry.muteFrom).nearest;
+ else throw new Error(`muteFix is nearest or clear, not ${JSON.stringify(patch.muteFix)}`);
+ }
if (patch.muteFrom !== undefined) {
const v = parseMuteFrom(patch.muteFrom, entry.start, entry.end);
if (v == null) delete entry.muteFrom;
@@ -466,9 +511,10 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n
try {
entry.muteFrom = parseMuteFrom(entry.muteFrom, entry.start, entry.end);
} catch {
- throw new Error(
+ throw new MarksOutside(
`the mute mark ${entry.muteFrom} must lie inside the window ` +
`${entry.start}–${entry.end} — widen the window, or clear the mark`,
+ { kind: "mute", window: { start: entry.start, end: entry.end }, marks: [{ index: null, id: null, at: entry.muteFrom, ...keptSecondNear(entry, entry.muteFrom) }] },
);
}
}
@@ -480,12 +526,34 @@ export function patchClipEntry(manifest, clipId, patch, { edit = "trim", now = n
// keeping a mark that no longer says anything about the clip.
if (patch.start !== undefined || patch.end !== undefined) {
const many = Array.isArray(entry.claims);
- rawMarksOf(entry).forEach((m, k) => {
- if (!isObj(m) || typeof m.at !== "number" || (m.at >= entry.start && m.at <= entry.end)) return;
+ const outside = rawMarksOf(entry)
+ .map((m, k) => ({ m, k }))
+ .filter(({ m }) => isObj(m) && typeof m.at === "number" && !(m.at >= entry.start && m.at <= entry.end));
+ // The refused save's fix, in the same write (MarksOutside): every stamp left outside moves to
+ // the first second that plays, the nearest one, a named second, or loses its `at`.
+ if (outside.length && patch.markFix !== undefined && patch.markFix !== null && patch.markFix !== "") {
+ const fix = patch.markFix;
+ for (const { m } of outside) {
+ if (fix === "clear") delete m.at;
+ else if (fix === "first" || fix === "nearest") m.at = keptSecondNear(entry, m.at)[fix];
+ else {
+ const v = Number(fix);
+ if (!Number.isFinite(v)) throw new Error(`markFix is first, nearest, clear or a source second, not ${JSON.stringify(fix)}`);
+ m.at = round2(v);
+ }
+ }
+ }
+ outside.forEach(({ m, k }) => {
+ if (typeof m.at !== "number" || (m.at >= entry.start && m.at <= entry.end)) return;
const name = many ? `the mark ${m.id}'s second (claims[${k}].at ${m.at})` : `the stamp's second (claim.at ${m.at})`;
- throw new Error(
+ throw new MarksOutside(
`${name} must lie inside the window ` +
`${entry.start}–${entry.end} — widen the window, or clear ${many ? "that mark's at" : "claim.at"}`,
+ {
+ kind: "mark",
+ window: { start: entry.start, end: entry.end },
+ marks: outside.filter((x) => typeof x.m.at === "number").map((x) => ({ index: many ? x.k : null, id: typeof x.m.id === "string" ? x.m.id : null, at: x.m.at, ...keptSecondNear(entry, x.m.at) })),
+ },
);
});
}