Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 91145b05e4a31909a99ae6dccbdd91ee79f3a050
parent ff6bf47c44b7ed7b5fbabdecc93d83aadd522dcb
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Tue, 10 Nov 2026 17:28:38 -0500

umtool: a failed Keep keeps the Fix note -- the review pass's Keep on a clip writes its verdict first and takes back the Fix mark it carried only once that write succeeded (bench/walkVerdict.ts keepClip); before, the mark was cleared first, so a refused or failed verdict write lost the note (L7b re-review should-fix 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Diffstat:
Mumtool/components/projects/bench/walkVerdict.test.ts | 34+++++++++++++++++++++++++++++++++-
Mumtool/components/projects/bench/walkVerdict.ts | 24++++++++++++++++++++++++
Mumtool/components/projects/workspace/ReviewPass.tsx | 20++++++++++----------
3 files changed, 67 insertions(+), 11 deletions(-)

diff --git a/umtool/components/projects/bench/walkVerdict.test.ts b/umtool/components/projects/bench/walkVerdict.test.ts @@ -4,7 +4,7 @@ // Run with: pnpm --filter umtool exec tsx --test components/projects/bench/walkVerdict.test.ts import { afterEach, test } from "node:test"; import assert from "node:assert/strict"; -import { writeWalkVerdict } from "./walkVerdict"; +import { keepClip, writeWalkVerdict, type ClipWrite } from "./walkVerdict"; const realFetch = globalThis.fetch; afterEach(() => { @@ -44,3 +44,35 @@ test("Keep writes `confirmed` on the token its own read gave, over no verdict or assert.deepEqual(puts, [{ project: "p", clip: "c1", token: "t1", verdict: "confirmed" }]); } }); + +test("Keep on a clip carrying a Fix: the verdict is written FIRST, and the mark (its note) is taken back only once that write succeeded", async () => { + const calls: string[] = []; + const failing = async (): Promise<ClipWrite> => { + calls.push("verdict"); + return { ok: false, error: "HTTP 500", stale: false }; + }; + const clearMark = async () => { + calls.push("clear"); + return null; + }; + let r = await keepClip({ confirmed: false, hasMark: true, writeVerdict: failing, clearMark }); + assert.deepEqual(calls, ["verdict"], "a failed verdict write leaves the Fix mark"); + assert.deepEqual(r, { error: "HTTP 500", wrote: false }); + calls.length = 0; + const stale = async (): Promise<ClipWrite> => ({ ok: false, error: "stale", stale: true }); + r = await keepClip({ confirmed: false, hasMark: true, writeVerdict: stale, clearMark }); + assert.equal(calls.length, 0); + assert.match(String(r.error), /changed since/); + const ok = async (): Promise<ClipWrite> => { + calls.push("verdict"); + return { ok: true, entry: {}, token: "t2", json: {} }; + }; + r = await keepClip({ confirmed: false, hasMark: true, writeVerdict: ok, clearMark }); + assert.deepEqual(calls, ["verdict", "clear"]); + assert.deepEqual(r, { error: null, wrote: true }); + // Confirmed already: only the mark is taken back, nothing written. + calls.length = 0; + r = await keepClip({ confirmed: true, hasMark: true, writeVerdict: ok, clearMark }); + assert.deepEqual(calls, ["clear"]); + assert.deepEqual(r, { error: null, wrote: false }); +}); diff --git a/umtool/components/projects/bench/walkVerdict.ts b/umtool/components/projects/bench/walkVerdict.ts @@ -50,3 +50,27 @@ export function writeWalkVerdict(project: string, clip: string, v: { verdict: "c return v.verdict === "confirmed" && (now === "incorrect" || now === "rejected") ? ruledInBench(now) : null; }); } + +/** + * A review pass's Keep on a clip, in the order that loses nothing: the verdict first (when it is not `confirmed` + * already), and only once it is written is the Fix mark it carried taken back -- a refused or failed write leaves + * the mark, and its note, where they were. `wrote`: a verdict was written (the draft changed). + */ +export async function keepClip(o: { + confirmed: boolean; + hasMark: boolean; + writeVerdict: () => Promise<ClipWrite>; + clearMark: () => Promise<string | null>; +}): Promise<{ error: string | null; wrote: boolean }> { + let wrote = false; + if (!o.confirmed) { + const w = await o.writeVerdict(); + if (!w.ok) return { error: w.stale ? "the draft changed since — try again" : w.error, wrote: false }; + wrote = true; + } + if (o.hasMark) { + const err = await o.clearMark(); + if (err) return { error: err, wrote }; + } + return { error: null, wrote }; +} diff --git a/umtool/components/projects/workspace/ReviewPass.tsx b/umtool/components/projects/workspace/ReviewPass.tsx @@ -8,7 +8,7 @@ import { clipBenchHref, openInDraftHref } from "@/lib/hrefs"; import { blockAnswer, clipKeepable, clipVerdict, reviewProgress } from "@/lib/report/reviewPassModel.mjs"; import AnchoredNotes from "@/components/notes/AnchoredNotes"; import { useSharedNotes } from "@/components/notes/NotesProvider"; -import { ruledInBench, writeWalkVerdict } from "../bench/walkVerdict"; +import { keepClip, ruledInBench, writeWalkVerdict } from "../bench/walkVerdict"; import { MANIFEST_CHANGED, announceManifestChanged } from "../timelineApi"; import VersionVerdict from "../review/VersionVerdict"; import type { PlayEntry } from "../review/PlayCut"; @@ -109,18 +109,18 @@ export function useReviewPass(project: string, entries: PlayEntry[], on: boolean if (readOnly) return READ_ONLY_SAID; if (mark === "fix" || e.type !== "clip") return postMark(e.id, mark, note); if (!clipKeepable(e)) return ruledInBench(String(clipVerdict(e))); - // A Fix it carried is taken back: kept now. - if (marks[e.id]) { - const err = await postMark(e.id, null, null); - if (err) return err; - } - if (clipVerdict(e) !== "confirmed") { - const w = await writeWalkVerdict(project, e.id, { verdict: "confirmed" }); - if (!w.ok) return w.stale ? "the draft changed since — try again" : w.error; + // The verdict first; a Fix it carried is taken back only once it is written (keepClip). + const r = await keepClip({ + confirmed: clipVerdict(e) === "confirmed", + hasMark: !!marks[e.id], + writeVerdict: () => writeWalkVerdict(project, e.id, { verdict: "confirmed" }), + clearMark: () => postMark(e.id, null, null), + }); + if (r.wrote) { setWritten((x) => ({ ...x, [e.id]: { mark: "keep", note: null } })); announceManifestChanged(project); } - return null; + return r.error; }, [project, readOnly, postMark, marks], );