commit 849fce04d1a832fbb3659e2dbe63a8fa6acff0ec
parent 9241b03df5e25a788fc829a07b5ee15cae5f58b6
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 4 Nov 2026 23:09:44 -0500
umtool: take status never reads an older run's word while a queue step renders the take
A step queued or blocked for the take is the answer (3 / 1) unless a render is live now; a
step that has started but whose take process has not written its own record yet reads
running ("starting", 3) -- not the previous run's done; a step that failed with no record of
its own (refused before the take's directory existed) reads failed with the step's error.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/umtool/lib/queue/cli.mjs b/umtool/lib/queue/cli.mjs
@@ -346,21 +346,29 @@ export async function takeStatus(project, { take, json, showLog, tail, reportsRo
const rows = [];
for (const id of ids) {
const rec = await readRenderRecord(path.join(takesRoot, id));
- const pending = steps.filter((s) => s.target.take === id && (s.state === "queued" || s.state === "blocked")).at(-1) ?? null;
+ // The newest queue step that renders this take, and whether the record is of its run or older.
+ const step = steps.filter((s) => s.target.take === id).at(-1) ?? null;
+ const stepAt = step ? Date.parse(step.startedAt ?? step.createdAt) : NaN;
+ const recIsOlder = !rec || Date.parse(rec.startedAt) < stepAt;
const recLive = rec && (rec.state === "running" || rec.state === "waiting");
let row;
- if (pending && !recLive && (!rec || Date.parse(pending.createdAt) > Date.parse(rec.startedAt))) {
- // Waiting in the queue: the step is the newest word on this take.
- row = {
- project: project.id,
- take: id,
- state: pending.state === "blocked" ? "blocked" : "queued",
- queue: { qid: pending.qid, state: pending.state, after: pending.after, error: pending.error },
- error: pending.state === "blocked" ? pending.error : null,
- previous: rec,
- };
- row.exit = pending.state === "blocked" ? 1 : 3;
- } else if (rec) {
+ const fromStep = (state, exit, error = null) => ({
+ project: project.id,
+ take: id,
+ state,
+ queue: { qid: step.qid, state: step.state, after: step.after, error: step.error },
+ error,
+ previous: rec,
+ exit,
+ });
+ // A step still to run renders this take again, whatever an earlier run recorded (a render live now speaks for itself).
+ if (step && !recLive && step.state === "queued") row = fromStep("queued", 3);
+ else if (step && !recLive && step.state === "blocked") row = fromStep("blocked", 1, step.error);
+ // Started, its take process not yet writing its own record (a second of setup): running, never the last run's word.
+ else if (step && recIsOlder && step.state === "running") row = { ...fromStep("running", 3), stage: "starting" };
+ // Ended without a record of its own (refused before the take's directory existed): the step says why.
+ else if (step && recIsOlder && (step.state === "failed" || step.state === "cancelled")) row = fromStep(step.state, 1, step.error);
+ else if (rec) {
row = { ...rec, exit: statusExitCode(rec.state) };
} else if (take) {
// No record: a take made before records (take.json built, its preview there) reads done from take.json.
diff --git a/umtool/lib/queue/store.test.mjs b/umtool/lib/queue/store.test.mjs
@@ -295,8 +295,14 @@ test("take status: queued from the queue, then the render record's state and exi
lines.length = 0;
assert.equal(await status(), 3);
assert.equal(JSON.parse(lines.join("\n")).state, "queued");
- // Its render recorded failed (newer than the step): failed, exit 1.
+ // The runner starts it; its take process has not written its record yet: running (never an older run's word).
const { openRenderRecord } = await import("../report/renderRecord.mjs");
+ const step = /** @type {any} */ (await getStep(dir, "q1"));
+ await writeFile(stepFile(dir, "q1"), JSON.stringify({ ...step, state: "running", startedAt: new Date().toISOString(), pid: process.pid, host: os.hostname() }));
+ lines.length = 0;
+ assert.equal(await status(), 3);
+ assert.equal(JSON.parse(lines.join("\n")).stage, "starting");
+ // Its render recorded failed (this attempt's record): failed, exit 1.
await sleep(5);
await (await openRenderRecord(path.join(projectDir, "takes", "t1"), { take: "t1", project: "demo" })).fail(new Error("1 entry could not be cut: m09: no source on disk"));
lines.length = 0;
@@ -305,6 +311,13 @@ test("take status: queued from the queue, then the render record's state and exi
assert.equal(j.state, "failed");
assert.match(j.error, /m09: no source on disk/);
assert.match(j.logPath, /takes\/t1\/render\.log$/);
+ // A later step that failed with no record of its own (refused before the take's directory): the step's error.
+ const q2 = await addStep(dir, { argv: ["take", "demo", "--id", "t1"], target: { project: "demo", take: "t1" } });
+ await sleep(5);
+ await writeFile(stepFile(dir, q2.qid), JSON.stringify({ ...q2, state: "failed", startedAt: new Date().toISOString(), endedAt: new Date().toISOString(), exitCode: 2, error: "--id <id>: the take's directory name (exit 2)" }));
+ lines.length = 0;
+ assert.equal(await status(), 1);
+ assert.match(JSON.parse(lines.join("\n")).error, /--id <id>/);
} finally {
await rm(root, { recursive: true, force: true });
}