Archilyzer · Source

archilyzer

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

commit aa45fb2a796345aec4e124db6f0186c580f505c8
parent f3ce86a97be65dfe3412ea8dc00fb75f0df23446
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 02:53:25 -0500

umtool: quote-check takes back a work dir it made when the editor refuses it as inside the corpus (and the parents made for it); the refusal is matched on '"out" … is inside the corpus', held to the controller's own sentence by a test through the real editor client

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

Diffstat:
Meditor/CHANGELOG.md | 6+++---
Mumtool/lib/report/quoteCheck.mjs | 39++++++++++++++++++++++++++++++++++-----
Mumtool/lib/report/quoteCheck.test.mjs | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 114 insertions(+), 8 deletions(-)

diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -3,10 +3,10 @@ ## [Unreleased] - **umtool e2e: the Inbox spec waits for the list after a Park, Mute or Undo.** Three runs failed where the list had not changed 5 seconds after Reactivate, Unmute or Undo. In each the write had been saved and the page's refresh had been asked for; the server was slow for those seconds (a neighbouring suite was building) and the check gave up first. The first look at the list after such a write now waits up to 20 seconds. Nothing in the app changed: the lifecycle and the mutes are read from disk on every render, and the rail's count is memoised for 10 seconds by design and cleared by those writes. - **umtool: the trail no longer draws a 0 lb point for a row with no number.** A measure event whose value was empty was read as 0 and plotted at the foot of the trail. Such a row is now left off; a real 0 is still drawn. -- **umtool: `posts attach` finds captures in the archive too.** On a project with its own channels tree (a `.shadow-channels`), `umtool posts attach` and `posts repeats` looked for a post's capture only there, so media captured into the real archive's `channels/<slug>/posts-media/<id>/` was not seen. They now look in the project's tree first and then the archive's, as the other readers do. The archive is only read: the files are copied into the project as before. `--dry-run` prints which tree each file would come from. +- **umtool: `posts attach` finds captures in the archive too.** On a project with its own channels tree (a `.shadow-channels`), `umtool posts attach` and `posts repeats` looked for a post's capture only there, so media captured into the real archive's `channels/<slug>/posts-media/<id>/` was not seen. They now look in the project's tree first and then the archive's, as the other readers do. The archive is only read: the files are copied into the project as before. `--dry-run` prints which tree each file would come from. A capture whose file name is not a plain name (`../../x`, `a/b`, `..`) is refused before any file is read or any folder made. - **umtool: an entry's chapter name is set from a terminal.** An entry's `chapter` names it in the chapter list (the YouTube text, `umtool export --format chapters`) in place of its on-screen title, and it could only be written by editing the manifest by hand. `umtool set <p> <entry> chapter='The weigh-in'` writes it for any entry (a clip, a post item, a still), `chapter=` clears it, and `--take <t>` writes it on that take alone. One line, at most 100 characters. -- **umtool: a windowed take preview no longer fails on an effect that names a clip outside the window.** `umtool take <p> --id <t> --preview --at S --dur S` on a cut with `render.chrome.fx.glitch.clips` or `fx.thenNow.pairs` was refused with "names k06, which is not a clip of the cut". The window's manifest now keeps only the named clips inside it (a glitch's only when a clip stands right before it in the window, a then/now pair only with both ends), as it already did for markers and claim checks; an effect left naming no clip is off in that window. The same for `fx.kineticQuote.clips` and `fx.redact.clips`. -- **umtool: `quote-check` works on a project whose `out/` is on the media drive.** The check asked the editor to write its word files under `<project>/out/quote-check/`; when `out/` is a link onto a media drive, that is inside the corpus and the editor refuses to write there, so every clip failed. The work files now go to `<project>/.quote-check/`, and if the editor refuses that too (the project itself is inside the corpus) to `<reports>/.umtool/quote-check/<project>/`, then `~/.cache/umtool/quote-check/<project>/`. The rows are still the project's `quote-check.json`; the editor's refusal is unchanged. +- **umtool: a windowed take preview no longer fails on an effect that names a clip outside the window.** `umtool take <p> --id <t> --preview --at S --dur S` on a cut with `render.chrome.fx.glitch.clips` or `fx.thenNow.pairs` was refused with "names k06, which is not a clip of the cut". The window's manifest now keeps only the named clips inside it (a glitch's only when a clip stands right before it in the window, a then/now pair only with both ends), as it already did for markers and claim checks; an effect left naming no clip is off in that window. A glitch in another mode (`on: "year"`) does not read its list and is left as it is. The same for `fx.kineticQuote.clips` and `fx.redact.clips`. +- **umtool: `quote-check` works on a project whose `out/` is on the media drive.** The check asked the editor to write its word files under `<project>/out/quote-check/`; when `out/` is a link onto a media drive, that is inside the corpus and the editor refuses to write there, so every clip failed. The work files now go to `<project>/.quote-check/`, and if the editor refuses that too (the project itself is inside the corpus) to `<reports>/.umtool/quote-check/<project>/`, then `~/.cache/umtool/quote-check/<project>/`. The rows are still the project's `quote-check.json`; the editor's refusal is unchanged. A directory the editor refuses is removed again if the check made it, so no empty `.quote-check/` is left on the media drive. - **umtool: the words under the promise clock's REFUNDED stamp can be the record's own.** The stamp always read "by <date> · no video" under REFUNDED or WITHDRAWN, whatever the outcome row said. A `promise_outcome` row may now carry `stampNote` (`umtool ledger <p> set <row> --stampNote "by her account · no receipt"`, `--stampNote null` to take it off): it is the stamp's second line, and the one-line strip over a post's card shows its first clause. Without one the words are as before. `umtool lint` warns when a note is longer than the stamp's line holds (26 characters). - **umtool: a loss goal no longer takes its base from a weight said years before.** A goal such as "lose 100" is shown against the latest weight he had given by then, however old: on the weight video that put "(FROM 368)" on a goal set eight years after he said 368. `deck.goals.baseMaxDays` (unset: as before) keeps a base only when its weight was said at most that many days before the goal; an older one is no base, so the note carries no "(FROM …)" and the dial draws no goal weight or tick from it. `umtool look <p> deck.goals.baseMaxDays=365`, and `umtool look` now takes `--take <t>` for the deck's keys, which sets them on that take alone. - **umtool: the dial's finale no longer shows the callout's labels over its hub.** With `deck.dial.rememberedAs: "callout"` the finale's dial drew every remembered weight's label box and the ghost needle and never hid them, so the boxes sat on the hub for the whole finale (take rev9-a9). They are hidden there now; the rim's marker and flag for the last remembered weight stay. diff --git a/umtool/lib/report/quoteCheck.mjs b/umtool/lib/report/quoteCheck.mjs @@ -23,7 +23,7 @@ // --quote-ruled`: heard and ruled by a person). // // Plain ESM: the CLI runs under bare node; the app reads the file. -import { mkdir, readFile, realpath, rename, writeFile } from "node:fs/promises"; +import { mkdir, readFile, realpath, rename, rmdir, writeFile } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { createCueSource, siteOriginFromManifest } from "umtool-report-to-video/cues"; @@ -279,8 +279,33 @@ export async function quoteCheckWorkDirs(dir, { reportsRoot = null, env = proces return out; } -/** Is this the editor's refusal of an `out` inside the corpus (transcribeFile.ts)? */ -const insideCorpus = (e) => /is inside the corpus/.test(e instanceof Error ? e.message : String(e)); +/** + * Is this the editor's refusal of an `out` inside the corpus? The controller's sentence is + * `"out" <path> is inside the corpus (<root>) — this command never writes there; pick a path outside it` + * (common/controller/transcribeFile.ts checkTranscribeFileRequest), answered at once as HTTP 400 `{ error }` by + * POST /api/ops/transcribe (the route's jobResponse), which askEditorOp throws as `the editor refused it (<route>, + * HTTP 400): <error>`. Matched on the part that says what it is -- `"out" … is inside the corpus` -- not on the path, + * the root or the advice after the dash (quoteCheck.test.mjs holds the controller's source to these words). + */ +export const OUT_INSIDE_CORPUS = /"out" .* is inside the corpus\b/; +const insideCorpus = (e) => OUT_INSIDE_CORPUS.test(e instanceof Error ? e.message : String(e)); + +/** + * Take back the directories a refused work dir cost: `dir` and every parent made for it, up to `first` (what + * mkdir's `recursive` says it made first) -- each only when empty (rmdir), so nothing that was there is touched + * and no empty `.quote-check/` is left inside a corpus location. + */ +async function unmake(dir, first) { + if (!first) return; + const stop = path.resolve(first); + let cur = path.resolve(dir); + for (;;) { + if (cur !== stop && !cur.startsWith(stop + path.sep)) return; + if (!(await rmdir(cur).then(() => true, () => false))) return; + if (cur === stop) return; + cur = path.dirname(cur); + } +} /** * Check the planned clips; merge the rows into quote-check.json. @@ -324,13 +349,17 @@ export async function runQuoteCheck(dir, manifest, plan, { transcribe = editorWo let words; try { for (;;) { - await mkdir(works[wi], { recursive: true }); + // The editor needs the directory to be there (it refuses an `out` whose directory is not), so it is made + // -- and taken back, with any parent made for it, the moment the editor says it is inside the corpus. + const made = await mkdir(works[wi], { recursive: true }); const out = path.join(works[wi], `${p.id}.words.json`); try { words = await transcribe({ path: p.source.path, start: p.file.start, end: p.file.end, out }, { emit: () => {} }); break; } catch (e) { - if (!insideCorpus(e) || wi + 1 >= works.length) throw e; + if (!insideCorpus(e)) throw e; + await unmake(works[wi], made); + if (wi + 1 >= works.length) throw e; log(`quote-check: the editor will not write in ${works[wi]} (inside the corpus) -- its work files go to ${works[wi + 1]}`); wi += 1; } diff --git a/umtool/lib/report/quoteCheck.test.mjs b/umtool/lib/report/quoteCheck.test.mjs @@ -240,3 +240,80 @@ test("the editor's work files are never under out/: <project>/.quote-check by it await rm(p.root, { recursive: true, force: true }); } }); + +test("through the real editor client: the editor's own refusal reaches the fall-through, and the refused work dir is taken back -- no empty .quote-check left in the corpus", async () => { + const http = await import("node:http"); + const { stat, readdir } = await import("node:fs/promises"); + const { OUT_INSIDE_CORPUS, quoteCheckWorkDirs } = await import("./quoteCheck.mjs"); + // The controller's sentence, as the editor's source has it: the words the fall-through matches are there. + const controller = await readFile(path.join(HERE, "..", "..", "..", "common", "controller", "transcribeFile.ts"), "utf8"); + const sentence = /error: `("out" \$\{req\.out\} is inside the corpus \(\$\{root\}\)[^`]*)`/.exec(controller); + assert.ok(sentence, "transcribeFile.ts still refuses an out inside the corpus in these words"); + const refusalFor = (out, root) => sentence[1].replace("${req.out}", out).replace("${root}", root); + assert.match(refusalFor("/mnt/media/x/.quote-check/c43.words.json", "/mnt/media"), OUT_INSIDE_CORPUS); + assert.doesNotMatch('"out": the directory /x does not exist', OUT_INSIDE_CORPUS); + assert.doesNotMatch("editor job abc failed — out of memory inside the corpus reader", OUT_INSIDE_CORPUS); + + const p = await project(); + const corpus = p.dir; // the project itself sits in a "location": its .quote-check is refused + const asked = []; + // The editor, stood in for over HTTP: /api/ops/transcribe answers as ops' jobResponse does (400 { ok: false, error } + // for a refusal, { ok: true, jobId } and the words written to `out` otherwise), /api/ops/job/<id> a finished job. + const server = http.createServer((req, res) => { + let text = ""; + req.on("data", (d) => (text += d)); + req.on("end", async () => { + const send = (status, body) => { res.writeHead(status, { "content-type": "application/json" }); res.end(JSON.stringify(body)); }; + if (req.method === "POST" && req.url === "/api/ops/transcribe") { + const body = JSON.parse(text); + asked.push(body.out); + if (body.out.startsWith(corpus + path.sep)) return send(400, { ok: false, error: refusalFor(body.out, corpus) }); + if (!(await stat(path.dirname(body.out)).catch(() => null))) return send(400, { ok: false, error: `"out": the directory ${path.dirname(body.out)} does not exist` }); + const words = await fakeTranscribe(body); + await writeFile(body.out, JSON.stringify({ words })); + return send(200, { ok: true, jobId: `j${asked.length}` }); + } + if (req.method === "GET" && req.url.startsWith("/api/ops/job/")) return send(200, { ok: true, job: { status: "done" }, tail: [] }); + return send(404, { ok: false, error: "no such route" }); + }); + }); + await new Promise((r) => server.listen(0, "127.0.0.1", r)); + const env = { url: process.env.ARCHILYZER_EDITOR_URL, token: process.env.WORKER_TOKEN }; + process.env.ARCHILYZER_EDITOR_URL = `http://127.0.0.1:${server.address().port}`; + process.env.WORKER_TOKEN = "test-token"; + try { + const dirs = await quoteCheckWorkDirs(p.dir, { reportsRoot: p.root, env: { XDG_CACHE_HOME: path.join(p.root, "cache") } }); + const plan = (await planQuoteCheck(p.dir, p.manifest, { channelsDirs: [p.channels] })).filter((r) => r.id !== "c43"); + const lines = []; + // No `transcribe` given: runQuoteCheck's own editorWords, askEditorOp and all. + const r = await runQuoteCheck(p.dir, p.manifest, plan, { cuesOf: fakeCues, workDirs: dirs, log: (l) => lines.push(l) }); + assert.equal(asked[0], path.join(dirs[0], "c44.words.json"), "the project's .quote-check is asked first"); + assert.equal(asked[1], path.join(dirs[1], "c44.words.json")); + assert.equal(r.work, dirs[1]); + assert.equal(r.doc.clips.c44.status, "ok", lines.join("\n")); + assert.match(lines.join("\n"), /the editor will not write in .* \(inside the corpus\)/); + assert.equal(await stat(dirs[0]).catch(() => null), null, "the refused .quote-check is not left behind"); + assert.ok((await readdir(dirs[1])).includes("c44.words.json")); + + // Every dir refused: each one made is taken back, with the parents made for it; the clip's failure says why. + await rm(dirs[1], { recursive: true, force: true }); + await rm(path.join(p.root, ".umtool"), { recursive: true, force: true }); + const inCorpus = [dirs[0], path.join(p.dir, "deep", "er", "work")]; + lines.length = 0; + const none = await runQuoteCheck(p.dir, p.manifest, plan, { cuesOf: fakeCues, workDirs: inCorpus, log: (l) => lines.push(l) }); + assert.match(lines.join("\n"), /c44: the transcription failed: the editor refused it \(\/api\/ops\/transcribe, HTTP 400\): "out" .* is inside the corpus/); + assert.equal(await stat(dirs[0]).catch(() => null), null); + assert.equal(await stat(path.join(p.dir, "deep")).catch(() => null), null, "the parents made for it too"); + assert.equal(none.results.c44, undefined); + // A work dir that was already there, with a file in it, is never removed. + await mkdir(dirs[0], { recursive: true }); + await writeFile(path.join(dirs[0], "kept.txt"), "x"); + await runQuoteCheck(p.dir, p.manifest, plan, { cuesOf: fakeCues, workDirs: [dirs[0]], log: () => {} }); + assert.ok((await readdir(dirs[0])).includes("kept.txt")); + } finally { + if (env.url === undefined) delete process.env.ARCHILYZER_EDITOR_URL; else process.env.ARCHILYZER_EDITOR_URL = env.url; + if (env.token === undefined) delete process.env.WORKER_TOKEN; else process.env.WORKER_TOKEN = env.token; + await new Promise((r) => server.close(r)); + await rm(p.root, { recursive: true, force: true }); + } +});