// The speakers readout — what the Speakers lane is holding, what it has freed, // how fast it goes and how long is left. Client-safe types and the one line // every surface prints (the lane deck, /cleanup, `pnpm ops get speakers`), so // the three can never word or round it differently. Built server-side by // controller/speakersReadout.ts from the channel snapshots and the ledger. import { formatBytes } from "./format"; export type SpeakersChannelRow = { slug: string; // Media on another drive (the channel names a mediaDir). external: boolean; // Audio held for the lane that it WILL clear (the hold minus what it never // clears), bytes and videos. waitingBytes: number; waitingVideos: number; // Audio held at the speakers gate that the lane will never clear (over the // duration cap, no input, the operation unconfigured). neverClearsBytes: number; neverClearsVideos: number; remainingAudioHours: number; unmeasuredVideos: number; voiceprinted: number; noFingerprintPossible: number; }; export type SpeakersReadout = { waitingBytes: number; waitingVideos: number; neverClearsBytes: number; neverClearsVideos: number; // This run (.speakers-run.json). freedBytes: number; freedVideos: number; runStartedAt: string | null; // Measured engine cost: wall seconds per audio-hour over `measured` sidecars. secondsPerAudioHour: number | null; measured: number; // Remaining work. Videos with no recorded duration are estimated at the mean // duration of the measured ones (and counted in unmeasuredVideos). remainingAudioHours: number; unmeasuredVideos: number; // Wall-clock days at concurrency 1, or null when nothing measured the rate. etaDays: number | null; voiceprinted: number; noFingerprintPossible: number; // Channels whose snapshot predates the readout's fields: their numbers are // missing until the next regeneration. staleSnapshots: number; channels: SpeakersChannelRow[]; }; function days(d: number): string { if (d < 1) return "under a day"; const n = d < 10 ? Math.round(d * 10) / 10 : Math.round(d); return `${n} day${n === 1 ? "" : "s"}`; } // "waiting: 368.78 GB in 3,634 videos · freed this run: 0 B · about 41 days left" export function speakersReadoutLine(r: SpeakersReadout): string { const waiting = `waiting: ${formatBytes(r.waitingBytes)} in ${r.waitingVideos.toLocaleString("en-US")} video${r.waitingVideos === 1 ? "" : "s"}`; const freed = `freed this run: ${formatBytes(r.freedBytes)}`; const left = r.waitingVideos === 0 ? "nothing left" : r.etaDays === null ? "time left not yet measured" : `about ${days(r.etaDays)} left`; return `${waiting} · ${freed} · ${left}`; }