commit c832eb79eda5ffd8171b2745c82add17ba9815ed
parent ba817293f0cec7e0fc5e888c0feaff1e6c378635
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 21 Nov 2026 14:34:13 -0500
docs: record-live's start recovery, restarts, insurance, boot restart and joins
OPERATING.md says what each of the four new safeguards does, its bounds
and what it costs; the editor's changelog has the bullet.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
2 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/OPERATING.md b/OPERATING.md
@@ -1219,10 +1219,61 @@ pnpm ops keep-videos --json '{"slug":"example-rumble","ids":["v1abcde"],"note":
left — stays in the store's staging dir, listed as `keptParts` (files, sizes, why), and the row needs a person
until acknowledged. A later recording does not clear that; nothing removes kept files automatically. On Kick, a
VOD that covers the stream removes the channel's live-edge part; one that does not keeps it.
+- **After a live-edge fallback, the start is tried again beside it.** From the first live-edge attempt, a from-start try
+ runs BESIDE the live-edge recorder (never touching it): every 15 min (jittered), one try at a time, at most 8 (about
+ 2 h; each failed try costs one extraction, as the failed attempt did). The tries stop when the live-edge recording
+ ends (a try still waiting is not made, one in flight is awaited), on a failure no try can help (`ended`, `private`,
+ `members`, `disk`, `argv`, from-the-start unsupported), on a second rate limit, on a Cancel. The row's
+ `startRecovery` says the tries and their state; when the landed file is a from-start try that holds the whole
+ stream the start is `recovered`, the row no longer needs a person, and the live-edge part goes under the coverage
+ rule below. Otherwise the start stays lost.
+- **A stalled or dead recorder is restarted while the stream is live.** Every path-A recorder (and every try beside
+ the live edge) has a watchdog: its part's files, scratch included, are compared every minute; no growth for
+ `liveRecording.stallMinutes` (10) stops THAT recorder (SIGINT), and its part stays. After a stall with bytes, or a
+ recorder that exited with bytes, one metadata read asks whether the stream is still live (an exit is read twice, a
+ minute apart: a stream that has just ended may read live a moment). Live: after 30 s a new part (`ytdlp-r<N>`, its
+ own stem) in the same mode; the earlier part stays for the landing's rules. Ended: the run lands. At most 3 restarts
+ in any hour and 12 in a run, and only with 20 GB free on the store's disk; past that the row says why
+ (`restarts.refused`) and needs a person. A stall with nothing written is an attempt that recorded nothing, on the
+ schedule above. Not for Kick (its VOD poll decides its end) or the browser path.
+- **An insurance recorder while the start catches up.** A from-start recording of a stream already live is behind
+ the live edge for a long time; a second recorder records the live edge beside it (`ytdlp-insure`), starting 60 s
+ after the from-start part's first bytes, and 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 `(frag N/M)` lines; none read, it runs to the
+ end). `"insurance"`: `true` (that), `"whole"` (the whole stream), `false` (none); absent, it is ON exactly when the
+ stream is marked keep before or when the recording starts — `doNotClean` asked, the record's Do-not-clean marker,
+ or a pending keep (`keep-videos`) — and off otherwise. Its part is removed at the landing only when the landed file
+ holds the whole stream; otherwise it is kept and listed (the stream removed mid-catch-up: it holds the end). It
+ costs one extraction and a viewer's live-edge reads, about a tenth of the catch-up's rate, until it stops; `"whole"`
+ doubles the realtime reads for the stream, as Kick's two recorders do. Not for Kick, the browser path or an
+ upcoming stream.
+- **Parts joined when together they hold more.** When the landed file would not hold the stream and two or more parts
+ with a known place do (a from-start part that stopped short and a live-edge part; live-edge parts a restart left one
+ after another), they are joined `-c copy` (`controller/liveJoin.ts`). A live-edge part's place is found by its
+ sound (its first 20 s searched in the part before, around its clock place) and checked again near the join; the
+ next part is cut where the one before ends (the keyframe before the cut: `duplicatedSeconds` heard twice). A part
+ that starts after the one before ends is joined as it is, and the GAP is stated by the clock — the joined file's
+ timeline after it is not the stream's. The joined file lands only when proven: its length is its segments' within
+ max(1 s, 0.2 %) and the sound 5–25 s either side of every join (and its head) matches its parts; its parts are
+ removed only after it has landed. The row's `joins` and `data/<id>/live-joins.json` (each segment: its place in the
+ stream, in its file and in the joined file) say where the joins are. A gap needs a person. Unproven, parts whose
+ codecs or picture size differ (no re-encode is made), or a part with no known place: the longest lands and the rest
+ are kept, as before.
- **An editor shutdown is not a Cancel.** A run stopped by the editor going down (a restart, a rollout) is
`interrupted` (`stoppedBy: "shutdown"`), never `cancelled`, and needs a person — Record again if the stream is still
live. A person's Cancel is `cancelled`; it needs a person only when the stream was must-keep (`doNotClean` or a
`note`), and is quiet otherwise.
+- **An editor restart's interruption restarts by itself** (`liveRecording.autoRestartOnBoot`, default on). 30 s after
+ the editor starts (not on an idle boot or the test server), the newest run of each stream that the shutdown
+ interrupted, or that a crash left saying `recording` (now `interrupted`, `stoppedBy: "crash"`), asks for a
+ record-live run with its own url and options. That run's first step is record-live's one paced metadata read:
+ live, it records again (the earlier parts stay for the landing's rules) and the interrupted row says `restart:
+ restarted` and, from its start, no longer needs a person; ended, it records nothing and lands what is in staging
+ (`landing`), or with nothing left says `ended` (the end is not recorded: needs a person); unreadable, it starts and
+ lands NOTHING (`unknown`, needs a person: Record again). A person's Cancel never restarts. A restart loop cannot
+ run: the row is marked before the job is asked (a run restarts once), at most 3 automatic restarts of a stream in
+ an hour (then `refused`), and a part file written after the boot — a recorder of the last process may still be
+ running — refuses it too.
- **Is it recording, and is it growing? `pnpm ops get live-recordings [<slug>[/<id>]] [--all]`** — never "is there
a job for this video id" (a live-chat capture is one too). Each run from its own record: `status` (`recording`,
`interrupted` when no record-live job runs it, `landed`, `failed`, `cancelled`), the job, `bytes` and
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,18 @@
# Changelog
## [Unreleased]
+- **A live recording keeps itself alive: the start retried beside the live edge, stalls restarted, an insurance
+ recorder, a restart after the editor's, and parts joined.**
+ - After a fallback to the live edge, from its start is tried again beside it every 15 min, at most 8 times; a try
+ that lands the whole stream recovers the start.
+ - A recorder whose files stop growing for `liveRecording.stallMinutes`, or that exits while the stream still reads
+ live, is restarted as a new part (at most 3 an hour, 12 a run); its earlier part stays for the landing.
+ - `"insurance"` on record-live: a live-edge recorder beside a from-start recording until it catches up (or the whole
+ stream). On by default for a stream marked keep.
+ - After an editor restart, a recording the shutdown or a crash interrupted restarts by itself once the stream reads
+ live (`liveRecording.autoRestartOnBoot`); ended, what is in staging lands; unreadable, nothing starts.
+ - Parts that together hold more than the longest are joined `-c copy` when proven (length and sound at each join),
+ the joins on the row and in `live-joins.json`; a gap is stated and needs a person.
- **A clip window past the end of a saved recording is cut from the saved video, clamped at the end.**
- Before, the last clip of a recording asked for a window that ended past the saved container (its cut plus a
3 s pad). The window was "not-covering" and went to the platform's download queue: a network fetch for footage