commit 13e15280c73ab762c5e8987701b4e48481824904
parent 8fdc0cf4047448a5aa4aca0fb254b3a4f55815ec
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 18 Nov 2026 23:00:57 -0500
x: review 3 M1/M2/S5/S6 -- a window is X's by the URL it fetches, on any channel; a saved-video window never goes to x.com; t.co is X's
M1: a fetch-windows job on clips:saved-video passes X's queue rule because
it cuts from disk. When its saved copy is gone or short by the time it
runs, an X source's window fails ("the saved copy no longer covers this
window; ask again and it runs on X's queue") and nothing is asked of X.
Any other X window in the batch controller asks xJobContextRefusal first,
and the single window's job does the same.
M2: xJobAsksX judges fetch-window(s) by params.webpageUrl and
params.items[].webpageUrl: an x.com/twitter.com page on any channel is an
X job (X's queue, jar rule, cap). The single window action and the batch
queue an X page on X's queue by default.
S5: an item with no URL is its channel's (each item's channel read for a
multi-channel batch): "no URL" never passes. find-copy's windows of a copy
and a mirror on another platform pass; fetch-copies passes, and its
controller refuses a copy whose address is X's.
S6: isXUrl takes t.co (and only twitter.com itself, not any host ending in
it); an import of a t.co link is queued on X's queue.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
11 files changed, 300 insertions(+), 17 deletions(-)
diff --git a/common/controller/fetchCopies.test.ts b/common/controller/fetchCopies.test.ts
@@ -221,3 +221,25 @@ test("the transcription lane picks the audio up: the snapshot moves a gone video
await c.close();
}
});
+
+// Review 3 S5: fetch-copies passes X's queue rule because it asks archive.org
+// (lib/xJobRule.ts xJobAsksX). A "copy" whose address is X's is therefore
+// never fetched here: it fails before any request, and the run goes on.
+test("review 3 S5: a copy whose address is X's is refused before any request; the others are fetched", async () => {
+ const c = await corpus();
+ try {
+ const f = fakeFetch();
+ const { d } = deps({ fetchCopy: f.fetchCopy });
+ const items: FetchCopyItem[] = [
+ { slug: SLUG, id: GONE_A, copy: { from: "wayback", url: "https://x.com/example/status/1900000000000003001" } },
+ { slug: SLUG, id: GONE_B, copy: { from: "archive.org", url: "https://t.co/AbCdEf123" } },
+ { slug: SLUG, id: GONE_C, copy: wayback(GONE_C) },
+ ];
+ const r = await fetchCopies({ paths: c.paths, items, gapMs: 0, deps: d });
+ assert.deepEqual(r.failed.map((x) => [x.item.id, x.class]), [[GONE_A, "not-a-copy"], [GONE_B, "not-a-copy"]]);
+ for (const x of r.failed) assert.match(x.message, /is X's: a copy is archive\.org's .* nothing was asked of X/);
+ assert.deepEqual(f.calls.map((x) => x.videoId), [GONE_C], "only the archive.org copy was fetched");
+ } finally {
+ await c.close();
+ }
+});
diff --git a/common/controller/fetchCopies.ts b/common/controller/fetchCopies.ts
@@ -34,6 +34,7 @@ import type { ChannelConfig } from "../lib/channelConfig";
import type { ClipCopy } from "../lib/clipWindow";
import type { JobProgress } from "../jobs/registry";
import { parseArchiveOrgUrl } from "../lib/archiveOrgId";
+import { isXUrl } from "../lib/xJobRule";
import { parseWaybackUrl } from "../lib/wayback";
import { ensureWaybackProvenance } from "../lib/wayback-server";
import { ensureArchiveOrgProvenanceSidecar } from "../lib/archiveOrg-server";
@@ -229,6 +230,15 @@ export async function fetchCopies({
break;
}
const label = fetchCopyItemLabel(item);
+ // A COPY IS ARCHIVE.ORG'S (review 3 S5): this job passes X's queue rule
+ // because it asks archive.org only (lib/xJobRule.ts xJobAsksX), so an
+ // address of X's is never fetched here.
+ if (isXUrl(item.copy.url)) {
+ fail(item, "not-a-copy", "its address is X's: a copy is archive.org's (the Wayback Machine or an archive.org item), and nothing was asked of X");
+ done++;
+ progress();
+ continue;
+ }
if (!configs.has(item.slug)) configs.set(item.slug, await deps.readChannelConfig(paths, item.slug).catch(() => null));
const config = configs.get(item.slug) ?? null;
if (!config) {
diff --git a/common/controller/fetchWindows.test.ts b/common/controller/fetchWindows.test.ts
@@ -911,3 +911,53 @@ test("a source-less posts channel's window is refused with its sentence, whateve
assert.equal(looked, 0, "no source URL was looked up for it");
assert.equal(r.fetched.length, 1, "the run goes on");
});
+
+// Review 3 M1: a window job on `clips:saved-video` is exempt from X's queue
+// rule because it cuts from disk. When the saved copy is gone (or no longer
+// covers) by the time it runs, an X source's window is NEVER fetched from
+// that queue: it fails with a sentence, and nothing is asked of X. Off that
+// queue, an X window is fetched only by a job on X's own queue.
+const X_CONFIG = { url: "https://x.com/example", platform: "twitter", sourceKind: "social" } as unknown as ChannelConfig;
+const jobCtx = (queueKey: string) => ({ jobId: "j-r3", kind: "fetch-windows", queueKey, onLog: () => {}, staleServices: new Set<string>() });
+const xItems = (): FetchWindowsItem[] => [
+ // An X channel's window, and an x.com video filed on a YouTube channel.
+ { ...item("1900000000000002001", "/ok"), slug: "xc", webpageUrl: "https://x.com/example/status/1900000000000002001" },
+ { ...item("v9", "/ok"), webpageUrl: "https://x.com/example/status/1900000000000002002" },
+ // An X channel's window with no URL of its own: its channel's page.
+ { slug: "xc", id: "1900000000000002003", from: 1, to: 2 },
+];
+
+test("review 3 M1: on clips:saved-video an X source's window whose saved copy is gone is refused, never fetched", async () => {
+ const { runInJobContext } = await import("../lib/jobContext");
+ const h = harness({
+ readChannelConfig: async (_p, slug) => (slug === "xc" ? X_CONFIG : CONFIG),
+ findVideoSourceUrl: async (_p, _slug, id) => `https://x.com/example/status/${id}`,
+ });
+ const before = await spawns();
+ // No saved copy is on disk: it was removed after the batch was planned.
+ const r = await runInJobContext(jobCtx("clips:saved-video"), async () => go(await corpus(), [...xItems(), item("v2", "/ok")], h));
+ assert.deepEqual(r.failed.map((f) => f.class), ["cut-failed", "cut-failed", "cut-failed"]);
+ for (const f of r.failed) {
+ assert.match(f.message, /^the saved copy no longer covers this window; ask again and it runs on X's queue/);
+ }
+ assert.equal(r.fetched.length, 1, "the YouTube window is not X's: it goes on as before");
+ assert.equal((await spawns()) - before, 1, "nothing was asked of X");
+});
+
+test("review 3 M1/M2: off clips:saved-video an X window is fetched only by a job on X's queue", async () => {
+ const { runInJobContext } = await import("../lib/jobContext");
+ const h = harness({
+ readChannelConfig: async (_p, slug) => (slug === "xc" ? X_CONFIG : CONFIG),
+ findVideoSourceUrl: async (_p, _slug, id) => `https://x.com/example/status/${id}`,
+ });
+ const before = await spawns();
+ const off = await runInJobContext(jobCtx("clips:youtube"), async () => go(await corpus(), xItems(), h));
+ assert.equal(off.fetched.length, 0);
+ for (const f of off.failed) assert.match(f.message, /X jobs run on X's queue only/);
+ assert.equal(off.failed.length, 3);
+ const none = await go(await corpus(), xItems().slice(0, 1), h);
+ assert.match(none.failed[0]?.message ?? "", /X is asked only by the editor's own jobs/);
+ assert.equal((await spawns()) - before, 0, "nothing was asked of X");
+ const on = await runInJobContext(jobCtx("platform:twitter"), async () => go(await corpus(), xItems().slice(0, 1), h));
+ assert.equal(on.fetched.length, 1, "on X's queue it is fetched");
+});
diff --git a/common/controller/fetchWindows.ts b/common/controller/fetchWindows.ts
@@ -22,6 +22,9 @@ import { isSourceSideCopyFailure, recordFailedCopy, type FailedCopy } from "../l
import { resolveCookiePolicy } from "../lib/cookiePolicy";
import { assertChannelMediaReachable, assertChannelTextReadable } from "../lib/channelMedia";
import { detectPlatform } from "../lib/platform";
+import { currentJobContext } from "../lib/jobContext";
+import { isXUrl, xJobContextRefusal } from "../lib/xJobRule";
+import { SAVED_VIDEO_CLIP_QUEUE } from "../lib/queueKeys";
import {
findInSyncContainingClipWindow,
findInSyncTieredWindowHolding,
@@ -1052,6 +1055,24 @@ export async function fetchWindows({
progress();
continue;
}
+ // AN X SOURCE IS FETCHED ONLY BY A JOB ON X'S QUEUE (review 3 M1/M2).
+ // A batch on `clips:saved-video` passed X's queue rule because it cuts
+ // from disk (lib/xJobRule.ts xJobAsksX); its saved copy gone or short by
+ // now, it never goes to x.com from there. Anywhere else, the rule where
+ // X is asked (xJobContextRefusal): inside a job, on X's queue.
+ if (isXUrl(url)) {
+ const job = currentJobContext();
+ const refusal =
+ job?.queueKey === SAVED_VIDEO_CLIP_QUEUE
+ ? "the saved copy no longer covers this window; ask again and it runs on X's queue (nothing was asked of X)"
+ : xJobContextRefusal(`The window ${label}`, "pnpm ops fetch-windows --json '{…}' (it queues X's windows on X's queue)");
+ if (refusal) {
+ fail(item, job?.queueKey === SAVED_VIDEO_CLIP_QUEUE ? "cut-failed" : "no-url", refusal);
+ done += 1;
+ progress();
+ continue;
+ }
+ }
// The cooldown's key, as the single fetch and every download path use it.
const platform = detectPlatform(url) ?? "unknown";
const whole = wholeRecordingFor(settings, platform, item, wholeRecording);
diff --git a/common/jobs/networkGuard.ts b/common/jobs/networkGuard.ts
@@ -119,9 +119,28 @@ async function channelPlatformOf(opts: NetworkJobOpts): Promise<string | null> {
// imports an x.com URL. An X channel's job that asks no platform at all —
// its transcription, windows cut from disk, a local file's import — is not
// X's (review 2 S5). One predicate: lib/xJobRule.ts xJobAsksX.
+//
+// A WINDOW IS X'S BY ITS URL (review 3 M2), on any channel; a window that
+// names no URL is fetched from its channel's page, so each such item's
+// channel is read here (a batch may span channels).
export async function jobAsksX(opts: NetworkJobOpts): Promise<boolean> {
const params = opts.spec?.params as Record<string, unknown> | undefined;
- return xJobAsksX({ kind: opts.kind, queueKey: opts.queueKey, channelPlatform: await channelPlatformOf(opts), ...(params ? { params } : {}) });
+ const itemChannelPlatforms: Record<string, string | null> = {};
+ if (opts.kind === "fetch-windows" && Array.isArray(params?.items)) {
+ for (const raw of params.items as unknown[]) {
+ const it = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
+ const named = typeof it.webpageUrl === "string" && it.webpageUrl.trim() !== "";
+ if (named || typeof it.slug !== "string" || Object.hasOwn(itemChannelPlatforms, it.slug)) continue;
+ itemChannelPlatforms[it.slug] = await channelPlatform(opts.paths, it.slug).catch(() => null);
+ }
+ }
+ return xJobAsksX({
+ kind: opts.kind,
+ queueKey: opts.queueKey,
+ channelPlatform: await channelPlatformOf(opts),
+ ...(params ? { params } : {}),
+ ...(Object.keys(itemChannelPlatforms).length ? { itemChannelPlatforms } : {}),
+ });
}
// ── 2 + 3. X ───────────────────────────────────────────────────────────────
diff --git a/common/jobs/pacingGuard.test.ts b/common/jobs/pacingGuard.test.ts
@@ -636,3 +636,35 @@ test("S5: an X channel's jobs that ask x.com nothing pass off X's queue; those t
assert.equal(clipWindowQueueKey(platformQueueKey("youtube")), "clips:youtube");
await reset();
});
+
+test("review 3 M2/S5: a window job is X's by its URLs on any channel; a URL-less item by its own channel, in a batch across channels", async () => {
+ await reset();
+ await writeJar(5 * 60 * 60_000);
+ for (let i = 0; i < 12; i++) await recordXJobStart(paths, fakeNow);
+ const yt = "yt-chan-r3";
+ await mkdir(path.join(transcripts, "channels", yt), { recursive: true });
+ await writeFile(path.join(transcripts, "channels", yt, "config.json"), JSON.stringify({ handling: "transcribe", platform: "youtube", name: yt, url: "https://www.youtube.com/@example" }));
+ const xs = SLUGS[0];
+ const g = (kind: string, queueKey: string, params: Record<string, unknown>, channelSlug?: string) =>
+ guardNetworkJob({ kind, queueKey, paths, ...(channelSlug ? { channelSlug } : {}), spec: { kind, slug: channelSlug ?? yt, params } as never });
+ const it = (slug: string, webpageUrl?: string) => ({ slug, id: "1", from: 1, to: 2, ...(webpageUrl ? { webpageUrl } : {}) });
+ const refusedOffX = (r: Awaited<ReturnType<typeof g>>, what: string) => {
+ assert.equal(r.ok, false, what);
+ assert.match(r.ok ? "" : r.error, /X jobs run on X's queue only/, what);
+ };
+ // An x.com video on a YouTube channel: X's (POST /api/media/fetch-window with a body webpageUrl).
+ refusedOffX(await g("fetch-window", "clips:youtube", { webpageUrl: "https://x.com/example/status/1" }, yt), "a single x.com window on a non-X channel");
+ refusedOffX(await g("fetch-windows", "clips:youtube", { items: [it(yt, "https://x.com/example/status/1")] }, yt), "a batch item's x.com URL");
+ // A multi-channel batch under a queue override: one URL-less item of an X channel makes it X's.
+ refusedOffX(await g("fetch-windows", "manual", { items: [it(yt, "https://www.youtube.com/watch?v=a"), it(xs)] }), "a URL-less X item in a multi-channel batch");
+ // Passes: no URL of X's and no item of an X channel without one.
+ for (const [what, r] of [
+ ["find-copy's windows on archive.org's clip queue, for an X channel", await g("fetch-windows", "clips:archiveorg", { items: [it(xs, "https://archive.org/details/example")] }, xs)],
+ ["a mirror on another platform", await g("fetch-windows", "clips:rumble", { items: [it(xs, "https://rumble.com/v-example.html")] }, xs)],
+ ["a multi-channel batch of YouTube pages", await g("fetch-windows", "manual", { items: [it(yt, "https://www.youtube.com/watch?v=a"), it(yt)] })],
+ ["fetch-copies of one X channel's gone videos", await g("fetch-copies", "platform:archiveorg", {}, xs)],
+ ] as const) {
+ assert.equal(r.ok, true, `${what}: ${r.ok ? "" : r.error}`);
+ }
+ await reset();
+});
diff --git a/common/lib/xJobRule.test.ts b/common/lib/xJobRule.test.ts
@@ -7,7 +7,7 @@ import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import path from "node:path";
import { runInJobContext } from "./jobContext";
-import { X_JOB_CAP, X_QUEUE_KEY, xJobCapSentence, xJobCapVerdict, xJobAsksX, xJobContextRefusal, xJobCounts, xQueueRefusal } from "./xJobRule";
+import { X_JOB_CAP, X_QUEUE_KEY, isXUrl, xJobCapSentence, xJobCapVerdict, xJobAsksX, xJobContextRefusal, xJobCounts, xQueueRefusal } from "./xJobRule";
const T0 = Date.parse("2026-11-18T12:00:00.000Z");
const MIN = 60_000;
@@ -154,3 +154,57 @@ test("S5: which network jobs ask x.com — by X's queue, X's clip queue, an impo
// The transcription worker asks x.com nothing even on X's queue: it does not count.
assert.equal(xJobCounts({ kind: "transcribe-one" }), false);
});
+
+// Review 3 M2, S5, S6: a window job is X's by the URL it will fetch, on ANY
+// channel; an item with no URL is its channel's; t.co is X's.
+test("review 3 M2: a window job is judged by its URLs — an x.com or twitter.com page on any channel is X's", () => {
+ const yt = (kind: string, queueKey: string, params: Record<string, unknown>, channelPlatform: string | null = "youtube") =>
+ xJobAsksX({ kind, queueKey, channelPlatform, params });
+ // The single window: its webpageUrl, on a channel that is not X's.
+ assert.equal(yt("fetch-window", "clips:youtube", { webpageUrl: "https://x.com/example/status/1" }), true);
+ assert.equal(yt("fetch-window", "clips:youtube", { webpageUrl: "https://mobile.twitter.com/example/status/1" }), true);
+ assert.equal(yt("fetch-window", "clips:youtube", { webpageUrl: "https://www.youtube.com/watch?v=abc" }), false);
+ // A batch: any item's URL that is X's makes the whole job X's.
+ const items = (...urls: Array<string | undefined>) => urls.map((u, i) => ({ slug: "c", id: `v${i}`, from: 1, to: 2, ...(u ? { webpageUrl: u } : {}) }));
+ assert.equal(yt("fetch-windows", "clips:youtube", { items: items("https://www.youtube.com/watch?v=a", "https://x.com/example/status/2") }), true);
+ assert.equal(yt("fetch-windows", "manual", { items: items("https://x.com/example/status/2") }, null), true, "a multi-channel batch under a queue override");
+ assert.equal(yt("fetch-windows", "clips:youtube", { items: items("https://www.youtube.com/watch?v=a") }), false);
+ // X's own queue is X's whatever the URLs.
+ assert.equal(yt("fetch-windows", "platform:twitter", { items: items("https://www.youtube.com/watch?v=a") }), true);
+ // Windows cut from the saved copy: the controller never takes the network
+ // for an X source there (M1), so the queue passes whatever the URL.
+ assert.equal(yt("fetch-windows", "clips:saved-video", { items: items("https://x.com/example/status/2") }, "twitter"), false);
+});
+
+test("review 3 S5: an X channel's window of a copy or a mirror on another platform passes; an item with no URL is its channel's", () => {
+ const x = (kind: string, queueKey: string, params?: Record<string, unknown>, extra: Partial<Parameters<typeof xJobAsksX>[0]> = {}) =>
+ xJobAsksX({ kind, queueKey, channelPlatform: "twitter", ...(params ? { params } : {}), ...extra });
+ const item = (webpageUrl?: string, slug = "x-chan") => ({ slug, id: "1", from: 1, to: 2, ...(webpageUrl ? { webpageUrl } : {}) });
+ // find-copy's windows of a copy, on archive.org's clip queue.
+ assert.equal(x("fetch-windows", "clips:archiveorg", { items: [item("https://web.archive.org/web/2026/https://example.org/v.mp4"), item("https://archive.org/details/example")] }), false);
+ // A mirror of the X video on another platform.
+ assert.equal(x("fetch-window", "clips:twitter-mirror", { webpageUrl: "https://rumble.com/v-example.html" }), false);
+ assert.equal(x("fetch-windows", "clips:rumble", { items: [item("https://rumble.com/v-example.html")] }), false);
+ // NO URL NEVER PASSES BY ITSELF: the item's channel decides.
+ assert.equal(x("fetch-window", "clips:youtube", {}), true, "a single window with no URL on an X channel");
+ assert.equal(x("fetch-window", "clips:youtube"), true, "no plan at all on an X channel");
+ assert.equal(x("fetch-windows", "clips:archiveorg", { items: [item("https://archive.org/details/example"), item(undefined)] }), true);
+ // A multi-channel batch: each URL-less item by its own channel's platform.
+ const multi = { items: [item("https://archive.org/details/example", "yt-chan"), item(undefined, "x-chan")] };
+ assert.equal(xJobAsksX({ kind: "fetch-windows", queueKey: "manual", params: multi, itemChannelPlatforms: { "yt-chan": "youtube", "x-chan": "twitter" } }), true);
+ assert.equal(xJobAsksX({ kind: "fetch-windows", queueKey: "manual", params: multi, itemChannelPlatforms: { "yt-chan": "youtube", "x-chan": "youtube" } }), false);
+ // fetch-copies: archive.org's (its controller refuses an X address).
+ assert.equal(x("fetch-copies", "platform:archiveorg"), false);
+});
+
+test("review 3 S6: a t.co short link is X's", () => {
+ for (const url of ["https://t.co/AbCdEf123", "http://t.co/x", "https://www.t.co/x"]) {
+ assert.equal(isXUrl(url), true, url);
+ assert.equal(xJobAsksX({ kind: "import-one", queueKey: "platform:youtube", channelPlatform: "youtube", params: { url } }), true, url);
+ }
+ for (const url of ["https://not-t.co/x", "https://example.com/t.co", "https://nottwitter.com/x", "not a url", ""]) {
+ assert.equal(isXUrl(url), false, url);
+ }
+ assert.equal(isXUrl("https://x.com/a/status/1"), true);
+ assert.equal(isXUrl("https://twitter.com/a/status/1"), true);
+});
diff --git a/common/lib/xJobRule.ts b/common/lib/xJobRule.ts
@@ -184,38 +184,103 @@ export function xJobCounts(plan: XJobPlan): boolean {
return p.media === false;
}
-// ── 4. which jobs ask x.com (review 2 S5) ─────────────────────────────────
+// ── 4. which jobs ask x.com (review 2 S5, review 3 M2/S5/S6) ───────────────
// X's clip windows run on X's own queue (lib/queueKeys.ts clipWindowQueueKey);
// the clip queue X once had is X's all the same.
export const X_CLIPS_QUEUE_KEY = "clips:twitter";
+// Windows cut from saved containers (lib/queueKeys.ts SAVED_VIDEO_CLIP_QUEUE).
+const SAVED_VIDEO_CLIP_QUEUE = "clips:saved-video";
+
+// IS THIS ADDRESS X'S? x.com and twitter.com (lib/platform.ts detectPlatform)
+// and X's short links, t.co (review 3 S6): a t.co link is answered by X, which
+// redirects to the post — asking it is asking X.
+export function isXUrl(url: unknown): boolean {
+ if (typeof url !== "string" || !url.trim()) return false;
+ if (detectPlatform(url.trim()) === "twitter") {
+ // detectPlatform takes any host ending in "twitter.com": only twitter.com
+ // itself and its subdomains are X's.
+ try {
+ const host = new URL(url.trim()).hostname.toLowerCase();
+ return host === "x.com" || host.endsWith(".x.com") || host === "twitter.com" || host.endsWith(".twitter.com");
+ } catch {
+ return false;
+ }
+ }
+ try {
+ const host = new URL(url.trim()).hostname.toLowerCase();
+ return host === "t.co" || host.endsWith(".t.co");
+ } catch {
+ return false;
+ }
+}
+
// The network job as queued: its kind, its queue, its channel's platform and
-// its spec's params.
+// its spec's params. `itemChannelPlatforms`: for a batch of windows, the
+// platform of each item's channel (by slug), read by the caller — an item
+// that names no URL is fetched from its channel's page.
export type XAskPlan = {
kind: string;
queueKey: string;
channelPlatform?: string | null;
params?: Readonly<Record<string, unknown>>;
+ itemChannelPlatforms?: Readonly<Record<string, string | null | undefined>>;
};
+const isWindowKind = (kind: string) => kind === "fetch-window" || kind === "fetch-windows";
+
+// The windows a window job will fetch: each one's page URL (when it names one)
+// and its channel. A single window's are its params'.
+function windowAsks(plan: XAskPlan): Array<{ url?: string; slug?: string }> {
+ const p = plan.params;
+ if (plan.kind === "fetch-windows" && p && Array.isArray(p.items)) {
+ return (p.items as unknown[]).map((raw) => {
+ const it = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : {};
+ const url = typeof it.webpageUrl === "string" && it.webpageUrl.trim() ? it.webpageUrl.trim() : undefined;
+ const slug = typeof it.slug === "string" ? it.slug : undefined;
+ return { ...(url ? { url } : {}), ...(slug ? { slug } : {}) };
+ });
+ }
+ const url = typeof p?.webpageUrl === "string" && p.webpageUrl.trim() ? p.webpageUrl.trim() : undefined;
+ // No plan to read: one window of the job's channel.
+ return [url ? { url } : {}];
+}
+
// DOES THIS NETWORK JOB ASK x.com? It does on X's queue (or X's old clip
-// queue), whatever its kind; an import of one URL asks that URL's host; and a
-// job for an X channel asks X — unless its work is one that asks no platform
-// at all, which then passes whatever queue it is on:
+// queue), whatever its kind. Then:
+// import-one asks its URL's host (isXUrl: x.com, twitter.com, t.co);
+// fetch-window(s) ask the URLs of their windows (review 3 M2), ON ANY
+// CHANNEL: an x.com page is X's wherever it is filed. A
+// window that names no URL is fetched from its
+// channel's page, so its CHANNEL decides — "no URL"
+// never passes by itself (S5). On `clips:saved-video`
+// they ask nothing: windows cut from the saved copy on
+// disk — and the controller never goes to the network
+// for an X source from that queue (M1,
+// controller/fetchWindows.ts);
+// fetch-copies archive.org (its controller refuses an X address);
// transcribe-one the transcription worker, over a file on disk;
-// fetch-window(s) on `clips:saved-video`: windows cut from the saved
-// copy on disk;
// import-media on its own queue (`import-media:<slug>`): a local
// file (an import of an x.com URL is queued on X's);
// import-archive-org archive.org.
// Everything else an X channel queues asks X, and is refused off X's queue.
export function xJobAsksX(plan: XAskPlan): boolean {
if (plan.queueKey === X_QUEUE_KEY || plan.queueKey === X_CLIPS_QUEUE_KEY) return true;
- if (plan.kind === "import-one" && typeof plan.params?.url === "string") return detectPlatform(plan.params.url) === "twitter";
- if (plan.channelPlatform !== "twitter") return false;
+ if (plan.kind === "import-one" && typeof plan.params?.url === "string") return isXUrl(plan.params.url);
if (plan.kind === "transcribe-one") return false;
- if ((plan.kind === "fetch-window" || plan.kind === "fetch-windows") && plan.queueKey === "clips:saved-video") return false;
+ if (isWindowKind(plan.kind)) {
+ if (plan.queueKey === SAVED_VIDEO_CLIP_QUEUE) return false;
+ return windowAsks(plan).some((w) => {
+ if (w.url) return isXUrl(w.url);
+ const platform = w.slug !== undefined && plan.itemChannelPlatforms && Object.hasOwn(plan.itemChannelPlatforms, w.slug)
+ ? plan.itemChannelPlatforms[w.slug]
+ : plan.channelPlatform;
+ return platform === "twitter";
+ });
+ }
+ if (plan.channelPlatform !== "twitter") return false;
+ if (plan.kind === "fetch-copies") return false;
if (plan.kind === "import-media" && plan.queueKey.startsWith("import-media:")) return false;
if (plan.kind === "import-archive-org") return false;
return true;
diff --git a/editor/app/channels/[slug]/pipelineActions.ts b/editor/app/channels/[slug]/pipelineActions.ts
@@ -17,6 +17,7 @@ import {
downloadQueueKey,
resolveQueueKey,
} from "yt-dlp-transcript-common/lib/queueKeys";
+import { isXUrl, X_QUEUE_KEY } from "yt-dlp-transcript-common/lib/xJobRule";
import {
detectPlatform,
platformQueueKey,
@@ -685,8 +686,9 @@ export async function importVideoAction(
// queue control starts at the CHANNEL's queue, which is therefore read as
// "no choice made"; any other queue the operator picks still wins.
const channelQueue = downloadQueueKey(channelConfig);
- // An x.com URL is X's: X's queue (review 2 S5; lib/xJobRule.ts).
- const ownQueue = archiveOrg || pacedPlatform || urlPlatform === "twitter" ? platformQueueKey(urlPlatform) : null;
+ // An x.com URL is X's: X's queue (review 2 S5; lib/xJobRule.ts) — and so
+ // is a t.co short link, which X answers (review 3 S6).
+ const ownQueue = isXUrl(videoUrl) ? X_QUEUE_KEY : archiveOrg || pacedPlatform ? platformQueueKey(urlPlatform) : null;
const override =
ownQueue && queueKey !== undefined && queueKey.trim() === channelQueue
? undefined
diff --git a/editor/app/channels/[slug]/videos/[id]/videoActions.ts b/editor/app/channels/[slug]/videos/[id]/videoActions.ts
@@ -38,6 +38,7 @@ import {
downloadQueueKey,
resolveQueueKey,
} from "yt-dlp-transcript-common/lib/queueKeys";
+import { isXUrl, X_QUEUE_KEY, xJobContextRefusal } from "yt-dlp-transcript-common/lib/xJobRule";
import { windowInFlight } from "yt-dlp-transcript-common/jobs/windowJobs";
import { getRegistry } from "yt-dlp-transcript-common/jobs/registry";
import { readChannelConfig } from "yt-dlp-transcript-common/controller/channels";
@@ -1907,8 +1908,10 @@ export async function fetchWindowAction(req: {
kind: "fetch-window",
// The platform's CLIP queue, not its download queue: a window must not
// wait behind a multi-hour persist or sync (lib/queueKeys.ts,
- // clipWindowQueueKey). An explicit override still wins.
- queueKey: resolveQueueKey(clipWindowQueueKey(downloadQueueKey(r.config)), req.queueKey),
+ // clipWindowQueueKey). An explicit override still wins. AN X PAGE IS
+ // X'S WHEREVER IT IS FILED (review 3 M2): its window runs on X's queue,
+ // and an override elsewhere is refused (lib/xJobRule.ts xJobAsksX).
+ queueKey: resolveQueueKey(isXUrl(url) ? X_QUEUE_KEY : clipWindowQueueKey(downloadQueueKey(r.config)), req.queueKey),
paths,
channelSlug: slug,
videoId,
@@ -1931,6 +1934,9 @@ export async function fetchWindowAction(req: {
},
fn: async (onLog, signal) => {
onLog(`${requesterLine(req.provenance)}\n`);
+ // X is asked only by a job on X's queue (lib/xJobRule.ts), checked where it is asked.
+ const notHere = isXUrl(url) ? xJobContextRefusal(`The window of ${slug}/${videoId}`, "POST /api/media/fetch-window (it queues an X window on X's queue)") : null;
+ if (notHere) throw new Error(notHere);
const once = (target: (StoredMediaUrl & { why: StoredUrlWhy }) | null) =>
fetchWindowManaged({
channelSlug: slug,
diff --git a/editor/app/channels/[slug]/videos/fetchWindowsAction.ts b/editor/app/channels/[slug]/videos/fetchWindowsAction.ts
@@ -12,6 +12,7 @@ import {
clipWindowQueueKey,
resolveQueueKey,
} from "yt-dlp-transcript-common/lib/queueKeys";
+import { isXUrl, X_QUEUE_KEY } from "yt-dlp-transcript-common/lib/xJobRule";
import { getRegistry } from "yt-dlp-transcript-common/jobs/registry";
import { windowInFlight } from "yt-dlp-transcript-common/jobs/windowJobs";
import { detectPlatform, queueKeyForUrl } from "yt-dlp-transcript-common/lib/platform";
@@ -465,8 +466,9 @@ async function planFetchWindows(
});
continue;
}
+ // An X page (a t.co link too) is X's: X's queue (review 3 M2/S6).
const queueKey = resolveQueueKey(
- whole ? queueKeyForUrl(url) : clipWindowQueueKey(queueKeyForUrl(url)),
+ isXUrl(url) ? X_QUEUE_KEY : whole ? queueKeyForUrl(url) : clipWindowQueueKey(queueKeyForUrl(url)),
queueOverride,
);
// One job per queue. Two platforms sharing a queue (an override) share a