commit db66f1196dbb1398d7d6b8e6c71ae8bd794b1e67
parent 8931da51993173f7257f00116dfb070ffeb89756
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 21 Nov 2026 16:23:45 -0500
listing: an interruption the boot pass restarted stays loud until the new run's part grows
REVIEW-1 of live-guard-2, 1.3: a row marked restarted stopped needing a
person the moment the new run read the stream live, before it recorded a
byte; a new run that then failed or landed short left nothing loud. The
exemption is gone from rowNeedsAttention. The listing lets such a row go
quiet only while the new run (resumeOf) records and its part grows, and
otherwise says why it is loud: no new run yet, not growing, failed, or
ended without the whole stream. A new run that holds the whole stream
supersedes it as before.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
4 files changed, 104 insertions(+), 10 deletions(-)
diff --git a/common/controller/liveRecordings.test.ts b/common/controller/liveRecordings.test.ts
@@ -203,3 +203,68 @@ test("needsAttention: interrupted always, a cancel only when must-keep, kept par
assert.equal(rowNeedsAttention({ ...base, status: "landed", acknowledgedAt: "t", keptParts: kept }), false);
assert.equal(rowNeedsAttention({ ...base, status: "landed", missingStream: "video" }), true);
});
+
+test("REVIEW 1.3 (live-guard-2): an interruption 'restarted' by the boot pass needs a person until the NEW run's part grows; a new run that failed or never began leaves it loud", async () => {
+ const id = "exmplrest01";
+ const t0 = minutesAgo(90).toISOString();
+ await upsertLiveRecordingRow(paths, SLUG, {
+ id,
+ url: `https://www.youtube.com/watch?v=${id}`,
+ platform: "youtube",
+ startedAt: t0,
+ endedAt: minutesAgo(31).toISOString(),
+ status: "interrupted",
+ stoppedBy: "shutdown",
+ fromStart: true,
+ attempts: 1,
+ mustKeep: true,
+ parts: [],
+ restart: { at: minutesAgo(30).toISOString(), by: "boot", state: "restarted", jobId: "job-new" },
+ });
+ const old = async (jobs: () => { id: string; kind: string; status: "running"; channelSlug: string; videoId: string }[] = () => []) =>
+ (await listLiveRecordings(paths, { slug: SLUG, id, now: NOW, all: true, jobs })).rows.find((r) => r.startedAt === t0)!;
+ // No new run at all.
+ let r = await old();
+ assert.equal(r.needsAttention, true, "the restart has not recorded a byte");
+ assert.match(r.reason, /no new run|not recorded/i);
+ // The new run records, and its part grows.
+ const stem = `.${id}.live-2026-11-20T11-30-00-000Z.ytdlp`;
+ const started = minutesAgo(29).toISOString();
+ await upsertLiveRecordingRow(paths, SLUG, {
+ id,
+ url: `https://www.youtube.com/watch?v=${id}`,
+ platform: "youtube",
+ startedAt: started,
+ status: "recording",
+ jobId: "job-new",
+ fromStart: true,
+ attempts: 1,
+ mustKeep: true,
+ resumeOf: t0,
+ parts: [{ method: "ytdlp", url: "u", fromStart: true, startedAt: started, stem }],
+ });
+ await writeFile(path.join(store, `${stem}.ts`), Buffer.alloc(2000));
+ await utimes(path.join(store, `${stem}.ts`), minutesAgo(1), minutesAgo(1));
+ const running = () => [{ id: "job-new", kind: "record-live", status: "running" as const, channelSlug: SLUG, videoId: id }];
+ r = await old(running);
+ assert.equal(r.needsAttention, false, "the new run records and grows");
+ // The new run failed: loud again, and says so.
+ await upsertLiveRecordingRow(paths, SLUG, {
+ id,
+ url: `https://www.youtube.com/watch?v=${id}`,
+ platform: "youtube",
+ startedAt: started,
+ endedAt: minutesAgo(5).toISOString(),
+ status: "failed",
+ error: "nothing was recorded",
+ jobId: "job-new",
+ fromStart: true,
+ attempts: 6,
+ mustKeep: true,
+ resumeOf: t0,
+ parts: [{ method: "ytdlp", url: "u", fromStart: true, startedAt: started, stem }],
+ });
+ r = await old();
+ assert.equal(r.needsAttention, true);
+ assert.match(r.reason, /failed/);
+});
diff --git a/common/controller/liveRecordings.ts b/common/controller/liveRecordings.ts
@@ -358,6 +358,25 @@ export async function listLiveRecordings(paths: Paths, opts: ListLiveRecordingsO
out.push({ ...view, reason: reasonOf(view, stallMinutes), check: liveRecordingCheckCommand(slug, row.id) });
}
}
+ // AN INTERRUPTION THE BOOT PASS RESTARTED (REVIEW-1 1.3 of live-guard-2) is
+ // quiet only while the NEW run (its row's resumeOf) records and its part
+ // grows; a new run that failed, ended short or never began leaves it loud,
+ // and says so. A new run that holds the whole stream supersedes it anyway.
+ for (const v of out) {
+ if (v.status !== "interrupted" || v.restart?.state !== "restarted" || v.acknowledgedAt || v.supersededBy) continue;
+ const nv = out.find((x) => x.slug === v.slug && x.id === v.id && x.resumeOf === v.startedAt);
+ const growing = nv && nv.status === "recording" && !nv.stalled && (nv.bytes ?? 0) > 0;
+ if (growing && !(v.keptParts && v.keptParts.length)) {
+ v.needsAttention = false;
+ v.reason = `${v.reason} — the new run records (${Math.round((nv.bytes ?? 0) / 1024 / 1024)} MB, growing)`;
+ } else if (!nv) {
+ v.reason = `${v.reason} — but no new run has recorded anything yet`;
+ } else if (nv.status === "recording" || nv.status === "interrupted") {
+ v.reason = `${v.reason} — but the new run is ${nv.stalled ? "NOT growing" : nv.status === "interrupted" ? "interrupted too" : "not recording yet"}`;
+ } else {
+ v.reason = `${v.reason} — but the new run ${nv.status === "failed" ? `failed: ${nv.error ?? "no reason recorded"}` : `ended ${nv.status}${nv.coverage && !nv.coverage.covers ? " without the whole stream" : ""}`}`;
+ }
+ }
out.sort((a, b) => Date.parse(b.startedAt) - Date.parse(a.startedAt));
return {
rows: out,
diff --git a/common/controller/recordLive.test.ts b/common/controller/recordLive.test.ts
@@ -1500,14 +1500,28 @@ test("slice 3 resume: the stream is still live → it records again; the interru
const id = "exmplresum1";
const t0 = "2026-11-21T08:00:00.000Z";
await interruptedRow(id, t0);
- const { run, calls, log } = await incidentRun(id, writesAfter(0), { request: { resumeOf: t0 } });
+ // The new run lands 600 s of a stream that started 590 s ago: the whole.
+ const { run, calls, log } = await incidentRun(id, writesAfter(0), {
+ request: { resumeOf: t0 },
+ meta: { ...YT_META(id), release_timestamp: Math.floor(Date.now() / 1000) - 590 },
+ });
assert.equal((await run).status, "landed");
assert.equal(calls.length, 1);
assert.ok(log.some((l) => /recording again/.test(l)));
const old = await oldRow(id, t0);
assert.equal(old.restart?.state, "restarted");
assert.equal(old.restart?.jobId, `job-${id}`);
- assert.equal(old.needsAttention, false, "the new run carries it");
+ assert.ok(old.supersededBy, "the new run holds the whole stream: it supersedes the interruption");
+ assert.equal(old.needsAttention, false);
+ // A restarted run that lands short leaves the interruption loud (REVIEW-1 1.3).
+ const id2 = "exmplresum5";
+ await interruptedRow(id2, t0);
+ const short = await incidentRun(id2, writesAfter(0), { request: { resumeOf: t0 } });
+ assert.equal((await short.run).status, "landed");
+ const old2 = await oldRow(id2, t0);
+ assert.equal(old2.restart?.state, "restarted");
+ assert.equal(old2.needsAttention, true, "600 s of a two-hour stream does not carry the interruption");
+ assert.match(old2.reason, /without the whole stream/);
const fresh = (await rowOf(id)).find((r) => r.startedAt !== t0)!;
assert.equal(fresh.resumeOf, t0);
});
diff --git a/common/lib/liveRecordings-server.ts b/common/lib/liveRecordings-server.ts
@@ -150,10 +150,10 @@ export async function loadLiveRecordingRows(paths: Pick<Paths, "channelsDir">, s
// Needs a person, as the row stands (the listing adds `interrupted` for a
// `recording` no job runs).
-// failed, interrupted always — but an interrupted run the
-// boot pass restarted from its start
-// (restart "restarted"): its new run's
-// row carries it
+// failed, interrupted always (the listing lets an
+// interruption the boot pass restarted
+// go quiet only while the NEW run's
+// part grows)
// cancelled when the stream was must-keep (a
// person's Cancel of any other stream
// is quiet)
@@ -178,10 +178,6 @@ export function rowNeedsAttention(
if (r.acknowledgedAt) return false;
if (r.keptParts && r.keptParts.length > 0) return true;
if (r.supersededBy) return false;
- // An interruption the boot pass restarted from its start is carried by the
- // new run's own row (it records the whole stream again, or says what it
- // lost); every other interruption needs a person.
- if (r.status === "interrupted" && r.restart?.state === "restarted" && r.fromStart === true) return false;
if (r.status === "failed" || r.status === "interrupted") return true;
if (r.status === "cancelled" && r.mustKeep === true) return true;
if (r.fallback === "live-edge" && r.startRecovery?.state !== "recovered") return true;