commit a869a2a4a1d1d18c69fdcfc9a8264b1d05317fb2
parent 6ee1ec016fef415e2f10a53fb35351972489bda2
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 15 Oct 2026 08:10:15 -0400
common: compose takes a gone source's moment as words only on prepare's word alone (review 1) — this host's index must list it as a `source-gone` warning (prepare's, after its reachability check, with no media to cut; the warning now names the state), the source must still be gone, and no media may be on disk since (a window or a capture fetched after prepare); otherwise `missing-media`, prepare again. No index, another host's, or a moment prepare failed for (unreachable, cut-failed, too-big) is refused as before
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
5 files changed, 99 insertions(+), 29 deletions(-)
diff --git a/common/publish/citedPostCaptures.ts b/common/publish/citedPostCaptures.ts
@@ -79,6 +79,16 @@ export function citedCaptureSourceDir(channelsDir: string, channel: string, id:
const isFile = async (p: string) => (await stat(p).catch(() => null))?.isFile() === true;
+// Whether a cited post has its captured screenshot now (compose's check that
+// a moment prepare called gone has not been captured since: release 29 E2).
+export async function hasCapturedShot(channelsDir: string, channel: string, id: string): Promise<boolean> {
+ try {
+ return await isFile(path.join(citedCaptureSourceDir(channelsDir, channel, id), SHOT_FILENAME));
+ } catch {
+ return false;
+ }
+}
+
// Copy the cited posts' captures into `<destRoot>/posts/`, and remove every
// capture there that is not cited. `channelsDir` is the corpus's
// `channels/`.
diff --git a/common/publish/composeReports.test.ts b/common/publish/composeReports.test.ts
@@ -183,7 +183,7 @@ function seedSite(siteId: string, extra: Record<string, unknown> = {}, withRepor
// What `archilyzer reports prepare` leaves: the manifest, the clips with
// their sidecars, the cited capture.
-function seedMedia(siteId: string, drop: string[] = []) {
+function seedMedia(siteId: string, drop: string[] = [], extra: { warnings?: unknown[]; indexSiteId?: string } = {}) {
const dir = reportMediaDir(paths, siteId);
const clip = (hash: string, kind: "video" | "audio", span: { from: number; to: number }) => {
const file = `${hash}${kind === "video" ? ".mp4" : ".m4a"}`;
@@ -213,10 +213,11 @@ function seedMedia(siteId: string, drop: string[] = []) {
writeJson(reportMediaIndexFile(paths, siteId), {
format: REPORT_MEDIA_FORMAT,
version: REPORT_MEDIA_VERSION,
- siteId,
+ siteId: extra.indexSiteId ?? siteId,
preparedAt: "2026-10-05T00:00:00.000Z",
moments,
problems: [],
+ ...(extra.warnings ? { warnings: extra.warnings } : {}),
});
}
@@ -512,16 +513,44 @@ test("a citation without prepared media fails compose with the list, unless --al
}
});
-test("a gone source with no prepared media is its words only, marked sourceGone; a live one is still refused", async () => {
+test("a gone source with no media is its words only ONLY on prepare's source-gone warning; compose never decides it alone", async () => {
// The recording deleted on its platform (lib/sourceGone.ts reads
// availability.json), the post deleted in posts-availability.json; neither
// has prepared media.
const avail = path.join(paths.channelsDir, VIDEOS, "data", "abc123", "availability.json");
const postsAvail = path.join(paths.channelsDir, SOCIAL, "posts-availability.json");
+ const SPAN = `${VIDEOS}/abc123/10.00-20.00`;
+ const POST = `${SOCIAL}/3kabc`;
+ const warn = (moment: string, gone: string) => ({ kind: "source-gone", moment, citations: [], gone, message: "gone" });
+ const refusedBoth = (e: unknown) => {
+ assert.ok(e instanceof ComposeReportsError);
+ assert.deepEqual(
+ e.problems.map((p) => [p.kind, p.moment]),
+ [
+ ["missing-media", SPAN],
+ ["missing-media", POST],
+ ],
+ );
+ return true;
+ };
writeJson(avail, { checkedAt: "2026-10-01T00:00:00.000Z", availability: "deleted" });
writeJson(postsAvail, { "3kabc": { availability: "deleted", checkedAt: "2026-10-01T00:00:00.000Z" } });
- seedMedia("cited", [`${VIDEOS}/abc123/10.00-20.00`, `${SOCIAL}/3kabc`]);
try {
+ // Gone on disk, but prepare said nothing (never ran, or failed it: unreachable,
+ // cut-failed, too-big are problems, not warnings): refused.
+ seedMedia("cited", [SPAN, POST]);
+ await assert.rejects(compose("cited"), refusedBoth);
+ // Another host's index warns: not this host's word.
+ seedMedia("cited", [SPAN, POST], { warnings: [warn(SPAN, "deleted"), warn(POST, "deleted")], indexSiteId: "full" });
+ await assert.rejects(compose("cited"), (e: unknown) => {
+ assert.ok(e instanceof ComposeReportsError);
+ const missing = e.problems.filter((p) => p.kind === "missing-media").map((p) => p.moment);
+ assert.ok(missing.includes(SPAN) && missing.includes(POST), JSON.stringify(missing));
+ return true;
+ });
+
+ // Prepare's word: accepted, marked.
+ seedMedia("cited", [SPAN, POST], { warnings: [warn(SPAN, "deleted"), warn(POST, "deleted")] });
await compose("cited");
const span = readJson<Record<string, unknown>>(pub("m", VIDEOS, "abc123", "10.00-20.00", "moment.json"));
assert.equal(span.sourceGone, "deleted");
@@ -537,21 +566,16 @@ test("a gone source with no prepared media is its words only, marked sourceGone;
assert.equal(view.citations.c02.sourceGone, undefined);
assert.ok(!existsSync(pub("media", "clips", VIDEOS, "abc123")));
- // Made private reads as gone too; live again (no availability): refused.
+ // Made private reads as gone too (the state is read now).
writeJson(avail, { checkedAt: "2026-10-01T00:00:00.000Z", availability: "private" });
await compose("cited");
assert.equal(readJson<Record<string, unknown>>(pub("m", VIDEOS, "abc123", "10.00-20.00", "moment.json")).sourceGone, "private");
+ // Live again since prepare: its warning is stale — refused, prepare again.
rmSync(avail);
rmSync(postsAvail);
await assert.rejects(compose("cited"), (e: unknown) => {
- assert.ok(e instanceof ComposeReportsError);
- assert.deepEqual(
- e.problems.map((p) => [p.kind, p.moment]),
- [
- ["missing-media", `${VIDEOS}/abc123/10.00-20.00`],
- ["missing-media", `${SOCIAL}/3kabc`],
- ],
- );
+ refusedBoth(e);
+ assert.match((e as InstanceType<typeof ComposeReportsError>).problems[0].message, /not now — prepare again/);
return true;
});
} finally {
diff --git a/common/publish/composeReports.ts b/common/publish/composeReports.ts
@@ -137,7 +137,8 @@ import {
type ReportFeeds,
type ReportPageView,
} from "../lib/report/views";
-import { citedEvidenceSpan, isAudioOnlyPlatform, type EvidenceSpan } from "../lib/evidenceClip-server";
+import { citedEvidenceSpan, isAudioOnlyPlatform, resolveEvidenceSource, type EvidenceSpan } from "../lib/evidenceClip-server";
+import { hasCapturedShot } from "./citedPostCaptures";
import {
citedMoments,
loadHostReports,
@@ -670,6 +671,23 @@ export async function resolveReports(opts: ResolveReportsOptions): Promise<Resol
const mediaOf = new Map<string, ReportMediaEntry>();
// moment key → its source's gone state, for a moment accepted with no media.
const sourceGone = new Map<string, GoneState>();
+ // Whether a moment's media is on disk now: a span's window, saved container
+ // or audio (what prepare would cut from), a post's captured shot.
+ const momentMediaOnDisk = async (m: (typeof momentInfo extends Map<string, infer V> ? V : never)): Promise<boolean> => {
+ if (m.kind === "post") return hasCapturedShot(paths.channelsDir, m.moment.channel, m.moment.id);
+ if (m.moment.kind !== "span") return false;
+ const span = await citedEvidenceSpan(paths.channelsDir, m.moment.channel, m.moment.id, { start: m.moment.start, end: m.moment.end, pad: m.pad });
+ const config = await configOf(m.moment.channel);
+ const source = await resolveEvidenceSource({
+ channelsDir: paths.channelsDir,
+ slug: m.moment.channel,
+ id: m.moment.id,
+ span,
+ audio: m.kind === "audio" || isAudioOnlyPlatform(config?.platform),
+ ffprobeBin: paths.ffprobeBin,
+ }).catch(() => null);
+ return source !== null;
+ };
for (const key of Object.keys(citedIn)) {
const m = momentInfo.get(key);
if (!m || refusedChannel.has(m.moment.channel)) continue;
@@ -678,19 +696,35 @@ export async function resolveReports(opts: ResolveReportsOptions): Promise<Resol
const missing = (kind: ComposeReportsProblemKind, message: string) =>
problems.push({ kind, moment: key, message: `${message} (cited by ${[...new Set(citedBy)].join(", ")})` });
if (!entry) {
- // A SOURCE GONE FROM ITS PLATFORM with no media prepared (release 29 E2):
- // accepted as a text-only moment, marked — the recording deleted or made
- // private (lib/sourceGone.ts), the post deleted in posts-availability.json.
- // A live source with no media is still refused.
- const gone =
+ // A SOURCE GONE FROM ITS PLATFORM with no media (release 29 E2): accepted
+ // as a text-only moment, marked — but only on PREPARE's word: this host's
+ // index lists it as a `source-gone` warning, which prepare gives only after
+ // its reachability check and when it had no media to cut. Compose never
+ // decides it alone: no index, another host's, or a moment prepare failed
+ // for (unreachable, cut-failed, too-big) stays `missing-media`. And the
+ // word must still hold: the source still gone, and no media on disk since
+ // (a copy find-copy fetched after prepare) — else prepare again.
+ const warned =
+ media?.siteId === host.id
+ ? media.warnings?.find((w) => w.kind === "source-gone" && w.moment === key)
+ : undefined;
+ if (!warned) {
+ missing("missing-media", "no prepared media — run Prepare evidence media (archilyzer reports prepare)");
+ continue;
+ }
+ const goneNow =
m.kind === "post"
? await postGoneState(paths.channelsDir, m.moment.channel, m.moment.id)
: await recordGoneState(paths.channelsDir, m.moment.channel, m.moment.id);
- if (gone) {
- sourceGone.set(key, gone);
+ if (!goneNow) {
+ missing("missing-media", "prepare found its source gone, and it is not now — prepare again");
+ continue;
+ }
+ if (await momentMediaOnDisk(m)) {
+ missing("missing-media", "its media is on disk now (fetched or captured since prepare) — prepare again");
continue;
}
- missing("missing-media", "no prepared media — run Prepare evidence media (archilyzer reports prepare)");
+ sourceGone.set(key, goneNow);
continue;
}
const files = entry.kind === "post" ? [entry.file, ...entry.media.map((f) => f.file)] : [entry.file];
diff --git a/common/publish/reportMedia.test.ts b/common/publish/reportMedia.test.ts
@@ -303,10 +303,10 @@ test("a gone recording or a deleted, never-captured post with no media is a warn
const lines: string[] = [];
const index = await prepareReportMedia({ siteId: GSITE, settings: PUBLIC, onLog: (l) => lines.push(l) });
assert.deepEqual(
- (index.warnings ?? []).map((w) => [w.kind, w.moment, w.citations]),
+ (index.warnings ?? []).map((w) => [w.kind, w.moment, w.citations, w.gone]),
[
- ["source-gone", `${CH}/gone2/1.00-2.00`, ["g1#g01"]],
- ["source-gone", `${X}/333`, ["g1#g02"]],
+ ["source-gone", `${CH}/gone2/1.00-2.00`, ["g1#g01"], "deleted"],
+ ["source-gone", `${X}/333`, ["g1#g02"], "deleted"],
],
);
assert.match(index.warnings![0].message, /deleted.*words only.*Source deleted/);
diff --git a/common/publish/reportMedia.ts b/common/publish/reportMedia.ts
@@ -174,6 +174,8 @@ export type ReportMediaProblem = {
moment?: string;
// A JSON path in the report (an invalid report's problems).
path?: string;
+ // A `source-gone` warning: what the source said when prepare looked.
+ gone?: GoneState;
};
export type ReportMediaIndex = {
@@ -300,8 +302,8 @@ export async function prepareReportMedia(opts: PrepareReportMediaOptions): Promi
log(` ✗ ${m.key}: ${message}`);
};
const warnings: ReportMediaProblem[] = [];
- const warnGone = (m: CitedMoment, message: string) => {
- warnings.push({ kind: "source-gone", moment: m.key, citations: m.citedBy, message });
+ const warnGone = (m: CitedMoment, gone: GoneState, message: string) => {
+ warnings.push({ kind: "source-gone", moment: m.key, citations: m.citedBy, gone, message });
log(` ! ${m.key}: ${message}`);
};
@@ -353,7 +355,7 @@ export async function prepareReportMedia(opts: PrepareReportMediaOptions): Promi
}
const gone = await sourceGoneState(await resolveVideoDir(paths.channelsDir, slug, m.moment.id));
if (gone) {
- warnGone(m, `the source says the video is ${gone} and no copy is on disk: the moment shows its words only, marked "${SOURCE_GONE_LABELS[gone]}" (pnpm ops find-copy looks for a copy)`);
+ warnGone(m, gone, `the source says the video is ${gone} and no copy is on disk: the moment shows its words only, marked "${SOURCE_GONE_LABELS[gone]}" (pnpm ops find-copy looks for a copy)`);
continue;
}
fail(m, "missing-media", `${r.message} — fetch the window or persist the video in the editor`);
@@ -378,7 +380,7 @@ export async function prepareReportMedia(opts: PrepareReportMediaOptions): Promi
const m = postMoment.get(`${miss.channel}/${miss.id}`);
if (!m) continue;
if (await postGoneState(paths.channelsDir, miss.channel, miss.id)) {
- warnGone(m, `the post is deleted and was never captured: the moment shows its words only, marked "${SOURCE_GONE_LABELS.deleted}"`);
+ warnGone(m, "deleted", `the post is deleted and was never captured: the moment shows its words only, marked "${SOURCE_GONE_LABELS.deleted}"`);
continue;
}
fail(m, "missing-media", miss.message);