commit 550673dcbd7d0f08f6e3bfc4b2c5ee5523083783
parent 786e448915e81c1eade741a0928dd3c19762fc2f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 10 Nov 2026 17:25:56 -0500
umtool: a cleared draft verdict never saves a version -- judgeDraft(null) clears the parent's while the draft is that version, else refuses (the draft with edits, or never saved, has no verdict to clear); before, `review-pass <p> verdict clear` saved the edited draft as the next version just to clear nothing on it (L7b re-review should-fix 3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat:
2 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/umtool/lib/report/versions.mjs b/umtool/lib/report/versions.mjs
@@ -217,6 +217,7 @@ export function withoutReviewFields(m) {
* it IS that version -- the parent is judged, nothing saved;
* else (or no parent): the draft is saved as the next version (saveVersionLocked; at no edits at all that is
* the parent again, nothing saved) and that version is judged.
+ * A clear (null) never saves: it clears the parent's when the draft is that version, else it is refused.
* Returns `{ judged, saved, entry }`: which version took the verdict, and whether one was saved for it.
*
* @param {{ id: string, dir: string }} project
@@ -237,6 +238,19 @@ export async function judgeDraft(project, verdict, { note, now = new Date() } =
return { judged: working.parent.id, saved: false, entry: r.entry };
}
}
+ // A clear has nothing to save for: a version is saved FOR a verdict, never for taking one away. The draft that
+ // is not its parent has no verdict to clear (re-review should-fix 3, 10 Nov).
+ if (verdict === null) {
+ if (working.parent && working.edits?.count === 0) {
+ const r = await setTakeVerdict(project.dir, working.parent.id, { verdict: null, ...(note !== undefined ? { note } : {}) });
+ return { judged: working.parent.id, saved: false, entry: r.entry };
+ }
+ throw new VersionRefused(
+ working.parent
+ ? `the draft has edits since ${working.parent.id}: it is not a version, so it has no verdict to clear (clear a version's with umtool takes verdict <p> <take> clear)`
+ : "the draft has never been saved as a version: it has no verdict to clear",
+ );
+ }
const s = await saveVersionLocked(project.dir, { now, why: "Saved for its verdict (the review pass)" });
const r = await setTakeVerdict(project.dir, s.id, { verdict, ...(note !== undefined ? { note } : {}) });
return { judged: s.id, saved: !!s.saved, entry: r.entry };
diff --git a/umtool/lib/report/versions.test.mjs b/umtool/lib/report/versions.test.mjs
@@ -517,6 +517,30 @@ test("a project naming a PRESET: its latest legacy take with no edits opens as n
}
});
+test("judgeDraft: a clear never saves a version -- the parent's is cleared while the draft is that version; a draft with edits (or never saved) is refused, nothing written", async () => {
+ const { root, dir, proj } = await project();
+ try {
+ // Never saved: nothing to clear, and no v1 made for it.
+ await assert.rejects(judgeDraft(proj, null), /never been saved as a version/);
+ assert.deepEqual((await listTakes(dir)).takes.filter((t) => t.version).map((t) => t.id), []);
+ await saveVersion(proj);
+ await judgeDraft(proj, "like");
+ // The draft is v1 (a walk verdict only): the clear is v1's.
+ await updateClip(dir, "a", { verdict: "confirmed" });
+ let r = await judgeDraft(proj, null);
+ assert.deepEqual([r.judged, r.saved], ["v1", false]);
+ assert.equal((await readVerdicts(dir)).v1?.verdict ?? null, null);
+ // An edge moved: the draft is not v1 -- refused, no v2.
+ await judgeDraft(proj, "like");
+ await updateClip(dir, "c", { end: 48 });
+ await assert.rejects(judgeDraft(proj, null), /edits since v1/);
+ assert.deepEqual((await listTakes(dir)).takes.filter((t) => t.version).map((t) => t.id), ["v1"]);
+ assert.equal((await readVerdicts(dir)).v1.verdict, "like", "v1's verdict untouched");
+ } finally {
+ await rm(root, { recursive: true, force: true });
+ }
+});
+
test("judgeDraft: a draft that differs from its parent only by the walk's and the review pass's fields judges the PARENT and saves nothing; any other edit saves the next version and judges it", async () => {
const { root, dir, proj } = await project();
try {