commit 4aded31daa4d5a7589746676a3aab94072b7175d
parent e6f734a9c8404bce55bb3ff3cdcfb26e9ebeaafe
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 17 Nov 2026 18:19:25 -0500
the re-read queue: a dry run writes nothing; a step never re-reads a read it cannot; its words off stdout with --json (review 2, N7, N5, question a)
N7: withBatches no longer makes narration/reads/ or rewrites queue.json for a dry run, and leaves the file
alone when nothing was queued. N5: runOneItem skips a read marked not queueable (a piece from a synthesized
take) even with no --only. (a): postsCommand's own lines went to stdout and polluted reread --one --json;
runOneItem now hands the inner command the caller's streams (stderr under --json).
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/umtool/lib/report/readsQueue.mjs b/umtool/lib/report/readsQueue.mjs
@@ -52,11 +52,16 @@ export async function readBatches(dir) {
}
}
-async function withBatches(dir, fn) {
+async function withBatches(dir, fn, { dryRun = false } = {}) {
+ // A DRY RUN WRITES NOTHING: no lock file, no directory, no rewrite of the batches.
+ if (dryRun) return (await fn(await readBatches(dir))).result;
const file = batchPath(dir);
await mkdir(path.dirname(file), { recursive: true });
return withNotesLock(file, async () => {
- const { batches, result } = await fn(await readBatches(dir));
+ const had = await readBatches(dir);
+ const { batches, result } = await fn(had);
+ // Nothing changed (nothing queued): the file is left as it is.
+ if (batches === had) return result;
const tmp = tmpPathFor(file);
await writeFile(tmp, `${JSON.stringify({ version: 1, batches: batches.slice(-20) }, null, 1)}\n`);
await rename(tmp, file);
@@ -136,7 +141,7 @@ export async function enqueueRereads(project, o = {}) {
if (!made.length) return { batches, result: { batch: null, steps: [], skipped } };
const batch = { id: `b${Date.now().toString(36)}`, at: new Date().toISOString(), by: o.by ?? "umtool reads reread", rows: rowsOut };
return { batches: [...batches, batch], result: { batch, steps: made, skipped } };
- });
+ }, { dryRun: !!o.dryRun });
}
/** A bench read's marker with no job yet counts as in flight this long (the post-narration route's own rule). */
@@ -187,12 +192,13 @@ export async function benchReadInFlight(dir, e, { now = Date.now(), jobEnded = e
* `run(argv)` runs a umtool argv (default: the CLI's own dispatch); `tts` / `narrate` the editor's ops as a test hands
* them (postsCommand's `tts`, cardNarrationCommand's `narrate`).
*/
-export async function runOneItem(project, item, ids, { reportsRoot = REPORTS_ROOT, run = null, log = (s) => console.log(s), tts = null, narrate = null, jobEnded = undefined } = {}) {
+export async function runOneItem(project, item, ids, { reportsRoot = REPORTS_ROOT, run = null, log = (s) => console.log(s), tts = null, narrate = null, jobEnded = undefined, quiet = null } = {}) {
const { rows, ctx } = await projectReads(project, { reportsRoot });
const e = ctx.manifest.timeline.find((x) => x?.id === item);
if (!e) throw new QueueError(`${item} is not in the cut any more`);
const want = new Set(ids ?? []);
- const reads = rows.filter((r) => r.item === item && (want.size ? want.has(r.id) : true) && (r.state === "stale" || (want.has(r.id) && r.state === "unpicked") || r.state === "none"));
+ // Never a read the queue cannot re-read (a piece from a synthesized take: its re-read is that take's, on the bench).
+ const reads = rows.filter((r) => r.item === item && r.queueable !== false && (want.size ? want.has(r.id) : true) && (r.state === "stale" || (want.has(r.id) && r.state === "unpicked") || r.state === "none"));
if (!reads.length) {
log(`${item}: nothing to re-read now (its reads are fresh, or re-read and waiting for a pick)`);
return { code: 0, argv: null, reads: [] };
@@ -202,8 +208,9 @@ export async function runOneItem(project, item, ids, { reportsRoot = REPORTS_ROO
const argv = itemRereadArgv(project.id, e, reads);
log(`${item}: re-reading ${reads.map((r) => r.id).join(", ")} -- umtool ${argv.join(" ")}`);
const exec = run ?? (async (a) => {
- if (a[0] === "posts") return (await import("./postsCli.mjs")).postsCommand(a.slice(1), { root: reportsRoot, ...(tts ? { tts } : {}) });
- if (a[0] === "narration") return (await import("./cardNarrationCli.mjs")).cardNarrationCommand(a.slice(1), { root: reportsRoot, ...(narrate ? { narrate } : {}) });
+ // `quiet` (`--json`): the command's own words where the caller says (stderr), never into the JSON on stdout.
+ if (a[0] === "posts") return (await import("./postsCli.mjs")).postsCommand(a.slice(1), { root: reportsRoot, ...(tts ? { tts } : {}), ...(quiet ?? {}) });
+ if (a[0] === "narration") return (await import("./cardNarrationCli.mjs")).cardNarrationCommand(a.slice(1), { root: reportsRoot, ...(narrate ? { narrate } : {}), ...(quiet ?? {}) });
throw new QueueError(`not a re-read command: ${a.join(" ")}`);
});
const code = await exec(argv);