Archilyzer · Source

archilyzer

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

commit 5b5bdd48485d02a229cc148285f0530bf1925fb4
parent 0a0b141b3c613d4d1824e0ba4d81b7a0c3d9b0cb
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 21 Nov 2026 16:53:28 -0500

docs: the store-aware landing, the restarts' rules, the insurance re-arm and the boot's reads

OPERATING.md and the editor's changelog say what the REVIEW-1 fixes of
live-guard-2 changed. Also: a join refused for want of disk is on the
row (spaceHeld), and the slice-4 tests carry a timeout so a regression
fails instead of hanging.

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

Diffstat:
MOPERATING.md | 40++++++++++++++++++++++++++++++----------
Mcommon/controller/recordLive.test.ts | 12++++++------
Mcommon/controller/recordLive.ts | 1+
Meditor/CHANGELOG.md | 3+++
4 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/OPERATING.md b/OPERATING.md @@ -1219,6 +1219,15 @@ 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. +- **A recording already in the store is never replaced or deleted around by one not proven to hold it.** When the + saved-video store already holds a container for the stream (an earlier run's landing — a shutdown's included), a + new run lands over it only when its file holds the whole stream from its start (the coverage rule), or when it is a + proven join that includes the stored container (as its base, when the run that stored it landed a part from its + start). Otherwise nothing lands: the store keeps what it holds, every part stays in staging as `keptParts`, the run + is `failed` ("not landed: …") and needs a person. And whenever the landing ends up keeping the stored container, + nothing is removed. A part is removed only when THIS landing stored and verified a file that holds it; a restart's + earlier sibling, a stalled part or an index-0 part is never "inside" a longer one by itself — only the coverage rule + removes it — and a live-edge part that ended over a minute after the landed part is kept. - **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 @@ -1233,14 +1242,21 @@ pnpm ops keep-videos --json '{"slug":"example-rumble","ids":["v1abcde"],"note": 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 + in any hour and 12 in a run; past that the row says why (`restarts.refused`) and needs a person. What the recorder + said is classified first, also for a part that died with bytes: ended, private, members-only and the disk are not + restarted; a 429 or the bot check gets ONE restart after 15 min, a second is refused. No from-start pass starts + once a from-start part holds the stream up to now (the coverage rule by the clock), and after a recorder that ended + with bytes while the stream still read live at most ONE extra from-start pass is made. The 20 GB floor is read + before every spawn — each restart, each start-recovery try, the insurance's start, a join — and a spawn under it + does not start; the row says so (`spaceHeld`) 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 + end). One that exits or stalls before the catch-up or the stream's end reads `died` (never "to the end") and is + started again; a from-start restart, behind the live edge again, re-arms one that had stopped after the catch-up; at + most 3 starts a run (`starts`). `"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 @@ -1254,8 +1270,10 @@ pnpm ops keep-videos --json '{"slug":"example-rumble","ids":["v1abcde"],"note": 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 + max(1 s, 0.2 %), the sound 5–25 s either side of every join (and its head and tail) matches its parts, and so does + the PICTURE 10 s either side (a small grey frame); a cut whose copy starts after the point asked (a hole) refuses + the join, and each overlap records where it was cut (`cutAt`, `cutFrom`). No join runs during a shutdown's + landing, and its scratch is removed however it ends. 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. @@ -1268,12 +1286,14 @@ pnpm ops keep-videos --json '{"slug":"example-rumble","ids":["v1abcde"],"note": 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 + restarted` — and needs a person until the NEW run's part is growing (a new run that fails, never starts or lands + short leaves it loud, and the listing says which); 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, the state is + read again after 2 and 8 minutes (not after a rate limit, members-only or the disk), and if it never reads it starts + and lands NOTHING (`unknown`: the stream may be live and NOT recorded, 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. + an hour (then `refused`), and a part file written after the boot, or one that changes between three looks 20 s + apart — a recorder of the last process may still be writing — 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/common/controller/recordLive.test.ts b/common/controller/recordLive.test.ts @@ -1626,7 +1626,7 @@ function insuranceFake(o: { mainSeconds?: number; edgeSeconds?: number; caughtUp 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 () => { +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", { timeout: 60_000 }, async () => { const id = "exmplinsur1"; const f = insuranceFake(); const { run, calls, waits } = await incidentRun(id, f.attempt, { request: { insurance: undefined }, deps: FAST_INSURE }); @@ -1644,7 +1644,7 @@ test("slice 4: a stream marked keep gets the insurance by default; it stops once 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 () => { +test("slice 4: the default is by keep mark (asked, or on the record before); the request overrides either way", { timeout: 60_000 }, 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 }); @@ -1668,7 +1668,7 @@ test("slice 4: the default is by keep mark (asked, or on the record before); the assert.equal((await rowOf("exmplinsur5"))[0]!.insurance, undefined); }); -test("slice 4: not marked keep, not asked: no insurance recorder at all", async () => { +test("slice 4: not marked keep, not asked: no insurance recorder at all", { timeout: 60_000 }, async () => { const id = "exmplinsur6"; const { run, calls } = await incidentRun(id, writesAfter(0), { request: { insurance: undefined, doNotClean: false, note: undefined }, deps: FAST_INSURE }); await run; @@ -1676,7 +1676,7 @@ test("slice 4: not marked keep, not asked: no insurance recorder at all", async 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 () => { +test("slice 4: \"whole\" is not stopped by the catch-up, only after the stream's end", { timeout: 60_000 }, async () => { const id = "exmplinsur7"; const f = insuranceFake(); const { run } = await incidentRun(id, f.attempt, { request: { insurance: "whole" }, deps: FAST_INSURE }); @@ -1686,7 +1686,7 @@ test("slice 4: \"whole\" is not stopped by the catch-up, only after the stream's 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 () => { +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", { timeout: 60_000 }, async () => { const id = "exmplinsur8"; const f = insuranceFake({ mainSeconds: 3000, edgeSeconds: 1800, caughtUp: false }); const { run } = await incidentRun(id, f.attempt, { @@ -1706,7 +1706,7 @@ test("slice 4: the stream removed mid-catch-up — the insurance part holds the 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 () => { +test("slice 4: the insurance knob is parsed and asked again by Record again", { timeout: 60_000 }, 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"); diff --git a/common/controller/recordLive.ts b/common/controller/recordLive.ts @@ -2248,6 +2248,7 @@ async function recordLiveRunInner( const free = await (deps.freeBytes ?? getFreeBytes)(storeRoot).catch(() => 0); if (free < need + RECORD_LIVE_MIN_FREE_BYTES) { room = false; + (record.spaceHeld ??= []).push({ what: "the join of the parts", at: now().toISOString(), freeBytes: free }); say(`Not joined: the store's disk has ${formatBytes(free)} free, a join of these parts needs ${formatBytes(need + RECORD_LIVE_MIN_FREE_BYTES)}. The longest lands; the rest are kept.`); } } diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -13,6 +13,9 @@ 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 recording already in the store is replaced only by one proven to hold it (the whole stream from its start, or a + proven join that includes it), and nothing is removed when nothing of a run was stored; the join's proof also + checks the picture. - **The copies scan dates a re-upload by the stream's day, not the upload's, and says what it could not date.** - Before, it dated every video by its channel's `recordedDate` rule, else its upload day. A re-upload channel with no rule was dated by its uploads, months after the streams its live mirror held, and the scan answered "0