Archilyzer · Source

archilyzer

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

commit 5fd3a574988f435ab3e5b74f02f999c5c5fde72f
parent 790d1a7f059c5cc6626502861010a971abfac5e7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 11 Nov 2026 01:03:15 -0500

speakers: one control and a readout -- the lane deck draws ONE button for the Speakers lane, "Work through speakers" (arms it AND lifts its hold, starts a run) / "Pause" (holds it, stays armed), with "waiting: X GB in N videos · freed this run: Y GB · about D days left" under it, and the same line on /cleanup; render mode holds the Speakers lane too

- The deck's Run/Stop + Hold/Resume pair for the backfill lane is gone: the
  two switches together had a state, armed and held, that read "running" while
  idle. workThroughSpeakersAction / pauseSpeakersAction (jobs/actions.ts);
  disarming outright stays on the lane console (and `pnpm ops lane`).
- The readout (lib/speakersReadout.ts types + line, controller/
  speakersReadout.ts): waiting = the awaiting-speakers hold minus what the lane
  never clears; freed this run from speakers-run.json; seconds per audio-hour
  measured from the sidecars' durationMs/audioSeconds; days left = remaining
  audio-hours (recorded durations; an unmeasured video at the measured mean) x
  that rate, at concurrency 1. Per-channel numbers come from a new snapshot
  block, `speakers` (work seconds, engine time, voiceprinted,
  noFingerprintPossible), filled in the fold the snapshot already does.
- Speakers stage: when the lane is paused it says "The Speakers lane is
  paused, so Run speaker work waits for it." and offers Work through speakers
  there; Run speaker work's tooltip says what it runs. The per-run hold message
  now names the lane and the control. Labels/counts follow what the lane
  DISPATCHES (backfillLaneDispatchOperations: the `operations` narrowing).
- Cleanup stage: "Diarize speakers" says what it does (this channel, now, even
  paused; fingerprints for already-diarized videos); the summary shows "X held
  for speakers (N videos)" instead of "Nothing to clean."; /cleanup counts a
  paused or disarmed lane's whole hold as never clearing on its own, gate 4
  says "run: Work through speakers".
- Settings form: the stale ggml sentence fixed and the line now points at
  Work through speakers; two switches, Keep the audio until its voice
  fingerprints are stored (requireVoiceprints) and Clean after capture.
- RENDER_MODE_LANES gains `backfill`; tests and the prose (AGENTS.md,
  WORKTREES.md, umtool docs) say three lanes. The fakes start the Speakers
  lane held, as it ships, so the existing call sequences stand; new
  assertions hold it when it is free.
- e2e: the deck-driven specs (backfill, widget) now drive Work through
  speakers / Pause and disarm through `pnpm ops lane`; fake-diarize writes
  voiceprints and does --voiceprints-only; seeded "diarized" sidecars carry
  voiceprints (cleanup-holds' vidD is a complete record, not a malformed one).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Diffstat:
MAGENTS.md | 2+-
MWORKTREES.md | 2+-
Mcommon/components/StreamActionLog.tsx | 4++++
Mcommon/controller/channelSnapshot.ts | 59++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mcommon/controller/operationBatch.ts | 2+-
Acommon/controller/speakersReadout.test.ts | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acommon/controller/speakersReadout.ts | 104+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/lib/operations.ts | 11+++++++++++
Mcommon/lib/renderPriority.mjs | 7++++---
Mcommon/lib/renderPriority.test.ts | 16++++++++++------
Acommon/lib/speakersReadout.ts | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/views/channelGroupSections.ts | 6+++---
Mcommon/views/pipeline/stageStatus.ts | 11+++++++++++
Mcommon/views/widgetSync.ts | 40+++++++++++++++++++++++++++++++++++++---
Meditor/app/api/ops/_renderMode.test.ts | 21++++++++++++++++-----
Meditor/app/api/ops/render-mode/route.ts | 2+-
Meditor/app/channels/[slug]/components/stages/CleanupStage.tsx | 4++--
Meditor/app/channels/[slug]/components/stages/SpeakersStage.tsx | 31+++++++++++++++++++++++++++++++
Meditor/app/channels/[slug]/page.tsx | 13++++++++-----
Meditor/app/cleanup/components/HoldSieve.tsx | 2+-
Meditor/app/cleanup/lib/loadCleanup.ts | 13+++++++++++++
Meditor/app/cleanup/page.tsx | 38++++++++++++++++++++++++++++++++++++++
Meditor/app/components/lanes/LaneDeck.tsx | 60++++++++++++++++++++++++++++++++++++++++--------------------
Meditor/app/jobs/actions.ts | 36++++++++++++++++++++++++++++++++++++
Meditor/app/operations/components/settings/DiarizationSettingsForm.tsx | 56+++++++++++++++++++++++++++++++++++++++++++++++++-------
Meditor/app/operations/renderMode.ts | 2+-
Meditor/app/operations/settingsActions.ts | 3+++
Meditor/app/widget/lib/syncInputs.ts | 6++++--
Meditor/e2e/backfill.spec.ts | 125+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Meditor/e2e/cleanup-holds.spec.ts | 11++++++++++-
Meditor/e2e/diarization.spec.ts | 15++++++++++++++-
Meditor/e2e/fixtures/bin/fake-diarize.mjs | 33+++++++++++++++++++++++++++++++--
Meditor/e2e/widget.spec.ts | 24++++++++++++++++--------
Mumtool/docs/cli.md | 2+-
Mumtool/docs/report-video.md | 2+-
Mumtool/lib/report/renderMode.mjs | 2+-
Mumtool/lib/report/renderMode.test.mjs | 13++++++++-----
37 files changed, 784 insertions(+), 145 deletions(-)

diff --git a/AGENTS.md b/AGENTS.md @@ -91,7 +91,7 @@ pnpm ops render-mode --json '{"on":true,"for":"90m"}' # the same with only pnpm While it is on, every other heavy job (e2e suites, `next build`s, the publish stages, other renders) waits at the heavy slot's door — `queue-lock: held for a render (umtool take <p> --id <t>, since 13:31) — waiting` is the gate working — while the render runs on the floor 4000 MB -and the cap 10240 MB; the editor's transcription and download lanes are held (only the ones +and the cap 10240 MB; the editor's transcription, download and Speakers lanes are held (only the ones not already held; only those are released). **A script uses `render-mode on -- <cmd …>`, never a bare `on`**: the command carries the token, the hold is its pid, and it ends when the command exits — a bare `on` in a script leaves a window behind and its later commands wait at the door (the chain trap); diff --git a/WORKTREES.md b/WORKTREES.md @@ -437,7 +437,7 @@ While it is on: released when it exits — done, failed, or umtool signalled (the signal is passed on); the exit code is the command's. A bare `on` in a script is the chain trap: the window outlives the script, and a command that never got the token waits at the door behind it. -- **the editor's transcription and download lanes are held** — only the ones not already +- **the editor's transcription, download and Speakers lanes are held** — only the ones not already held, and only those are released at the end (a hold someone else made stays). With no editor to ask, render mode still holds the door and says the lanes were not held. - the umtool take panel and the editor's `/jobs` show a banner; **close Firefox and other diff --git a/common/components/StreamActionLog.tsx b/common/components/StreamActionLog.tsx @@ -26,6 +26,8 @@ type Props = { * that need a typed-confirmation gate before allowing the action. */ disabled?: boolean; + /** What the button does, in one sentence, as its tooltip. */ + title?: string; /** * Called when a run SETTLES — the job's stream has been read to the end (or * the trigger refused before one existed). `started` is false for a refusal. @@ -57,6 +59,7 @@ export function StreamActionLog({ cancelAction, extraControls, disabled = false, + title, onSettled, }: Props) { const accessibleName = label ?? buttonLabel; @@ -205,6 +208,7 @@ export function StreamActionLog({ size="sm" onClick={handleClick} disabled={!hydrated || running || disabled} + title={title} > {running ? runningLabel : buttonLabel} </Button> diff --git a/common/controller/channelSnapshot.ts b/common/controller/channelSnapshot.ts @@ -484,6 +484,9 @@ export type ChannelSnapshot = { // fifth gate: the real gate needs a live probe, and folding a guess into the // hero figure would move the sidebar badge and /cleanup's Est. reclaim too. reclaimableAtRiskBytes?: number; + // The Speakers lane over this channel (the speakers readout's per-channel + // row). Optional: snapshots written before it lack it. + speakers?: SpeakersWork; // The audio audit's verdicts over the channel (release 32). Optional: older // snapshots lack it; readers show nothing until the next regen. audioIntegrity?: AudioIntegrityTally; @@ -503,6 +506,35 @@ export type HeldAudio = { diarizationNeverClears: number; }; +export type SpeakersWork = { + // Audio seconds of the awaiting-diarization videos the lane will clear (the + // hold minus diarizationNeverClears), by recorded duration; and how many of + // them have no duration on disk. + workSeconds: number; + workUnmeasured: number; + // The engine's measured cost on this channel's sidecars: summed durationMs + // over summed audioSeconds, from `measured` sidecars. + engineMs: number; + engineAudioSeconds: number; + measured: number; + // Sidecars with complete voice fingerprints; and diarized videos without + // them whose audio is already gone — no fingerprint is possible for those. + voiceprinted: number; + noFingerprintPossible: number; +}; + +export function emptySpeakersWork(): SpeakersWork { + return { + workSeconds: 0, + workUnmeasured: 0, + engineMs: 0, + engineAudioSeconds: 0, + measured: 0, + voiceprinted: 0, + noFingerprintPossible: 0, + }; +} + export function emptyHeldAudio(): HeldAudio { return { noTranscript: 0, @@ -1319,6 +1351,7 @@ export async function generateChannelSnapshot( let totalClipsBytes = 0; const heldAudioBytes = emptyHeldAudio(); const heldAudioCounts = emptyHeldAudio(); + const speakers = emptySpeakersWork(); let reclaimableAtRiskBytes = 0; // Is the lane that would release an awaiting-diarization video even running? // allOperations drops a kind whose enabled() is false, so an ABSENT entry @@ -1372,11 +1405,24 @@ export async function generateChannelSnapshot( // fingerprints is held at the same gate as an absent one — what it waits // for is the Speakers lane either way. Only a video that holds audio pays // the read. + const diarRecord = files.hasDiarization + ? await loadDiarization(path.join(dataDir, id)) + : null; + const diarVoiceprinted = hasVoiceprints(diarRecord); + if (diarRecord) { + if (diarVoiceprinted) speakers.voiceprinted++; + else if (files.audioFiles.length === 0) speakers.noFingerprintPossible++; + // The engine's own clock, for the readout's rate: wall time over the + // audio it was given. + if ((diarRecord.durationMs ?? 0) > 0 && (diarRecord.audioSeconds ?? 0) > 0) { + speakers.engineMs += diarRecord.durationMs!; + speakers.engineAudioSeconds += diarRecord.audioSeconds!; + speakers.measured++; + } + } const diarizedForCleanup = files.hasDiarization && - (!voiceprintGuardOn || - files.audioFiles.length === 0 || - hasVoiceprints(await loadDiarization(path.join(dataDir, id)))); + (!voiceprintGuardOn || files.audioFiles.length === 0 || diarVoiceprinted); if (files.audioFiles.length > 0) { const gate = attributeAudioHold({ // The sweep's own gate — entries.includes("transcript.json"). NOT @@ -1416,6 +1462,12 @@ export async function generateChannelSnapshot( ) { heldAudioBytes.diarizationNeverClears += audioBytes; heldAudioCounts.diarizationNeverClears += 1; + } else if (gate === "awaitingDiarization") { + // Work the Speakers lane WILL do, in audio seconds (the readout's + // "days left"). The recorded duration; a video without one counted. + const sec = coverage?.cov.duration ?? 0; + if (sec > 0) speakers.workSeconds += sec; + else speakers.workUnmeasured++; } } } @@ -1937,6 +1989,7 @@ export async function generateChannelSnapshot( totalClipsBytes, heldAudioBytes, heldAudioCounts, + speakers, reclaimableAtRiskBytes, audioIntegrity, }; diff --git a/common/controller/operationBatch.ts b/common/controller/operationBatch.ts @@ -341,7 +341,7 @@ function backfillLaneLimit( hold: { hold: true, reason: "paused", - message: "Backfill lane disabled in settings — holding.", + message: "The Speakers lane is paused — holding. Work through speakers (on its lane card) lifts it.", }, }; } diff --git a/common/controller/speakersReadout.test.ts b/common/controller/speakersReadout.test.ts @@ -0,0 +1,81 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { buildSpeakersReadout } from "./speakersReadout"; +import { emptySpeakersLedger } from "../lib/speakersLedger-server"; +import { speakersReadoutLine } from "../lib/speakersReadout"; +import { emptyHeldAudio, emptySpeakersWork } from "./channelSnapshot"; + +const GB = 1024 ** 3; + +function brief(slug: string, o: { + external?: boolean; + awaitingBytes: number; + awaitingVideos: number; + neverBytes?: number; + neverVideos?: number; + workSeconds?: number; + unmeasured?: number; + engineMs?: number; + engineAudioSeconds?: number; + measured?: number; + speakers?: boolean; +}) { + const heldAudioBytes = { ...emptyHeldAudio(), awaitingDiarization: o.awaitingBytes, diarizationNeverClears: o.neverBytes ?? 0 }; + const heldAudioCounts = { ...emptyHeldAudio(), awaitingDiarization: o.awaitingVideos, diarizationNeverClears: o.neverVideos ?? 0 }; + return { + slug, + config: (o.external ? { mediaDir: "/mnt/x" } : {}) as never, + snapshot: { + heldAudioBytes, + heldAudioCounts, + ...(o.speakers === false + ? {} + : { + speakers: { + ...emptySpeakersWork(), + workSeconds: o.workSeconds ?? 0, + workUnmeasured: o.unmeasured ?? 0, + engineMs: o.engineMs ?? 0, + engineAudioSeconds: o.engineAudioSeconds ?? 0, + measured: o.measured ?? 0, + }, + }), + } as never, + }; +} + +test("the readout: waiting is the hold the lane WILL clear; rate from the sidecars; days at concurrency 1", () => { + const r = buildSpeakersReadout( + [ + // 10 GB held, 2 GB of it never clears; 9 h of work measured, 1 video unmeasured. + brief("ext", { external: true, awaitingBytes: 10 * GB, awaitingVideos: 10, neverBytes: 2 * GB, neverVideos: 2, workSeconds: 7 * 3600, unmeasured: 1 }), + brief("int", { awaitingBytes: 1 * GB, awaitingVideos: 2, workSeconds: 2 * 3600, engineMs: 600_000, engineAudioSeconds: 3600, measured: 4 }), + brief("old", { awaitingBytes: GB, awaitingVideos: 1, speakers: false }), + ], + { ...emptySpeakersLedger(), freedBytes: 3 * GB, freedVideos: 5, startedAt: "2026-11-11T00:00:00.000Z" }, + ); + assert.equal(r.waitingBytes, 10 * GB); + assert.equal(r.waitingVideos, 11); + assert.equal(r.neverClearsVideos, 2); + assert.equal(r.secondsPerAudioHour, 600); + assert.equal(r.unmeasuredVideos, 1); + // 9 measured hours; the unmeasured video is estimated at the measured mean. + assert.ok(r.remainingAudioHours > 9 && r.remainingAudioHours < 11); + assert.equal(r.etaDays, Math.round(((r.remainingAudioHours * 600) / 86400) * 10) / 10); + assert.equal(r.staleSnapshots, 1); + // Corpus disk first. + assert.deepEqual(r.channels.map((c) => c.slug), ["int", "old", "ext"]); + assert.equal(r.freedBytes, 3 * GB); + assert.equal( + speakersReadoutLine(r), + `waiting: 10.00 GB in 11 videos · freed this run: 3.00 GB · about ${r.etaDays! < 1 ? "under a day" : `${r.etaDays} day${r.etaDays === 1 ? "" : "s"}`} left`, + ); +}); + +test("the readout line with nothing measured and nothing waiting", () => { + const unmeasured = buildSpeakersReadout([brief("a", { awaitingBytes: GB, awaitingVideos: 1, workSeconds: 3600 })], emptySpeakersLedger()); + assert.equal(unmeasured.etaDays, null); + assert.match(speakersReadoutLine(unmeasured), /time left not yet measured$/); + const none = buildSpeakersReadout([], emptySpeakersLedger()); + assert.equal(speakersReadoutLine(none), "waiting: 0 B in 0 videos · freed this run: 0 B · nothing left"); +}); diff --git a/common/controller/speakersReadout.ts b/common/controller/speakersReadout.ts @@ -0,0 +1,104 @@ +// The speakers readout, built (lib/speakersReadout.ts has the types and the +// line). Everything comes from what is already on disk and cheap: each +// channel's snapshot (heldAudioBytes / heldAudioCounts for the hold, the +// `speakers` block for work seconds and the measured engine rate) and the +// ledger for "freed this run". No per-video read here: the snapshot paid for +// those when it was regenerated. + +import type { Paths } from "../lib/paths"; +import type { ChannelBrief } from "./channels"; +import { listChannelBriefs } from "./channels"; +import { readSpeakersLedger, type SpeakersLedger } from "../lib/speakersLedger-server"; +import type { SpeakersChannelRow, SpeakersReadout } from "../lib/speakersReadout"; + +// PURE: the readout for these briefs and this ledger. +export function buildSpeakersReadout( + briefs: ReadonlyArray<Pick<ChannelBrief, "slug" | "config" | "snapshot">>, + ledger: SpeakersLedger, +): SpeakersReadout { + const channels: SpeakersChannelRow[] = []; + let engineMs = 0; + let engineAudioSeconds = 0; + let measured = 0; + let staleSnapshots = 0; + for (const b of briefs) { + const snap = b.snapshot; + const held = snap?.heldAudioBytes; + const count = snap?.heldAudioCounts; + const work = snap?.speakers; + if (!snap || !held || !count) continue; + if (!work) staleSnapshots++; + if (work) { + engineMs += work.engineMs; + engineAudioSeconds += work.engineAudioSeconds; + measured += work.measured; + } + const row: SpeakersChannelRow = { + slug: b.slug, + external: !!b.config?.mediaDir || !!b.config?.dataDir, + waitingBytes: Math.max(0, held.awaitingDiarization - held.diarizationNeverClears), + waitingVideos: Math.max(0, count.awaitingDiarization - count.diarizationNeverClears), + neverClearsBytes: held.diarizationNeverClears, + neverClearsVideos: count.diarizationNeverClears, + remainingAudioHours: (work?.workSeconds ?? 0) / 3600, + unmeasuredVideos: work?.workUnmeasured ?? 0, + voiceprinted: work?.voiceprinted ?? 0, + noFingerprintPossible: work?.noFingerprintPossible ?? 0, + }; + if ( + row.waitingVideos > 0 || + row.neverClearsVideos > 0 || + row.voiceprinted > 0 || + row.noFingerprintPossible > 0 + ) { + channels.push(row); + } + } + // The lane's own order: corpus disk first, then the biggest hold. + channels.sort( + (a, b) => + Number(a.external) - Number(b.external) || + b.waitingBytes - a.waitingBytes || + a.slug.localeCompare(b.slug), + ); + const sum = (f: (r: SpeakersChannelRow) => number) => channels.reduce((s, r) => s + f(r), 0); + const waitingVideos = sum((r) => r.waitingVideos); + const unmeasuredVideos = sum((r) => r.unmeasuredVideos); + const measuredHours = sum((r) => r.remainingAudioHours); + const measuredVideos = waitingVideos - unmeasuredVideos; + const meanHours = measuredVideos > 0 ? measuredHours / measuredVideos : 0; + const remainingAudioHours = measuredHours + unmeasuredVideos * meanHours; + const secondsPerAudioHour = + measured > 0 && engineAudioSeconds > 0 ? engineMs / 1000 / (engineAudioSeconds / 3600) : null; + const etaDays = + secondsPerAudioHour === null ? null : (remainingAudioHours * secondsPerAudioHour) / 86_400; + return { + waitingBytes: sum((r) => r.waitingBytes), + waitingVideos, + neverClearsBytes: sum((r) => r.neverClearsBytes), + neverClearsVideos: sum((r) => r.neverClearsVideos), + freedBytes: ledger.freedBytes, + freedVideos: ledger.freedVideos, + runStartedAt: ledger.startedAt, + secondsPerAudioHour: secondsPerAudioHour === null ? null : Math.round(secondsPerAudioHour), + measured, + remainingAudioHours: Math.round(remainingAudioHours * 10) / 10, + unmeasuredVideos, + etaDays: etaDays === null ? null : Math.round(etaDays * 10) / 10, + voiceprinted: sum((r) => r.voiceprinted), + noFingerprintPossible: sum((r) => r.noFingerprintPossible), + staleSnapshots, + channels, + }; +} + +export async function loadSpeakersReadout( + paths: Paths, + briefs?: ReadonlyArray<Pick<ChannelBrief, "slug" | "config" | "snapshot">>, +): Promise<SpeakersReadout> { + const [list, ledger] = await Promise.all([ + briefs ? Promise.resolve(briefs) : listChannelBriefs(paths), + readSpeakersLedger(paths), + ]); + return buildSpeakersReadout(list, ledger); +} diff --git a/common/lib/operations.ts b/common/lib/operations.ts @@ -1670,6 +1670,17 @@ export function backfillLaneOperations(settings: SiteSettings): Operation[] { ); } +// The backfill lane's kinds AS IT DISPATCHES THEM: backfillLaneOperations with +// the lane's `operations` narrowing (autoQueue.backfill.operations) applied — +// what operationsForLane("backfill") runs, for the surfaces that name and count +// the lane (the deck, the Speakers stage, the /channels sections). Asks no +// laneFor, so a partial settings object is safe here. +export function backfillLaneDispatchOperations(settings: SiteSettings): Operation[] { + const only = settings.autoQueue?.backfill?.operations; + const lane = backfillLaneOperations(settings); + return only && only.length > 0 ? lane.filter((k) => only.includes(k.id)) : lane; +} + // The READ-SIDE twin of backfillLaneOperations: given a snapshot's per-kind map, // return only the entries belonging to the shared backfill lane — KEYED, so a // surface can say WHICH kind a number came from. backfillLaneEntriesOf below is this diff --git a/common/lib/renderPriority.mjs b/common/lib/renderPriority.mjs @@ -14,7 +14,7 @@ // subprocesses: RENDER_PRIORITY_TOKEN) is admitted, with the floor 4000 MB // and the cap 10240 MB unless HEAVY_MIN_FREE_MB / HEAVY_CAP_MB say // otherwise; -// - holds the editor's transcription and download lanes, remembering which +// - holds the editor's transcription, download and Speakers lanes, remembering which // ones IT held (`lanesHeld`), so ending it releases only those — a lane // someone else held before stays held. // @@ -51,8 +51,9 @@ import path from "node:path"; export const RENDER_PRIORITY_FLOOR_MB = 4000; /** The render's heavy cap (MemoryMax) in render mode, absent HEAVY_CAP_MB. */ export const RENDER_PRIORITY_CAP_MB = 10240; -/** The editor lanes render mode holds. */ -export const RENDER_MODE_LANES = Object.freeze(["transcription", "download"]); +/** The editor lanes render mode holds: the GPU transcription lane, downloads, and + * the Speakers (backfill) lane — CPU diarization, ~4 cores, which a render wants. */ +export const RENDER_MODE_LANES = Object.freeze(["transcription", "download", "backfill"]); /** A manual window with no --for ends after this. */ export const DEFAULT_RENDER_MODE_WINDOW_MS = 2 * 60 * 60 * 1000; /** The env var a render (and everything under it) carries the hold's token in. */ diff --git a/common/lib/renderPriority.test.ts b/common/lib/renderPriority.test.ts @@ -36,7 +36,9 @@ function tmpFile() { } /** A fake editor's lanes: `held` is what it holds; `calls` what was asked. */ -function fakeLanes(held: Record<string, boolean> = {}, { failRelease = false } = {}) { +// The Speakers (backfill) lane starts held, as it ships. +function fakeLanes(initial: Record<string, boolean> = {}, { failRelease = false } = {}) { + const held: Record<string, boolean> = { backfill: true, ...initial }; const calls: string[] = []; const lanes: RenderModeLanes = { async isHeld(lane) { @@ -139,13 +141,15 @@ test("describeRenderPriority and parseDurationMs", () => { test("on holds only the lanes not held already, and off releases only those", async () => { const file = tmpFile(); - const ed = fakeLanes({ download: true }); // someone else's hold + // Someone else's hold on download; the Speakers (backfill) lane running — + // a render takes its cores too (RENDER_MODE_LANES). + const ed = fakeLanes({ download: true, backfill: false }); const on = await renderModeOn({ file, holder: { pid: process.pid, cmd: "umtool take p --id t", project: "p", take: "t" }, lanes: ed.lanes, editor: "http://localhost:3001" }); assert.equal(on.ok, true); - assert.deepEqual(on.state?.lanesHeld, ["transcription"]); + assert.deepEqual(on.state?.lanesHeld, ["transcription", "backfill"]); assert.deepEqual(on.state?.lanesSkipped, ["download"]); assert.equal(on.state?.until, null); // a take's hold ends with its process - assert.deepEqual(ed.calls, ["hold transcription"]); + assert.deepEqual(ed.calls, ["hold transcription", "hold backfill"]); const onDisk = readRenderPriorityState(file); assert.equal(onDisk?.token, on.state?.token); assert.equal(readRenderPriority(file).held, true); @@ -161,8 +165,8 @@ test("on holds only the lanes not held already, and off releases only those", as assert.equal(existsSync(file), true); const off = await renderModeOff({ file, token: on.state?.token, lanes: ed.lanes }); - assert.deepEqual(off.released, ["transcription"]); - assert.deepEqual(ed.calls, ["hold transcription", "release transcription"]); + assert.deepEqual(off.released, ["transcription", "backfill"]); + assert.deepEqual(ed.calls, ["hold transcription", "hold backfill", "release transcription", "release backfill"]); assert.equal(ed.held.download, true, "the hold it found stays"); assert.equal(existsSync(file), false); }); diff --git a/common/lib/speakersReadout.ts b/common/lib/speakersReadout.ts @@ -0,0 +1,70 @@ +// 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}`; +} diff --git a/common/views/channelGroupSections.ts b/common/views/channelGroupSections.ts @@ -14,7 +14,7 @@ import { import { DIGEST_OPERATION_ID, allOperations, - backfillLaneOperations, + backfillLaneDispatchOperations, backfillLaneEntriesOf, operationsGroupLabel, reachableOperationWork, @@ -102,7 +102,7 @@ export function laneOffFor( if (station === "digest") { return !allOperations(settings).some((k) => k.id === DIGEST_OPERATION_ID); } - if (station === "speakers") return backfillLaneOperations(settings).length === 0; + if (station === "speakers") return backfillLaneDispatchOperations(settings).length === 0; return false; } @@ -328,7 +328,7 @@ export function buildChannelGroupSections( digest: station("digest"), speakers: station("speakers"), speakersLabel: operationsGroupLabel( - backfillLaneOperations(settings).map((k) => k.id), + backfillLaneDispatchOperations(settings).map((k) => k.id), ), }; }); diff --git a/common/views/pipeline/stageStatus.ts b/common/views/pipeline/stageStatus.ts @@ -14,6 +14,7 @@ import { // three client components (AttentionStrip, NextAction, OverviewPanel) for its // types. A type import is erased, a value import would not be. import type { ChannelMediaLocation } from "../../lib/channelMedia"; +import { formatBytes } from "../../lib/format"; export type SnapshotBuckets = ChannelSnapshot["buckets"]; @@ -558,6 +559,16 @@ export function computeStageStatuses( ), ); } + // Audio held for the Speakers lane. Not pending work for THIS stage (Clean + // audio cannot take it yet), but the reason the disk is not freed — the + // summary used to say "Nothing to clean." with gigabytes held. + const heldForSpeakers = snapshot.heldAudioBytes?.awaitingDiarization ?? 0; + const heldForSpeakersCount = snapshot.heldAudioCounts?.awaitingDiarization ?? 0; + if (heldForSpeakers > 0) { + cleanupParts.push( + `${formatBytes(heldForSpeakers)} held for speakers (${pluralize(heldForSpeakersCount, "video", "videos")})`, + ); + } const cleanup: StageStatus = { id: "cleanup", title: "Cleanup", diff --git a/common/views/widgetSync.ts b/common/views/widgetSync.ts @@ -1,10 +1,13 @@ import type { SiteSettings } from "../lib/settings"; import { digestCountOf, type ChannelBrief } from "../controller/channels"; import { digestWorkOf } from "../controller/channelSnapshot"; +import { buildSpeakersReadout } from "../controller/speakersReadout"; +import { emptySpeakersLedger, type SpeakersLedger } from "../lib/speakersLedger-server"; +import { speakersReadoutLine } from "../lib/speakersReadout"; import { isGateHeld } from "../lib/pauseGates"; import { - backfillLaneOperations, backfillLaneOperationEntriesOf, + backfillLaneDispatchOperations, operationCostBasis, operationLabel, operationsGroupLabel, @@ -114,6 +117,16 @@ export type WidgetSyncPayload = { // word survives only on the controls that genuinely act on the shared queue, // and even there the card now lists what is in it. groupLabel: string; + // THE SPEAKERS READOUT, as the lane card prints it (lib/speakersReadout.ts): + // the one line, and the four numbers it leads with. Optional: a payload + // from before it reads as no readout. + speakers?: { + line: string; + waitingBytes: number; + waitingVideos: number; + freedBytes: number; + etaDays: number | null; + }; // The same numbers, kept apart by kind — which is the only form of them that // means anything. Summed, this lane reads "77,952 reachable · 77,134 need // media": both correct, and together a figure in no unit, since 99.5% of the @@ -166,6 +179,9 @@ export type WidgetSyncInputs = { // polls — which is why the briefs arrive as an argument rather than being // read here: the caller already has them, memoized per request. briefs: readonly ChannelBrief[]; + // The Speakers lane's "freed this run" (lib/speakersLedger-server.ts). Absent + // reads as an empty run. + speakersLedger?: SpeakersLedger; }; // Build the widget sync payload. Both the HTTP route and the dashboard cockpit's @@ -240,6 +256,8 @@ export function buildWidgetSyncPayload( // below — no extra read. let digestBlocked = 0; let digestDeferred = 0; + const narrowed = settings.autoQueue.backfill.operations; + const narrowedTo = narrowed && narrowed.length > 0 ? narrowed : null; for (const c of channels) { videos += c.snapshot?.totals.videos ?? 0; const n = digestCountOf(c.snapshot); @@ -259,6 +277,9 @@ export function buildWidgetSyncPayload( // only ever meant diarization plus attribution — the digest coverage figure // it shows beside this one is computed separately, from digestCountOf above. for (const [id, entry] of backfillLaneOperationEntriesOf(c.snapshot?.backfill)) { + // A lane narrowed to some operations (autoQueue.backfill.operations) + // counts only those: the rest is not this lane's work while it is. + if (narrowedTo && !narrowedTo.includes(id)) continue; backfillReachable += reachableOperationWork(entry); backfillNeedsMedia += entry.missingInput; const acc = backfillByKind.get(id) ?? { @@ -310,14 +331,27 @@ export function buildWidgetSyncPayload( armed: settings.autoQueue.digest.enabled, }, backfill: { + speakers: (() => { + const r = buildSpeakersReadout(channels, inputs.speakersLedger ?? emptySpeakersLedger()); + return { + line: speakersReadoutLine(r), + waitingBytes: r.waitingBytes, + waitingVideos: r.waitingVideos, + freedBytes: r.freedBytes, + etaDays: r.etaDays, + }; + })(), reachable: backfillReachable, needsMedia: backfillNeedsMedia, videos, held: isGateHeld(settings, "backfill"), armed: settings.autoQueue.backfill.enabled, - anyKind: backfillLaneOperations(settings).length > 0, + // What the lane DISPATCHES (backfillLaneDispatchOperations: its `operations` + // narrowing applied), so a speakers-only lane is named and broken down as + // what it runs. + anyKind: backfillLaneDispatchOperations(settings).length > 0, groupLabel: operationsGroupLabel( - backfillLaneOperations(settings).map((k) => k.id), + backfillLaneDispatchOperations(settings).map((k) => k.id), ), kinds: [...backfillByKind] .map(([id, counts]) => ({ diff --git a/editor/app/api/ops/_renderMode.test.ts b/editor/app/api/ops/_renderMode.test.ts @@ -19,18 +19,28 @@ const { getWorkerPool } = await import("yt-dlp-transcript-common/jobs/workerPool const { renderModeReapTick } = await import("../../operations/renderMode"); test.after(() => corpus.cleanup()); -const held = (lane: "transcription" | "download") => getSettings().autoQueue[lane].held === true; +const held = (lane: "transcription" | "download" | "backfill") => getSettings().autoQueue[lane].held === true; test("on holds the lanes not already held (and says so), off releases only those", async () => { - await corpus.writeSettings({ minFreeDiskGB: 0, autoQueue: { ...getSettings().autoQueue, download: { ...getSettings().autoQueue.download, held: true } } }); + // The Speakers (backfill) lane running: a render takes its cores too. + await corpus.writeSettings({ + minFreeDiskGB: 0, + autoQueue: { + ...getSettings().autoQueue, + download: { ...getSettings().autoQueue.download, held: true }, + backfill: { ...getSettings().autoQueue.backfill, held: false }, + }, + }); assert.equal(held("download"), true); assert.equal(held("transcription"), false); + assert.equal(held("backfill"), false); const on = await callPost(POST!, { on: true, for: "90m", note: "the Ember cut" }); assert.equal(on.status, 200, JSON.stringify(on.body)); const state = on.body.state as { token: string; lanesHeld: string[]; lanesSkipped: string[]; until: string; editor: string }; - assert.deepEqual(state.lanesHeld, ["transcription"]); + assert.deepEqual(state.lanesHeld, ["transcription", "backfill"]); assert.deepEqual(state.lanesSkipped, ["download"]); + assert.equal(held("backfill"), true); assert.match(String(on.body.join), /^RENDER_PRIORITY_TOKEN=[0-9a-f]{16}$/); assert.match(state.editor, /^http:\/\/localhost:\d+$/); assert.equal(held("transcription"), true); @@ -45,12 +55,13 @@ test("on holds the lanes not already held (and says so), off releases only those assert.equal(got.status, 200); assert.equal(got.body.held, true); assert.equal(got.body.token, undefined, "the read side carries no token"); - assert.deepEqual(got.body.lanesHeld, ["transcription"]); + assert.deepEqual(got.body.lanesHeld, ["transcription", "backfill"]); const off = await callPost(POST!, { on: false }); assert.equal(off.status, 200, JSON.stringify(off.body)); - assert.deepEqual(off.body.released, ["transcription"]); + assert.deepEqual(off.body.released, ["transcription", "backfill"]); assert.equal(held("transcription"), false); + assert.equal(held("backfill"), false); assert.equal(getWorkerPool().isPaused(), false); assert.equal(held("download"), true, "someone else's hold stays"); assert.equal(existsSync(STATE), false); diff --git a/editor/app/api/ops/render-mode/route.ts b/editor/app/api/ops/render-mode/route.ts @@ -14,7 +14,7 @@ export const dynamic = "force-dynamic"; // RENDER MODE (common/lib/renderPriority.mjs; AGENTS.md "Render mode"): a // render the operator is waiting for gets the machine — every other heavy job -// waits at the heavy slot's door, and this editor's transcription and download +// waits at the heavy slot's door, and this editor's transcription, download and Speakers (backfill) // lanes are held (only the ones not held already; only those are released). // The same switch as `umtool render-mode`, for a session that has only `pnpm ops`. // diff --git a/editor/app/channels/[slug]/components/stages/CleanupStage.tsx b/editor/app/channels/[slug]/components/stages/CleanupStage.tsx @@ -89,7 +89,7 @@ export function CleanupStage({ <div className="flex flex-col gap-2"> <Heading title="Diarize speakers" - desc="Capture who is speaking when, to diarization.json beside each transcript, for every video here that still has audio. This is the half of the decision that has a deadline: Clean audio below deletes the audio, and nothing can reconstruct it afterwards. While diarization is on, that sweep holds back any transcribed video without a sidecar — so running this is what releases the audio it is protecting." + desc="This channel, now — even while the Speakers lane is paused: who is speaking when (diarization.json) and each speaker's voice fingerprint, for every video here that still has audio; a video already diarized only gets its fingerprints. Clean audio below holds a transcribed video's audio until both exist, so running this is what releases it. The whole corpus, one video at a time, is Work through speakers on the Speakers lane." /> <StreamActionLog trigger={() => diarizeChannelAction(slug, cleanQueue)} @@ -112,7 +112,7 @@ export function CleanupStage({ <div className="flex flex-col gap-2"> <Heading title="Clean audio for transcribed videos" - desc="Delete audio.* files in any video directory that has a transcript.json (whisper output). YouTube videos with only auto-sub .vtt files have no audio and are skipped automatically." + desc="Delete audio.* files in any video directory that has a transcript.json (whisper output). YouTube videos with only auto-sub .vtt files have no audio and are skipped automatically. While diarization is on, a video awaiting its speakers or voice fingerprints keeps its audio." /> <ReclaimEstimate bytes={transcribedAudioBytes} /> <StreamActionLog diff --git a/editor/app/channels/[slug]/components/stages/SpeakersStage.tsx b/editor/app/channels/[slug]/components/stages/SpeakersStage.tsx @@ -26,6 +26,8 @@ import { StreamActionLog } from "yt-dlp-transcript-common/components/StreamActio import { QueueControl } from "../../../../components/QueueControl"; import { cancelJobAction } from "../../../../jobs/actions"; import { backfillChannelAction } from "../../backfillActions"; +import { LaneActionButton } from "../../../../components/lanes/LaneActionButton"; +import { workThroughSpeakersAction } from "../../../../jobs/actions"; import { OperationWork } from "./OperationWork"; export type OperationRowView = { @@ -78,6 +80,10 @@ type Props = { // No backfill feature is switched on at all. The card still renders (the rail // is fixed) but says so rather than reporting an empty work list as "done". anyEnabled: boolean; + // The Speakers lane's gate is shut. A run here waits on it (backfillLaneLimit + // holds at zero), so the card says so and offers the lane's own control + // rather than leaving "Run speaker work" to idle at "holding". + laneHeld?: boolean; }; export function SpeakersStage({ @@ -89,6 +95,7 @@ export function SpeakersStage({ anyEnabled, groupLabel, actionLabel, + laneHeld = false, }: Props) { // "speaker work" → "Speaker work". Sentence case, not title case: it is a // phrase, and "Speaker Work" is a proper noun this system does not have. @@ -152,6 +159,29 @@ export function SpeakersStage({ </> ), }, + ...(anyEnabled && laneHeld + ? [ + { + key: "lane-paused", + ariaLabel: "speakers lane paused", + node: ( + <span className="flex flex-wrap items-center gap-2"> + <span> + The Speakers lane is paused, so {runLabel} waits for it. + </span> + <LaneActionButton + label="Work through speakers" + glyph="⟳" + ariaLabel="work through speakers" + title="Arm the Speakers lane and lift its hold: every channel's speakers and voice fingerprints, one video at a time." + variant="idle" + action={() => workThroughSpeakersAction()} + /> + </span> + ), + }, + ] + : []), ...(missingInput > 0 ? [ { @@ -252,6 +282,7 @@ export function SpeakersStage({ buttonLabel={runLabel} runningLabel="Running…" label={runLabel} + title={`This channel only, now: ${operations.map((k) => k.label.toLowerCase()).join(", ") || "nothing enabled"} for the videos listed below, one at a time on the Speakers lane's queue.`} extraControls={ <QueueControl value={queue} diff --git a/editor/app/channels/[slug]/page.tsx b/editor/app/channels/[slug]/page.tsx @@ -67,6 +67,7 @@ import { countPlaylist } from "yt-dlp-transcript-common/controller/channels"; import { loadFailedTranscriptions } from "yt-dlp-transcript-common/controller/failedTranscriptions"; import { savedVideoTotals } from "yt-dlp-transcript-common/controller/savedVideoInventory"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; +import { isGateHeld } from "yt-dlp-transcript-common/lib/pauseGates"; import { locationLabelOfDataDir } from "yt-dlp-transcript-common/lib/storageLocations"; import { probeAllLocations } from "yt-dlp-transcript-common/controller/storageLocations"; import { STORAGE_STATUS_LABEL } from "yt-dlp-transcript-common/views/storage"; @@ -133,7 +134,7 @@ import { MirrorStage } from "./components/stages/MirrorStage"; import { readMirrorScan } from "yt-dlp-transcript-common/lib/mirrors/scanFile-server"; import { getOperation, - backfillLaneOperations, + backfillLaneDispatchOperations, operationsActionLabel, operationsGroupLabel, OPERATION_GROUP_ORDER, @@ -444,10 +445,11 @@ export default async function ChannelDetailPage({ buckets.downloadedNoTranscript.filter((id) => !excludedDownloadIds.has(id)); // Enabled lane backfills. A settings read, no I/O. // - // backfillLaneOperations, still: this is the BACKFILL lane's list, and the snapshot - // now carries an entry for every catalog operation including digest, which has - // its own station and its own queue key. - const laneOperations = backfillLaneOperations(settings); + // The BACKFILL lane's list as it DISPATCHES (backfillLaneDispatchOperations): the snapshot + // carries an entry for every catalog operation including digest, which has its + // own station and queue key, and a lane narrowed by `autoQueue.backfill. + // operations` (speakers only) runs — and so names — only those. + const laneOperations = backfillLaneDispatchOperations(settings); // A mirror channel's last scan (release 31, lane D): one small file, read // only for a channel whose config has `mirror`. const mirrorOf = config.mirror?.of ?? []; @@ -734,6 +736,7 @@ export default async function ChannelDetailPage({ // The lane's name comes from what it HOLDS, not from its queue key. groupLabel={operationsGroupLabel(laneOperations.map((k) => k.id))} actionLabel={operationsActionLabel(laneOperations.map((k) => k.id))} + laneHeld={isGateHeld(settings, "backfill")} /> ); case "cleanup": { diff --git a/editor/app/cleanup/components/HoldSieve.tsx b/editor/app/cleanup/components/HoldSieve.tsx @@ -97,7 +97,7 @@ export function HoldSieve({ summary }: { summary: CleanupSummary }) { { n: 4, label: "awaiting diarization", - clears: "run: Diarize", + clears: "run: Work through speakers", bytes: heldBytes.awaitingDiarization, count: heldCounts.awaitingDiarization, neverClears: heldBytes.diarizationNeverClears, diff --git a/editor/app/cleanup/lib/loadCleanup.ts b/editor/app/cleanup/lib/loadCleanup.ts @@ -7,6 +7,8 @@ import { type HeldAudio, } from "yt-dlp-transcript-common/controller/channelSnapshot"; import { loadFailedTranscriptions } from "yt-dlp-transcript-common/controller/failedTranscriptions"; +import { getSettings } from "yt-dlp-transcript-common/lib/settings"; +import { isGateHeld } from "yt-dlp-transcript-common/lib/pauseGates"; // One channel's row in the cleanup ledger. The three reclaim estimates come // straight from the snapshot's precomputed `cleanupBytes` (already net of @@ -191,6 +193,17 @@ export async function loadCleanupSummary( } } + // A PAUSED SPEAKERS LANE CLEARS NOTHING ON ITS OWN. The snapshot's + // diarizationNeverClears is what the lane would never clear even when it + // runs; while it is held or disarmed, ALL of the awaiting-speakers hold is + // stuck until somebody presses Work through speakers. Applied here, at read + // time, because the lane's state is not in any snapshot. + const lane = getSettings(); + if (!lane.autoQueue.backfill.enabled || isGateHeld(lane, "backfill")) { + heldBytes.diarizationNeverClears = heldBytes.awaitingDiarization; + heldCounts.diarizationNeverClears = heldCounts.awaitingDiarization; + } + return { rows, includedReclaimBytes, diff --git a/editor/app/cleanup/page.tsx b/editor/app/cleanup/page.tsx @@ -10,6 +10,13 @@ import { ReleaseLedger } from "./components/ReleaseLedger"; import { ChannelWorkTable } from "../components/channelWork/ChannelWorkTable"; import { sectionsFor } from "../components/channelWork/sections"; import { getActionableSummary } from "../lib/actionable/loadActionable"; +import { getChannelBriefs } from "../lib/requestCache"; +import { loadSpeakersReadout } from "yt-dlp-transcript-common/controller/speakersReadout"; +import { speakersReadoutLine } from "yt-dlp-transcript-common/lib/speakersReadout"; +import { getSettings } from "yt-dlp-transcript-common/lib/settings"; +import { isGateHeld } from "yt-dlp-transcript-common/lib/pauseGates"; +import { LaneActionButton } from "../components/lanes/LaneActionButton"; +import { workThroughSpeakersAction } from "../jobs/actions"; export const dynamic = "force-dynamic"; @@ -22,6 +29,12 @@ export default async function CleanupPage() { // second way. The two cleanup sections are the only channel-work sections // that belong to no operation: they are bytes, and bytes are this page. const actionable = await getActionableSummary(paths); + // The Speakers lane's readout — the same line the lane card prints — beside + // the hold it is working down (the sieve's gate 4). + const speakers = await loadSpeakersReadout(paths, await getChannelBriefs(paths)); + const settings = getSettings(); + const speakersWorking = + settings.autoQueue.backfill.enabled && !isGateHeld(settings, "backfill"); const { rows, includedReclaimBytes, @@ -120,6 +133,31 @@ export default async function CleanupPage() { The hero answers "how much can I reclaim right now"; these two answer the question an operator with weeks of queued GPU work actually has. */} <HoldSieve summary={summary} /> + <section + aria-label="speakers readout" + className="flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-border bg-card px-5 py-3 text-sm" + > + <span className="font-medium">Speakers</span> + <span className="tabular-nums text-muted-foreground"> + {speakersReadoutLine(speakers)} + </span> + {speakers.noFingerprintPossible > 0 && ( + <span className="text-xs text-muted-foreground"> + {speakers.noFingerprintPossible.toLocaleString("en-US")} diarized before + fingerprints, audio already gone: no fingerprint possible + </span> + )} + {!speakersWorking && speakers.waitingVideos > 0 && ( + <LaneActionButton + label="Work through speakers" + glyph="⟳" + ariaLabel="work through speakers" + title="Arm the Speakers lane and lift its hold: every channel's speakers and voice fingerprints, one video at a time." + variant="idle" + action={workThroughSpeakersAction} + /> + )} + </section> <ReleaseLedger ledger={buildCleanupLedger(summary)} /> {!hasAnything ? ( diff --git a/editor/app/components/lanes/LaneDeck.tsx b/editor/app/components/lanes/LaneDeck.tsx @@ -10,7 +10,12 @@ import { useSectionFrame } from "../../widget/components/WidgetSection"; import { LaneCard, type LaneControl } from "./LaneCard"; import { deriveLaneState, formatCount } from "yt-dlp-transcript-common/views/laneState"; import { pauseLaneControl } from "./pauseControl"; -import { armLaneAction, disarmLaneAction } from "../../jobs/actions"; +import { + armLaneAction, + disarmLaneAction, + pauseSpeakersAction, + workThroughSpeakersAction, +} from "../../jobs/actions"; // The four lanes, and the ONLY place lane → server-action wiring lives. Rendered // identically by the dashboard band and the monitor widget's controls section, @@ -360,36 +365,40 @@ export function LaneDeck({ // queue key; it survives below only on the two controls that genuinely act on // the shared queue, and the card now says what is in it. const backfillGroup = backfill?.groupLabel ?? "Derived data"; + // ONE CONTROL, for the operator's one decision about this lane: work through + // the speakers, or not now. It used to be a Run/Stop switch beside a + // Hold/Resume gate, and the two together had a state — armed and held — that + // read "running" while doing nothing, which is where "Run speaker work" went + // to idle at "holding". Work through speakers arms the lane AND lifts the + // hold; Pause holds it (the video in flight finishes) and leaves it armed, so + // pressing Work through speakers again — or a restart — resumes it. Disarming + // outright is the lane console's Stop, on its operation pages. + const backfillWorking = backfillArmed && !backfillHeld; const backfillControls: LaneControl[] = backfillAvailable ? [ - backfillArmed + backfillWorking ? { - key: "backfill-arm", - label: "Stop the lane", - glyph: "■", - ariaLabel: "disarm backfill lane", + key: "speakers", + label: "Pause", + glyph: "❙❙", + ariaLabel: "pause speakers", title: - "Switch the backfill lane off and let its runner finish what it is holding. The video in flight completes; nothing already written is lost, and the lane's rules are left alone.", + "Hold the Speakers lane: the video in flight finishes and nothing new starts. It stays armed — Work through speakers picks up where it was.", variant: "active", - action: () => disarmLaneAction("backfill"), + action: () => pauseSpeakersAction(), onChange: onSynced, } : { - key: "backfill-arm", - label: "Run the lane", + key: "speakers", + label: "Work through speakers", glyph: "⟳", - ariaLabel: "arm backfill lane", + ariaLabel: "work through speakers", title: - "Switch the backfill lane on and start its runner, on whatever its rules claim — every channel and every operation unless somebody has narrowed them. Survives a restart. The rules are on any of its operation pages.", + "Capture each video's speakers and voice fingerprints while its audio is still on disk, one video at a time beside transcription — and, with Clean after capture on, delete that audio once both are stored. Arms the lane and lifts its hold.", variant: "idle", - action: () => armLaneAction("backfill"), + action: () => workThroughSpeakersAction(), onChange: onSynced, }, - pauseLaneControl({ - lane: "backfill", - held: backfillHeld, - onChange: onSynced, - }), ] : []; @@ -476,8 +485,19 @@ export function LaneDeck({ aria-label="backfill lane members" className="block text-xs text-muted-foreground" > - {laneOperations.length} operations share one backfill queue and one - pause: {laneOperations.map((k) => k.label).join(", ")}. + {laneOperations.length} operations share the Speakers lane and its + one control: {laneOperations.map((k) => k.label).join(", ")}. + </span> + )} + {backfillAvailable && backfill?.speakers && ( + // THE READOUT, where the button is: what the lane is holding, what + // it has freed, how long is left (lib/speakersReadout.ts — the same + // line /cleanup and `pnpm ops get speakers` print). + <span + aria-label="speakers readout" + className="block text-xs tabular-nums text-muted-foreground" + > + {backfill.speakers.line} </span> )} {backfillArmed && backfillHeld && ( diff --git a/editor/app/jobs/actions.ts b/editor/app/jobs/actions.ts @@ -4,6 +4,8 @@ import { revalidatePath } from "next/cache"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { saveSettings } from "../settings/saveSettings"; +import { startSpeakersRun } from "yt-dlp-transcript-common/lib/speakersLedger-server"; +import { pauseLaneAction, resumeLaneAction } from "../operations/actions"; import { laneRootFromScope } from "yt-dlp-transcript-common/lib/laneMigration"; import { isDefaultChannelPriority } from "yt-dlp-transcript-common/lib/channelPriority"; import { operationsForLane } from "yt-dlp-transcript-common/lib/operations"; @@ -332,3 +334,37 @@ export async function endRenderModeAction(): Promise<{ ok: boolean; error?: stri ? { ok: false, error: `not released: ${r.failed.map((f) => `${f.lane} (${f.error})`).join(", ")}` } : { ok: true }; } + +// THE SPEAKERS LANE'S ONE CONTROL (the lane deck's "Work through speakers"). +// +// Arms the backfill lane AND lifts its hold, in that order of need — the two +// switches the deck used to draw as a separate Run and Hold pair, which left a +// lane that read "running" while held, and a "Run speaker work" that idled at +// "holding". Pressed on a lane that was not already working (disarmed or held) +// it also starts a new speakers run: the readout's "freed this run" counts from +// here (lib/speakersLedger-server.ts). +export async function workThroughSpeakersAction(): Promise<ArmLaneResult> { + try { + const before = getSettings().autoQueue.backfill; + const wasWorking = before.enabled && before.held !== true; + if (before.held === true) { + const resumed = await resumeLaneAction("backfill"); + if (!resumed.ok) return { ok: false, error: resumed.error }; + } + const armed = await armLaneAction("backfill"); + if (!armed.ok) return armed; + if (!wasWorking) await startSpeakersRun(getPaths()); + revalidatePath("/cleanup"); + return armed; + } catch (e) { + return { ok: false, error: (e as Error).message }; + } +} + +// "Pause": the gate, not the switch. The video in flight finishes; the lane +// stays armed, so Work through speakers (or a restart) resumes where it was. +export async function pauseSpeakersAction(): Promise<ArmLaneResult> { + const out = await pauseLaneAction("backfill"); + revalidatePath("/cleanup"); + return out.ok ? { ok: true } : { ok: false, error: out.error }; +} diff --git a/editor/app/operations/components/settings/DiarizationSettingsForm.tsx b/editor/app/operations/components/settings/DiarizationSettingsForm.tsx @@ -75,15 +75,57 @@ export function DiarizationSettingsForm({ </span> <span className="text-xs text-muted-foreground"> Off by default, from measurement rather than caution. On this box - transcription runs at ~221 s per audio-hour on the GPU (16× real - time, over 3,602 videos); diarization runs on the CPU at roughly - 500–680, because no diarization model has been ported to ggml and - neither ONNX nor PyTorch has a Vulkan path on Linux. Inline - therefore makes the whole pipeline ~3–4× slower and idles the GPU. + transcription runs at ~221 s per audio-hour on the GPU; the + sherpa-onnx engine diarizes on the CPU at roughly 500–680, so + inline makes the whole pipeline ~3–4× slower and idles the GPU. For a large batch, leave this off, let transcription run at full speed with the box above holding the audio, and catch up - afterwards with <strong>Diarize speakers</strong> on each channel. - Turn it on for steady state. + beside it with <strong>Work through speakers</strong> on the + Speakers lane. Turn it on for steady state. + </span> + </span> + </label> + <label className="flex items-start gap-2 text-sm"> + <input + type="checkbox" + name="diarizationRequireVoiceprints" + defaultChecked={seedChecked( + state, + "diarizationRequireVoiceprints", + initial.requireVoiceprints, + )} + className="mt-1" + /> + <span className="flex flex-col gap-1"> + <span className="font-medium"> + Keep the audio until its voice fingerprints are stored + </span> + <span className="text-xs text-muted-foreground"> + A fingerprint (one per speaker, in <code>diarization.json</code>) + cannot be made once the audio is gone, so Clean audio skips a + diarized video without them — &quot;awaiting voice + fingerprint&quot; — until the Speakers lane adds them. + </span> + </span> + </label> + <label className="flex items-start gap-2 text-sm"> + <input + type="checkbox" + name="diarizationCleanAfterCapture" + defaultChecked={seedChecked( + state, + "diarizationCleanAfterCapture", + initial.cleanAfterCapture, + )} + className="mt-1" + /> + <span className="flex flex-col gap-1"> + <span className="font-medium">Clean after capture</span> + <span className="text-xs text-muted-foreground"> + Delete a video&apos;s audio as soon as the Speakers lane has stored + its speakers and fingerprints — through every Clean audio gate + (keep-latest, do not clean, the availability check). The bytes + freed show on the Speakers lane and on /cleanup. </span> </span> </label> diff --git a/editor/app/operations/renderMode.ts b/editor/app/operations/renderMode.ts @@ -28,7 +28,7 @@ import { saveSettings } from "../settings/saveSettings"; // this checkout's git common dir (the editor runs from editor/), or // RENDER_PRIORITY_FILE — the e2e servers set their own. -type RenderLane = "transcription" | "download"; +type RenderLane = "transcription" | "download" | "backfill"; export function renderModeFile(): string { return renderPriorityFile(process.env, { root: process.cwd() }); diff --git a/editor/app/operations/settingsActions.ts b/editor/app/operations/settingsActions.ts @@ -155,6 +155,9 @@ export async function saveDiarizationSettingsAction( enabled: formData.get("diarizationEnabled") === "on", inlineAfterTranscribe: formData.get("diarizationInlineAfterTranscribe") === "on", + requireVoiceprints: + formData.get("diarizationRequireVoiceprints") === "on", + cleanAfterCapture: formData.get("diarizationCleanAfterCapture") === "on", threshold: num(formData, "diarizationThreshold", dDiar.threshold), threads: num(formData, "diarizationThreads", dDiar.threads), concurrency: num(formData, "diarizationConcurrency", dDiar.concurrency), diff --git a/editor/app/widget/lib/syncInputs.ts b/editor/app/widget/lib/syncInputs.ts @@ -3,6 +3,7 @@ import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { readSchedulerState } from "yt-dlp-transcript-common/jobs/syncSchedulerState"; import type { WidgetSyncInputs } from "yt-dlp-transcript-common/views/widgetSync"; import { getChannelBriefs } from "../../lib/requestCache"; +import { readSpeakersLedger } from "yt-dlp-transcript-common/lib/speakersLedger-server"; // THE READS BEHIND THE WIDGET'S SYNC STRIP. // @@ -18,9 +19,10 @@ import { getChannelBriefs } from "../../lib/requestCache"; // of the three. export async function widgetSyncInputs(): Promise<WidgetSyncInputs> { const paths = getPaths(); - const [state, briefs] = await Promise.all([ + const [state, briefs, speakersLedger] = await Promise.all([ readSchedulerState(paths), getChannelBriefs(paths), + readSpeakersLedger(paths), ]); - return { settings: getSettings(), now: Date.now(), state, briefs }; + return { settings: getSettings(), now: Date.now(), state, briefs, speakersLedger }; } diff --git a/editor/e2e/backfill.spec.ts b/editor/e2e/backfill.spec.ts @@ -136,6 +136,22 @@ async function laneArmed(): Promise<boolean> { return (await backfillLane()).enabled ?? false; } +async function laneHeldNow(): Promise<boolean> { + return ((await backfillLane()) as { held?: boolean }).held ?? false; +} + +// Disarm through `pnpm ops lane`, so an armed lane does not bleed into the next +// spec. The deck no longer draws a disarm: its one control is Work through +// speakers / Pause, and switching the lane off is the console's (and ops'). +async function disarmLane(request: APIRequestContext): Promise<void> { + const res = await request.post(`${baseUrl}/api/ops/lane`, { + headers: { authorization: "Bearer test-worker-token" }, + data: { lane: "backfill", enabled: false }, + }); + expect(res.status()).toBe(200); + await expect.poll(laneArmed, { timeout: 30_000 }).toBe(false); +} + const SLOW = 120_000; // (1) The stage card reports the two populations SEPARATELY. @@ -396,40 +412,36 @@ test("the disk floor refuses to re-acquire anything", async ({ page }) => { // in the same settings write as the switch — so what has to be pinned instead is // the other half of that: disarming must NOT clear the tree, because an operator // authored it and switching a lane off is not throwing it away. -test("the lane arms from the dashboard and disarms without losing its rules", async ({ +test("Work through speakers arms the lane AND lifts its hold, keeping its rules", async ({ page, + request, }) => { test.setTimeout(SLOW); await resetData("one-transcribe-channel-with-audio"); - await writeSettings(backfillSettings()); + // Disarmed AND held — the state the live lane shipped in, two switches off. + await writeSettings({ ...backfillSettings(), autoQueue: { backfill: { held: true } } }); await page.goto("/"); - const arm = page.getByRole("button", { name: "arm backfill lane" }); - await expect(arm).toBeEnabled({ timeout: 30_000 }); - await arm.click(); + const work = page.getByRole("button", { name: "work through speakers" }); + await expect(work).toBeEnabled({ timeout: 30_000 }); + // ONE control: the Run/Hold pair is gone from the deck. + for (const name of ["arm backfill lane", "disarm backfill lane", "pause backfill", "resume backfill"]) { + await expect(page.getByRole("button", { name })).toHaveCount(0); + } + await work.click(); - await expect.poll(laneArmed, { timeout: 30_000 }).toBe(true); - // An unscoped arm is one catch-all leaf — what an empty `sweepChannels` meant. + await expect + .poll(async () => ({ armed: await laneArmed(), held: await laneHeldNow() }), { timeout: 30_000 }) + .toEqual({ armed: true, held: false }); + // An unscoped arm keeps the one catch-all leaf — what an empty `sweepChannels` meant. expect( (await backfillLane()).root?.children?.map((c) => c.match), ).toEqual([{ type: "all" }]); + // And the control becomes its reverse. + await expect(page.getByRole("button", { name: "pause speakers" })).toBeEnabled({ timeout: 30_000 }); - const disarm = page.getByRole("button", { name: "disarm backfill lane" }); - await expect(disarm).toBeEnabled({ timeout: 30_000 }); - await disarm.click(); - - await expect - .poll( - async () => { - const lane = await backfillLane(); - return { - enabled: lane.enabled ?? false, - rules: lane.root?.children?.length ?? 0, - }; - }, - { timeout: 30_000 }, - ) - .toEqual({ enabled: false, rules: 1 }); + await disarmLane(request); + expect((await backfillLane()).root?.children?.length ?? 0).toBe(1); // The sweep's own controls are gone from this surface, not merely relabelled // — BOTH halves, and both aria-labels, because the deck drew whichever half @@ -543,7 +555,7 @@ test("an armed lane comes back after a restart", async ({ page, request }) => { await writeSettings(backfillSettings()); await page.goto("/"); - const arm = page.getByRole("button", { name: "arm backfill lane" }); + const arm = page.getByRole("button", { name: "work through speakers" }); await expect(arm).toBeEnabled({ timeout: 30_000 }); await arm.click(); await expect.poll(laneArmed, { timeout: 30_000 }).toBe(true); @@ -561,11 +573,7 @@ test("an armed lane comes back after a restart", async ({ page, request }) => { expect(body.resumed).not.toBe(body.cancelled); // Clean up, so an armed lane does not bleed into the next spec. - await page.goto("/"); - const disarm = page.getByRole("button", { name: "disarm backfill lane" }); - await expect(disarm).toBeEnabled({ timeout: 30_000 }); - await disarm.click(); - await expect.poll(laneArmed, { timeout: 30_000 }).toBe(false); + await disarmLane(request); }); // (9) THE WHOLE POINT OF THE SEPARATE QUEUE KEY: a backfill job and a @@ -795,39 +803,33 @@ test("the diarization page shows the channel and both populations", async ({ // not just the label, for exactly that reason. It also asserts the button // renders WITHOUT a sweep armed — an operator pauses a hand-clicked // backfill-channel job too, not only an armed lane. -test("the dashboard pauses and resumes the backfill lane", async ({ page }) => { +test("the dashboard's one control: Pause holds the lane and leaves it armed; Work through speakers lifts the hold", async ({ + page, + request, +}) => { test.setTimeout(SLOW); await resetData("one-transcribe-channel-with-audio"); await writeSettings(backfillSettings()); - // THE LANE'S GATE, on the lane. Slice 1.4 moved it off the inverted - // `backfill.enabled` (deleted by S0-pause) and onto - // `autoQueue.backfill.held`, so the polarity here is the plain one: held - // means held. - const laneHeld = async () => - ( - await readJson<{ autoQueue?: { backfill?: { held?: boolean } } }>( - testPaths().settingsFile, - ).catch(() => ({}) as { autoQueue?: { backfill?: { held?: boolean } } }) - ).autoQueue?.backfill?.held ?? false; - await page.goto("/"); - const pause = page.getByRole("button", { name: "pause backfill" }); + await page.getByRole("button", { name: "work through speakers" }).click(); + await expect.poll(laneArmed, { timeout: 30_000 }).toBe(true); + + const pause = page.getByRole("button", { name: "pause speakers" }); await expect(pause).toBeEnabled({ timeout: 30_000 }); await pause.click(); - - await expect.poll(laneHeld, { timeout: 30_000 }).toBe(true); - - // THE LANE'S ARM SWITCH IS UNTOUCHED: pausing must not disarm the lane, or - // "pause" would quietly become "stop" and days of queued work would need - // re-arming. (The fixture leaves it disarmed, so `false` is what "unchanged" - // looks like here.) - expect(await laneArmed()).toBe(false); - - const resume = page.getByRole("button", { name: "resume backfill" }); - await expect(resume).toBeEnabled({ timeout: 30_000 }); - await resume.click(); - await expect.poll(laneHeld, { timeout: 30_000 }).toBe(false); + // THE LANE'S GATE (`autoQueue.backfill.held`), not its switch: a pause is + // not a stop, or days of queued work would need re-arming. + await expect.poll(laneHeldNow, { timeout: 30_000 }).toBe(true); + expect(await laneArmed()).toBe(true); + + const work = page.getByRole("button", { name: "work through speakers" }); + await expect(work).toBeEnabled({ timeout: 30_000 }); + await work.click(); + await expect.poll(laneHeldNow, { timeout: 30_000 }).toBe(false); + expect(await laneArmed()).toBe(true); + + await disarmLane(request); }); // ONE GATE, TWO SURFACES. /operations/diarization and the dashboard draw the @@ -841,6 +843,7 @@ test("the dashboard pauses and resumes the backfill lane", async ({ page }) => { // surfaces disagreeing about which lane they hold. test("an operation page holds the same lane the dashboard does", async ({ page, + request, }) => { test.setTimeout(SLOW); await resetData("one-transcribe-channel-with-audio"); @@ -870,14 +873,16 @@ test("an operation page holds the same lane the dashboard does", async ({ // A hold is not a stop: the lane's arm switch is untouched. expect(await laneArmed()).toBe(false); - // The dashboard shows the same lane held, and releases it. + // The dashboard shows the same lane NOT working, and its one control lifts + // the hold (and arms the lane: the deck has one switch for both). await page.goto("/"); - const resumeOnDashboard = page.getByRole("button", { - name: "resume backfill", + const workOnDashboard = page.getByRole("button", { + name: "work through speakers", }); - await expect(resumeOnDashboard).toBeEnabled({ timeout: 30_000 }); - await resumeOnDashboard.click(); + await expect(workOnDashboard).toBeEnabled({ timeout: 30_000 }); + await workOnDashboard.click(); await expect.poll(laneHeld, { timeout: 30_000 }).toBe(false); + await disarmLane(request); }); // (11) THE RE-DOWNLOAD ON A SUBTITLE CHANNEL: audio, not captions. diff --git a/editor/e2e/cleanup-holds.spec.ts b/editor/e2e/cleanup-holds.spec.ts @@ -90,7 +90,16 @@ test("the sieve attributes every held byte to exactly one gate, and names the ho await seedTranscript("vidD"); await writeFile( resolvePath(dataRel("vidD", "diarization.json")), - JSON.stringify({ segments: [], engine: "test", createdAt: "2026-01-01" }), + // A COMPLETE sidecar — turns and voice fingerprints — which is what the + // sweep's gate (and so the snapshot's) needs to call a video diarized. + JSON.stringify({ + videoId: "vidD", + generatedAt: "2026-01-01T00:00:00.000Z", + speakers: 1, + turns: [{ start: 0, end: 1, speaker: 0 }], + engine: { engine: "test" }, + voiceprints: [{ speaker: 0, seconds: 1, embedded: 1, centroid: [1, 0], embeddingModel: "t" }], + }), ); await fetch(`${baseUrl}/api/test/invalidate-cache`).catch(() => {}); diff --git a/editor/e2e/diarization.spec.ts b/editor/e2e/diarization.spec.ts @@ -34,7 +34,13 @@ async function seedTranscript(videoId: string): Promise<void> { ); } -async function seedDiarization(videoId: string): Promise<void> { +// With voice fingerprints by default (what "diarized" means since +// diarization.requireVoiceprints); `voiceprints: false` is a sidecar written +// before they existed. +async function seedDiarization( + videoId: string, + { voiceprints = true }: { voiceprints?: boolean } = {}, +): Promise<void> { await writeFile( resolvePath(dataRel(videoId, "diarization.json")), JSON.stringify({ @@ -43,6 +49,13 @@ async function seedDiarization(videoId: string): Promise<void> { speakers: 1, turns: [{ start: 0, end: 10, speaker: 0 }], engine: { engine: "fake-diarize", threshold: 0.5 }, + ...(voiceprints + ? { + voiceprints: [ + { speaker: 0, seconds: 10, embedded: 1, centroid: [1, 0], embeddingModel: "null" }, + ], + } + : {}), }) + "\n", ); } diff --git a/editor/e2e/fixtures/bin/fake-diarize.mjs b/editor/e2e/fixtures/bin/fake-diarize.mjs @@ -18,7 +18,14 @@ // vidC is the designated failing id because it is already in the shared // one-transcribe-channel-with-audio fixture's archive; a spec can exercise the // failure path without renaming dirs into ids the batch would never pick up. -import { writeFile } from "node:fs/promises"; +// +// VOICEPRINTS, as the real wrapper now writes them: one per speaker, with the +// embedding model's basename. A dir containing "novoiceprint" gets a record +// WITHOUT them (what every sidecar written before them looks like). +// `--voiceprints-only <record>` is the wrapper's voiceprint step: it adds them +// to the record it is given, keeping everything else, and writes --output (or +// the record itself). +import { readFile, writeFile } from "node:fs/promises"; import path from "node:path"; import { installFixtureWatchdog } from "./_watchdog.mjs"; @@ -31,7 +38,8 @@ function arg(flag) { return i < 0 ? undefined : argv[i + 1]; } -const out = arg("--output") ?? arg("-o"); +const voiceprintsOnly = arg("--voiceprints-only"); +const out = arg("--output") ?? arg("-o") ?? voiceprintsOnly; const videoId = arg("--video-id") ?? path.basename(process.cwd()); const seg = arg("--seg"); const emb = arg("--emb"); @@ -52,6 +60,24 @@ if ( process.exit(3); } +const voiceprintsFor = (turns) => + [...new Set(turns.map((t) => t.speaker))].sort((a, b) => a - b).map((speaker) => ({ + speaker, + seconds: turns.filter((t) => t.speaker === speaker).reduce((s, t) => s + (t.end - t.start), 0), + embedded: 1, + centroid: [speaker === 0 ? 1 : 0, speaker === 0 ? 0 : 1], + embeddingModel: emb ? path.basename(emb) : "fake.onnx", + })); + +if (voiceprintsOnly) { + const record = JSON.parse(await readFile(voiceprintsOnly, "utf8")); + record.voiceprints = voiceprintsFor(record.turns ?? []); + record.voiceprintsAt = new Date().toISOString(); + await writeFile(out, JSON.stringify(record) + "\n"); + process.stderr.write(`[fake-diarize] voiceprints for ${record.voiceprints.length} speaker(s) -> ${out}\n`); + process.exit(0); +} + const turns = [ { start: 0, end: 4.5, speaker: 0 }, { start: 4.5, end: 7.25, speaker: 1 }, @@ -74,6 +100,9 @@ await writeFile( version: "e2e", threshold, }, + ...(cwd.toLowerCase().includes("novoiceprint") + ? {} + : { voiceprints: voiceprintsFor(turns), voiceprintsAt: new Date().toISOString() }), }) + "\n", ); process.stderr.write( diff --git a/editor/e2e/widget.spec.ts b/editor/e2e/widget.spec.ts @@ -813,16 +813,24 @@ test("the widget's controls hold and release the backfill lane", async ({ ).autoQueue?.backfill?.held ?? false; await page.goto("/widget?controls=1&backfill=1"); - const pause = page.getByRole("button", { name: "pause backfill" }); - await expect(pause).toBeEnabled({ timeout: 30_000 }); - await pause.click(); + // The Speakers lane's one control (the deck's): Work through speakers arms + // the lane and lifts its hold; Pause holds it. + const work = page.getByRole("button", { name: "work through speakers" }); + await expect(work).toBeEnabled({ timeout: 30_000 }); + await work.click(); + await expect.poll(laneHeld, { timeout: 30_000 }).toBe(false); - await expect.poll(laneHeld, { timeout: 30_000 }).toBe(true); // The label flips immediately, because the click refetches the payload it // reads rather than waiting out the 15s poll floor. - const resume = page.getByRole("button", { name: "resume backfill" }); - await expect(resume).toBeVisible({ timeout: 15_000 }); + const pause = page.getByRole("button", { name: "pause speakers" }); + await expect(pause).toBeVisible({ timeout: 15_000 }); + await pause.click(); + await expect.poll(laneHeld, { timeout: 30_000 }).toBe(true); - await resume.click(); - await expect.poll(laneHeld, { timeout: 30_000 }).toBe(false); + // Disarm, so an armed lane does not bleed into the next spec. + const off = await page.request.post(`${baseUrl}/api/ops/lane`, { + headers: { authorization: "Bearer test-worker-token" }, + data: { lane: "backfill", enabled: false }, + }); + expect(off.status()).toBe(200); }); diff --git a/umtool/docs/cli.md b/umtool/docs/cli.md @@ -76,7 +76,7 @@ Inbox cannot disagree about what is wrong with one. | `take <project> --id <id> --preview [--from <take>] [--at S --dur S \| --full] [--priority] [--json]` | the take's **preview**: the take as stored (a draft too, from its walked patch) composed exactly as its render is -- the same 1920×1080 layout, segments, chrome frames and sound -- with only its final picture encoded smaller and faster (`render.preview`: 1280×720, x264 veryfast, crf 26) into `takes/<id>/out/<slug>.preview.mp4`; its build, schedule and record (`render.json`, `render.log`) in `takes/<id>/out/preview/`. The full render (`preview.mp4`, `out/<slug>.mp4`, `out/sourced/`, `take.json`, `render.json`) is never touched. Reuses this take's own full render, and `--from`'s full render and preview ([report-video.md](report-video.md#fast-feedback-preview-and-changes-renders), [knobs.md](knobs.md#fast-feedback-a-preview-and-a-reel-of-the-changes)) | | `take <project> --id <id> --changes [--from <take>] [--pad 3] [--no-preview] [--priority] [--json]` | the take's **changes reel**: only what changed against `--from` (default: the take's own `from`, or the take a draft was made from) -- each added, re-read, re-picked, re-voiced, trimmed, held, fx'd, … item with a neighbour either side, rendered in one build (`takes/<id>/out/changes/`), cut to the item ± `--pad` s, a label burned in (`21:19 · p-2116831815466193102 · re-voiced`: its time in the FULL cut), joined into `takes/<id>/out/<slug>.changes.mp4`; a removed item shows as the join it leaves. `takes/<id>/changes.json` lists the pieces with their full-cut times and how exact they are (`times.basis`: `measured` -- the base's measured schedule plus the changed items' measured lengths -- or `estimate`). Preview quality unless `--no-preview`. Nothing changed: no reel, and the list says so | | `take <project> --id <id> --import-item <project>:<item>[,<item>…] [--import-item …] [--after <entry> \| --before <entry>] [--as <id>] [--dry-run] [--json]` | **items of another project into a take** (`takeImport.mjs`): each entry CLONED from the source's manifest as it is now (its card, context, knobs, narration with its takes and its pick) into the take's timeline -- one write, an undo point of the take's (`timeline <p> --take <id> undo`); the files it names (narration takes and their `take-<n>.*` sidecars, the parts' cache files, attachments, a context post's media, the picture of each author it draws that the take lacks, added to the take's `postAvatars`) **hard-linked** into this project's dir at the same path, so the render and the lint find them (copied across filesystems; the same file already there is left; ANOTHER file at the path: linked under `imports/<source>/<path>` and the clone names that). The source project and this project's manifest are only read. **Placed** `--after`/`--before` an entry of the take (several items in the order named, one after another), else by the post's date when the take's posts are in date order, else at the end. **Again**: updated in place from the source (moved only with `--after`/`--before`), `unchanged` with no write when nothing differs. `--as`: one item under another id (a second copy). `--dry-run`: the plan and the placement, nothing linked or written. `--json`: `items[] {id, action added\|updated\|unchanged\|moved, at {index, after, before}, narration {takes, pick, file}, files[], avatars[]}`, `revision`. Refused while the take renders. **Exit 0 · 1 refused (no such item, take or entry; a link out of the project) · 2 usage** | -| `take … --priority` · `takes make … --priority` · `render-mode on [--for 90m] [--note T] [--json \| --print-token]` · `render-mode on [--for 90m] [--note T] [--print-token] -- <cmd …>` · `render-mode off [--force] [--json]` · `render-mode status [--json]` | **render mode**: a render the operator waits for gets the machine. `--priority` turns it on for the take's (or the batch's) lifetime — on at the start, off at the end, on a failure and on a signal; the Takes page's **Give renders the machine** is the same flag. While it is on, every other heavy job (e2e suites, `next build`s, the publish stages, other renders) waits at the heavy slot's door (`queue-lock: held for a render (…) — waiting`), the render runs on the floor 4000 MB and the cap 10240 MB, and the editor's transcription and download lanes are held through its ops (`lane`; only the ones not already held, and only those are released at off). `render-mode on` is a window (default 2h) for a chain of renders: every `umtool take` started in it renders in it, another command joins with the `RENDER_PRIORITY_TOKEN` it prints (`--print-token`: the token alone on stdout, the rest on stderr). **`on … -- <cmd …>` is the form for a script**: the command is spawned with the token in its environment, the hold is the command's pid, and it is released when the command exits — done, failed, or umtool signalled (the signal is passed on); umtool exits with the command's code, and inside a manual window the command joins it. A bare `on` in a script leaves the window behind (the chain trap). `off` ends it (a running take's hold only with `--force`, else it ends with the take); `status` says what holds it and releases a stale hold's lanes. A hold whose process is gone or whose window is over is no hold. Needs WORKER_TOKEN and the editor at ARCHILYZER_EDITOR_URL for the lanes; without them it still holds the door. **Exit 1** when it is already on, or a lane could not be released ([report-video.md](report-video.md#render-mode-giving-a-render-the-machine); WORKTREES.md, "Render mode") | +| `take … --priority` · `takes make … --priority` · `render-mode on [--for 90m] [--note T] [--json \| --print-token]` · `render-mode on [--for 90m] [--note T] [--print-token] -- <cmd …>` · `render-mode off [--force] [--json]` · `render-mode status [--json]` | **render mode**: a render the operator waits for gets the machine. `--priority` turns it on for the take's (or the batch's) lifetime — on at the start, off at the end, on a failure and on a signal; the Takes page's **Give renders the machine** is the same flag. While it is on, every other heavy job (e2e suites, `next build`s, the publish stages, other renders) waits at the heavy slot's door (`queue-lock: held for a render (…) — waiting`), the render runs on the floor 4000 MB and the cap 10240 MB, and the editor's transcription, download and Speakers lanes are held through its ops (`lane`; only the ones not already held, and only those are released at off). `render-mode on` is a window (default 2h) for a chain of renders: every `umtool take` started in it renders in it, another command joins with the `RENDER_PRIORITY_TOKEN` it prints (`--print-token`: the token alone on stdout, the rest on stderr). **`on … -- <cmd …>` is the form for a script**: the command is spawned with the token in its environment, the hold is the command's pid, and it is released when the command exits — done, failed, or umtool signalled (the signal is passed on); umtool exits with the command's code, and inside a manual window the command joins it. A bare `on` in a script leaves the window behind (the chain trap). `off` ends it (a running take's hold only with `--force`, else it ends with the take); `status` says what holds it and releases a stale hold's lanes. A hold whose process is gone or whose window is over is no hold. Needs WORKER_TOKEN and the editor at ARCHILYZER_EDITOR_URL for the lanes; without them it still holds the door. **Exit 1** when it is already on, or a lane could not be released ([report-video.md](report-video.md#render-mode-giving-a-render-the-machine); WORKTREES.md, "Render mode") | | `take status <project> [--id <take>] [--json] [--log] [--tail N]` | a take's **render record** (`takes/<take>/render.json`, written by every render whoever started it — a terminal, the Takes page, the queue): `state` (`running`, `waiting` at the heavy slot, `done`, `failed`, `cancelled`; `queued` or `blocked` while a queue step waits to render it), `stage` and a rough `percent`, the `error` (the first error line, not a bare "exited 1") and the log's last 40 lines (`tail`), on done the `mp4` and its measured `seconds`; `--log` prints the FULL `takes/<take>/render.log`. A "running" whose process is gone reads **failed** ("the render process is gone"); a done whose mp4 is missing or 0 bytes reads **failed**. **Exit 0 done · 3 queued, waiting or running · 1 failed, cancelled, blocked or none.** Without `--id`: every take with a record, the newest's exit ([queue and poll](#queue-and-poll-instead-of-scripting)); and its fast-feedback renders beside it, `preview` and `changes` (each one's state, mp4, seconds, log; a changes reel's piece count, its base and its list), a queued `--preview`/`--changes` step said as such -- never as the take's own render | | `queue add [--after <qid>\|last] [--label T] [--timeout <minutes>] [--json] -- <umtool subcommand argv…>` | a **step** of the durable queue: the argv of a umtool command, one word per argument (no shell), stored under `<reports root>/.umtool-queue/` and run by the **umtool app** (its systemd unit), one step at a time, in order — so it survives the session that queued it, an app restart and a ship. Prints the qid (`q<N>`) alone on stdout. `--after` waits for that step to be **done**; when it fails or is cancelled this one is **blocked** (and so is whatever waits on it). `--timeout`: the step's limit (default 720 minutes). A step does not start while the app's own job runner is busy (a Takes-page job), and a heavy step still takes the machine's heavy slot and render mode by itself | | `queue ls [--all] [--json]` · `queue status <qid> [--json]` · `queue wait <qid> [--timeout <s>]` · `queue log <qid> [--tail N]` · `queue cancel <qid>` · `queue retry <qid>` | the queue: `ls` the runner (is the app running it) and the steps not finished or finished in the last 24 h; `status` one step (**exit 0 done · 3 queued or running · 1 failed, blocked or cancelled**); `wait` the same after up to `<s>` seconds (default 90); `log` its FULL log (`logs/<qid>.log`; earlier attempts kept as `<qid>.<n>.log`); `cancel` a queued or blocked step at once, a running one stopped (its process group); `retry` a failed or cancelled step back in the queue with every step blocked behind it. A step that was running when the app died reads **failed** ("the step's process is gone"), its log kept — it is never re-run on its own | diff --git a/umtool/docs/report-video.md b/umtool/docs/report-video.md @@ -2406,7 +2406,7 @@ render holds the machine. While render mode is on, every other heavy job waits at the heavy slot's door (e2e suites, `next build`s, the publish stages, other renders); the render is admitted on the floor -4000 MB and the cap 10240 MB; the editor's transcription and download lanes are held — only +4000 MB and the cap 10240 MB; the editor's transcription, download and Speakers lanes are held — only the ones that were not held already, and only those are let go. A take's hold ends with the take: done, failed, or stopped (Ctrl-C, the job's Stop). A window ends at its `until` (2 h unless `--for`), or with `off`. A hold whose process died is no hold: the gate ignores diff --git a/umtool/lib/report/renderMode.mjs b/umtool/lib/report/renderMode.mjs @@ -11,7 +11,7 @@ // umtool render-mode status [--json] // // On: the state file (beside the heavy slot's lock), then the editor's -// transcription and download lanes held through its ops — the `lane` action +// transcription, download and Speakers lanes held through its ops — the `lane` action // `pnpm ops lane` posts — each only if it was not held already, and recorded, // so off releases only those. The editor is ARCHILYZER_EDITOR_URL with // WORKER_TOKEN, read as `pnpm ops` reads them (fetchWindows.mjs editorConfig). diff --git a/umtool/lib/report/renderMode.test.mjs b/umtool/lib/report/renderMode.test.mjs @@ -21,8 +21,11 @@ function tmpFile() { return path.join(mkdtempSync(path.join(tmpdir(), "render-mode-")), "heavy.lock.render.json"); } -/** A fake editor's lanes: `held` what it holds, `calls` what was asked. */ -function fakeLanes(held = {}) { +/** A fake editor's lanes: `held` what it holds, `calls` what was asked. The + * Speakers (backfill) lane starts held, as it ships — so these tests' calls are + * the two lanes a render actually takes from a fresh install. */ +function fakeLanes(initial = {}) { + const held = { backfill: true, ...initial }; const calls = []; return { held, @@ -108,7 +111,7 @@ await withTakePriority({ priority: true, project: "p", take: "t", log: (l) => co const code = await new Promise((r) => child.on("exit", (c) => r(c))); assert.equal(code, 143); assert.equal(existsSync(file), false); - assert.equal(readFileSync(log, "utf8"), "hold transcription\nhold download\nrelease transcription\nrelease download\n"); + assert.equal(readFileSync(log, "utf8"), "hold transcription\nhold download\nhold backfill\nrelease transcription\nrelease download\nrelease backfill\n"); }); test("a take inside a manual window joins it (flag or not) and leaves it on; beside another render it takes nothing", async () => { @@ -159,7 +162,7 @@ test("umtool render-mode on | status | off, with --json; off of a running take's assert.equal(out.at(-1), "render mode is off"); assert.equal(await renderModeCommand(["on", "--for", "soon"], io), 2); assert.equal(await renderModeCommand(["on", "--for", "90m"], io), 0); - assert.match(out.join("\n"), /render mode ON until \d\d:\d\d — lanes held: transcription \(download already held — left alone\)/); + assert.match(out.join("\n"), /render mode ON until \d\d:\d\d — lanes held: transcription \(download, backfill already held — left alone\)/); assert.match(out.join("\n"), /export RENDER_PRIORITY_TOKEN=[0-9a-f]{16}/); assert.equal(await renderModeCommand(["on"], io), 1, "already on"); out.length = 0; @@ -362,7 +365,7 @@ process.exit(await renderModeCommand(["on", "--", process.execPath, "-e", child] const code = await new Promise((r) => proc.on("exit", (c) => r(c))); assert.equal(code, 143); assert.equal(existsSync(file), false); - assert.equal(readFileSync(log, "utf8"), "hold transcription\nhold download\nrelease transcription\nrelease download\n"); + assert.equal(readFileSync(log, "utf8"), "hold transcription\nhold download\nhold backfill\nrelease transcription\nrelease download\nrelease backfill\n"); for (let i = 0; i < 100 && !readFileSync(childLog, "utf8").includes("TERM"); i += 1) await new Promise((r) => setTimeout(r, 20)); assert.equal(readFileSync(childLog, "utf8"), "ready\nTERM\n", "the command got the signal"); });