// FREE UP SPACE: the pure half (lane space-suggestions). The scan // (controller/spaceScan.ts, the `space-scan` job) measures the disks and writes // `transcripts/.space-suggestions.json`; this module is the shape of that file // and every rule that orders, groups and bounds it. The page // (/cleanup/space), the ops read (`get space-suggestions`) and the /cleanup // summary line read the file through these functions. Pure: no fs, so a page // and a test call it alike. // // THE PAGE ONLY PROPOSES. Every suggestion's `actions` is the existing ops // call that does it (compress-text, cleanup, relocate, evict-clips, // delete-file, compact-saved-videos, drop-saved-alternate, // kept-failed-encodes, live-recording-verify) — there is no new way to delete // or move here, and the writer refuses whatever it refuses when it runs. import { formatBytes } from "./format"; import type { SavedVideoAlternate, SavedVideoPointer } from "./savedVideo"; // 2 (review 2, F2): rows carry what the click re-checks (hold, targets, // digest); a file of another version is refused at the click ("rescan first"). export const SPACE_SCAN_VERSION = 2; export const SPACE_SUGGESTIONS_FILENAME = ".space-suggestions.json"; export const SPACE_SCAN_JOB_KIND = "space-scan"; export const SPACE_SCAN_QUEUE = "space-scan"; // Rows kept per kind per disk; past it the file counts the rest exactly. export const SPACE_ITEMS_PER_KIND = 50; // The age past which a clip window is proposed for eviction (by age only). export const SPACE_CLIP_AGE_DAYS = 30; // The age past which a downloader's partial counts as abandoned. export const SPACE_PARTIAL_AGE_DAYS = 7; // What a move must leave on its target beyond the free-space floor. export const SPACE_MOVE_MARGIN_BYTES = 5 * 1024 ** 3; export type SpaceDiskStatus = "ok" | "not-mounted" | "not-answering"; // What of a disk is the archive's, by what it is. Every figure is allocated // bytes (st_blocks × 512, what df counts), each inode once. export type SpaceArchiveShare = { // Audio, raw live chat and kept chat captures (the media tier). media: number; // Transcripts, captions, metadata, sidecars: channels' text. text: number; // Fetched clip windows (`data//clips/`). clips: number; // The saved-video store (containers, alternates, staging, scratch). store: number; // Browser-playable copies (prepare-playable). playable: number; // Site builds (export/.export-builds, export/public, homepage/out). builds: number; // umtool's report projects (its REPORTS_DIR). reports: number; // Everything else under transcripts/ (index.mdb, .jobs, export, …). other: number; }; export type SpaceDisk = { id: string; label: string; mountpoint: string | null; status: SpaceDiskStatus; detail?: string; // "corpus disk", "location