Archilyzer · Source

archilyzer

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

commit f7d61b20f55f006e98cb237be3c9d183c9f48f0b
parent 14cae07d455f382be9c6d0fc5b9cfa38dfe29882
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon,  9 Nov 2026 23:07:26 -0500

umtool: embed-ids, teaser and ledger rm want the token they handed out (400 without); a still's temp file is unique (L6 review 3)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/app/api/report/embed-ids/route.ts | 3++-
Mumtool/app/api/report/ledger/route.ts | 2++
Mumtool/app/api/report/teaser/route.ts | 3++-
Mumtool/e2e/inspector-ledger.spec.ts | 5+++++
Mumtool/e2e/inspector-teaser-insert.spec.ts | 5+++++
Mumtool/lib/report/stillGrab.mjs | 3++-
6 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/umtool/app/api/report/embed-ids/route.ts b/umtool/app/api/report/embed-ids/route.ts @@ -43,13 +43,14 @@ export async function POST(request: Request) { } const r = await resolveReport(String(body.project ?? "")); if ("error" in r) return Response.json({ error: r.error }, { status: r.status }); + if (typeof body.token !== "string" || !body.token) return Response.json({ error: "token is required: GET the route first (a write over a newer draft is refused, never silent)" }, { status: 400 }); const clips = Array.isArray(body.clips) ? body.clips.map(String) : null; try { const { result, editNotes } = await withEditNotes(r.project, async () => { // The rows as the manifest is NOW (read inside the request, the writer checks the token). const m = (await readManifest(r.project.dir)) as Record<string, unknown>; const rows = await embedIdRows(r.project.dir, m, { doc: await readLinkCheck(r.project.dir) }); - return setSiteVideos(r.project.dir, embedIdFixes(rows, clips), { token: typeof body.token === "string" ? body.token : null }); + return setSiteVideos(r.project.dir, embedIdFixes(rows, clips), { token: body.token as string }); }); return Response.json({ ok: true, fixed: result.fixed, token: result.token, editNotes }, { headers: noStore }); } catch (e) { diff --git a/umtool/app/api/report/ledger/route.ts b/umtool/app/api/report/ledger/route.ts @@ -97,6 +97,8 @@ export async function POST(request: Request) { return Response.json({ ok: true, row: result.row, token: result.token, editNotes }, { headers: noStore }); } if (body.op === "rm") { + // A removal is checked against the draft this panel read: never a blind delete. + if (!token) return Response.json({ error: "token is required to remove a row: GET the route first" }, { status: 400 }); const { result, editNotes } = await withEditNotes(r.project, () => removeLedgerRow(r.project.dir, id, { token })); return Response.json({ ok: true, removed: result.row?.id ?? id, token: result.token, editNotes }, { headers: noStore }); } diff --git a/umtool/app/api/report/teaser/route.ts b/umtool/app/api/report/teaser/route.ts @@ -49,7 +49,8 @@ export async function POST(request: Request) { } const r = await resolveReport(String(body.project ?? "")); if ("error" in r) return Response.json({ error: r.error }, { status: r.status }); - const token = typeof body.token === "string" ? body.token : null; + if (typeof body.token !== "string" || !body.token) return Response.json({ error: "token is required: GET the route first (a write over a newer draft is refused, never silent)" }, { status: 400 }); + const token = body.token as string; try { if (body.op === "insert") { const { result, editNotes } = await withEditNotes(r.project, () => insertTeaser(r.project.dir, (body.spec ?? {}) as Record<string, unknown>, body.position ?? "end", { token })); diff --git a/umtool/e2e/inspector-ledger.spec.ts b/umtool/e2e/inspector-ledger.spec.ts @@ -78,6 +78,11 @@ test("add a row (date, scope, value, basis, source), refused without its basis; await expect(panel.locator('[data-ledger-said="ok"]')).toContainText("Saved d01"); expect(row("d01")?.event).toBe("stop"); + // A removal without the token the panel read is refused. + const bare = await page.request.post("/api/report/ledger", { data: { project: P, op: "rm", id: "d01" } }); + expect(bare.status()).toBe(400); + expect(row("d01")).toBeDefined(); + await panel.locator('[data-ledger-edit="d01"]').click(); await panel.locator('[data-ledger-remove="d01"]').click(); await expect(panel.locator('[data-ledger-said="ok"]')).toContainText("Removed d01"); diff --git a/umtool/e2e/inspector-teaser-insert.spec.ts b/umtool/e2e/inspector-teaser-insert.spec.ts @@ -75,6 +75,11 @@ test("a cold open at the start, then its row's Edit changes its beat; Undo takes expect(timeline()[0]).toEqual({ type: "teaser", id: "cold", lines: ["Cold open"], beat: 0.9 }); expect(takeText()).toBe(take); + // The route wants the token it handed out: a write without one is refused. + const bare = await request.post("/api/report/teaser", { data: { project: P, op: "set", id: "cold", patch: { beat: 1.1 } } }); + expect(bare.status()).toBe(400); + expect(timeline()[0]).toEqual({ type: "teaser", id: "cold", lines: ["Cold open"], beat: 0.9 }); + const r = await request.post("/api/report/timeline", { data: { project: P, op: "undo" } }); expect(r.ok(), await r.text()).toBe(true); expect((await r.json()).op).toBe("teaser"); diff --git a/umtool/lib/report/stillGrab.mjs b/umtool/lib/report/stillGrab.mjs @@ -81,7 +81,8 @@ export async function grabStill(project, manifest, clipId, at, { ffmpeg = FFMPEG const dir = path.join(project.dir, SHOTS_DIR); await mkdir(dir, { recursive: true }); const out = path.join(dir, file); - const tmp = path.join(dir, `.${file}.part-${process.pid}.png`); + // Two grabs of one second at once never share a temp file. + const tmp = path.join(dir, `.${file}.part-${process.pid}-${Math.random().toString(36).slice(2, 10)}.png`); try { await execFileP(ffmpeg, ["-v", "error", "-y", "-ss", src.offset.toFixed(3), "-i", src.file, "-frames:v", "1", "-an", tmp], { timeout: 60_000 }); const st = await stat(tmp).catch(() => null);