commit d5e7dff9d600cb61d65ff18958846d18d70fadb2
parent b8064cfab42374879a3c0310128dc51605d4a99f
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Tue, 24 Nov 2026 16:42:50 -0500
space-suggestions: e2e spec, the e2e server's reports dir, ENVIRONMENT.md, CHANGELOG, OPERATING.md
SPACE_SCAN_REPORTS_DIR points the scan's umtool-reports sizing at the slot's own
data, so an e2e scan never walks ~/reports.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
6 files changed, 137 insertions(+), 2 deletions(-)
diff --git a/ENVIRONMENT.md b/ENVIRONMENT.md
@@ -97,8 +97,9 @@ Tokens, credentials and knobs a running process reads. Most configuration is not
| `NITTER_INSTANCES` | a built-in list | Comma-separated Nitter instances for the X fallback fetcher, in order of preference. | common/social/xNitterFetcher.ts |
| `ARCHILYZER_X_BROWSER` | the first of `chromium`, `google-chrome`, `google-chrome-stable`, `chrome` on PATH, else Playwright's bundled Chromium | The Chromium-family browser /settings' "Connect X account" opens (a path, or a name looked up on PATH), and a forum-thread channel's "Connect forum session" too. It is launched without the automation signals, in the X session profile (or the forum host's profile); a value that is not an executable refuses the connect rather than opening another browser. | common/social/xBrowser.ts |
| `UMTOOL_MEDIA_DIR` | unset (no media root: a project link's target is kept) | umtool's media root, where a tiered project's `out/` (and its deliverables) are linked to. Read by `archilyzer reports delete` and the editor's `delete-article` / `delete-iteration` too: an iteration project's link that is exactly its mirror there is removed with its target. Its other uses are documented in [umtool/docs](umtool/docs/README.md). | common/lib/report/delete.ts, umtool (lib/paths.mjs) |
-| `REPORTS_DIR` | `~/reports` (or the parent of `SONG_REPORTS_DIR`) | umtool's reports root, the tree its projects hang off; with `UMTOOL_MEDIA_DIR`, it says where a project's media mirror is (`<media>/<path relative to it>`) for a delete. | common/lib/report/delete.ts, common/bin/case.ts, umtool (lib/paths.mjs) |
+| `REPORTS_DIR` | `~/reports` (or the parent of `SONG_REPORTS_DIR`) | umtool's reports root, the tree its projects hang off; with `UMTOOL_MEDIA_DIR`, it says where a project's media mirror is (`<media>/<path relative to it>`) for a delete. | common/lib/report/delete.ts, common/bin/case.ts, common/controller/spaceScan.ts, umtool (lib/paths.mjs) |
| `SONG_REPORTS_DIR` | unset | umtool's um-song deliverables tree; when `REPORTS_DIR` is unset, its parent is the reports root a delete and `archilyzer case` read (as umtool does). | common/lib/report/delete.ts, common/bin/case.ts, umtool (song/paths.mjs) |
+| `SPACE_SCAN_REPORTS_DIR` | `REPORTS_DIR`, else `~/reports` | umtool's reports root as the space scan sizes it (measured only: the archive's share of its disk). The e2e servers point it at their own data, so a scan never walks the operator's reports. | common/controller/spaceScan.ts |
| `UMTOOL_URL` | unset (no link; the MCP's `notes` off) | umtool's front door; when set, the video page links to it, its Find clips hands the recording to umtool's clip finder (the `find-clips` job posts to `/api/report/clips` with WORKER_TOKEN), and the MCP's `notes` tool reads the operator's notes there and writes a reply as the agent's (e.g. `http://localhost:3050`). Unset: Find clips is disabled. | editor/app/channels/[slug]/videos/[id]/page.tsx, common/lib/umtoolUrl.ts, mcp/src/archivalTools.ts |
| `TRANSCRIPT_SITE_URL` | — | MCP server: one published archive to read over HTTP. Also the default connected archive (common/lib/remoteArchives.ts): the editor, umtool and the MCP offer it as a source when settings.remoteArchives does not list it, without writing it. | mcp/src/sources.ts |
| `ARCHILYZER_ALLOW_PRIVATE_ARCHIVES` | off | `1` lets the editor connect an archive whose host is this machine or its network (loopback, private, link-local, a `.local` name, or a name resolving to such an address), which is refused otherwise: umtool, which can connect one, is open on the LAN. TRANSCRIPT_SITE_URL's archive, and one already written in settings.json, are connected without it. The check is made once, when the archive is connected: a name re-pointed at a private address afterwards is not rechecked (the archive is still read on its own origin only). | common/controller/remoteArchives.ts |
diff --git a/OPERATING.md b/OPERATING.md
@@ -2277,6 +2277,30 @@ file and leaves it stored), looked at again (size and hash), and only then is th
again (the dry run says how much): about 20 times the stored size. Kept earlier captures
(`chat-capture-kept.*.json.zst`) are not restored: an older checkout ignores them, and they stay where they are.
+### Free up space (which disk, and what frees it)
+
+```sh
+pnpm ops space-scan --wait # measure every disk the archive writes to (reads only)
+pnpm ops space-scan --json '{"compaction":false}' --wait # the same without the compaction selector's ffprobe pass
+pnpm ops get space-suggestions # the fullest disk's list, biggest saving first
+pnpm ops get space-suggestions platter # another disk's
+```
+
+The editor's `/cleanup/space` is the same list. A `space-scan` job measures the corpus disk, each storage location,
+and the disks of the saved-video store, the site builds and umtool's reports. It counts allocated bytes, each inode
+once; a file with another hard link is never counted as freed, and a tier link counts on its target's disk. It writes
+`transcripts/.space-suggestions.json` and nothing else.
+
+Each suggestion carries `actions`, the existing ops call that does it: compress-text (caption tracks first on the
+corpus disk), the cleanup sweeps, relocate, evict-clips, delete-file for abandoned partials, compact-saved-videos,
+drop-saved-alternate for compacted originals and alternates, kept-failed-encodes, and live-recording-verify. Run that
+call, or press the row's button; the writer refuses what it refuses when it runs. Two things to know:
+- A compaction frees the store's disk only, and only once its original is dropped.
+- A move frees only the media tier, never the text.
+
+Held (do-not-clean, a pinned video's copies, a live recording, a move in flight), the selector's refusals and the
+archive's bytes no writer here removes are listed with their reason or owner.
+
### Compact saved videos
```sh
diff --git a/common/lib/envVars.ts b/common/lib/envVars.ts
@@ -133,8 +133,9 @@ const DECLARED: EnvVarDecl[] = [
{ name: "NITTER_INSTANCES", audience: "runtime", default: "a built-in list", readBy: "common/social/xNitterFetcher.ts", doc: "Comma-separated Nitter instances for the X fallback fetcher, in order of preference." },
{ name: "ARCHILYZER_X_BROWSER", audience: "runtime", default: "the first of `chromium`, `google-chrome`, `google-chrome-stable`, `chrome` on PATH, else Playwright's bundled Chromium", readBy: "common/social/xBrowser.ts", doc: "The Chromium-family browser /settings' \"Connect X account\" opens (a path, or a name looked up on PATH), and a forum-thread channel's \"Connect forum session\" too. It is launched without the automation signals, in the X session profile (or the forum host's profile); a value that is not an executable refuses the connect rather than opening another browser." },
{ name: "UMTOOL_MEDIA_DIR", audience: "runtime", default: "unset (no media root: a project link's target is kept)", readBy: "common/lib/report/delete.ts, umtool (lib/paths.mjs)", doc: "umtool's media root, where a tiered project's `out/` (and its deliverables) are linked to. Read by `archilyzer reports delete` and the editor's `delete-article` / `delete-iteration` too: an iteration project's link that is exactly its mirror there is removed with its target. Its other uses are documented in [umtool/docs](umtool/docs/README.md)." },
- { name: "REPORTS_DIR", audience: "runtime", default: "`~/reports` (or the parent of `SONG_REPORTS_DIR`)", readBy: "common/lib/report/delete.ts, common/bin/case.ts, umtool (lib/paths.mjs)", doc: "umtool's reports root, the tree its projects hang off; with `UMTOOL_MEDIA_DIR`, it says where a project's media mirror is (`<media>/<path relative to it>`) for a delete." },
+ { name: "REPORTS_DIR", audience: "runtime", default: "`~/reports` (or the parent of `SONG_REPORTS_DIR`)", readBy: "common/lib/report/delete.ts, common/bin/case.ts, common/controller/spaceScan.ts, umtool (lib/paths.mjs)", doc: "umtool's reports root, the tree its projects hang off; with `UMTOOL_MEDIA_DIR`, it says where a project's media mirror is (`<media>/<path relative to it>`) for a delete." },
{ name: "SONG_REPORTS_DIR", audience: "runtime", default: "unset", readBy: "common/lib/report/delete.ts, common/bin/case.ts, umtool (song/paths.mjs)", doc: "umtool's um-song deliverables tree; when `REPORTS_DIR` is unset, its parent is the reports root a delete and `archilyzer case` read (as umtool does)." },
+ { name: "SPACE_SCAN_REPORTS_DIR", audience: "runtime", default: "`REPORTS_DIR`, else `~/reports`", readBy: "common/controller/spaceScan.ts", doc: "umtool's reports root as the space scan sizes it (measured only: the archive's share of its disk). The e2e servers point it at their own data, so a scan never walks the operator's reports." },
{ name: "UMTOOL_URL", audience: "runtime", default: "unset (no link; the MCP's `notes` off)", readBy: "editor/app/channels/[slug]/videos/[id]/page.tsx, common/lib/umtoolUrl.ts, mcp/src/archivalTools.ts", doc: "umtool's front door; when set, the video page links to it, its Find clips hands the recording to umtool's clip finder (the `find-clips` job posts to `/api/report/clips` with WORKER_TOKEN), and the MCP's `notes` tool reads the operator's notes there and writes a reply as the agent's (e.g. `http://localhost:3050`). Unset: Find clips is disabled." },
{ name: "TRANSCRIPT_SITE_URL", audience: "runtime", default: "—", readBy: "mcp/src/sources.ts", doc: "MCP server: one published archive to read over HTTP. Also the default connected archive (common/lib/remoteArchives.ts): the editor, umtool and the MCP offer it as a source when settings.remoteArchives does not list it, without writing it." },
{ name: "ARCHILYZER_ALLOW_PRIVATE_ARCHIVES", audience: "runtime", default: "off", readBy: "common/controller/remoteArchives.ts", doc: "`1` lets the editor connect an archive whose host is this machine or its network (loopback, private, link-local, a `.local` name, or a name resolving to such an address), which is refused otherwise: umtool, which can connect one, is open on the LAN. TRANSCRIPT_SITE_URL's archive, and one already written in settings.json, are connected without it. The check is made once, when the archive is connected: a name re-pointed at a private address afterwards is not rechecked (the archive is still read on its own origin only)." },
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,28 @@
# Changelog
## [Unreleased]
+- **Free up space: `/cleanup/space`, every disk the archive writes to and what frees space on each.**
+ - The disks, the fullest first and marked: each one's size, free space now, how much of it is the archive's (by
+ kind: media, text, clip windows, saved videos, playable copies, site builds, umtool reports, the index) and how
+ much is not. An unmounted or unanswering location reads "not scanned", never empty.
+ - The disk picked lists what would free space on it, by kind, the biggest first, with caption compression leading
+ the corpus disk. Each row says how much it frees and where (measured, or an estimate and from what), what a move
+ fills and whether it fits, and what is lost.
+ - The kinds: compressing caption tracks or raw live chats, the cleanup sweeps, moving a channel's media to a
+ location, evicting clip windows untouched for 30 days, abandoned partial downloads, compacting saved videos, and
+ dropping compacted originals, alternates and failed encodes. Also live landings to verify again, and source
+ containers left outside the store (a link to the video page only).
+ - Every button runs the existing writer for its kind (compress-text, cleanup, relocate, evict-clips, delete-file,
+ compact-saved-videos, drop-saved-alternate, kept-failed-encodes, live-recording-verify). It offers a dry run where
+ the writer answers one at once, and a tick where the writer wants a person's word.
+ - Compaction frees nothing until the original is dropped, and the row says so.
+ - Held and why: do-not-clean, a pinned video's copies, a live recording, a move in flight. Then the compaction
+ selector's refusals by rule, and the archive's bytes no writer here removes, with their owner (umtool's reports:
+ `umtool prune --all`).
+ - The numbers come from a scan, a `space-scan` job (Refresh; `pnpm ops space-scan`), into
+ `transcripts/.space-suggestions.json`. It only reads: allocated bytes, each inode once, and a hard-linked file is
+ never counted as freed. `pnpm ops get space-suggestions [<disk>]` answers the same list. `/cleanup` gets the two
+ tabs and a one-line summary.
- **A live recording keeps itself alive: the start retried beside the live edge, stalls restarted, an insurance
recorder, a restart after the editor's, and parts joined.**
- A from-start recorder that dies, stalls or is stopped by an editor shutdown is RESUMED in place from yt-dlp's
diff --git a/editor/e2e/servers.ts b/editor/e2e/servers.ts
@@ -272,6 +272,9 @@ export function slotServers(slot: number, mode: E2EMode, env: Env = process.env)
// Render mode's state (common/lib/renderPriority.mjs): the slot's own, so
// its heartbeat never ends — and its /jobs never shows — the machine's.
editorEnv.RENDER_PRIORITY_FILE = join(paths.transcriptsDir, ".render-priority.json");
+ // umtool's reports as the space scan sizes them (controller/spaceScan.ts):
+ // the slot's own, so a scan never walks the operator's ~/reports.
+ editorEnv.SPACE_SCAN_REPORTS_DIR = join(paths.transcriptsDir, ".space-scan-reports");
// A start-mode server runs the stamped build (shared, read-only); a second
// `next dev` needs a dist dir of its own (Next locks `<distDir>/dev/lock`).
if (mode === "start" && !env.CI) editorEnv.E2E_NEXT_DIST_DIR = E2E_DIST_DIR;
diff --git a/editor/e2e/space-suggestions.spec.ts b/editor/e2e/space-suggestions.spec.ts
@@ -0,0 +1,84 @@
+import { mkdir, stat, utimes, writeFile } from "node:fs/promises";
+import path from "node:path";
+import { test, expect } from "@playwright/test";
+import { resetData, resolvePath, testPaths } from "./helpers";
+import { baseUrl } from "./baseUrl";
+
+// /cleanup/space (lane space-suggestions): Refresh runs the space scan as a
+// job; the disks render, fullest marked; caption compression leads the corpus
+// disk; a suggestion's button runs the existing writer (here evict-clips, by
+// age) and a rescan no longer lists what it freed. A dry run answers in place
+// (compress-text's). Nothing here reaches a platform.
+
+const SLUG = "test-transcribe";
+const DATA = `${testPaths().transcriptsDir}/channels/${SLUG}/data`;
+const RESULT = `${testPaths().transcriptsDir}/.space-suggestions.json`;
+const DAY = 86_400_000;
+
+async function seed(): Promise<string> {
+ await writeFile(resolvePath(`${DATA}/vidA/transcript.en.vtt`), "WEBVTT\n\n" + "00:00.000 --> 00:01.000\nhello\n\n".repeat(4000));
+ const clip = resolvePath(`${DATA}/vidB/clips/10.00-20.00.mp4`);
+ await mkdir(path.dirname(clip), { recursive: true });
+ await writeFile(clip, Buffer.alloc(200_000, 1));
+ const old = new Date(Date.now() - 60 * DAY);
+ await utimes(clip, old, old);
+ return clip;
+}
+
+async function scan(page: import("@playwright/test").Page): Promise<void> {
+ const before = await stat(resolvePath(RESULT)).then((s) => s.mtimeMs, () => 0);
+ await page.getByRole("button", { name: "Refresh" }).click();
+ await expect
+ .poll(async () => stat(resolvePath(RESULT)).then((s) => s.mtimeMs, () => 0), { timeout: 60_000 })
+ .toBeGreaterThan(before);
+ await page.reload();
+}
+
+test("free up space: a scan, the disks, caption compression first, an eviction through its writer", async ({ page }) => {
+ await resetData("one-transcribe-channel-with-audio");
+ const clip = await seed();
+ await fetch(`${baseUrl}/api/test/invalidate-cache`).catch(() => {});
+
+ await page.goto("/cleanup");
+ await expect(page.getByLabel("space summary")).toContainText("No space scan yet.");
+ await page.getByRole("link", { name: "Free up space" }).first().click();
+ await expect(page).toHaveURL(/\/cleanup\/space$/);
+ await expect(page.getByText("No scan yet.")).toBeVisible();
+
+ await scan(page);
+ const corpus = page.getByLabel("disk corpus");
+ await expect(corpus).toBeVisible();
+ await expect(corpus).toContainText("fullest");
+ await expect(corpus).toContainText("The archive's:");
+
+ // Caption compression leads the corpus disk's list.
+ const groups = page.getByRole("region", { name: "suggestions" }).locator("[aria-label^='group ']");
+ await expect(groups.first()).toHaveAttribute("aria-label", "group compress-captions");
+ const evict = page.getByLabel("group evict-clips");
+ await expect(evict).toContainText(`${SLUG}`);
+
+ // A dry run answers in place, and runs nothing.
+ const captions = page.getByLabel("group compress-captions");
+ await captions.getByRole("button", { name: "Compress…" }).first().click();
+ await captions.getByRole("button", { name: "Dry run" }).click();
+ await expect(captions.getByLabel("dry run")).toContainText(SLUG);
+ await captions.getByRole("button", { name: "Cancel" }).click();
+
+ // The eviction: the confirm names the ops call; Confirm runs evict-clips.
+ await evict.getByRole("button", { name: "Free it…" }).first().click();
+ await expect(evict.getByRole("group")).toContainText("pnpm ops evict-clips");
+ await evict.getByRole("button", { name: "Confirm" }).click();
+ await expect(evict.getByRole("status")).toContainText("rescan to update");
+ await expect.poll(() => existsAbs(clip), { timeout: 30_000 }).toBe(false);
+
+ // A rescan no longer lists it; the summary line on /cleanup names the disk.
+ await page.goto("/cleanup/space");
+ await scan(page);
+ await expect(page.getByLabel("group evict-clips")).toHaveCount(0);
+ await page.goto("/cleanup");
+ await expect(page.getByLabel("space summary")).toContainText("Corpus disk:");
+});
+
+async function existsAbs(p: string): Promise<boolean> {
+ return stat(p).then(() => true, () => false);
+}