commit 457c4a304d4074f1af1c1e4f919ce4d99b677275
parent 06845ceb37eb35dd3c9850f01015563b45d284ec
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 9 Nov 2026 20:06:32 -0500
umtool: knobs.md and palette.spec.ts for the ⌘K review fixes (files, confirm, hosts, Runs, a stale project)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 118 insertions(+), 1 deletion(-)
diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md
@@ -1722,6 +1722,29 @@ another site, and a body carrying a raw argv -- `app/api/queue/route.ts` still n
verb gets its row there (`verbs.test.mjs` fails, naming it, until it has one) and its help lines in
`lib/cli/groups.mjs`; `node umtool/lib/cli/docs.mjs` rewrites cli.md's generated section.
+What a form may name, and what it asks first:
+
+- **Files.** An output (`trailer --out`, a take's `--id`, a reel, `--name`) is a bare name, never a directory or
+ `..`; the CLI writes it where it writes its own. An input file (`take --patch`, `trailer --beats`, `modules apply
+ --config`, `candidates import`, `timeline groups import`, `posts narrate --recording`, …) is a file of the
+ project, relative to its directory: the server runs it only when its realpath (symlinks followed) is inside the
+ project's, as that absolute path (`lib/cli/confine.mjs`). `@file`, and a key=value whose value is `@…`, `/…`,
+ `~/…` or climbs out with `..`, are a terminal's; `new --from` takes a share URL or `<channel>/<id>`, never a
+ report.md. `vertical --out` and `voice-match --out` (any path) are terminal-only.
+- **No undo.** A verb that deletes, evicts or kills (`prune --yes`, `pool prune`, `index --prune`, `takes freeze
+ --apply`, `takes make --force`, `take --force`, `queue cancel`, `takes cancel`, `render-mode off --force`, `notes
+ resolve`/`wontfix`, `notes reply --resolve`, `ledger rm`, `fetch --refetch`, `refresh --yes`, `speaker-check
+ --remove`, `preset save --force`) asks a second press, **Yes, <what it does>**; `POST /api/cli` wants
+ `confirm: true` and answers 409 without it.
+- **This machine only.** A write from a page (`POST /api/cli`, and the draft's **Save version** / **Open in
+ draft**: `lib/report/sameOrigin.mjs`) is refused when its Host, its X-Forwarded-Host or its Origin is not this
+ machine -- `localhost`, `*.localhost`, `127.x`, `::1` -- so a page whose DNS name is re-pointed at 127.0.0.1 (DNS
+ rebinding) cannot drive it. `UMTOOL_ALLOWED_HOSTS=name,name` (host names, no ports) adds the names a proxy in front
+ of umtool serves it as. `POST /api/cli` also refuses a request with no Origin and no `Sec-Fetch-Site` (a terminal
+ runs the command itself).
+- **Runs.** What a form started stays under **Runs** in the palette (nothing typed) for the page's life: an Escape
+ mid-run loses nothing. The same queued command sent twice within 5 s is the one step.
+
## Reading them back
`umtool show <p>` prints a **knobs** block — each clip's claim knobs, audio and blur (which clip stamps), the stamp's
diff --git a/umtool/e2e/palette.spec.ts b/umtool/e2e/palette.spec.ts
@@ -154,12 +154,106 @@ test("POST /api/cli runs only registry form verbs, from this app's pages, with v
const shown = (await (await page.request.get(`/api/cli?job=${job.id}`)).json()) as { job: { log: string[] } };
expect(shown.job.log.join("\n")).toContain("The Basic Fixture");
- // A verb that renders (or holds the heavy slot) is a step of the durable queue.
+ // A verb that renders (or holds the heavy slot) is a step of the durable queue; the same one asked
+ // again at once (a double Enter) is that step.
r = await post({ verb: "prep", values: { project: PROJECT, "--status": true } });
expect(r.status()).toBe(202);
const { queued } = (await r.json()) as { queued: { qid: string } };
expect(queued.qid).toMatch(/^q\d+$/);
+ const again = await post({ verb: "prep", values: { project: PROJECT, "--status": true } });
+ expect(again.status()).toBe(200);
+ expect(((await again.json()) as { queued: { qid: string }; deduped: boolean })).toMatchObject({ queued: { qid: queued.qid }, deduped: true });
await expect
.poll(async () => ((await (await page.request.get(`/api/cli?qid=${queued.qid}`)).json()) as { step: { state: string } }).step.state, { timeout: 90_000 })
.toBe("done");
});
+
+test("POST /api/cli: files stay in the project, @file is a terminal's, no-undo verbs want confirm, and a rebound host is refused", async ({ page }) => {
+ test.setTimeout(120_000);
+ await page.goto(urls.homeHref());
+ const origin = new URL(page.url()).origin;
+ const post = (data: unknown, headers: Record<string, string> = { origin }) => page.request.post("/api/cli", { data, headers });
+ const said = async (r: Awaited<ReturnType<typeof post>>) => ((await r.json()) as { error?: string }).error ?? "";
+
+ // An output is a bare name; an input a file of the project, by its realpath; @file is refused.
+ let r = await post({ verb: "trailer", values: { project: PROJECT, "--take": "t1", "--out": "../../escape.mp4" } });
+ expect(r.status()).toBe(400);
+ expect(await said(r)).toContain("bare name");
+ for (const patch of ["../../../../etc/passwd", "/etc/passwd"]) {
+ r = await post({ verb: "take", values: { project: PROJECT, "--id": "t1", "--patch": patch, "--draft": true } });
+ expect(r.status(), patch).toBe(400);
+ expect(await said(r)).toMatch(/not a file of the project|no such file in the project/);
+ expect(await said(r)).not.toContain("root:");
+ }
+ r = await post({ verb: "candidates add", values: { project: PROJECT, proposal: "@/etc/passwd" } });
+ expect(r.status()).toBe(400);
+ expect(await said(r)).toContain("terminal only");
+ r = await post({ verb: "posts set-item", values: { project: PROJECT, item: "c01", settings: "parent.0=@/etc/passwd" } });
+ expect(r.status()).toBe(400);
+
+ // No undo: 409 until confirmed.
+ r = await post({ verb: "prune", values: { project: PROJECT, "--yes": true } });
+ expect(r.status()).toBe(409);
+ expect(((await r.json()) as { confirm?: string }).confirm).toContain("delete");
+ r = await post({ verb: "prune", values: { project: PROJECT, "--yes": true }, confirm: true });
+ expect(r.status()).toBe(202);
+ const { job } = (await r.json()) as { job: { id: string } };
+ await expect.poll(async () => ((await (await page.request.get(`/api/cli?job=${job.id}`)).json()) as { job: { state: string } }).job.state, { timeout: 60_000 }).not.toBe("running");
+
+ // DNS rebinding: a name that is not this machine, as the forwarded host or the origin.
+ const port = new URL(origin).port;
+ r = await post({ verb: "show", values: { project: PROJECT } }, { origin, "x-forwarded-host": `rebind.example:${port}` });
+ expect(r.status()).toBe(403);
+ r = await post({ verb: "show", values: { project: PROJECT } }, { origin: `http://rebind.example:${port}`, "x-forwarded-host": `rebind.example:${port}` });
+ expect(r.status()).toBe(403);
+ expect(await said(r)).toContain("UMTOOL_ALLOWED_HOSTS");
+});
+
+test("a no-undo verb asks a second press; a run outlives Escape (Runs); a client-side move leaves no stale project", async ({ page }) => {
+ test.setTimeout(180_000);
+ await page.setViewportSize({ width: 1366, height: 768 });
+ await page.goto(urls.section(PROJECT, "build"));
+ await open(page);
+ await page.keyboard.type(">prune");
+ await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:prune", { timeout: 30_000 });
+ await page.keyboard.press("Enter");
+ const form = palette(page).locator("[data-cli-form='prune']");
+ await expect(form.locator("[data-cli-arg='project'] input")).toHaveValue(PROJECT);
+ await form.locator("[data-cli-arg='--yes'] input").check();
+ await form.locator("[data-cli-run]").click();
+ const confirm = form.locator("[data-cli-confirm]");
+ await expect(confirm).toContainText("Yes, delete those work files");
+ await expect(form.locator("[data-cli-state]")).toHaveCount(0);
+ await shot(page, "palette-confirm");
+ await confirm.click();
+ await expect(form.locator("[data-cli-state]")).toHaveAttribute("data-cli-state", /done|failed/, { timeout: 90_000 });
+
+ // A read started, then Escape: it is under Runs, and opens on its log.
+ await form.locator("[data-cli-back]").click();
+ await page.locator("[data-jump-input]").fill(">show");
+ await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:show");
+ await page.keyboard.press("Enter");
+ const show = palette(page).locator("[data-cli-form='show']");
+ await show.locator("[data-cli-run]").click();
+ await page.keyboard.press("Escape");
+ await expect(palette(page)).toBeHidden();
+ await page.keyboard.press("Control+k");
+ const runs = palette(page).locator("[data-jump-item^='run:job-']");
+ await expect(runs).toHaveCount(2);
+ await expect(runs.first()).toContainText("umtool show");
+ await runs.first().click();
+ await expect(show.locator("[data-cli-state]")).toHaveAttribute("data-cli-state", "done", { timeout: 60_000 });
+ await expect(show.locator("[data-cli-log]")).toContainText("The Basic Fixture");
+
+ // A jump to the Inbox (a client-side move: the palette stays mounted), then a form at once: no project.
+ await show.locator("[data-cli-back]").click();
+ await page.locator("[data-jump-input]").fill("inbox");
+ await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "inbox");
+ await page.keyboard.press("Enter");
+ await expect(page).toHaveURL(/\/$/);
+ await page.keyboard.press("Control+k");
+ await page.keyboard.type(">look");
+ await expect(palette(page).locator("[role=option][aria-selected=true]")).toHaveAttribute("data-jump-item", "cmd:look");
+ await page.keyboard.press("Enter");
+ await expect(palette(page).locator("[data-cli-form='look'] [data-cli-arg='project'] input")).toHaveValue("");
+});