Archilyzer · Source

archilyzer

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

commit d0d20ac9a0434695364a8d23a6cc652a6169ae80
parent a25af365c639d66be0733956205006d682185e46
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 21 Nov 2026 14:23:28 -0500

record-live: an insurance recorder at the live edge while the start catches up

A from-start recording of a stream already live is behind the live edge
for a long time; a stream removed then loses everything between the
catch-up point and its end. Now a second recorder records the live edge
beside it, its own part, starting 60 s (jittered) after the from-start
part's first bytes so the two extractions are never back to back. It
stops 5 min after the from-start recorder has caught up (every stream it
reports within 30 fragments of its total, read from yt-dlp's own progress
lines), or runs the whole stream with "insurance": "whole". With no
progress line read it runs to the end, the safe direction. Not for Kick
(two recorders already), path B or an upcoming stream; not started if the
run falls back to the live edge.

Default, as ruled: ON when the stream is marked keep before or when the
recording starts (doNotClean asked, the record's Do-not-clean marker, a
pending keep), OFF otherwise; "insurance": true | "whole" | false
overrides either way and Record again asks it again. Its part goes at
landing only when the landed file holds the whole stream; otherwise it is
kept and listed. Cost: one extraction and a viewer's live-edge reads, a
tenth of the from-start recorder's catch-up rate, stopped after catch-up.

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

Diffstat:
MCOMMANDS.md | 5+++--
Mcommon/controller/liveRecordings.ts | 14++++++++++++++
Mcommon/controller/recordLive.test.ts | 148++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
Mcommon/controller/recordLive.ts | 166++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Mcommon/lib/liveCapture.ts | 82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcommon/lib/liveRecordings-server.ts | 3+++
Meditor/app/api/ops/record-live/route.ts | 1+
Mscripts/archilyzer-ops.mjs | 24++++++++++++++++++++++--
8 files changed, 425 insertions(+), 18 deletions(-)

diff --git a/COMMANDS.md b/COMMANDS.md @@ -147,7 +147,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run) | `remote-listing` | remote-listing lists an Odysee or BitChute channel upstream and diffs it against what it holds: {"slug"}. One flat-playlist read on the platform's queue (refused while it is held or cooling down; a 429 backs it off), nothing written. `get remote-listing <slug>` waits for the job and prints {listed, held, notHeld: \[{id, url}\], heldNotListed: \[id\], ...} on stdout. | | | `attach-media` | attach-media copies each held video's file out of a LOCAL archive into the saved-video store, as its source container (nothing fetched): {"slug", "source"} — an absolute path to a directory, a .zip (read in place) or a .7z. The id is the folder's trailing "(&lt;id&gt;)", else the file's yt-dlp suffix; "items": \[{"id", "path"}\] names exact files (path inside the source), "match" narrows the folders by regex. "createRecords": true writes a record for a video the channel does not hold; "replace": true re-attaches over a saved container. "fillDates": true gives a held record attach-media made (saved-video.json origin "local-archive") that has no upload\_date the date from its folder's description.txt, through the metadata history ("dated" in the log and summary); a record with a date, or one attach-media did not make, is never touched. "dryRun": true logs each folder's class (attach, not-held, already-attached, lost, no-media, unmatched, ambiguous, and dated) and the held videos with no media in it, and writes nothing. The log ends with a summary: line; a re-run resumes. | `pnpm ops attach-media --json '{"slug":"demo-yt","source":"/abs/YouTube.zip","match":"aaaaaaaaaaa\|bbbbbbbbbbb","fillDates":true,"dryRun":true}' --wait` | | `import-media` | import-media makes ONE file from outside the archive a normal transcribed item: {"slug", "path"} (absolute) and which record — "url" (the source page: one metadata-only pass makes or refreshes the record, under the id the archive keys it by — Rumble's URL id), "id" (a record already here) or "meta": {"title", "date"?, "duration"?, "description"?} (by hand). ffprobe must read it; an MPEG-TS, a .part or an FLV is remuxed -c copy to mp4 (+faststart), never re-encoded. It lands in the saved-video store only when longer than a container already there ("replace": true lands it anyway), then audio.&lt;fmt&gt;, the archive line and media-import.json. "move": true removes the original once the copy verifies; "audio": false lands the container only; "transcribe": true queues a transcribe-one job (held by any pause; without it the transcription lane takes it by its rules); "doNotClean": true marks it, with "note". "dryRun": true says what it would do and writes nothing. A directory, a .zip or a .7z goes to attach-media ("id", "replace", "dryRun" only). | `pnpm ops import-media --json '{"slug":"demo-rumble","path":"/abs/stream.mp4.part","url":"https://rumble.com/v1abcde-title.html","move":true}' --wait`<br>`pnpm ops import-media --json '{"slug":"demo-archive","path":"/abs/talk.mkv","meta":{"title":"A talk","date":"2019-05-01"},"dryRun":true}' --wait` | -| `record-live` | record-live records a live stream until it ends, then lands it as import-media lands a file: {"slug", "url"} (or "id" of a record here), "fromStart"? (true: yt-dlp --live-from-start — Rumble's DVR playlist holds a stream's first 4 hours), "maxHeight"? (720; null = the tallest), "separate"? (true: the video at maxHeight plus the best audio, merged — the default on YouTube, whose live streams from the start offer no single stream with both; false: one muxed stream — Rumble, Kick), "transcribe"?, "doNotClean"?, "note"?, "dryRun"?. On Rumble a refused yt-dlp falls back to the page's own playlist (a browser under xvfb, then ffmpeg). On Kick ("kick.com/&lt;channel&gt;" or its VOD) the ongoing VOD is polled from its first segment beside the channel's live stream. One job per stream; job cancel stops it with SIGINT and lands what it has (video and audio left unmerged are merged, -c copy); the longest part wins. Refused for a stream that is not live. "preclip": true (or {"everyMinutes", "maxChunkMinutes", "overlapSeconds", "scan", "mine", "project"}, over settings.livePreclip) starts live-preclip once the first part begins, and implies "transcribe". A from-start attempt that records nothing (yt-dlp: "The downloaded file is empty"), or only one of its two streams, is tried again at +60 and +180 s, then from the live edge at 0, +60 and +180 s (each wait jittered). The failure's class decides: ended, private/removed, members-only/login and a full or unwritable disk are not retried; a 429 or the bot check gets ONE more try after 15 min, then stops; empty, network and unknown failures keep the schedule; a Cancel ends it. The row records the class (failureClass). A live-edge fallback says what it lost (the first N min of the stream) and needs a person. The landing never removes a part it is not known to contain (an earlier run's, one from another point of the stream, one it cannot land): those are kept in staging and listed (keptParts) until acknowledged. The reply is {jobId, kind, "check"}: the `get live-recordings` command that answers for it. --wait-started returns once a FROM-START part's bytes grow (the recording's row on stdout, exit 0; a run asked fromStart: false, any part's), exit 3 when it records only from the live edge (the start is lost), exit 1 with the reason it failed; 15 minutes by default, --wait-timeout overrides. | `pnpm ops record-live --json '{"slug":"demo-rumble","url":"https://rumble.com/v1abcde-title.html"}'`<br>`pnpm ops record-live --json '{"slug":"demo-kick","url":"https://kick.com/somechannel"}'`<br>`pnpm ops record-live --json '{"slug":"demo-yt","url":"https://www.youtube.com/watch?v=<id>","preclip":{"everyMinutes":10}}'`<br>`pnpm ops record-live --json '{"slug":"demo-yt","url":"https://www.youtube.com/watch?v=<id>","doNotClean":true}' --wait-started` | +| `record-live` | record-live records a live stream until it ends, then lands it as import-media lands a file: {"slug", "url"} (or "id" of a record here), "fromStart"? (true: yt-dlp --live-from-start — Rumble's DVR playlist holds a stream's first 4 hours), "maxHeight"? (720; null = the tallest), "separate"? (true: the video at maxHeight plus the best audio, merged — the default on YouTube, whose live streams from the start offer no single stream with both; false: one muxed stream — Rumble, Kick), "transcribe"?, "doNotClean"?, "note"?, "dryRun"?. On Rumble a refused yt-dlp falls back to the page's own playlist (a browser under xvfb, then ffmpeg). On Kick ("kick.com/&lt;channel&gt;" or its VOD) the ongoing VOD is polled from its first segment beside the channel's live stream. One job per stream; job cancel stops it with SIGINT and lands what it has (video and audio left unmerged are merged, -c copy); the longest part wins. Refused for a stream that is not live. "preclip": true (or {"everyMinutes", "maxChunkMinutes", "overlapSeconds", "scan", "mine", "project"}, over settings.livePreclip) starts live-preclip once the first part begins, and implies "transcribe". A from-start attempt that records nothing (yt-dlp: "The downloaded file is empty"), or only one of its two streams, is tried again at +60 and +180 s, then from the live edge at 0, +60 and +180 s (each wait jittered). The failure's class decides: ended, private/removed, members-only/login and a full or unwritable disk are not retried; a 429 or the bot check gets ONE more try after 15 min, then stops; empty, network and unknown failures keep the schedule; a Cancel ends it. The row records the class (failureClass). A live-edge fallback says what it lost (the first N min of the stream) and needs a person. The landing never removes a part it is not known to contain (an earlier run's, one from another point of the stream, one it cannot land): those are kept in staging and listed (keptParts) until acknowledged. The reply is {jobId, kind, "check"}: the `get live-recordings` command that answers for it. --wait-started returns once a FROM-START part's bytes grow (the recording's row on stdout, exit 0; a run asked fromStart: false, any part's), exit 3 when it records only from the live edge (the start is lost), exit 1 with the reason it failed; 15 minutes by default, --wait-timeout overrides. After a live-edge fallback, from its start is tried again BESIDE the live-edge recording (never touching it): every 15 min (jittered), one try at a time, at most 8; a try that holds the whole stream when landed recovers the start (startRecovery). Each recorder has a stall watchdog: no growth for liveRecording.stallMinutes (10) stops that recorder, its part kept; while the stream still reads live (one metadata read; an exit is read twice, a minute apart) a new part records — at most 3 restarts an hour and 12 a run (restarts). "insurance"?: true \| "whole" \| false — a live-edge recorder beside a from-start recording of a stream already live, until the start has caught up (+5 min), or for the whole stream; absent, on exactly when the stream is marked keep ("doNotClean", the record's Do-not-clean marker, a pending keep) when the recording starts. Its part goes at landing only when the landed file holds the whole stream; otherwise it is kept and listed. After an editor restart, a run the shutdown or a crash interrupted restarts by itself (once per run, 3 an hour per stream, never after a Cancel; liveRecording. autoRestartOnBoot): the new run reads the stream's state first — live, it records; ended, it lands what is in staging; unreadable, it starts nothing and the row needs a person. | `pnpm ops record-live --json '{"slug":"demo-rumble","url":"https://rumble.com/v1abcde-title.html"}'`<br>`pnpm ops record-live --json '{"slug":"demo-kick","url":"https://kick.com/somechannel"}'`<br>`pnpm ops record-live --json '{"slug":"demo-yt","url":"https://www.youtube.com/watch?v=<id>","preclip":{"everyMinutes":10}}'`<br>`pnpm ops record-live --json '{"slug":"demo-yt","url":"https://www.youtube.com/watch?v=<id>","doNotClean":true}' --wait-started` | | `local-media-configure` | local-media-configure gives a video channel a LOCAL MEDIA LIBRARY: {"slug", "sourceId", "directory"} — a stable lowercase id and an absolute directory on the editor server whose recordings stay where they are (never copied, moved or deleted). Written through the channel config; a channel that already has one is refused, and so is queued or running channel work. Playback is not set. Synchronous. | `pnpm ops local-media-configure --json '{"slug":"demo-local","sourceId":"library-1","directory":"/mnt/recordings"}'` | | `local-media-preview` | local-media-preview scans the library and writes nothing: {"slug"} -&gt; {preview: {sourceToken, counts, candidates}}. Each .mp4 directly in the directory (not its subdirectories) with its same-named .info.json and .vtt (or .srt) is "new", "existing" (its record is held) or "issue" (with issues). The sourceToken and a candidate's fingerprint (or preparationFingerprint, when it has no .info.json) are what the other local-media actions take. An unreachable library is an error, never an empty preview. | `pnpm ops local-media-preview --json '{"slug":"demo-local"}'` | | `local-media-prepare` | local-media-prepare reviews details for a recording with no .info.json and writes nothing: {"slug", "sourceToken", "media", "sourceFingerprint" (the candidate's preparationFingerprint), "details": {"mode": "inspect" \| "manual", "title", "recordedDate"? (YYYY-MM-DD), "durationSeconds"? (manual)}} -&gt; {review: {metadata, fingerprint}}. "inspect" measures the duration with ffprobe. Import it with local-media-import, the review's fingerprint and "preparation": {"sourceFingerprint", "details"}. | `pnpm ops local-media-prepare --json '{"slug":"demo-local","sourceToken":"<token>","media":"talk.mp4","sourceFingerprint":"<fp>","details":{"mode":"inspect","title":"A talk"}}'` | @@ -493,7 +493,8 @@ get live-recordings [<slug>[/<id>]] [--all] is THE answer to "is this bytes and lastGrowthAt while recording), stalled (not grown for settings.liveRecording.stallMinutes, 10), streamElapsedSeconds, capturedSeconds (once landed), coverage, attempts, failureClass, - fallback, lost, missingStream, keptParts, error, mustKeep, + fallback, lost, startRecovery, restarts, insurance, restart (what the + boot pass did), missingStream, keptParts, error, mustKeep, needsAttention, reason, check; `files` names a live-recordings.json that did not read (set aside, never overwritten). Default: what is recording, what needs a person, the last 7 days; --all every run kept diff --git a/common/controller/liveRecordings.ts b/common/controller/liveRecordings.ts @@ -155,6 +155,19 @@ function reasonOf(v: Omit<LiveRecordingView, "reason" | "check">, stallMinutes: }; extra.unshift(words[rs.state] ?? `start recovery: ${rs.state}`); } + if (v.insurance) { + const ins = v.insurance; + const w: Record<string, string> = { + waiting: "the insurance recorder waits for the from-start recording to begin", + recording: `the insurance recorder records the live edge beside it${ins.mode === "whole" ? " (the whole stream)" : " until it catches up"}`, + "caught-up": "the insurance recorder stopped: the from-start recording caught up", + ended: "the insurance recorder recorded the live edge to the end", + stalled: "the insurance recorder stalled and was stopped", + failed: `the insurance recorder recorded nothing${ins.reason ? ` (${ins.reason})` : ""}`, + "not-started": `no insurance recorder${ins.reason ? ` (${ins.reason})` : ""}`, + }; + extra.push(w[ins.state] ?? `insurance: ${ins.state}`); + } if (v.restarts && v.restarts.count > 0) extra.push(`its recorder was restarted ${v.restarts.count} time${v.restarts.count === 1 ? "" : "s"} (stalled or died while live)`); if (v.restarts?.refused) extra.push(`NOT restarted again though the stream was live: ${v.restarts.refused}`); const tail = extra.length ? `; ${extra.join("; ")}` : ""; @@ -305,6 +318,7 @@ export async function listLiveRecordings(paths: Paths, opts: ListLiveRecordingsO ...(own?.coverage ? { coverage: own.coverage } : {}), ...(own?.startRecovery ? { startRecovery: own.startRecovery } : {}), ...(own?.restarts ? { restarts: own.restarts } : {}), + ...(own?.insurance ? { insurance: own.insurance } : {}), attempts: own?.attempts ?? row.attempts, parts, slug, diff --git a/common/controller/recordLive.test.ts b/common/controller/recordLive.test.ts @@ -644,7 +644,7 @@ const ytChannel = async () => { const ytLiveMeta = (id: string) => ({ ...YT_META(id), release_timestamp: Math.floor(Date.now() / 1000) - 7200 }); const ytUrl = (id: string) => `https://www.youtube.com/watch?v=${id}`; -type Attempt = (args: string[], n: number, signal: AbortSignal) => Promise<{ exitCode: number | null; stderrTail: string; signalled: boolean }>; +type Attempt = (args: string[], n: number, signal: AbortSignal, onLine?: (l: string) => void) => Promise<{ exitCode: number | null; stderrTail: string; signalled: boolean }>; const writesAfter = (failures: number, stderr = EMPTY): Attempt => async (args, n) => { if (n <= failures) return { exitCode: 1, stderrTail: stderr, signalled: false }; const out = args[args.indexOf("-o") + 1]!.replace(/\.%\(ext\)s$/, ".mp4"); @@ -676,7 +676,8 @@ async function incidentRun( let recoveryWaits = 0; const run = recordLiveRun({ paths, - request: { slug: YT_SLUG, url: ytUrl(id), fromStart: true, transcribe: true, doNotClean: true, note: "must not lose", ...(opts.request ?? {}) }, + // The insurance recorder (slice 4) is off unless a case asks for it. + request: { slug: YT_SLUG, url: ytUrl(id), fromStart: true, transcribe: true, doNotClean: true, note: "must not lose", insurance: false, ...(opts.request ?? {}) }, plan: { url: ytUrl(id), platform: "youtube", id }, channelConfig: YT_CONFIG, cookiePolicy: NO_COOKIES, @@ -688,9 +689,9 @@ async function incidentRun( fetchText: async () => { throw new Error("no playlist read is expected"); }, - spawn: async ({ args, signal }: { args: string[]; signal: AbortSignal }) => { + spawn: async ({ args, signal, onLine }: { args: string[]; signal: AbortSignal; onLine?: (l: string) => void }) => { calls.push(args); - return attempt(args, calls.length, signal); + return attempt(args, calls.length, signal, onLine); }, wait: async (ms) => { waits.push(ms); @@ -1544,3 +1545,142 @@ test("slice 3 resume: ended with nothing left says so and still needs a person; assert.match(rows2[0]!.restart?.reason ?? "", /timed out/); assert.equal(rows2[0]!.needsAttention, true); }); + +// --- SLICE 4: the insurance recorder beside a from-start recording catching up ------ +// +// On by default for a stream marked keep before or when the recording starts; +// the request's `insurance` overrides. It records the live edge, its own part, +// and stops once the from-start recorder has caught up (yt-dlp's `(frag N/M)` +// on every stream) plus a margin — or runs the whole stream when asked. + +const isInsurance = (args: string[]) => /\.ytdlp-insure$/.test(outOf(args)); +const FAST_INSURE = { insurancePollMs: 5, insuranceMarginMs: 10, insuranceGraceMs: 10 }; +function insuranceFake(o: { mainSeconds?: number; edgeSeconds?: number; caughtUp?: boolean } = {}) { + let started!: () => void; + const insStarted = new Promise<void>((r) => (started = r)); + let stoppedBy: "signal" | null = null; + let mainReturned!: () => void; + const mainDone = new Promise<void>((r) => (mainReturned = r)); + const state = { stoppedBy: () => stoppedBy }; + const attempt: Attempt = async (args, _n, signal, onLine) => { + if (isInsurance(args)) { + assert.equal(fromStartArg(args), false, "the insurance records the live edge"); + await writeFile(`${outOf(args)}.mp4`, `format=mov,mp4;seconds=${o.edgeSeconds ?? 600};`); + started(); + await Promise.race([ + new Promise<void>((r) => signal.addEventListener("abort", () => r(), { once: true })), + mainDone.then(() => new Promise((r) => setTimeout(r, 200))), + ]); + if (signal.aborted) { + stoppedBy = "signal"; + return { exitCode: null, stderrTail: "", signalled: true }; + } + return { exitCode: 1, stderrTail: "ERROR: [youtube] x: Private video\n", signalled: false }; + } + await writeFile(`${outOf(args)}.mp4`, `format=mov,mp4;seconds=${o.mainSeconds ?? 7200};`); + onLine?.("1: [download] 10.0% of ~ 1.20GiB at 2.00MiB/s ETA 10:00 (frag 100/3000)"); + onLine?.("2: [download] 10.0% of ~ 90.0MiB at 1.00MiB/s ETA 10:00 (frag 300/9000)"); + await insStarted; + if (o.caughtUp !== false) { + onLine?.("1: [download] 99.9% of ~ 1.20GiB at 2.00MiB/s ETA 00:01 (frag 2990/3000)"); + await new Promise((r) => setTimeout(r, 60)); + assert.equal(stoppedBy, null, "not stopped while the audio stream is still behind"); + onLine?.("2: [download] 99.9% of ~ 90.0MiB at 1.00MiB/s ETA 00:01 (frag 8990/9000)"); + await new Promise((r) => setTimeout(r, 80)); + } + mainReturned(); + if (o.mainSeconds !== undefined && o.mainSeconds < 7200) { + return { exitCode: 1, stderrTail: "ERROR: [youtube] x: Private video\n", signalled: false }; + } + return { exitCode: 0, stderrTail: "", signalled: false }; + }; + return { attempt, state }; +} + +test("slice 4: a stream marked keep gets the insurance by default; it stops once every stream has caught up, and covered by the whole it goes at landing", async () => { + const id = "exmplinsur1"; + const f = insuranceFake(); + const { run, calls, waits } = await incidentRun(id, f.attempt, { request: { insurance: undefined }, deps: FAST_INSURE }); + const s = await run; + assert.equal(s.status, "landed"); + assert.equal(calls.length, 2, "the from-start recorder and the insurance"); + assert.equal(calls.filter(isInsurance).length, 1); + assert.equal(f.state.stoppedBy(), "signal", "stopped after the catch-up"); + assert.ok(waits.includes(60_000), "a pause after the from-start part's first bytes"); + const row = (await rowOf(id))[0]!; + assert.deepEqual(row.insurance, { mode: "catch-up", by: "default", state: "caught-up" }); + assert.equal(s.landed?.seconds, 7200); + assert.equal(row.coverage?.covers, true); + assert.ok(row.removedParts?.some((r) => /ytdlp-insure$/.test(r.stem)), "removed only because the landed file holds the whole stream"); + assert.equal(row.needsAttention, false); +}); + +test("slice 4: the default is by keep mark (asked, or on the record before); the request overrides either way", async () => { + // Not marked, asked: on. + const asked = insuranceFake({ caughtUp: false }); + const a = await incidentRun("exmplinsur3", asked.attempt, { request: { insurance: true, doNotClean: false, note: undefined }, deps: FAST_INSURE }); + await a.run; + assert.equal(a.calls.filter(isInsurance).length, 1); + assert.equal((await rowOf("exmplinsur3"))[0]!.insurance?.by, "asked"); + // Marked on the record before the recording: on by default. + const { setDoNotClean } = await import("../lib/doNotClean-server"); + const dir = path.join(CORPUS, "channels", YT_SLUG, "data", "exmplinsur4"); + await mkdir(dir, { recursive: true }); + await setDoNotClean(dir, true, "keep this one"); + const pre = insuranceFake({ caughtUp: false }); + const b = await incidentRun("exmplinsur4", pre.attempt, { request: { insurance: undefined, doNotClean: false, note: undefined }, deps: FAST_INSURE }); + await b.run; + assert.equal(b.calls.filter(isInsurance).length, 1); + assert.equal((await rowOf("exmplinsur4"))[0]!.insurance?.by, "default"); + // Marked, asked off: none. + const off = await incidentRun("exmplinsur5", writesAfter(0), { request: { insurance: false }, deps: FAST_INSURE }); + await off.run; + assert.equal(off.calls.length, 1); + assert.equal((await rowOf("exmplinsur5"))[0]!.insurance, undefined); +}); + +test("slice 4: not marked keep, not asked: no insurance recorder at all", async () => { + const id = "exmplinsur6"; + const { run, calls } = await incidentRun(id, writesAfter(0), { request: { insurance: undefined, doNotClean: false, note: undefined }, deps: FAST_INSURE }); + await run; + assert.equal(calls.length, 1); + assert.equal((await rowOf(id))[0]!.insurance, undefined); +}); + +test("slice 4: \"whole\" is not stopped by the catch-up, only after the stream's end", async () => { + const id = "exmplinsur7"; + const f = insuranceFake(); + const { run } = await incidentRun(id, f.attempt, { request: { insurance: "whole" }, deps: FAST_INSURE }); + await run; + const row = (await rowOf(id))[0]!; + assert.equal(row.insurance?.mode, "whole"); + assert.equal(row.insurance?.state, "ended", "stopped by the grace after the stream ended, not by the catch-up"); +}); + +test("slice 4: the stream removed mid-catch-up — the insurance part holds the end the from-start part never reached: kept, listed, needing a person", async () => { + const id = "exmplinsur8"; + const f = insuranceFake({ mainSeconds: 3000, edgeSeconds: 1800, caughtUp: false }); + const { run } = await incidentRun(id, f.attempt, { + request: { insurance: undefined }, + deps: FAST_INSURE, + refresh: { failAfterFirst: `ERROR: [youtube] ${id}: Private video. Sign in if you've been granted access to this video` }, + }); + const s = await run; + assert.equal(s.status, "landed"); + assert.equal(s.landed?.seconds, 3000, "the longest lands"); + const row = (await rowOf(id))[0]!; + assert.equal(row.coverage?.covers, false); + const kept = row.keptParts?.find((k) => /ytdlp-insure$/.test(k.stem)); + assert.ok(kept, "the insurance part is kept"); + assert.equal(kept!.seconds, 1800); + assert.equal(row.needsAttention, true); + assert.ok((await readdir(store())).some((n) => n.includes(".ytdlp-insure.")), "its file is still on disk"); +}); + +test("slice 4: the insurance knob is parsed and asked again by Record again", async () => { + const { recordAgainRequest } = await import("./recordLive"); + const ok = parseRecordLiveRequest({ slug: "s", url: "https://www.youtube.com/watch?v=exmplknob01", insurance: "whole" }); + assert.equal((ok as { insurance?: unknown }).insurance, "whole"); + assert.match((parseRecordLiveRequest({ slug: "s", url: "https://www.youtube.com/watch?v=exmplknob01", insurance: "yes" }) as { error: string }).error, /insurance/); + assert.deepEqual(recordAgainRequest({ slug: "s", insurance: false } as never), { insurance: false }); +}); diff --git a/common/controller/recordLive.ts b/common/controller/recordLive.ts @@ -67,6 +67,11 @@ import { LIVE_RESTART_CONFIRM_MS, LIVE_RESTART_WAIT_MS, LIVE_WATCH_MS, + LIVE_INSURANCE_DELAY_MS, + LIVE_INSURANCE_END_GRACE_MS, + LIVE_INSURANCE_MARGIN_MS, + catchUpTracker, + insuranceDecision, restartRefusal, classifyAttempt, extractionRefused, @@ -86,6 +91,7 @@ import { ytdlpLiveArgs, type KeptPart, type LiveBootRestartState, + type LiveInsurance, type RemovedPart, type LiveFailureClass, type LivePart, @@ -103,14 +109,14 @@ import { liveRecordingSidecar } from "../lib/mediaImport-server"; import { loadLiveRecordingRows, rowOfRecord, upsertLiveRecordingRow } from "../lib/liveRecordings-server"; import { liveRecordingCheckCommand, liveStallMinutes } from "./liveRecordings"; import { markLiveBootRestart } from "./liveRecordingBoot"; -import { setDoNotClean } from "../lib/doNotClean-server"; +import { isDoNotClean, setDoNotClean } from "../lib/doNotClean-server"; import type { Paths } from "../lib/paths"; import { detectPlatform } from "../lib/platform"; import { savedVideoDir, savedVideoRoot } from "../lib/savedVideo"; import { assertSavedVideosStoreWritable } from "../lib/savedVideoStore"; import { getFreeBytes } from "../lib/diskSpace"; import { formatBytes } from "../lib/format"; -import { applyPendingKeep } from "../lib/pendingKeep-server"; +import { applyPendingKeep, loadPendingKeep } from "../lib/pendingKeep-server"; import { mp4CanHold, type MediaProbe } from "../lib/mediaImport"; import { getRegistry } from "../jobs/registry"; import { runManagedFunction, type StreamActionResult } from "../jobs/streamCommand"; @@ -148,6 +154,7 @@ export const RECORD_LIVE_BODY_KEYS = [ "note", "dryRun", "preclip", + "insurance", ] as const; // The user agent path B's ffmpeg and the playlist reads present: the Firefox on @@ -191,6 +198,11 @@ export type RecordLiveRequest = { // while it records — its own job (controller/livePreclip.ts), started once // the first part begins. Implies `transcribe` unless that is false. preclip?: PreclipOptions; + // THE INSURANCE RECORDER (slice 4, lib/liveCapture.ts LiveInsurance): true + // = the live edge beside the from-start recording until it catches up; + // "whole" = the whole stream; false = none. Absent: on exactly when the + // stream is marked keep before or when the recording starts. + insurance?: boolean | "whole"; // INTERNAL (never a body key): the boot pass's restart of the interrupted // run that started at this time (controller/liveRecordingBoot.ts). The // run reads the stream's state first and records only if it is live. @@ -228,6 +240,10 @@ export function parseRecordLiveRequest( } const note = str("note"); if (note) out.note = note; + if (body.insurance !== undefined) { + if (body.insurance === true || body.insurance === false || body.insurance === "whole") out.insurance = body.insurance; + else return { error: '"insurance" is true (until the start catches up), "whole" (the whole stream) or false' }; + } const preclip = parsePreclipKnob(body.preclip, preclipDefaults); if (preclip && "error" in preclip) return preclip; if (preclip) { @@ -322,6 +338,8 @@ export type RecorderSpawn = (opts: { onLog: (s: string) => void; signal: AbortSignal; label: string; + // Every line the recorder prints, progress included (before the thinning). + onLine?: (line: string) => void; }) => Promise<RecorderOutcome>; // A progress line yt-dlp or ffmpeg repeats every second for hours. yt-dlp @@ -339,7 +357,7 @@ export function isProgressLine(line: string): boolean { // asks its ffmpeg to quit with `q` and the file is finalized), its output in // the job's log with the per-second progress thinned to one line every five // minutes. A Cancel sends SIGINT, then SIGKILL after RECORDER_GRACE_MS. -export const spawnRecorder: RecorderSpawn = ({ bin, args, cwd, onLog, signal, label }) => +export const spawnRecorder: RecorderSpawn = ({ bin, args, cwd, onLog, signal, label, onLine }) => new Promise((resolve) => { onLog(`[${label}] $ ${bin} ${args.map((a) => (/\s/.test(a) ? JSON.stringify(a) : a)).join(" ")}\n`); const child = spawn(bin, args, { cwd, stdio: ["ignore", "pipe", "pipe"] }); @@ -353,6 +371,7 @@ export const spawnRecorder: RecorderSpawn = ({ bin, args, cwd, onLog, signal, la for (const line of text.split(/[\r\n]+/)) { const l = line.trim(); if (!l) continue; + onLine?.(l); if (isProgressLine(l)) { const now = Date.now(); if (now - lastProgress < PROGRESS_EVERY_MS) continue; @@ -595,6 +614,12 @@ export type RecordLiveDeps = { // growth is a stall (default settings.liveRecording.stallMinutes). watchMs?: number; stallMs?: number; + // The insurance recorder's look for the from-start part's first bytes + // (default 5 s), its margin after catch-up and its grace after the end + // (defaults LIVE_INSURANCE_MARGIN_MS, LIVE_INSURANCE_END_GRACE_MS). + insurancePollMs?: number; + insuranceMarginMs?: number; + insuranceGraceMs?: number; }; export type RecordLiveJobOpts = { @@ -780,7 +805,7 @@ function stopOf(deps: RecordLiveDeps | undefined): { status: "interrupted" | "ca // transcribe, keep (doNotClean) and its note, and the live pre-clip. export function recordAgainRequest(req: RecordLiveRequest): Record<string, unknown> { const out: Record<string, unknown> = {}; - for (const k of ["fromStart", "maxHeight", "separate", "transcribe", "doNotClean", "note", "preclip"] as const) { + for (const k of ["fromStart", "maxHeight", "separate", "transcribe", "doNotClean", "note", "preclip", "insurance"] as const) { if (req[k] !== undefined) out[k] = req[k]; } return out; @@ -1191,13 +1216,27 @@ async function recordLiveRunInner( // recovery: a slice-2 try. noWait: never `--wait-for-video` (a restart or // a try is of a stream already live). watch: the stall watchdog (off for // Kick's channel recorder, which its VOD poll ends). - opts: { recovery?: boolean; restart?: number; noWait?: boolean; watch?: boolean } = {}, + // insurance: slice 4's part. stop: a stop of this recorder alone (the + // insurance's, once caught up). onStart: its stem, once begun. onLine: + // every line it prints. + opts: { + recovery?: boolean; + restart?: number; + noWait?: boolean; + watch?: boolean; + insurance?: boolean; + stop?: AbortSignal; + onStart?: (stem: string) => void; + onLine?: (line: string) => void; + } = {}, ): Promise<RecorderOutcome & { part: LivePart; stem: string; stalled: boolean }> => { const file = separate ? stemPath(tag) : partPath(tag); const part = begin("ytdlp", url, file, mode !== "now"); if (opts.recovery) part.recovery = true; if (opts.restart) part.restart = opts.restart; + if (opts.insurance) part.insurance = true; const stem = part.stem!; + opts.onStart?.(stem); await save(); const waitForVideo = !opts.noWait && liveStatus === "is_upcoming" && tag !== "channel"; const args = ytdlpLiveArgs({ @@ -1221,8 +1260,11 @@ async function recordLiveRunInner( // recorder waiting for it with nothing written is not stalled. const own = new AbortController(); const onJobAbort = () => own.abort(); - if (signal.aborted) own.abort(); - else signal.addEventListener("abort", onJobAbort, { once: true }); + if (signal.aborted || opts.stop?.aborted) own.abort(); + else { + signal.addEventListener("abort", onJobAbort, { once: true }); + opts.stop?.addEventListener("abort", onJobAbort, { once: true }); + } let stalled = false; let timer: NodeJS.Timeout | null = null; if (opts.watch !== false) { @@ -1256,10 +1298,19 @@ async function recordLiveRunInner( } let o: RecorderOutcome; try { - o = await runRecorder({ bin: paths.ytdlpBin, args, cwd: channelDir, onLog, signal: own.signal, label: tag }); + o = await runRecorder({ + bin: paths.ytdlpBin, + args, + cwd: channelDir, + onLog, + signal: own.signal, + label: tag, + ...(opts.onLine ? { onLine: opts.onLine } : {}), + }); } finally { if (timer) clearInterval(timer); signal.removeEventListener("abort", onJobAbort); + opts.stop?.removeEventListener("abort", onJobAbort); } if (stalled) part.stalled = true; finish(part, `${extraNote}yt-dlp exit ${o.exitCode ?? "null"}${o.signalled ? (stalled ? " (stopped: stalled)" : " (stopped)") : ""}`); @@ -1350,6 +1401,78 @@ async function recordLiveRunInner( // stream end often exits 1), a Cancel and an argv no try can fix end the // attempts. const schedule = liveAttemptSchedule(fromStart); + // SLICE 4 — THE INSURANCE RECORDER (lib/liveCapture.ts LiveInsurance): + // the live edge beside the from-start recording while it catches up. + // On by default when the stream is marked keep before or when the + // recording starts; the request's `insurance` overrides. Not for an + // upcoming stream (its from-start recording is never behind). + const keepMarked = + req.doNotClean === true || + (await isDoNotClean(videoDir).catch(() => false)) || + (await loadPendingKeep(paths, req.slug).catch(() => [])).some((e) => e.id === id); + const decided = fromStart && liveStatus !== "is_upcoming" ? insuranceDecision({ asked: req.insurance, keepMarked }) : null; + if (!decided && req.insurance) say("No insurance recorder: it runs only beside a from-start recording of a stream already live."); + const insureStop = new AbortController(); + const mainDoneCtl = new AbortController(); + let insuranceStopFor: "caught-up" | "ended" | null = null; + let mainStem: string | null = null; + let mainFromStart = false; + const tracker = catchUpTracker(); + let caughtUpTimer: NodeJS.Timeout | null = null; + let graceTimer: NodeJS.Timeout | null = null; + const margin = deps.insuranceMarginMs ?? LIVE_INSURANCE_MARGIN_MS; + // The main recorder's parts: which one records now, and its progress. + const onMainStart = (mode: "from-start" | "index0" | "now") => (stem: string) => { + mainStem = stem; + mainFromStart = mode !== "now"; + tracker.reset(); + }; + const onMainLine = (l: string) => { + if (record.insurance?.mode !== "catch-up" || caughtUpTimer || insureStop.signal.aborted || !mainFromStart) return; + if (!tracker.feed(l)) return; + say(`The from-start recording has caught up with the live edge; the insurance recorder stops in ${spanWords(margin / 1000)}.`); + caughtUpTimer = setTimeout(() => { + insuranceStopFor = "caught-up"; + insureStop.abort(); + }, margin); + }; + const insureLoop = async (): Promise<void> => { + const ins: LiveInsurance = { mode: decided!.mode, by: decided!.by, state: "waiting" }; + record.insurance = ins; + await save(); + const waitStop = AbortSignal.any([signal, insureStop.signal, mainDoneCtl.signal]); + const notStarted = async (reason: string) => { + ins.state = "not-started"; + ins.reason = reason; + await save(); + }; + // The from-start part's first bytes (its extraction is done). + while (!waitStop.aborted && !record.fallback) { + if (mainStem && mainFromStart && (await bytesOf(mainStem)) > 0) break; + await sleep(deps.insurancePollMs ?? 5_000, waitStop); + } + if (record.fallback) return notStarted("the run fell back to the live edge"); + if (signal.aborted) return notStarted("stopped"); + if (insureStop.signal.aborted) return notStarted("the from-start recording caught up before it began"); + if (mainDoneCtl.signal.aborted) return notStarted("the from-start recording ended before it began"); + await waitFor(stretch(LIVE_INSURANCE_DELAY_MS), waitStop); + if (signal.aborted || mainDoneCtl.signal.aborted) return notStarted("the from-start recording ended before it began"); + if (insureStop.signal.aborted) return notStarted("the from-start recording caught up before it began"); + ins.state = "recording"; + say( + `The insurance recorder records the live edge beside the from-start recording` + + `${ins.mode === "whole" ? " for the whole stream" : " until it catches up"} (${ins.by === "default" ? "the stream is marked keep" : "asked"}).`, + ); + const o = await ytdlpPart(plan.url, "ytdlp-insure", "now", "insurance; ", { insurance: true, noWait: true, stop: insureStop.signal }); + const bytes = await bytesOf(o.stem); + if (o.stalled) ins.state = "stalled"; + else if (bytes === 0 && !o.signalled) { + ins.state = "failed"; + ins.reason = lastErrorLine(o.stderrTail) ?? `yt-dlp exit ${o.exitCode ?? "null"}`; + } else ins.state = insuranceStopFor === "caught-up" ? "caught-up" : "ended"; + await save(); + }; + const insurance: Promise<void> | null = decided ? insureLoop() : null; let index0 = false; let fromStartFailures = 0; let edgeFailures = 0; @@ -1454,7 +1577,10 @@ async function recordLiveRunInner( // SLICE 2: the first live-edge attempt after a fallback starts the // from-start tries beside it (their first is 15 min away). if (mode === "now" && fromStart && record.fallback === "live-edge" && recovery === null) recovery = recoverStart(index0); - const o = await ytdlpPart(plan.url, tag, mode, mode === "index0" ? "--no-live-from-start + -live_start_index 0; " : ""); + const o = await ytdlpPart(plan.url, tag, mode, mode === "index0" ? "--no-live-from-start + -live_start_index 0; " : "", { + onStart: onMainStart(mode), + onLine: onMainLine, + }); // This attempt's own part (a try beside it may have begun one since). const last = { part: o.part, stem: o.stem }; const bytes = await bytesOf(last.stem); @@ -1609,7 +1735,12 @@ async function recordLiveRunInner( restarts.at.push(now().toISOString()); const k = restarts.count; say(`Restart ${k} (${why}, the stream ${state === "live" ? "is live" : "state unknown"}): a new part ${cur.mode === "now" ? "from the live edge" : "from its start"}; the earlier part is kept for the landing.`); - const o = await ytdlpPart(plan.url, `ytdlp-r${k}`, cur.mode, `restart ${k} (${why}); `, { restart: k, noWait: true }); + const o = await ytdlpPart(plan.url, `ytdlp-r${k}`, cur.mode, `restart ${k} (${why}); `, { + restart: k, + noWait: true, + onStart: onMainStart(cur.mode), + onLine: onMainLine, + }); const bytes = await bytesOf(o.stem); if (bytes === 0 && !o.signalled) { const c = classifyAttempt({ ...o, bytes }); @@ -1623,6 +1754,21 @@ async function recordLiveRunInner( } cur = { o, bytes, mode: cur.mode }; } + // The main recording is over. The insurance: with the stream read as + // ended, it is stopped after a grace (its live edge is at the end too); + // otherwise it runs on by itself — it may be the only recorder left. + mainDoneCtl.abort(); + if (insurance) { + if (endRead && !insureStop.signal.aborted) { + graceTimer = setTimeout(() => { + insuranceStopFor ??= "ended"; + insureStop.abort(); + }, deps.insuranceGraceMs ?? LIVE_INSURANCE_END_GRACE_MS); + } + await insurance; + } + if (caughtUpTimer) clearTimeout(caughtUpTimer); + if (graceTimer) clearTimeout(graceTimer); // The live-edge recording is over: a recovery try still WAITING stops // (the stream ended, or the live edge failed); one in flight is awaited, // never stopped — it may hold the only copy. diff --git a/common/lib/liveCapture.ts b/common/lib/liveCapture.ts @@ -457,6 +457,9 @@ export type LivePart = { // A restart of the recording after a stall or a recorder that died while // the stream was live (1-based). restart?: number; + // The insurance recorder's part: the live edge, beside a from-start + // recording that is catching up (LiveInsurance). + insurance?: boolean; }; export type MissingStream = "video" | "audio" | "unknown"; @@ -555,8 +558,87 @@ export type LiveRecordingRecord = { // This run was started by the boot pass after an editor restart, for the // interrupted run that started at this time (its row's startedAt). resumeOf?: string; + // The insurance recorder beside the from-start recording (LiveInsurance). + insurance?: LiveInsurance; }; +// --- the insurance recorder: the live edge while the start catches up ---------- +// +// A from-start recording of a stream that has run for a while is BEHIND the +// live edge for a long time (20 Nov 2026: fragment 4453 of 30299 after ten +// minutes). A stream removed in that window loses everything between the +// catch-up point and its end. The insurance recorder records the live edge +// beside it — its own part, its own recorder — and stops LIVE_INSURANCE_MARGIN_MS +// after the from-start recorder has caught up (every stream it reports within +// LIVE_CAUGHT_UP_FRAGS fragments of its total), or runs the whole stream +// ("whole"). It starts LIVE_INSURANCE_DELAY_MS after the from-start part's +// first bytes, so the two extractions are never back to back. Its part lands +// only under the landing's rules: removed when the landed file holds the +// whole stream, else kept and listed. +// +// ON by default when the stream is marked keep before or when the recording +// starts (doNotClean asked, the record's Do-not-clean marker, a pending +// keep); OFF otherwise; the request's `insurance` overrides either way. +export const LIVE_CAUGHT_UP_FRAGS = 30; +export const LIVE_INSURANCE_DELAY_MS = 60_000; +export const LIVE_INSURANCE_MARGIN_MS = 5 * 60_000; +// After the main recording ends with the stream read as ended. +export const LIVE_INSURANCE_END_GRACE_MS = 2 * 60_000; + +// waiting for the from-start part's first bytes (and the pause) +// recording it records +// caught-up stopped: the from-start recording caught up (+ the margin) +// ended its recorder ended (the stream ended, or the grace after it) +// stalled the stall watchdog stopped it (not restarted) +// failed it recorded nothing +// not-started not needed or not possible: the from-start part never +// recorded, the run fell back to the live edge, or it caught +// up before the insurance began +export type LiveInsuranceState = "waiting" | "recording" | "caught-up" | "ended" | "stalled" | "failed" | "not-started"; + +export type LiveInsurance = { + mode: "catch-up" | "whole"; + // On by the keep-mark default, or asked by the request. + by: "default" | "asked"; + state: LiveInsuranceState; + reason?: string; +}; + +// Whether the insurance runs, and how: the request's `insurance` (true, false, +// "whole") wins; absent, on ("catch-up") exactly when the stream is marked keep. +export function insuranceDecision(o: { asked: boolean | "whole" | undefined; keepMarked: boolean }): Pick<LiveInsurance, "mode" | "by"> | null { + if (o.asked === false) return null; + if (o.asked === "whole") return { mode: "whole", by: "asked" }; + if (o.asked === true) return { mode: "catch-up", by: "asked" }; + return o.keepMarked ? { mode: "catch-up", by: "default" } : null; +} + +// yt-dlp's fragment progress, `[download] … (frag N/M)`, with the separate +// stream's number (`1: …`, `2: …`; "0" for a muxed one). +export function parseFragProgress(line: string): { stream: string; frag: number; total: number } | null { + const m = /^(?:(\d+):\s*)?\[download\].*\(frag (\d+)\/(\d+)\)/.exec(line.trim()); + if (!m) return null; + return { stream: m[1] ?? "0", frag: Number(m[2]), total: Number(m[3]) }; +} + +// Caught up: every stream that has reported is within LIVE_CAUGHT_UP_FRAGS of +// its total. `feed` answers whether it is now. +export function catchUpTracker(): { feed: (line: string) => boolean; reset: () => void; seen: () => boolean } { + const by = new Map<string, { frag: number; total: number }>(); + return { + feed(line) { + const p = parseFragProgress(line); + if (!p) return false; + by.set(p.stream, { frag: p.frag, total: p.total }); + return [...by.values()].every((v) => v.total > 0 && v.frag >= v.total - LIVE_CAUGHT_UP_FRAGS); + }, + reset() { + by.clear(); + }, + seen: () => by.size > 0, + }; +} + // WHAT THE BOOT PASS DID WITH AN INTERRUPTED RUN (controller/liveRecordingBoot.ts), // on that run's row. Written BEFORE the new run is asked for (`starting`), so // a row is restarted at most once, even if the boot itself dies after. diff --git a/common/lib/liveRecordings-server.ts b/common/lib/liveRecordings-server.ts @@ -34,6 +34,7 @@ import type { LiveRecordingStatus, LostSpan, LiveBootRestart, + LiveInsurance, LiveRestarts, MissingStream, StartRecovery, @@ -80,6 +81,7 @@ export type LiveRecordingRow = { // startedAt; and, on an interrupted run, what the boot pass did with it. resumeOf?: string; restart?: LiveBootRestart; + insurance?: LiveInsurance; acknowledgedAt?: string; acknowledgedBy?: string; // The run (its jobId, else its startedAt) that later landed this id. @@ -256,6 +258,7 @@ export function rowOfRecord( ...(rec.startRecovery ? { startRecovery: { ...rec.startRecovery } } : {}), ...(rec.restarts ? { restarts: { ...rec.restarts, at: [...rec.restarts.at] } } : {}), ...(rec.resumeOf ? { resumeOf: rec.resumeOf } : {}), + ...(rec.insurance ? { insurance: { ...rec.insurance } } : {}), }; } diff --git a/editor/app/api/ops/record-live/route.ts b/editor/app/api/ops/record-live/route.ts @@ -7,6 +7,7 @@ export const dynamic = "force-dynamic"; // POST { slug, url? | id?, fromStart? (true), maxHeight? (720; null = tallest), // separate? (YouTube true, else false), transcribe?, doNotClean?, note?, +// insurance? (true | "whole" | false; absent: on when marked keep), // dryRun? } -> { ok: true, jobId, kind: "record-live", check } // // `check` is the command that answers for the recording afterwards (`pnpm ops diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs @@ -547,7 +547,7 @@ const ACTIONS = [ // LIVE STREAM RECORDED from its start (plans/live-capture.md): import-media // ({slug, path, url? | id? | meta?, move?, replace?, audio?, transcribe?, // doNotClean?, note?, dryRun?}) and record-live ({slug, url? | id?, - // fromStart?, maxHeight?, separate?, transcribe?, doNotClean?, note?, dryRun?}), each a + // fromStart?, maxHeight?, separate?, transcribe?, doNotClean?, note?, insurance?, dryRun?}), each a // job; both land through the same code. "import-media", "record-live", @@ -2680,6 +2680,25 @@ export function usage() { " part's), exit 3 when it records only from the live edge (the start is", " lost), exit 1 with the reason it failed; 15 minutes by default,", " --wait-timeout overrides.", + " After a live-edge fallback, from its start is tried again BESIDE the", + " live-edge recording (never touching it): every 15 min (jittered), one", + " try at a time, at most 8; a try that holds the whole stream when landed", + " recovers the start (startRecovery). Each recorder has a stall watchdog:", + " no growth for liveRecording.stallMinutes (10) stops that recorder, its", + " part kept; while the stream still reads live (one metadata read; an exit", + " is read twice, a minute apart) a new part records — at most 3 restarts", + " an hour and 12 a run (restarts). \"insurance\"?: true | \"whole\" | false —", + " a live-edge recorder beside a from-start recording of a stream already", + " live, until the start has caught up (+5 min), or for the whole stream;", + " absent, on exactly when the stream is marked keep (\"doNotClean\", the", + " record's Do-not-clean marker, a pending keep) when the recording starts.", + " Its part goes at landing only when the landed file holds the whole", + " stream; otherwise it is kept and listed. After an editor restart, a run", + " the shutdown or a crash interrupted restarts by itself (once per run, 3", + " an hour per stream, never after a Cancel; liveRecording.", + " autoRestartOnBoot): the new run reads the stream's state first — live,", + " it records; ended, it lands what is in staging; unreadable, it starts", + " nothing and the row needs a person.", "", "get live-recordings [<slug>[/<id>]] [--all] is THE answer to \"is this", " stream being recorded, and is it growing\" — never a job for the video", @@ -2689,7 +2708,8 @@ export function usage() { " bytes and lastGrowthAt while recording), stalled (not grown for", " settings.liveRecording.stallMinutes, 10), streamElapsedSeconds,", " capturedSeconds (once landed), coverage, attempts, failureClass,", - " fallback, lost, missingStream, keptParts, error, mustKeep,", + " fallback, lost, startRecovery, restarts, insurance, restart (what the", + " boot pass did), missingStream, keptParts, error, mustKeep,", " needsAttention, reason, check; `files` names a live-recordings.json that", " did not read (set aside, never overwritten). Default: what is recording,", " what needs a person, the last 7 days; --all every run kept",