Archilyzer · Source

archilyzer

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

commit ce1a289229c9c374a5a4e585ca69248624e1b8b3
parent 29bb4b76e5ec9adcdfd657f04afe41bfd8f5a06d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 21 Nov 2026 06:15:53 -0500

clean-unverified review 2: no prune after a stopped check, replay rules for the channel key, a held retry defers, ops answers the plan's counts

- The saved-video retention prune is skipped whenever the availability
  check did not complete (rate-limited or failed), on the first run and on
  every retry, and the log says why. This was also true on main.
- Replay of the clean kinds (a /jobs Retry, Retry all failed, `pnpm ops job
  retry`, the boot's re-queue) reads the channel key now: key on, a clean
  replays unchecked with no count, titled "Clean audio without checking ·
  channel setting", first line "Clean without checking (channel setting)",
  no prune; a confirmed clean without checking replays only with its
  carried plan; key off, nothing replays unchecked (a confirmed one is
  refused). One rule, replayCleanSpec, behind the editor's handler.
- A scheduled retry whose channel's media is held when its time comes (a
  relocation, a drive away) or whose job is refused waits 15 min and tries
  again with the same attempt, at most 96 times (24 h), then gives up
  visibly: the record stays, the Cleanup stage says why, Dismiss clears it.
- `pnpm ops cleanup {"unchecked": true}` answers the plan's counts, and the
  job logs them before anything is removed.
- Turning the key on cancels a scheduled rate-limit retry; the dashboard's
  checked Clean audio refuses if the key came on since its count.
- OPERATING.md, CHANNEL.md (key description), the turn-on confirmation and
  the CHANGELOG list every path that runs unchecked with no count.

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

Diffstat:
MCHANNEL.md | 2+-
MCOMMANDS.md | 2+-
MOPERATING.md | 20+++++++++++++++-----
Mcommon/controller/cleanAudioFromTranscribed.ts | 32+++++++++++++++++++-------------
Mcommon/controller/cleanAudioJob.test.ts | 42++++++++++++++++++++++++++++++++++--------
Mcommon/controller/cleanAudioJob.ts | 85+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Acommon/controller/cleanReplay.test.ts | 223+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/controller/cleanRetrySchedule.test.ts | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/controller/cleanRetrySchedule.ts | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Mcommon/controller/cleanUnchecked.test.ts | 51++++++++++++++++++++++++++++++++++++++++++++++++++-
Mcommon/jobs/jobDetail.test.ts | 6++++++
Mcommon/jobs/jobDetail.ts | 9+++++++++
Mcommon/lib/channelConfig.ts | 2+-
Mcommon/lib/cleanAudioConfirm.test.ts | 3++-
Mcommon/lib/cleanAudioConfirm.ts | 3++-
Meditor/CHANGELOG.md | 11++++++++++-
Meditor/app/api/ops/cleanup/route.ts | 8+++++++-
Meditor/app/channels/[slug]/cleanRetryScheduler.ts | 11+++++++++++
Meditor/app/channels/[slug]/components/stages/CleanWithoutChecking.tsx | 12++++++++----
Meditor/app/channels/[slug]/whisperActions.ts | 9++++++++-
Meditor/app/channels/actions.ts | 6++++++
Meditor/app/components/actions/InlineActionButton.tsx | 6++++--
Meditor/app/jobs/jobReplayRegistry.ts | 20+++++++++++---------
Mscripts/archilyzer-ops.mjs | 7+++++--
24 files changed, 618 insertions(+), 71 deletions(-)

diff --git a/CHANNEL.md b/CHANNEL.md @@ -45,7 +45,7 @@ Regenerate this file with `pnpm --filter yt-dlp-transcript-common exec tsx bin/f | `excludeFromCleanup` | config | Leave this channel's reclaimable bytes out of the aggregate "cleanable data" total on /cleanup and its badge. The per-channel cleanup sweeps stay available; only the running total changes. | | `excludeFromCompaction` | config | Keep this channel's saved videos out of compaction (`compact-saved-videos`, a re-encode to AV1 that becomes the active copy): neither the selector nor an explicit list touches them. For a channel whose stored bytes are kept as evidence. Absent = false. | | `cleanAfterCaptureUnverified` | config | Let clean-after-capture (settings `diarization.cleanAfterCapture`) delete this channel's audio with NO availability check. Only for a channel with no `url`: with no source there is nothing to list, so the automatic per-video clean holds every such channel ("no source to check: clean by hand") unless this is true. The manual Clean audio sweep is unaffected. Absent/false = held. | -| `cleanAudioWithoutChecking` | config | Every clean of this channel's transcribed audio runs WITHOUT the availability check: the Clean audio button, the /cleanup row, `pnpm ops cleanup` and clean after capture alike ask the source nothing, so the audio of a video no longer available anywhere is removed too (it is no longer pinned do-not-clean). Every other protection holds: do-not-clean marks, the keep-latest window, the speaker holds (awaiting diarization / voice fingerprint), untranscribed videos, an unreachable or moving media drive. Those jobs run as "Clean audio without checking"; the key is read again when each starts, and a saved video container is never pruned by them. A new channel never starts with it (createChannel drops it). For a platform whose VODs expire by design (Twitch, Kick), where "gone from the source" is the normal state; never set by platform. Absent/false = checked. Set on the channel's Cleanup stage or with `pnpm ops channel-config {"cleanAudioWithoutChecking": true}`. | +| `cleanAudioWithoutChecking` | config | Every clean of this channel's transcribed audio runs WITHOUT the availability check: the Clean audio button, the /cleanup row, `pnpm ops cleanup` and clean after capture alike ask the source nothing, so the audio of a video no longer available anywhere is removed too (it is no longer pinned do-not-clean). Every other protection holds: do-not-clean marks, the keep-latest window, the speaker holds (awaiting diarization / voice fingerprint), untranscribed videos, an unreachable or moving media drive. Those jobs run as "Clean audio without checking"; the key is read again when each starts, and a saved video container is never pruned by them. The buttons (Cleanup stage, /cleanup, the dashboard) show a count first; these run unchecked with NO count, the key being the standing consent: clean after capture, `pnpm ops cleanup` with no `unchecked` flag, a /jobs Retry, Retry all failed or `pnpm ops job retry` of a clean of this channel, and the boot's re-queue of one a restart caught queued (titled "Clean audio without checking · channel setting"). A rate-limited clean's retry stays checked; no other automatic lane runs a channel clean. A replayed confirmed clean without checking needs its carried plan, and none replays unchecked once the key is off. A new channel never starts with it (createChannel drops it). For a platform whose VODs expire by design (Twitch, Kick), where "gone from the source" is the normal state; never set by platform. Absent/false = checked. Set on the channel's Cleanup stage or with `pnpm ops channel-config {"cleanAudioWithoutChecking": true}`. | | `syncIntervalMinutes` | config | Auto-sync cadence: the scheduler syncs this channel when `now - lastSyncedAt >= syncIntervalMinutes`. Absent = inherit the global default; 0 = auto-sync off (still manually syncable); positives clamp to [1, 44640] (~31 days). A missing `url`, or a `sync` tier of paused in the channel-priority document, also disables auto-sync. AN INSTAGRAM CHANNEL is synced seldom, because every sync is a logged-in read: absent = every 12 hours at the most often (the global default when that is longer), and a value of its own is never under 240 (4 hours); 0 still turns it off (`common/jobs/syncScheduler.ts`). | | `fullSweepIntervalMinutes` | config | Full-sweep cadence: a sync upgrades itself to a full sweep when `now - lastFullSweepAt >= fullSweepIntervalMinutes`. Absent = inherit `syncScheduler.fullSweepIntervalMinutes`; 0 = never sweep (every sync is a paged walk); positives clamp to [1, 44640]. | | `skipLiveDownloads` | config | Per-channel override for the global `skipLiveDownloads`. Absent = inherit; false = allow downloading currently-live / upcoming videos. | diff --git a/COMMANDS.md b/COMMANDS.md @@ -204,7 +204,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run) | `delete-file` | delete-file deletes one file of one video, as its Files list does: {"slug", "id", "file"}. A tiered media file goes with its bytes on the media drive (never a bare link); refused while that drive is not answering. No undo. | | | `do-not-clean` | do-not-clean sets one video's "Do not clean" marker: {"slug", "id", "keep"?: true}; "keep": false removes it. (keep-videos is the bulk form.) | | | `drop-saved-alternate` | drop-saved-alternate deletes one saved alternate of one video, as its "Drop this alternate" button does: {"slug", "id", "file", "dryRun"?}. "file" is a name `get saved-alternates` lists under "alternates"; the active copy, an unlisted name and any path are refused, and so is a store being moved. The file goes from the store and its entry from saved-video.json (the rest of the pointer is untouched); one already gone is cleaned from the pointer ("existed": false). "dryRun": true answers the same and changes nothing. No undo. An ORIGINAL ("keptAs": "original", the source of a compacted copy) needs "confirmOriginal": true; the compacted copy is read back from disk (size, sha256, container, length) before it goes; a video not freshly checked on its platform needs a review of this copy recorded first; and nothing goes while a download or persist of the video is queued or running, or while it is being compacted. A FORMER original ("former-original") needs its own "confirmFormerOriginal": true, and the same gone/review rule. | | -| `cleanup` | cleanup runs one of a channel's cleanup sweeps as a job: {"slug", "sweep": "transcribed" (audio of transcribed videos — the /cleanup total) \| "extra-formats" \| "wrong-format" \| "failed-transcriptions" (clears the list; deletes nothing)}. Do-not-clean videos are skipped; `get cleanup <slug>` says what each would reclaim. "unchecked": true (transcribed only) is "Clean without checking": the source is not asked, so the audio of videos no longer available anywhere goes too; every other protection holds; the job is "Clean audio without checking". With "dryRun": true it answers what it would remove — {plan: {ids, videos, files, bytes, protected, awaitingDiarization, awaitingVoiceprint, inspected}} — and starts nothing; without it the plan is counted at the call and the job removes at most those videos' audio. It never touches a saved video. A checked clean the source rate-limits ends deferred and schedules a retry off the queue after at least 15 min (twice at most), then gives up; `job cancel <the deferred job id>` cancels the retry. | `pnpm ops cleanup --json '{"slug":"x","sweep":"transcribed"}' --wait`<br>`pnpm ops cleanup --json '{"slug":"x","sweep":"transcribed","unchecked":true,"dryRun":true}'` | +| `cleanup` | cleanup runs one of a channel's cleanup sweeps as a job: {"slug", "sweep": "transcribed" (audio of transcribed videos — the /cleanup total) \| "extra-formats" \| "wrong-format" \| "failed-transcriptions" (clears the list; deletes nothing)}. Do-not-clean videos are skipped; `get cleanup <slug>` says what each would reclaim. "unchecked": true (transcribed only) is "Clean without checking": the source is not asked, so the audio of videos no longer available anywhere goes too; every other protection holds; the job is "Clean audio without checking". With "dryRun": true it answers what it would remove — {plan: {ids, videos, files, bytes, protected, awaitingDiarization, awaitingVoiceprint, inspected}} — and starts nothing; without it the plan is counted at the call, its counts answered ({jobId, plan}) and logged, and the job removes at most those videos' audio. It never touches a saved video. With the channel's cleanAudioWithoutChecking on, "transcribed" with no flag runs unchecked with no count (so do job retry and retry-failed of a clean). A checked clean the source rate-limits ends deferred and schedules a retry off the queue after at least 15 min (twice at most), then gives up; `job cancel <the deferred job id>` cancels the retry. | `pnpm ops cleanup --json '{"slug":"x","sweep":"transcribed"}' --wait`<br>`pnpm ops cleanup --json '{"slug":"x","sweep":"transcribed","unchecked":true,"dryRun":true}'` | | `diarize` | diarize runs a channel's "Diarize speakers" as a job: {"slug"}. Every video still holding audio with no current diarization.json is diarized, and a diarized one without voice fingerprints gets them from its own turns — the voiceprint backfill, one channel at a time. Runs while the Speakers lane is paused; nothing is deleted. | `pnpm ops diarize --json '{"slug":"x"}' --wait` | | `web-search` | web-search searches the web (DuckDuckGo's HTML page) and answers the results: {"query", "n"?: 6 (at most 20)} -&gt; {results: \[{title, url, snippet}\]}. Read only, through the editor's one web queue: one request at a time, 3 s apart, backing off on a 429 or 503. For context; a web page is never cited as what someone said. | `pnpm ops web-search --json '{"query":"second shop opening","n":5}'` | | `web-fetch` | web-fetch reads one web page as plain text: {"url", "maxChars"?: 12000 (at most 60000)} -&gt; {page: {url, finalUrl, status, contentType, title?, text, truncated}}. http and https only; a private or loopback host (by name, by address, or by what its name resolves to, every redirect checked) is refused before any request, and so is a page that is not text (a PDF, an image). Read only, on the same web queue as web-search. | `pnpm ops web-fetch --json '{"url":"https://example.com/news/item","maxChars":4000}'` | diff --git a/OPERATING.md b/OPERATING.md @@ -1111,18 +1111,26 @@ pnpm ops channel-config --json '{"slug":"example","cleanAudioWithoutChecking":tr the audio of videos no longer available anywhere is removed too. Every other protection holds: do-not-clean, the keep-latest window, awaiting diarization or voice fingerprint, untranscribed videos, and a media drive that is unreachable or being moved (asked again immediately before anything is removed). It never touches a saved video: - the saved-video retention prune runs only in a checked Clean audio. The page counts first (`dryRun`: files, bytes, + the saved-video retention prune runs only in a checked Clean audio whose availability check completed — never in an + unchecked one, and never after a check the source rate-limited or that failed (on the first run and every retry). The page counts first (`dryRun`: files, bytes, videos, what it keeps, and the video `ids`) and asks: "Remove N audio files (X) from M transcribed videos without checking? The source is not asked, so the audio of videos no longer available anywhere is removed too." The job carries those ids and removes **at most** them: a video protected since is skipped, one that became eligible since is left for the next run ("not in the confirmed plan" in its log). Over ops, a call without `dryRun` counts at the call and carries that plan. The job is titled "Clean audio without checking". A Retry of it, or a restart that caught it queued, runs it again with its carried plan only; with no plan it removes nothing and ends failed, - "Confirmed plan lost; confirm again". + "Confirmed plan lost; confirm again" (on a key-off channel a replay of it is refused instead). The `cleanup` reply + answers the plan's counts, and the job's log states them before anything is removed. - **`cleanAudioWithoutChecking`** on a channel (CHANNEL.md; the Cleanup stage's checkbox, which asks before turning it on) makes every clean of it unchecked: Clean audio, the /cleanup card, the dashboard's buttons, `cleanup` over ops - and clean after capture. Each button then shows the same counted confirmation and carries its plan; a `cleanup` - call with no flag, and clean after capture, discover when they start. The key is read again when the job starts: if + and clean after capture. Each button then shows the same counted confirmation and carries its plan. **With the key + on, these run unchecked with no count** — the key is the operator's standing consent for the channel: clean after + capture, a `cleanup` call with no `unchecked` flag, a /jobs **Retry**, **Retry all failed** or `pnpm ops job retry` + of a clean of the channel, and the boot's re-queue of one a restart caught queued. Each discovers when it starts and + is titled "Clean audio without checking · channel setting", its first log line "Clean without checking (channel + setting): …". A rate-limited clean's retry stays checked; no other automatic lane runs a channel clean. A replayed + confirmed "Clean without checking" (· confirmed count) runs again only with its carried plan, and on a channel whose + key is off no replay runs unchecked at all: it is refused. The key is read again when the job starts: if it was turned off meanwhile, the job runs checked and says so in its log. Off unless set; never set by platform; a new channel never starts with it. Clean after capture still holds a URL-less channel (`cleanAfterCaptureUnverified`) and a whole-recording one (`diarization.cleanWholeRecordingAudio`) — those holds @@ -1137,7 +1145,9 @@ pnpm ops channel-config --json '{"slug":"example","cleanAudioWithoutChecking":tr or the platform's cooldown, whichever is later. The retry waits **off the queue** — a record in `.jobs/clean-retries.json` and a timer — so it holds neither the channel's queue nor a job slot, and it is queued as "Clean audio (rate-limit retry)" only when its time comes (later still if the cooldown is still running then). - The record survives a restart: the retry keeps its attempt and its time. **Cancel** the deferred job to cancel the + The record survives a restart: the retry keeps its attempt and its time. If the channel's media is held when its + time comes (a relocation in flight, a drive away), it waits 15 minutes and tries again, same attempt, for up to 24 + hours; then it gives up and the Cleanup stage says why until dismissed. **Cancel** the deferred job to cancel the retry (`pnpm ops job cancel <deferred job id>`), or use **Cancel retry** on the Cleanup stage; any Clean audio or Clean without checking a person starts on the channel replaces it. After 2 retries the next rate limit ends the job **failed**: "Gave up: rate-limited … It needs a person". A failure that is diff --git a/common/controller/cleanAudioFromTranscribed.ts b/common/controller/cleanAudioFromTranscribed.ts @@ -66,8 +66,9 @@ export type UncheckedReason = "button" | "channel-setting"; // The first line of an unchecked clean's log, in both of its forms. export function uncheckedLogLine(reason: UncheckedReason): string { return ( - "Clean without checking: the source is not asked, so the audio of videos no longer available anywhere is removed too" + - (reason === "channel-setting" ? " (this channel's cleanAudioWithoutChecking is on)." : ".") + (reason === "channel-setting" ? "Clean without checking (channel setting): " : "Clean without checking: ") + + "the source is not asked, so the audio of videos no longer available anywhere is removed too" + + (reason === "channel-setting" ? " (this channel's cleanAudioWithoutChecking is on; no count was shown for this run unless it carries a plan)." : ".") ); } @@ -335,17 +336,22 @@ export async function cleanAudioFromTranscribed({ // Retention prune of the saved-video store: evict any keep-latest containers // that have rolled out of the window (pinned/manually-archived ones survive). - // NEVER IN AN UNCHECKED SWEEP (review 1, F1, BLOCKING). The prune keeps a - // rolled-out container only when the video is do-not-clean, and in the - // checked sweep that pin is written by the availability gate just above — - // for a video gone from the source, whose container may be its only copy - // anywhere. An unchecked sweep skips the gate, so no pin would exist and the - // prune would evict exactly those containers, uncounted by any plan. - const prune = unchecked - ? (log( - "Saved-video retention prune skipped: a clean without checking never touches a saved video container (a checked Clean audio runs it).", - ), - { pruned: 0, bytesFreed: 0 }) + // ONLY WHEN THE AVAILABILITY GATE COMPLETED (review 1 F1, review 2 F1). The + // prune keeps a rolled-out container only when the video is do-not-clean, + // and that pin is written by the gate just above — for a video gone from + // the source, whose container may be its only copy anywhere. So the prune + // is skipped when the gate did not run to the end: + // - an UNCHECKED sweep skips the gate, so no pin would exist; + // - a checked sweep whose gate STOPPED (the source rate-limited it, or it + // failed) wrote no pins past where it stopped — on the first run and on + // every retry of the chain. (Before this lane the prune ran then too.) + const pruneSkipped = unchecked + ? "a clean without checking never touches a saved video container (a checked Clean audio runs it)" + : stopped + ? `the availability check did not complete (${stopped.kind === "rate-limit" ? `rate-limited by ${stopped.platform}` : "it failed"}), so a video gone from the source may not be pinned yet` + : null; + const prune = pruneSkipped + ? (log(`Saved-video retention prune skipped: ${pruneSkipped}.`), { pruned: 0, bytesFreed: 0 }) : await pruneSavedVideos({ channelSlug, paths, onLog: log, signal }); return { diff --git a/common/controller/cleanAudioJob.test.ts b/common/controller/cleanAudioJob.test.ts @@ -11,6 +11,7 @@ import { PLAN_LOST_SENTENCE, cleanAudioRequestFor, cleanReplayFor, + REPLAY_UNCHECKED_KEY_OFF, runCleanAudioJob, type CleanRetry, } from "./cleanAudioJob"; @@ -336,21 +337,46 @@ test("what a request queues: kind, unchecked reason and carried plan, from the k }); test("replay: unchecked only with the explicit flag and its carried plan; a retry's replay is a fresh chain", () => { - assert.deepEqual(cleanReplayFor("clean-audio-transcribed", {}), { ok: true, call: "clean" }); - assert.deepEqual(cleanReplayFor("clean-audio-transcribed", { plan: ["a"] }), { ok: true, call: "clean", plan: ["a"] }); + const cleanReplay = (k: string, p: Record<string, unknown>) => cleanReplayFor(k, p, true); + assert.deepEqual(cleanReplay("clean-audio-transcribed", {}), { ok: true, call: "clean" }); + assert.deepEqual(cleanReplay("clean-audio-transcribed", { plan: ["a"] }), { ok: true, call: "clean", plan: ["a"] }); assert.deepEqual( - cleanReplayFor("clean-audio-retry", { retry: { attempt: 1, of: "j", notBefore: 1, platform: "rumble" }, plan: ["a"] }), + cleanReplay("clean-audio-retry", { retry: { attempt: 1, of: "j", notBefore: 1, platform: "rumble" }, plan: ["a"] }), { ok: true, call: "clean" }, "the retry's chain and count are the schedule's, never a replay's", ); - assert.deepEqual(cleanReplayFor("clean-audio-unchecked", { unchecked: "button", plan: ["a", "b"] }), { + assert.deepEqual(cleanReplay("clean-audio-unchecked", { unchecked: "button", plan: ["a", "b"] }), { ok: true, call: "unchecked", plan: ["a", "b"], }); // No plan: replayed into a job that ends failed (PLAN_LOST_SENTENCE), never an unbounded run. - assert.deepEqual(cleanReplayFor("clean-audio-unchecked", { unchecked: "button" }), { ok: true, call: "unchecked" }); - assert.deepEqual(cleanReplayFor("clean-audio-unchecked", { unchecked: "button", plan: "a" }), { ok: true, call: "unchecked" }); - assert.deepEqual(cleanReplayFor("clean-audio-unchecked", { unchecked: "channel-setting" }), { ok: true, call: "clean" }); - assert.equal(cleanReplayFor("clean-audio-unchecked", {}).ok, false); + assert.deepEqual(cleanReplay("clean-audio-unchecked", { unchecked: "button" }), { ok: true, call: "unchecked" }); + assert.deepEqual(cleanReplay("clean-audio-unchecked", { unchecked: "button", plan: "a" }), { ok: true, call: "unchecked" }); + assert.deepEqual(cleanReplay("clean-audio-unchecked", { unchecked: "channel-setting" }), { ok: true, call: "clean" }); + assert.equal(cleanReplay("clean-audio-unchecked", {}).ok, false); + // Key OFF: a confirmed unchecked run is never replayed unchecked. + assert.deepEqual(cleanReplayFor("clean-audio-unchecked", { unchecked: "button", plan: ["a"] }, false), { + ok: false, + info: true, + error: REPLAY_UNCHECKED_KEY_OFF, + }); +}); + +test("ops nit: a carried plan's counts are stated in the job's log before anything is removed", async () => { + const paths = await corpus(); + const { probes } = rateLimitedListing(); + const logs: string[] = []; + await runCleanAudioJob({ + ...base(paths, { + unchecked: "button", + plan: ["a", "b"], + planCounts: { files: 2, bytes: 200, videos: 2, protected: 0, awaitingDiarization: 0, awaitingVoiceprint: 0 }, + onLog: (m) => logs.push(m), + }), + deps: { probes, scheduleRetry: retryRecorder().scheduleRetry, now: () => T0 }, + }); + const counted = logs.findIndex((l) => l.startsWith("Plan counted when this clean was asked for: 2 audio file(s) (200 bytes) from 2 video(s); kept: 0")); + const removed = logs.findIndex((l) => l.startsWith("Removed ")); + assert.ok(counted >= 0 && removed > counted, logs.join("\n")); }); diff --git a/common/controller/cleanAudioJob.ts b/common/controller/cleanAudioJob.ts @@ -108,27 +108,45 @@ export function planFromParams(p: Record<string, unknown> | undefined): string[] return Array.isArray(v) && v.every((x) => typeof x === "string") ? (v as string[]) : undefined; } -// HOW A CLEAN JOB IS REPLAYED (a person's Retry, and the boot's re-queue of a -// job a restart caught queued): -// - clean-audio-transcribed → Clean audio again (its plan, if it carried one); -// - clean-audio-retry → Clean audio again: a FRESH chain (a scheduled retry -// is re-armed at boot from its own record, never replayed); -// - clean-audio-unchecked with "button" → unchecked again WITH ITS CARRIED -// PLAN, removing at most that; a spec with no plan replays into a job that -// ends failed, "Confirmed plan lost; confirm again" (PLAN_LOST_SENTENCE); -// - clean-audio-unchecked with "channel-setting" → Clean audio, so the key -// as it is now decides; +// HOW A CLEAN JOB IS REPLAYED — by every replay path alike: a /jobs Retry, +// Retry all failed, `pnpm ops job retry`, and the boot's re-queue of a job a +// restart caught queued (all four go through the editor's runJobSpec). Operator +// ruling (review 2): the channel key is the operator's standing consent for +// that channel, so on a KEY-ON channel a replay may run unchecked WITHOUT a +// new count, like any key-driven job (the key read at start, "without +// checking (channel setting)" in its title and first line, no prune). But a +// replay never becomes a person-confirmed unchecked run without its plan, and +// on a KEY-OFF channel no replay runs unchecked at all: +// - clean-audio-transcribed, clean-audio-retry (a FRESH chain: a scheduled +// retry is re-armed from its own record, never replayed) and a +// "channel-setting" clean-audio-unchecked → Clean audio again, the key as +// it is now decides (a carried plan, if any, still bounds it); +// - a "button" clean-audio-unchecked (a person confirmed a count) → on a +// key-on channel, unchecked again WITH ITS CARRIED PLAN only; with no plan +// it replays into a job that removes nothing and ends failed, "Confirmed +// plan lost; confirm again". On a key-OFF channel it is REFUSED: it would +// be an unchecked run nobody asked for now; // - anything else is refused. export type CleanReplay = | { ok: true; call: "clean" | "unchecked"; plan?: string[] } - | { ok: false; error: string }; + | { ok: false; error: string; info?: boolean }; -export function cleanReplayFor(kind: string, params: Record<string, unknown> | undefined): CleanReplay { +export const REPLAY_UNCHECKED_KEY_OFF = + "This was a clean without checking, and this channel cleans checked now: a Retry does not run it unchecked. Run Clean without checking again and confirm its count, or Clean audio."; + +export function cleanReplayFor( + kind: string, + params: Record<string, unknown> | undefined, + keyOn: boolean, +): CleanReplay { const plan = planFromParams(params); if (kind === "clean-audio-transcribed") return { ok: true, call: "clean", ...(plan ? { plan } : {}) }; if (kind === "clean-audio-retry") return { ok: true, call: "clean" }; if (kind === "clean-audio-unchecked") { - if (params?.unchecked === "button") return { ok: true, call: "unchecked", ...(plan ? { plan } : {}) }; + if (params?.unchecked === "button") { + if (!keyOn) return { ok: false, info: true, error: REPLAY_UNCHECKED_KEY_OFF }; + return { ok: true, call: "unchecked", ...(plan ? { plan } : {}) }; + } if (params?.unchecked === "channel-setting") return { ok: true, call: "clean", ...(plan ? { plan } : {}) }; return { ok: false, @@ -138,6 +156,43 @@ export function cleanReplayFor(kind: string, params: Record<string, unknown> | u return { ok: false, error: `not a clean-audio kind: ${kind}` }; } +// The replay itself, over the actions it calls (the editor's cleanAudioAction +// and cleanAudioUncheckedAction): the channel's key is read NOW. +export async function replayCleanSpec<R>( + spec: { kind: string; slug: string; params?: Record<string, unknown> }, + deps: { + readConfig: (slug: string) => Promise<ChannelConfig | null>; + clean: (slug: string, queueKey: string | undefined, plan?: string[]) => Promise<R>; + unchecked: (slug: string, queueKey: string | undefined, plan?: string[]) => Promise<R>; + }, +): Promise<R | { ok: false; error: string; info?: boolean }> { + const p = spec.params ?? {}; + const queueKey = typeof p.queueKey === "string" ? p.queueKey : undefined; + const keyOn = uncheckedReasonFor(await deps.readConfig(spec.slug).catch(() => null)) !== undefined; + const r = cleanReplayFor(spec.kind, p, keyOn); + if (!r.ok) return r; + return r.call === "unchecked" ? deps.unchecked(spec.slug, queueKey, r.plan) : deps.clean(spec.slug, queueKey, r.plan); +} + +// What the plan counted, as the job's log states it before anything is removed +// (and `pnpm ops cleanup {"unchecked": true}` answers it). +export type CleanPlanCountsLog = { + files: number; + bytes: number; + videos: number; + protected: number; + awaitingDiarization: number; + awaitingVoiceprint: number; +}; + +export function planCountsLine(c: CleanPlanCountsLog): string { + return ( + `Plan counted when this clean was asked for: ${c.files} audio file(s) (${c.bytes} bytes) from ${c.videos} video(s); ` + + `kept: ${c.protected} marked do not clean or in the keep-latest window, ${c.awaitingDiarization} awaiting diarization, ` + + `${c.awaitingVoiceprint} awaiting voice fingerprint.` + ); +} + function clock(ms: number): string { return new Date(ms).toISOString().slice(11, 16) + " UTC"; } @@ -148,6 +203,7 @@ export async function runCleanAudioJob({ jobId, unchecked, plan, + planCounts, retry, onLog, signal, @@ -162,6 +218,8 @@ export async function runCleanAudioJob({ unchecked?: UncheckedReason; // The confirmed plan's video ids: the run removes at most these. plan?: readonly string[]; + // The plan's counts, logged before anything is removed (an ops call). + planCounts?: CleanPlanCountsLog; retry?: CleanRetry; onLog: (m: string) => void; signal?: AbortSignal; @@ -195,6 +253,7 @@ export async function runCleanAudioJob({ sentence: `This retry was started before its time (not before ${clock(retry.notBefore)}): nothing was asked or cleaned.`, }; } + if (plan && planCounts) onLog(planCountsLine(planCounts)); if (retry) { onLog(`Retry ${retry.attempt} of ${CLEAN_RATE_LIMIT_MAX_RETRIES} of rate-limited clean ${retry.of}.`); } diff --git a/common/controller/cleanReplay.test.ts b/common/controller/cleanReplay.test.ts @@ -0,0 +1,223 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { access, mkdir, mkdtemp, readdir, readFile, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import type { Paths } from "../lib/paths"; +import type { JobSpec } from "../jobs/jobSpec"; +import type { VerifyProbes } from "./verifyBeforeClean"; +import { + PLAN_LOST_SENTENCE, + REPLAY_UNCHECKED_KEY_OFF, + cleanAudioRequestFor, + replayCleanSpec, + runCleanAudioJob, + type CleanJobOutcome, +} from "./cleanAudioJob"; +import { readChannelConfig } from "./channels"; +import { jobSpecDetail } from "../jobs/jobDetail"; +import { settleQueuedJobMetas } from "../jobs/bootQueuedJobs"; + +// Run with: +// pnpm --filter yt-dlp-transcript-common exec tsx --test controller/cleanReplay.test.ts +// +// REPLAYING A CLEAN (lane clean-unverified, review 2 ruling): the four replay +// paths — a /jobs Retry, Retry all failed, `pnpm ops job retry`, and the boot's +// re-queue — all reach replayCleanSpec (the editor's runJobSpec → +// JOB_REPLAY_HANDLERS → replayClean; the boot's requeue is runJobSpec too). +// Each path is driven here as its caller drives it, over the same composition +// the editor's actions make: cleanAudioRequestFor on the config read at the +// call, then the job body. On a KEY-ON channel a replay may run unchecked with +// no count ("channel setting", no prune); a confirmed run needs its plan; on a +// KEY-OFF channel nothing replays unchecked. + +const ROOT = await mkdtemp(path.join(tmpdir(), "clean-replay-")); +process.env.SETTINGS_FILE = path.join(ROOT, "settings.json"); +await writeFile(process.env.SETTINGS_FILE, JSON.stringify({ verifyAvailabilityBeforeClean: true })); +const T0 = Date.parse("2026-11-21T03:00:00.000Z"); + +let n = 0; +async function corpus(keyOn: boolean) { + const dir = path.join(ROOT, `c${n++}`); + const paths = { + channelsDir: path.join(dir, "channels"), + transcriptsDir: dir, + savedVideosDir: path.join(dir, "saved"), + jobsDir: path.join(dir, ".jobs"), + ytdlpBin: path.join(dir, "no-ytdlp"), + } as unknown as Paths; + await mkdir(paths.jobsDir, { recursive: true }); + await mkdir(path.join(paths.channelsDir, "ch", "data"), { recursive: true }); + await writeFile( + path.join(paths.channelsDir, "ch", "config.json"), + JSON.stringify({ handling: "transcribe", name: "ch", url: "https://www.twitch.tv/example", ...(keyOn ? { cleanAudioWithoutChecking: true } : {}) }), + ); + for (const id of ["a", "b"]) { + const v = path.join(paths.channelsDir, "ch", "data", id); + await mkdir(v, { recursive: true }); + await writeFile(path.join(v, "transcript.json"), "{}"); + await writeFile(path.join(v, "audio.mp3"), Buffer.alloc(100)); + } + return paths; +} + +type Ran = { kind: string; unchecked?: string; detail?: string; out: CleanJobOutcome; logs: string[]; asked: number }; + +// The editor's actions, composed as whisperActions composes them: the request +// from the config read NOW, then the job body (its key read again at start). +function actions(paths: Paths) { + const ran: Ran[] = []; + const run = async (explicit: "button" | undefined, slug: string, plan?: string[]) => { + const req = cleanAudioRequestFor(await readChannelConfig(paths, slug), { ...(explicit ? { explicit } : {}), ...(plan ? { plan } : {}) }); + const params = { ...(req.unchecked ? { unchecked: req.unchecked } : {}), ...(req.plan ? { plan: req.plan } : {}) }; + let asked = 0; + const probes: VerifyProbes = { + quick: async () => (asked++, { knownCount: 2, freshCount: 2, maybeMissingCount: 0, ids: [] }), + }; + const logs: string[] = []; + const out = await runCleanAudioJob({ + channelSlug: slug, + paths, + jobId: `job-${ran.length}`, + ...(req.unchecked ? { unchecked: req.unchecked } : {}), + ...(req.plan ? { plan: req.plan } : {}), + onLog: (m) => logs.push(m), + deps: { probes, now: () => T0, cooldownRemainingMs: async () => 0, scheduleRetry: async () => ({ ok: false, error: "none" }) }, + }); + const r: Ran = { kind: req.kind, ...(req.unchecked ? { unchecked: req.unchecked } : {}), detail: jobSpecDetail(req.kind, { kind: req.kind, slug, params }), out, logs, asked }; + ran.push(r); + return { ok: true as const, jobId: `job-${ran.length - 1}` }; + }; + return { + ran, + deps: { + readConfig: (slug: string) => readChannelConfig(paths, slug), + clean: (slug: string, _q: string | undefined, plan?: string[]) => run(undefined, slug, plan), + unchecked: (slug: string, _q: string | undefined, plan?: string[]) => run("button", slug, plan), + }, + }; +} + +// The four paths, each as its caller drives replay. +type Path = "retry" | "retry-all-failed" | "ops-job-retry" | "boot"; +const PATHS: Path[] = ["retry", "retry-all-failed", "ops-job-retry", "boot"]; + +async function replayBy(via: Path, paths: Paths, spec: JobSpec, deps: ReturnType<typeof actions>["deps"]) { + if (via === "retry" || via === "ops-job-retry") return replayCleanSpec(spec, deps); + if (via === "retry-all-failed") { + // Every failed job with a spec, one after another. + const out = []; + for (const s of [spec]) out.push(await replayCleanSpec(s, deps)); + return out[0]; + } + // The boot: a meta a restart caught queued, re-queued through its spec. + const metaId = `M${n++}`; + await writeFile( + path.join(paths.jobsDir, `${metaId}.meta.json`), + JSON.stringify({ id: metaId, kind: spec.kind, queueKey: "channel:ch", status: "queued", queuedAt: Date.now() - 60_000, channelSlug: "ch", spec }), + ); + let answer: unknown; + const res = await settleQueuedJobMetas({ + paths, + bootedAt: Date.now() + 60_000, + log: () => {}, + requeue: async (s) => { + const r = await replayCleanSpec(s, deps); + answer = r; + return r as { ok: true; jobId: string } | { ok: false; error: string }; + }, + }); + if (!answer) return { ok: false, error: `not re-queued: ${JSON.stringify(res.cancelled)}` }; + return answer; +} + +const has = (paths: Paths, id: string) => + access(path.join(paths.channelsDir, "ch", "data", id, "audio.mp3")).then(() => true, () => false); + +const CHECKED_SPECS: JobSpec[] = [ + { kind: "clean-audio-transcribed", slug: "ch", params: {} }, + { kind: "clean-audio-retry", slug: "ch", params: { retry: { attempt: 1, of: "j", notBefore: 1, platform: "twitch", id: "j.retry1" } } }, + { kind: "clean-audio-unchecked", slug: "ch", params: { unchecked: "channel-setting" } }, +]; +const BUTTON_WITH_PLAN: JobSpec = { kind: "clean-audio-unchecked", slug: "ch", params: { unchecked: "button", plan: ["a"] } }; +const BUTTON_NO_PLAN: JobSpec = { kind: "clean-audio-unchecked", slug: "ch", params: { unchecked: "button" } }; + +for (const via of PATHS) { + test(`${via}, key OFF: no replay runs unchecked — the clean kinds run checked, a confirmed unchecked one is refused`, async () => { + for (const spec of CHECKED_SPECS) { + const paths = await corpus(false); + const a = actions(paths); + await replayBy(via, paths, spec, a.deps); + // At boot a queued retry is not replayed at all: its schedule re-arms it. + if (via === "boot" && spec.kind === "clean-audio-retry") { + assert.equal(a.ran.length, 0); + continue; + } + assert.equal(a.ran.length, 1, `${spec.kind}: replayed`); + const [r] = a.ran; + assert.equal(r.kind, "clean-audio-transcribed", `${spec.kind}: checked kind`); + assert.equal(r.unchecked, undefined); + assert.equal(r.asked, 1, `${spec.kind}: the source was asked`); + assert.ok(!r.logs.some((l) => l.includes("without checking")), r.logs.join("\n")); + } + for (const spec of [BUTTON_WITH_PLAN, BUTTON_NO_PLAN]) { + const paths = await corpus(false); + const a = actions(paths); + const out = (await replayBy(via, paths, spec, a.deps)) as { ok: boolean; error?: string }; + assert.equal(a.ran.length, 0, "nothing ran"); + assert.equal(out.ok, false); + if (via !== "boot") assert.equal(out.error, REPLAY_UNCHECKED_KEY_OFF); + assert.equal(await has(paths, "a"), true); + assert.equal(await has(paths, "b"), true); + } + if (via === "boot") { + // The boot pass closes a refused re-queue with the refusal. + const paths = await corpus(false); + const a = actions(paths); + await replayBy(via, paths, BUTTON_WITH_PLAN, a.deps); + const files = (await readdir(paths.jobsDir)).filter((f) => f.endsWith(".meta.json")); + const metas = await Promise.all(files.map((f) => readFile(path.join(paths.jobsDir, f), "utf8"))); + assert.ok(metas.some((m) => m.includes("re-queue refused") && m.includes("cleans checked now")), metas.join("\n")); + } + }); + + test(`${via}, key ON: a clean replays unchecked with no count ("channel setting", no prune); a confirmed one needs its plan`, async () => { + for (const spec of CHECKED_SPECS) { + const paths = await corpus(true); + const a = actions(paths); + await replayBy(via, paths, spec, a.deps); + if (via === "boot" && spec.kind === "clean-audio-retry") { + assert.equal(a.ran.length, 0, "a queued retry is re-armed by its schedule, never replayed at boot"); + continue; + } + assert.equal(a.ran.length, 1); + const [r] = a.ran; + assert.equal(r.kind, "clean-audio-unchecked", `${spec.kind}`); + assert.equal(r.unchecked, "channel-setting"); + assert.equal(r.detail, "channel setting", "the title reads … without checking · channel setting"); + assert.ok(r.logs[0]?.startsWith("Clean without checking (channel setting):"), r.logs.join("\n")); + assert.ok(r.logs.some((l) => l.startsWith("Saved-video retention prune skipped")), r.logs.join("\n")); + assert.equal(r.asked, 0, "the source was not asked"); + assert.equal(r.out.end, "done"); + } + // A confirmed run with its plan: unchecked, at most the plan. + { + const paths = await corpus(true); + const a = actions(paths); + await replayBy(via, paths, BUTTON_WITH_PLAN, a.deps); + assert.equal(a.ran[0]?.unchecked, "button"); + assert.equal(a.ran[0]?.detail, "confirmed count"); + assert.equal(await has(paths, "a"), false); + assert.equal(await has(paths, "b"), true, "not in the carried plan"); + } + // A confirmed run without its plan: removes nothing, ends failed. + { + const paths = await corpus(true); + const a = actions(paths); + await replayBy(via, paths, BUTTON_NO_PLAN, a.deps); + assert.deepEqual(a.ran[0]?.out, { end: "failed", sentence: PLAN_LOST_SENTENCE }); + assert.equal(await has(paths, "a"), true); + assert.equal(await has(paths, "b"), true); + } + }); +} diff --git a/common/controller/cleanRetrySchedule.test.ts b/common/controller/cleanRetrySchedule.test.ts @@ -5,6 +5,8 @@ import { tmpdir } from "node:os"; import path from "node:path"; import type { Paths } from "../lib/paths"; import { + HOLD_PAUSE_MS, + MAX_HOLDS, MAX_REARMS, armCleanRetriesAtBoot, cancelCleanRetries, @@ -43,6 +45,8 @@ function fakeProcess(start = T0) { const enqueued: ScheduledCleanRetry[] = []; const cancelledJobs: string[] = []; let cooldown = 0; + let hold: string | null = null; + let refuse: string | null = null; const deps: CleanRetryDeps = { now: () => now, setTimer: (fn, ms) => { @@ -53,9 +57,11 @@ function fakeProcess(start = T0) { clearTimer: (h) => void pending.delete(h as number), cooldownRemainingMs: async () => cooldown, enqueue: async (e) => { + if (refuse) return { ok: false, error: refuse }; enqueued.push({ ...e }); return { ok: true, jobId: `job-${enqueued.length}` }; }, + mediaHold: async () => hold, cancelJob: (id) => (cancelledJobs.push(id), true), }; return { @@ -64,6 +70,8 @@ function fakeProcess(start = T0) { cancelledJobs, pending, setCooldown: (ms: number) => void (cooldown = ms), + setHold: (why: string | null) => void (hold = why), + setRefuse: (why: string | null) => void (refuse = why), // Advance the clock, firing due timers (and letting their async work run). async advance(ms: number) { now += ms; @@ -209,3 +217,51 @@ test("one retry per channel: a new one supersedes the old; another channel's is assert.deepEqual((await readCleanRetries(p)).map((e) => e.slug), ["other"]); proc.restart(); }); + +test("review 2 F3: a relocation or an absent drive when its time comes DEFERS the retry, same attempt — never a silent drop", async () => { + const p = await jobsDir(); + const proc = fakeProcess(); + await scheduleCleanRetry(p, REQ, proc.deps); + proc.setHold('Channel "ch" media is in transition: a media relocation (out) is in progress'); + await proc.advance(15 * MIN); + assert.equal(proc.enqueued.length, 0, "not queued while held"); + const [held] = await readCleanRetries(p); + assert.equal(held.attempt, 1, "the same attempt"); + assert.equal(held.holds, 1); + assert.match(held.heldReason ?? "", /in transition/); + assert.equal(held.notBefore, T0 + 15 * MIN + HOLD_PAUSE_MS); + // A refused enqueue (the job's own media guard) holds it the same way. + proc.setHold(null); + proc.setRefuse("media unreachable"); + await proc.advance(HOLD_PAUSE_MS); + assert.equal((await readCleanRetries(p))[0].holds, 2); + // The media is back: queued, with the same attempt; the reason is cleared. + proc.setRefuse(null); + await proc.advance(HOLD_PAUSE_MS); + assert.equal(proc.enqueued.length, 1); + assert.equal(proc.enqueued[0].attempt, 1); + assert.equal((await readCleanRetries(p))[0].heldReason, undefined); + proc.restart(); +}); + +test("review 2 F3: held for 24 h it gives up VISIBLY — the record stays, says why, is not re-armed at boot, and Cancel dismisses it", async () => { + assert.equal(MAX_HOLDS * HOLD_PAUSE_MS, 24 * 60 * MIN); + const p = await jobsDir(); + const proc = fakeProcess(); + await scheduleCleanRetry(p, REQ, proc.deps); + proc.setHold("the drive is not mounted"); + await proc.advance(15 * MIN); + for (let i = 1; i < MAX_HOLDS; i++) await proc.advance(HOLD_PAUSE_MS); + assert.equal(proc.enqueued.length, 0); + const [gone] = await readCleanRetries(p); + assert.ok(gone, "kept, not dropped"); + assert.match(gone.gaveUp ?? "", /^Gave up after 96 tries over 24 h: the drive is not mounted/); + assert.equal(proc.pending.size, 0, "no timer"); + proc.restart(); + const next = fakeProcess(T0 + 48 * 60 * MIN); + const boot = await armCleanRetriesAtBoot(p, next.deps); + assert.deepEqual(boot.armed, []); + assert.equal((await readCleanRetries(p)).length, 1, "still there for the Cleanup stage"); + await cancelCleanRetries(p, { slug: "ch" }, next.deps); + assert.deepEqual(await readCleanRetries(p), []); +}); diff --git a/common/controller/cleanRetrySchedule.ts b/common/controller/cleanRetrySchedule.ts @@ -57,12 +57,29 @@ export type ScheduledCleanRetry = { rearms?: number; // Times a restart caught it running and it was re-armed. restarts?: number; + // HELD (review 2 F3): times its time came while the channel's media was not + // reachable (a relocation in flight, a drive away) or its job was refused, + // and why the last time — so the Cleanup stage can say so. + holds?: number; + heldReason?: string; + // Set when it was held MAX_HOLDS times in a row: it no longer fires, and + // the Cleanup stage says why until a person dismisses it (Cancel retry) or a + // new clean replaces it. Never dropped silently. + gaveUp?: string; }; type StoreFile = { version: 1; retries: ScheduledCleanRetry[] }; export const CLEAN_RETRIES_FILENAME = "clean-retries.json"; export const MAX_REARMS = 8; +// A retry whose channel's media is held when its time comes waits HOLD_PAUSE_MS +// and tries again, at most MAX_HOLDS times: 96 × 15 min = 24 hours. A media +// move of a large channel takes hours, and a drive coming back after a reboot +// minutes, so a day covers both; a drive away longer than that is not a pause, +// and a retry a day late is no longer the clean that was asked for — it gives +// up visibly instead. +export const HOLD_PAUSE_MS = 15 * 60_000; +export const MAX_HOLDS = 96; // setTimeout's ceiling (~24.8 days); a longer wait is re-armed when it fires. const MAX_TIMER_MS = 2 ** 31 - 1; @@ -115,6 +132,9 @@ export type CleanRetryDeps = { enqueue: (entry: ScheduledCleanRetry) => Promise<{ ok: true; jobId: string } | { ok: false; error: string }>; // Cancel a queued job (the registry's cancel). cancelJob?: (jobId: string) => boolean; + // Why the channel's media cannot be touched now (a relocation marker, an + // unreachable drive), or null — asked when the timer fires, before queueing. + mediaHold?: (slug: string) => Promise<string | null>; log?: (m: string) => void; }; @@ -137,6 +157,7 @@ function clearTimerFor(id: string, deps: CleanRetryDeps): void { function arm(paths: Pick<Paths, "jobsDir">, entry: ScheduledCleanRetry, deps: CleanRetryDeps): void { clearTimerFor(entry.id, deps); + if (entry.gaveUp) return; const now = (deps.now ?? Date.now)(); const ms = Math.min(MAX_TIMER_MS, Math.max(0, entry.notBefore - now)); const set = deps.setTimer ?? ((fn: () => Promise<unknown>, d: number) => setTimeout(() => void fn(), d)); @@ -180,10 +201,10 @@ export async function fireCleanRetry( paths: Pick<Paths, "jobsDir">, id: string, deps: CleanRetryDeps, -): Promise<"enqueued" | "rearmed" | "gone" | "early" | "failed"> { +): Promise<"enqueued" | "rearmed" | "gone" | "early" | "held" | "gave-up"> { const now = (deps.now ?? Date.now)(); const entry = (await readCleanRetries(paths)).find((e) => e.id === id); - if (!entry || entry.state !== "scheduled") return "gone"; + if (!entry || entry.state !== "scheduled" || entry.gaveUp) return "gone"; // Never before its time (a long wait is armed in setTimeout-sized steps). if (now < entry.notBefore) { arm(paths, entry, deps); @@ -203,11 +224,36 @@ export async function fireCleanRetry( arm(paths, moved, deps); return "rearmed"; } - const res = await deps.enqueue(entry).catch((err) => ({ ok: false as const, error: (err as Error).message })); + // THE MEDIA HELD (review 2 F3): a relocation in flight or a drive away when + // its time comes DEFERS the retry, same attempt; so does a refused enqueue + // (the job's own media guard). Never a silent drop. + const held = await (deps.mediaHold?.(entry.slug) ?? Promise.resolve(null)).catch((err) => (err as Error).message); + const res = held + ? ({ ok: false as const, error: held }) + : await deps.enqueue(entry).catch((err) => ({ ok: false as const, error: (err as Error).message })); if (!res.ok) { - await update(paths, (list) => ({ list: list.filter((e) => e.id !== id), out: null })); - deps.log?.(`[clean-retry] ${id}: could not be queued (${res.error}); dropped.`); - return "failed"; + const after = await update(paths, (list) => { + const e = list.find((x) => x.id === id && x.state === "scheduled"); + if (!e) return { list: null, out: null }; + e.holds = (e.holds ?? 0) + 1; + e.heldReason = res.error; + if (e.holds >= MAX_HOLDS) { + e.gaveUp = + `Gave up after ${e.holds} tries over ${Math.round((MAX_HOLDS * HOLD_PAUSE_MS) / 3_600_000)} h: ${res.error}. ` + + "Nothing was asked or cleaned; run Clean audio again once the channel's media is back."; + } else { + e.notBefore = now + HOLD_PAUSE_MS; + } + return { list, out: { ...e } }; + }); + if (!after) return "gone"; + if (after.gaveUp) { + deps.log?.(`[clean-retry] ${id}: ${after.gaveUp}`); + return "gave-up"; + } + deps.log?.(`[clean-retry] ${id}: held (${res.error}); tries again at ${new Date(after.notBefore).toISOString()}.`); + arm(paths, after, deps); + return "held"; } const kept = await update(paths, (list) => { const e = list.find((x) => x.id === id); @@ -216,6 +262,7 @@ export async function fireCleanRetry( if (e.state === "scheduled") { e.state = "enqueued"; e.jobId = res.jobId; + delete e.heldReason; } return { list, out: true }; }); @@ -281,6 +328,10 @@ export async function armCleanRetriesAtBoot( const dropped: string[] = []; const next: ScheduledCleanRetry[] = []; for (const e of list) { + if (e.gaveUp) { + next.push(e); // kept for the Cleanup stage to say why; never fired + continue; + } if (e.state === "running") { if ((e.restarts ?? 0) >= 1) { dropped.push(e.id); diff --git a/common/controller/cleanUnchecked.test.ts b/common/controller/cleanUnchecked.test.ts @@ -11,7 +11,7 @@ import { } from "./cleanAudioFromTranscribed"; import type { VerifyProbes } from "./verifyBeforeClean"; import type { CheckRequestDeps } from "./availabilityVerdict"; -import { uncheckedReasonFor } from "./cleanAudioJob"; +import { runCleanAudioJob, uncheckedReasonFor } from "./cleanAudioJob"; import { parseChannelConfig } from "../lib/channelConfig"; import { channelConfigSchema } from "../lib/channelConfigSchema"; import { EnumerationIncompleteError } from "../ytdlp/runYtdlp"; @@ -489,3 +489,52 @@ test("a new channel never starts with cleanAudioWithoutChecking: createChannel d assert.equal("cleanAudioWithoutChecking" in cfg, false); assert.equal(cfg.name, "f"); }); + +// --- Review 2 ----------------------------------------------------------------- + +test("review 2 F1: a checked clean the source rate-limits prunes no saved container — across the whole retry chain", async () => { + await settings({ enabled: false }); + const { paths, video } = await corpus({ keepLatest: 1, url: "https://rumble.com/c/example" }); + await video("new", { uploadDate: "20261101" }); + // Rolled out of the window, gone upstream, never probed: only the listing + // could have found it gone, and the listing is rate-limited. + const old = await video("old", { uploadDate: "20261001" }); + await writeFile(path.join(old, "source-media.mp4"), "container-bytes"); + await persistSourceVideo({ + videoDir: old, + sourceFilename: "source-media.mp4", + storeDir: path.join(paths.savedVideosDir, "ch", "old"), + keepReason: "keep-latest", + }); + const { calls, probes } = throwingProbes(); + probes.quick = async () => { + calls.quick++; + throw new EnumerationIncompleteError(1, "rumble", null, 0); + }; + const T = Date.parse("2026-11-21T03:00:00.000Z"); + const retries: Array<undefined | { attempt: number; of: string; notBefore: number; platform: string }> = [ + undefined, + { attempt: 1, of: "j0", notBefore: T - 1, platform: "rumble" }, + { attempt: 2, of: "j0", notBefore: T - 1, platform: "rumble" }, + ]; + const ends: string[] = []; + for (const retry of retries) { + const logs: string[] = []; + const out = await runCleanAudioJob({ + channelSlug: "ch", + paths, + jobId: retry ? `j${retry.attempt}` : "j0", + ...(retry ? { retry } : {}), + onLog: (m) => logs.push(m), + deps: { probes, now: () => T, cooldownRemainingMs: async () => 0, scheduleRetry: async (r) => ({ ok: true, id: `${r.of}.retry${r.attempt}` }) }, + }); + ends.push(out.end); + assert.notEqual(await loadSavedVideo(old), null, `the container survives step ${retry?.attempt ?? 0}`); + assert.ok( + logs.some((l) => l.startsWith("Saved-video retention prune skipped: the availability check did not complete (rate-limited by rumble)")), + logs.join("\n"), + ); + } + assert.deepEqual(ends, ["deferred", "deferred", "failed"]); + assert.equal(await exists(path.join(old, "audio.mp3")), true, "nothing unverified was cleaned"); +}); diff --git a/common/jobs/jobDetail.test.ts b/common/jobs/jobDetail.test.ts @@ -64,3 +64,9 @@ test("a batch names who asked, for what, and how many windows", () => { test("other kinds add nothing", () => { assert.equal(jobSpecDetail("sync", spec("sync", { requestedBy: "x" })), undefined); }); + +test("lane clean-unverified: a clean without checking says why on its row", () => { + assert.equal(jobSpecDetail("clean-audio-unchecked", { kind: "clean-audio-unchecked", slug: "x", params: { unchecked: "channel-setting" } }), "channel setting"); + assert.equal(jobSpecDetail("clean-audio-unchecked", { kind: "clean-audio-unchecked", slug: "x", params: { unchecked: "button", plan: ["a"] } }), "confirmed count"); + assert.equal(jobSpecDetail("clean-audio-transcribed", { kind: "clean-audio-transcribed", slug: "x", params: {} }), undefined); +}); diff --git a/common/jobs/jobDetail.ts b/common/jobs/jobDetail.ts @@ -27,6 +27,15 @@ export function jobSpecDetail( if (!runId || !target) return undefined; return `run ${runId.slice(-6)} · ${target}`; } + // A CLEAN WITHOUT CHECKING (lane clean-unverified) says why it is + // unchecked, so the row reads "Clean audio without checking · channel + // setting" for a run the channel's key made (no count shown, unless it + // carries a plan) apart from a count a person confirmed. + if (kind === "clean-audio-unchecked") { + if (p.unchecked === "channel-setting") return "channel setting"; + if (p.unchecked === "button") return "confirmed count"; + return undefined; + } if (kind !== "fetch-window" && kind !== "fetch-windows") return undefined; const by = s(p.requestedBy); if (!by) return undefined; diff --git a/common/lib/channelConfig.ts b/common/lib/channelConfig.ts @@ -374,7 +374,7 @@ export const CHANNEL_CONFIG_FIELD_DOCS: FieldDocs<ChannelConfig> = { cleanAfterCaptureUnverified: "Let clean-after-capture (settings `diarization.cleanAfterCapture`) delete this channel's audio with NO availability check. Only for a channel with no `url`: with no source there is nothing to list, so the automatic per-video clean holds every such channel (\"no source to check: clean by hand\") unless this is true. The manual Clean audio sweep is unaffected. Absent/false = held.", cleanAudioWithoutChecking: - "Every clean of this channel's transcribed audio runs WITHOUT the availability check: the Clean audio button, the /cleanup row, `pnpm ops cleanup` and clean after capture alike ask the source nothing, so the audio of a video no longer available anywhere is removed too (it is no longer pinned do-not-clean). Every other protection holds: do-not-clean marks, the keep-latest window, the speaker holds (awaiting diarization / voice fingerprint), untranscribed videos, an unreachable or moving media drive. Those jobs run as \"Clean audio without checking\"; the key is read again when each starts, and a saved video container is never pruned by them. A new channel never starts with it (createChannel drops it). For a platform whose VODs expire by design (Twitch, Kick), where \"gone from the source\" is the normal state; never set by platform. Absent/false = checked. Set on the channel's Cleanup stage or with `pnpm ops channel-config {\"cleanAudioWithoutChecking\": true}`.", + "Every clean of this channel's transcribed audio runs WITHOUT the availability check: the Clean audio button, the /cleanup row, `pnpm ops cleanup` and clean after capture alike ask the source nothing, so the audio of a video no longer available anywhere is removed too (it is no longer pinned do-not-clean). Every other protection holds: do-not-clean marks, the keep-latest window, the speaker holds (awaiting diarization / voice fingerprint), untranscribed videos, an unreachable or moving media drive. Those jobs run as \"Clean audio without checking\"; the key is read again when each starts, and a saved video container is never pruned by them. The buttons (Cleanup stage, /cleanup, the dashboard) show a count first; these run unchecked with NO count, the key being the standing consent: clean after capture, `pnpm ops cleanup` with no `unchecked` flag, a /jobs Retry, Retry all failed or `pnpm ops job retry` of a clean of this channel, and the boot's re-queue of one a restart caught queued (titled \"Clean audio without checking · channel setting\"). A rate-limited clean's retry stays checked; no other automatic lane runs a channel clean. A replayed confirmed clean without checking needs its carried plan, and none replays unchecked once the key is off. A new channel never starts with it (createChannel drops it). For a platform whose VODs expire by design (Twitch, Kick), where \"gone from the source\" is the normal state; never set by platform. Absent/false = checked. Set on the channel's Cleanup stage or with `pnpm ops channel-config {\"cleanAudioWithoutChecking\": true}`.", syncIntervalMinutes: "Auto-sync cadence: the scheduler syncs this channel when `now - lastSyncedAt >= syncIntervalMinutes`. Absent = inherit the global default; 0 = auto-sync off (still manually syncable); positives clamp to [1, 44640] (~31 days). A missing `url`, or a `sync` tier of paused in the channel-priority document, also disables auto-sync. AN INSTAGRAM CHANNEL is synced seldom, because every sync is a logged-in read: absent = every 12 hours at the most often (the global default when that is longer), and a value of its own is never under 240 (4 hours); 0 still turns it off (`common/jobs/syncScheduler.ts`).", fullSweepIntervalMinutes: diff --git a/common/lib/cleanAudioConfirm.test.ts b/common/lib/cleanAudioConfirm.test.ts @@ -29,5 +29,6 @@ test("the counted confirmation states what goes, that the source is not asked, a test("turning the channel key on states what it changes before it changes it", () => { assert.match(TURN_ON_CONFIRMATION, /^Turn on cleaning without checking for this channel\?/); assert.match(TURN_ON_CONFIRMATION, /without asking the source whether the video is still there/); - assert.match(TURN_ON_CONFIRMATION, /clean after capture does not ask/); + assert.match(TURN_ON_CONFIRMATION, /these do not: clean after capture/); + assert.match(TURN_ON_CONFIRMATION, /a Retry \(or Retry all failed\) of an earlier clean, and a clean a restart re-queues/); }); diff --git a/common/lib/cleanAudioConfirm.ts b/common/lib/cleanAudioConfirm.ts @@ -38,5 +38,6 @@ export function cleanConfirmationText(plan: CleanPlanCounts): { ask: string; kep export const TURN_ON_CONFIRMATION = "Turn on cleaning without checking for this channel? From now on every clean of its audio — Clean audio here and on /cleanup, " + "the dashboard's buttons, pnpm ops and clean after capture — deletes audio without asking the source whether the video is still there, " + - "so the audio of a video removed upstream is deleted too. The buttons still show a count before they run; clean after capture does not ask. " + + "so the audio of a video removed upstream is deleted too. The buttons still show a count before they run; these do not: clean after capture, " + + "pnpm ops cleanup without its unchecked flag, a Retry (or Retry all failed) of an earlier clean, and a clean a restart re-queues. " + "Videos already marked do not clean, the keep-latest window and the speaker holds stay kept."; diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -21,7 +21,16 @@ restart; it runs as **Clean audio (rate-limit retry)** when its time comes. Cancel the deferred job, or Cancel retry on the Cleanup stage, to cancel it. After two retries it ends failed, "Gave up: rate-limited", for a person. A failure that is not a rate limit ends failed, "Could not verify availability", with no retry. A - rate-limited listing now records the platform cooldown, as Sync does. + rate-limited listing now records the platform cooldown, as Sync does. A retry whose channel's media is held when + its time comes (a relocation, a drive away) waits and tries again for up to a day, and the Cleanup stage says so. + - **Fixed (also on earlier releases): a checked Clean audio whose availability check the source rate-limited, or + that failed, no longer runs the saved-video retention prune.** The prune keeps a rolled-out keep-latest container + only when the video is pinned do-not-clean, and the check that pins a video gone from the source had not finished, + so such a container — possibly the only copy — could be evicted. It now logs that the prune was skipped and why. + - With the channel key on, a /jobs Retry, Retry all failed, `pnpm ops job retry` and a restart's re-queue of a clean + run without checking and without a count, titled "Clean audio without checking · channel setting"; a confirmed + clean without checking replays only with its plan, and never once the key is off. `pnpm ops cleanup + {"unchecked": true}` answers the plan's counts. Turning the key on cancels a scheduled rate-limit retry. - **umtool: the gap mark's border is the deck's accent colour.** - The operator picked variant B. The border is drawn in the deck's accent, the colour of the deck's accent rule and the dots in its source line, at full opacity. The box behind the text is near-black at 90 %, and the text diff --git a/editor/app/api/ops/cleanup/route.ts b/editor/app/api/ops/cleanup/route.ts @@ -71,10 +71,16 @@ export async function POST(request: Request) { // A non-dry unchecked call is its own confirmation: its plan is computed // NOW and carried, so the job removes at most what this call would have // answered (the intersection with what is still eligible when it starts). + // Its reply, and the job's log before anything is removed, state the + // plan's counts. if (unchecked) { const r = await planCleanAudioUncheckedAction(slug); if (!r.ok) return opsFail(r.error); - return jobResponse(await cleanAudioUncheckedAction(slug, undefined, r.plan.ids)); + const { ids, ...counts } = r.plan; + const job = await cleanAudioUncheckedAction(slug, undefined, ids, counts); + if (!job.ok) return jobResponse(job); + void job.stream.cancel(); + return NextResponse.json({ ok: true, jobId: job.jobId, plan: counts }); } return jobResponse(await SWEEPS[sweep](slug)); }); diff --git a/editor/app/channels/[slug]/cleanRetryScheduler.ts b/editor/app/channels/[slug]/cleanRetryScheduler.ts @@ -1,6 +1,7 @@ import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getRegistry, onJobEnd } from "yt-dlp-transcript-common/jobs/registry"; import { platformCooldownRemainingMs } from "yt-dlp-transcript-common/jobs/downloadBackoff"; +import { assertChannelMediaReachable } from "yt-dlp-transcript-common/lib/channelMedia"; import { armCleanRetriesAtBoot, cancelCleanRetries, @@ -33,6 +34,16 @@ export function cleanRetryDeps(): CleanRetryDeps { return { ok: true, jobId: r.jobId }; }, cancelJob: (jobId) => getRegistry().cancel(jobId), + // A relocation in flight or a drive away when its time comes: the retry + // waits and tries again (cleanRetrySchedule: HOLD_PAUSE_MS, MAX_HOLDS). + mediaHold: async (slug) => { + try { + await assertChannelMediaReachable(paths, slug); + return null; + } catch (err) { + return (err as Error).message; + } + }, log: (m) => console.log(m), }; } diff --git a/editor/app/channels/[slug]/components/stages/CleanWithoutChecking.tsx b/editor/app/channels/[slug]/components/stages/CleanWithoutChecking.tsx @@ -192,9 +192,13 @@ export function ScheduledCleanRetryNote({ slug, retry }: { slug: string; retry: return ( <div aria-label="scheduled clean retry" className="flex flex-wrap items-center gap-2 text-sm"> <span> - {retry.state === "enqueued" - ? `The source rate-limited the last Clean audio: retry ${retry.attempt} of 2 is queued.` - : `The source rate-limited the last Clean audio: retry ${retry.attempt} of 2 is scheduled, not before ${when}.`} + {retry.gaveUp + ? `The source rate-limited the last Clean audio, and its retry ${retry.attempt} of 2 gave up: ${retry.gaveUp}` + : retry.state === "enqueued" + ? `The source rate-limited the last Clean audio: retry ${retry.attempt} of 2 is queued.` + : retry.heldReason + ? `The source rate-limited the last Clean audio: retry ${retry.attempt} of 2 is held (${retry.heldReason}); it tries again at ${when}.` + : `The source rate-limited the last Clean audio: retry ${retry.attempt} of 2 is scheduled, not before ${when}.`} </span> <button type="button" @@ -206,7 +210,7 @@ export function ScheduledCleanRetryNote({ slug, retry }: { slug: string; retry: }} className="rounded border border-border px-2 py-0.5 text-xs hover:bg-accent disabled:opacity-50" > - Cancel retry + {retry.gaveUp ? "Dismiss" : "Cancel retry"} </button> </div> ); diff --git a/editor/app/channels/[slug]/whisperActions.ts b/editor/app/channels/[slug]/whisperActions.ts @@ -28,6 +28,7 @@ import { runCleanAudioJob, uncheckedReasonFor, type CleanAudioRequest, + type CleanPlanCountsLog, type CleanRetry, } from "yt-dlp-transcript-common/controller/cleanAudioJob"; import { @@ -357,9 +358,12 @@ export async function cleanAudioUncheckedAction( slug: string, queueKey?: string, plan?: string[], + // The plan's counts, stated in the job's log before anything is removed + // (`pnpm ops cleanup {"unchecked": true}` counts at the call). + planCounts?: CleanPlanCountsLog, ): Promise<StreamActionResult> { await supersedeCleanRetries(slug); - return runCleanAudio(slug, queueKey, cleanAudioRequestFor(null, { explicit: "button", plan })); + return runCleanAudio(slug, queueKey, cleanAudioRequestFor(null, { explicit: "button", plan }), undefined, planCounts); } // The retry of a rate-limited clean, queued by its schedule at its not-before @@ -418,6 +422,7 @@ function runCleanAudio( queueKey: string | undefined, req: CleanAudioRequest, retry?: CleanRetry, + planCounts?: CleanPlanCountsLog, ): Promise<StreamActionResult> { const paths = getPaths(); const kind = retry ? "clean-audio-retry" : req.kind; @@ -436,6 +441,7 @@ function runCleanAudio( queueKey, ...(unchecked ? { unchecked } : {}), ...(plan ? { plan } : {}), + ...(plan && planCounts ? { planCounts } : {}), ...(retry ? { retry } : {}), }, }, @@ -452,6 +458,7 @@ function runCleanAudio( jobId: ctx.jobId, ...(unchecked ? { unchecked } : {}), ...(plan ? { plan } : {}), + ...(plan && planCounts ? { planCounts } : {}), ...(retry ? { retry } : {}), onLog, signal, diff --git a/editor/app/channels/actions.ts b/editor/app/channels/actions.ts @@ -1,5 +1,7 @@ "use server"; +import { cancelCleanRetries } from "yt-dlp-transcript-common/controller/cleanRetrySchedule"; +import { cleanRetryDeps } from "./[slug]/cleanRetryScheduler"; import { isRemoteOnlyChannel } from "yt-dlp-transcript-common/lib/channelConfig"; import { prepareLocalArchiveChannel } from "./lib/prepareLocalArchiveChannel"; import { withRumbleDefaults } from "yt-dlp-transcript-common/lib/rumbleDefaults"; @@ -656,6 +658,10 @@ export async function setCleanAudioWithoutCheckingAction( await (on ? patchChannelConfig(paths, slug, { cleanAudioWithoutChecking: true }) : patchChannelConfig(paths, slug, {}, { unset: ["cleanAudioWithoutChecking"] })); + // A rate-limited clean's scheduled retry would list the source and pin gone + // videos do-not-clean, which every unchecked clean then skips: turning the + // key on cancels it. + if (on) await cancelCleanRetries(paths, { slug }, cleanRetryDeps()).catch(() => []); revalidatePath(`/channels/${slug}`); revalidatePath("/cleanup"); return undefined; diff --git a/editor/app/components/actions/InlineActionButton.tsx b/editor/app/components/actions/InlineActionButton.tsx @@ -9,6 +9,7 @@ import { } from "../../channels/[slug]/pipelineActions"; import { cleanAudioAction, + cleanAudioButtonAction, cleanExtraAudioFormatsAction, prepareCleanAudioAction, transcribeMissingAction, @@ -98,7 +99,7 @@ async function runAction(variant: Variant): Promise<StreamActionResult> { return redownloadShortAudioBucketAction(variant.slug); } if (variant.kind === "cleanTranscribedAudio") { - return cleanAudioAction(variant.slug); + return cleanAudioButtonAction(variant.slug); } if (variant.kind === "cleanExtraFormats") { return cleanExtraAudioFormatsAction(variant.slug); @@ -181,7 +182,8 @@ export function InlineActionButton({ setStatus({ kind: "idle" }); return; } - result = await cleanAudioAction(slug); + // Refuses if the key came on since the prepare said "checked". + result = await cleanAudioButtonAction(slug); } if (!result.ok) { setStatus({ kind: "error", message: result.error }); diff --git a/editor/app/jobs/jobReplayRegistry.ts b/editor/app/jobs/jobReplayRegistry.ts @@ -12,7 +12,8 @@ import { savePageNowBatchAction } from "../channels/[slug]/waybackLiveActions"; import { xRunAction } from "../review/xRunActions"; import { coerceClipCopy } from "yt-dlp-transcript-common/lib/clipWindow"; import { isStoredUrlMode } from "yt-dlp-transcript-common/lib/storedMediaUrl"; -import { cleanReplayFor } from "yt-dlp-transcript-common/controller/cleanAudioJob"; +import { replayCleanSpec } from "yt-dlp-transcript-common/controller/cleanAudioJob"; +import { readChannelConfig } from "yt-dlp-transcript-common/controller/channels"; import { readChannelSnapshot } from "yt-dlp-transcript-common/controller/channelSnapshot"; import type { JobSpec, ReplayBucket } from "yt-dlp-transcript-common/jobs/jobSpec"; import type { StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand"; @@ -145,14 +146,15 @@ function params(spec: JobSpec): { return { p, queueKey: str(p.queueKey) }; } -const replayClean: ReplayHandler = async (spec) => { - const { p, queueKey } = params(spec); - const r = cleanReplayFor(spec.kind, p); - if (!r.ok) return r; - return r.call === "unchecked" - ? cleanAudioUncheckedAction(spec.slug, queueKey, r.plan) - : cleanAudioAction(spec.slug, queueKey, r.plan); -}; +// Every replay path (Retry, Retry all failed, `ops job retry`, the boot's +// re-queue) comes through runJobSpec to here; the channel's key is read now +// (controller/cleanAudioJob.ts replayCleanSpec). +const replayClean: ReplayHandler = (spec) => + replayCleanSpec(spec, { + readConfig: (slug) => readChannelConfig(getPaths(), slug), + clean: (slug, queueKey, plan) => cleanAudioAction(slug, queueKey, plan), + unchecked: (slug, queueKey, plan) => cleanAudioUncheckedAction(slug, queueKey, plan), + }); // A PUBLISH STAGE (release 18): the spec IS the stage request, so a retry // re-enqueues it as it was — same run id, same preconditions, which the child diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs @@ -1632,8 +1632,11 @@ export function usage() { ' holds; the job is "Clean audio without checking". With "dryRun": true it', ' answers what it would remove — {plan: {ids, videos, files, bytes,', ' protected, awaitingDiarization, awaitingVoiceprint, inspected}} — and', - ' starts nothing; without it the plan is counted at the call and the job', - ' removes at most those videos\' audio. It never touches a saved video.', + ' starts nothing; without it the plan is counted at the call, its counts', + ' answered ({jobId, plan}) and logged, and the job removes at most those', + ' videos\' audio. It never touches a saved video. With the channel\'s', + ' cleanAudioWithoutChecking on, "transcribed" with no flag runs unchecked', + ' with no count (so do job retry and retry-failed of a clean).', ' A checked clean the source rate-limits ends deferred and schedules a', ' retry off the queue after at least 15 min (twice at most), then gives', ' up; `job cancel <the deferred job id>` cancels the retry.',