commit d065a8a887788c08ddc571646ba35bad6dae138b
parent 4a865d047927fbca14a94a04803935fcfdeece6a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Sat, 21 Nov 2026 01:46:07 -0500
ops: get copies, copies-scan and copies-release
The source groups' copies report (`pnpm ops get copies [<group>]`, read
only): each group's channels in order of preference, its last scan, its
pairs by link, what the fallback copies of confirmed recordings hold
(audio bytes through tier links, null with the reason when a channel's
media cannot be read), the releases, and what the transcription and
Speakers lanes skip and hold right now with each reason (the same
computeLeafPending the console polls). `copies-scan` enqueues the scan;
`copies-release` is the one writer of a group's releases, with undo.
COMMANDS.md, SETTINGS.md and settings.json.example regenerated; an
editor CHANGELOG bullet.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
10 files changed, 310 insertions(+), 0 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -234,6 +234,8 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run)
| `bench-verdicts` | bench-verdicts runs the verdict bench as a bench-verdicts job: {"models": \["…"\], "run"?, "reports"?: \["<article>"\], "window"? (seconds, default 60), "windowMode"? ("seconds" \| "turn": the cited speaker's turn, bounded by the window), "maxUsd"? (default 5), "limit"? (a stratified sample, by the operator's verdict), "itemsFrom"? (an earlier run's exact items; no reports, window, windowMode, limit or dedupe with it), "dedupe"? (true: a claim repeating an earlier one, the same text over the same cited spans, is asked once; default: every claim is asked)} -> {jobId, run}. Every claim of the registry's fact-checks (or of "reports") with the operator's verdict and a citation with cues is asked of each model, one claim per call (the report's title, the claim's section, the claim, its quotes, the transcript in the window; never the findings or the verdict), and scored against the rulings. On draft:local when any model is local (through the GPU arbiter; unloaded at the end), else draft:api; the run stops at maxUsd, and an API run is refused past caps.daily. A "run" that exists continues with this call's models only (answered pairs are skipped; refused under another prompt version). Results stay local, in .generation/bench/verdicts/<run>/ (umtool's /tools/bench). The log ends with @@bench-verdicts {run, status, items, skipped, spentUsd, stopped?}. | `pnpm ops bench-verdicts --json '{"models":["claude-sonnet-5-5","qwen3:8b"],"maxUsd":5}' --wait` |
| `frame-scan` | frame-scan reads a saved stream's frames for a profile's progress: {"slug", "id", "profile"? ("poker", the default), "everySeconds"? (default settings.generation.frames.everySeconds, 10), "from"?, "to"? (source seconds), "maxFrames"? (5000), "model"? (default the `frames` route's model), "maxUsd"? (default frames.maxUsd, at most caps.max), "hero"? (the hero's screen name, a hint), "framesPerAsk"? (1-8), "crop"? (\[x, y, w, h\] as fractions of the picture: the part read and hashed, e.g. the poker client beside a webcam), "fresh"? (read every frame again: another model or prompt), "evict"?, "rederive"?} -> {jobId, model, queueKey}. The video's saved container is sampled (keyframes, one ffmpeg a half hour) into a frame cache on the channel's media side; near-duplicate frames are skipped; the rest are read by the vision model and the numbers the streamer said are read from the transcript; frame-scan.<profile>.json beside the video gets the readings and the derived series, events, segments and flags (a frame and a spoken number that disagree). On `frames` (API) or draft:local (a local vision model, through the GPU arbiter). The same body again resumes: read frames are never asked again. Refused when the video is not saved (persist-videos first) or past caps.daily; the run stops before an ask that would pass maxUsd. {"evict": true} removes the frame cache and answers at once; {"rederive": true} works the derived timeline out again from the readings the sidecar holds (no model, no frame; refused while a scan of the video runs) and answers {rederived: {before, after, tournaments, eventsByKind}}. The log ends with @@frame-scan {slug, id, profile, file, frames, kept, read, failed, readings, spentUsd, totalUsd, events, tournaments, flags, stopped?}. | `pnpm ops frame-scan --json '{"slug":"demo-channel","id":"dQw4w9WgXcQ","profile":"poker","maxUsd":2}' --wait`<br>`pnpm ops frame-scan --json '{"slug":"demo-channel","id":"dQw4w9WgXcQ","hero":"DemoHero","crop":[0.02,0.1,0.7,0.68],"from":3000,"to":3600}' --wait`<br>`pnpm ops frame-scan --json '{"slug":"demo-channel","id":"dQw4w9WgXcQ","evict":true}'`<br>`pnpm ops frame-scan --json '{"slug":"demo-channel","id":"dQw4w9WgXcQ","rederive":true}'` |
| `mirror-scan` | mirror-scan pairs a mirror channel with the creator it copies: {"slug", "dryRun"?} -> {jobId}. The channel's config names the creator's channels (mirror.of; channel-config's "mirrorOf"); refused without them. Each of the mirror's videos, dated by its recorded date (else its upload date), is matched with the creator's videos uploaded one day before to two after, by title words and duration (the index's records; no media, no network); per video the matches and a status: only-copy (no creator platform has it public), creator-deleted (removed on one platform, public on another), never-uploaded (missing on one platform, public on the rest) or creator-public. The other way: the creator's removed (deleted or private) uploads dated inside the mirror's window, and which the mirror holds. Written to transcripts/mirrors/<slug>.json (private: never published); the channel page's Mirror stage shows it. dryRun writes nothing. The log ends with @@mirror-scan {slug, dryRun, file?, of, missing?, window, videos, matched, byStatus, byPlatform, creatorRemoved: {inWindow, held, byChannel}}. | `pnpm ops mirror-scan --json '{"slug":"demo-vod-archive","dryRun":true}' --wait`<br>`pnpm ops mirror-scan --json '{"slug":"demo-vod-archive"}' --wait` |
+| `copies-scan` | copies-scan pairs a source group's channels video by video: {"group", "dryRun"?} -> {jobId}. The group is settings.sourceGroups' (an ordered list of channels holding the same recordings, the preferred source first; pnpm ops settings sets it). Two videos are candidates when their recorded dates are at most dateWindowDays apart; where both have a cue file their words decide (40 phrases probed, the largest set at one consistent offset: 8 or more confirmed, 4-7 partial, fewer not a pair), and where one has no words agreeing runtimes make a metadata-only pair. No media, no network. Written to transcripts/copies/<group>.json (private: never published), each pair with its link, its evidence and when it was first seen; a scan that finds what the file says leaves it as it was. With the group's lanes on, the transcription and Speakers lanes skip a confirmed copy whose other copy has the work done and hold a metadata-only one (get copies says each one's reason). dryRun writes nothing. The log ends with @@copies-scan {group, dryRun, unchanged, file?, channels, missing?, totals}. | |
+| `copies-release` | copies-release releases copies to their lanes: {"group", "video": "<channel>/<dir>" \| "videos": \[...\], "undo"?, "note"?} -> {group, released}. A released video is queued by its lanes as if it had no source group, whether it was held (a metadata-only match, or waiting on its preferred copy) or skipped; undo takes the release back. Written to transcripts/copies/<group>.releases.json, which the scan never touches. | |
| `report-schedule` | report-schedule keeps a recurring report on a cadence the editor ticks: {"action": "list" \| "create" \| "update" \| "pause" \| "resume" \| "delete" \| "tick-now" \| "reset-triage" \| "learn" \| "unlearn" \| "promote-alias" \| "add-spelling", …}. create takes {"shape": "living" \| "series", "topic", "question"?, "channels", "case"?, "from"?, "terms"?, "regex"?, "cadence" ({"kind": "daily" \| "weekly" \| "every", "at": "HH:MM", "dow"?, "days"?} or "weekly mon 06:00"), "tz"?, "article"? (living), "autoMakeCurrent"? (living), "model"?, "maxUsd"?, "dryRun"?} -> {plan, schedule?}: the plan names the first tick, the model and its cap. A living report is one article kept current: each tick fetches the scope (R4's stage 1) and refreshes it, the new iteration left ready (or made current with autoMakeCurrent); its first tick is its first sweep. A series makes an edition each tick: a new article <series>-<date> over the window since the last edition ("<topic> · week of <date>"); a window the terms (or, with none, any recording) do not match is a quiet edition: recorded, no article, $0. Ticks run as report-tick jobs, one at a time, never on an idle boot, held by the lane's gate (lane report-schedule); a window missed while the editor was down is ONE catch-up tick. A cap refusal ends a tick held-by-cap. update {"id", …} (a new cadence re-plans from now); pause / resume {"id"}; delete {"id", "confirm"?} answers the plan unless confirm is true; tick-now {"id"} -> {jobId} (refused while a tick of it is queued or running); --wait prints the tick's @@report-tick {json}. list {"id"?} answers the schedules with their chip, call and spend, and the lane. A tick whose scan hit a cap (or did not reach a channel) and found nothing ends partial, naming what it did not reach — never quiet. reset-triage {"id", "k"?, "confirm"?} discards a schedule's triage state (its runs from run k on, default all; seen.json, so the next run counts new from its since; the quiet editions they covered): the plan unless confirm is true; refused while a tick runs. learn {"id", "dryRun"?} runs the proposal pass now (R6.3: learned spellings): the triage model lists likely mis-hearings of each name in the terms; each must occur in scope (an uncapped count) and the judge must say, quoting the line, that it means the name, before it joins the candidate query as an escaped literal ("terms + N learned"); the answer is the plan (the names it asks about) and the job (a report-draft job on the triage model's lane); dryRun answers the plan only. A create of a schedule that triages, a change of its terms, and a tick a week after the last pass start one too. unlearn {"id", "spelling"} removes a learned spelling (never learned again). promote-alias {"id", "spelling", "site"?, "confirm"?} writes it as a search alias (global, or the site's), a new alias or a trigger on the one for that name: the plan unless confirm is true. add-spelling {"id", "spelling", "means"} adds a spelling by hand (no model): "means" is one of the names the terms watch; it is counted in scope and its proving line found by code, and kept (source hand) only when it occurs; a removed spelling added by hand is no longer blocked. | `pnpm ops report-schedule --json '{"action":"create","shape":"series","topic":"Co-host updates","channels":["demo-channel"],"cadence":"weekly mon 06:00","dryRun":true}'`<br>`pnpm ops report-schedule --json '{"action":"create","shape":"watch","topic":"Co-host watch","channels":["demo-channel"],"terms":"co-host","cadence":"daily 06:00","dryRun":true}'`<br>`pnpm ops report-schedule --json '{"action":"list"}'`<br>`pnpm ops report-schedule --json '{"action":"tick-now","id":"co-host-updates"}' --wait`<br>`pnpm ops report-schedule --json '{"action":"delete","id":"co-host-updates","confirm":true}'`<br>`pnpm ops report-schedule --json '{"action":"reset-triage","id":"co-host-updates"}'`<br>`pnpm ops report-schedule --json '{"action":"learn","id":"co-host-updates","dryRun":true}'`<br>`pnpm ops report-schedule --json '{"action":"promote-alias","id":"co-host-updates","spelling":"Gothics"}'` |
| `audio-audit` | audio-audit decodes every audio file a channel holds, with error tolerance, and writes the verdict beside it in audio-integrity.json: {"slug" \| "platform" (every channel on it, e.g. "odysee"), "scope"? ("untranscribed", the default: videos with no transcript yet; "all": every video holding audio), "max"? (files decoded across the run), "force"? (decode again a file whose record is still its own)} -> {jobIds, channels, refused}. One audio-audit job per channel on the audio-audit queue: one file at a time machine-wide, at idle I/O priority and nice 19. The verdict is clean, damaged (a gap, or under 98% of the container's duration decodes) or undecodable, with the decoded seconds, the gaps, the file's size and mtime and ffmpeg's version. The same body again resumes (a file whose record matches is skipped). A channel whose media is unreachable is refused; a drive that stops answering mid-run ends that channel's job with the sentence (failed), as do two decodes in a row past their deadline (a minute plus a tenth of the audio's length). Corrupt full sources are left to their retry. Damaged untranscribed files (and their salvage transcripts) are the report's corruptHeldAudio bucket, held out of the transcription lane: retry-bucket {"bucket": "corruptHeldAudio"} refetches them; a transcription of one salvages automatically. Each log ends with @@audio-audit {slug, scope, held, fresh, planned, checked, clean, damaged, undecodable, unmeasured, timedOut, corruptFullSource, stopped?}. | `pnpm ops audio-audit --json '{"platform":"odysee","scope":"untranscribed"}' --wait`<br>`pnpm ops audio-audit --json '{"slug":"demo-odysee","scope":"all","max":50}'` |
| `fetch-chat` | fetch-chat fetches ONE video's live chat replay and nothing else: {"slug", "id"} — the chat-only yt-dlp pass (the channel's cookies, the platform's pace) on the platform's download queue, then live\_chat.cues.json. YouTube only: another platform answers "no chat fetcher for <platform>" (info, no job), as do a chat already here and fresh and a video never live. A pass that finds no replay ends done and says so. A pass the source refuses for the video as members-only or private records that in its availability.json (source fetch); a removal is recorded only by the channel's Check availability. A chat captured while the stream was live is put on the recording's clock (the broadcast's start, or a recording begun "from now" its own start) and its cues say which in "clock". "renormalize": true parses the raw chat already on disk again, fresh or not, with no network — for a chat normalized before that; refused when no raw is here (it never fetches). | `pnpm ops fetch-chat --json '{"slug":"demo-yt","id":"<videoId>"}' --wait`<br>`pnpm ops fetch-chat --json '{"slug":"demo-yt","id":"<videoId>","renormalize":true}' --wait` |
@@ -271,6 +273,7 @@ Usage: pnpm ops <action> [--json '<body>' | --file <path>] [--wait]
pnpm ops get cleanup <slug>
pnpm ops get speakers
pnpm ops get lookouts [<id>]
+ pnpm ops get copies [<group>]
pnpm ops get lookout-run <id> [--run <runId>]
pnpm ops get remote-listing <slug> [--wait-timeout <seconds>]
pnpm ops get transcript <videoId> [--slug <slug>]
@@ -433,6 +436,15 @@ get lookouts [<id>] is the saved lookouts (settings.lookouts, SETTINGS.md):
<id>/), the latest run (when, window, model, calls, seconds, ideas), how
many of that run's ideas have no verdict yet, and the verdicts given.
Reads settings and the store only, never a channel's videos.
+get copies [<group>] is the source groups' copies report (settings.sourceGroups,
+ SETTINGS.md), read only: each group's channels in order of preference,
+ whether the lanes act on it, its last scan (transcripts/copies/<group>.json:
+ when, the totals), its pairs by link (confirmed by text, metadata only,
+ partial, inside one channel), what the fallback copies of confirmed
+ recordings hold (seconds; audio bytes through tier links, null with the
+ reason when a channel's media cannot be read now) and the released videos;
+ and `lanes`: what the transcription and Speakers lanes skip and hold right
+ now, each video with its reason. With <group>, every pair and its evidence.
get lookout-run <id> [--run <runId>] is one lookout's latest run (or the
one named), whole: its window, the selection it read, calls, seconds,
the reading counts (read, reused from fresh notes, failed), its ideas and
diff --git a/SETTINGS.md b/SETTINGS.md
@@ -61,6 +61,7 @@ A copied example PINS every default it spells — including each lane's `autoQue
| [`jobs`](#jobs) | object — see below |
| [`serviceCookies`](#servicecookies) | object — see below |
| [`lookouts`](#lookouts) | object — see below |
+| [`sourceGroups`](#sourcegroups) | `[]` |
| [`privacy`](#privacy) | object — see below |
## `adminTitle`
@@ -1543,6 +1544,32 @@ Default:
}
```
+## `sourceGroups`
+
+Channels that archive the SAME recordings from different sources (lane cross-source-dupes, lib/copies/): each group an ORDERED list of channel slugs, the preferred source first. `pnpm ops copies-scan` pairs the members' videos (recorded date and runtime, then their words) into `transcripts/copies/<id>.json`, never published; `pnpm ops get copies` is the read-only report. With a group, the transcription and Speakers lanes skip a TEXT-CONFIRMED copy whose other copy has the work done, and HOLD a metadata-only one, visibly, until the wait ends or `pnpm ops copies-release` releases it; the copy that already has a transcript keeps it whatever the order. Downloads, files, records and the published sites are untouched, and no time is mapped between copies. Empty = no group, every lane exactly as before. See SourceGroup.
+
+#### `sourceGroups[]`
+
+Per entry — each entry spells its own values.
+
+| Key | Description |
+|---|---|
+| `id` | The group's id: a lowercase slug (`a-z`, `0-9`, `-`, at most 64), the name its scan is kept under (`transcripts/copies/<id>.json`, never published). Omitted: made from `label`. An entry with neither is dropped, and so is a second entry with an id already used. |
+| `label` | What the group is called in the report. Omitted: the id. |
+| `channels` | The member channels' slugs, IN ORDER OF PREFERENCE: the first is the preferred source and gets new work; the rest are fallbacks, kept, synced and downloaded exactly as before. A slug listed twice, or already in an earlier group, is dropped; a group left with fewer than two channels is dropped. A slug this corpus does not hold is ignored when the group is used. |
+| `lanes` | Whether the transcription and Speakers lanes act on the group's pairs: skip a text-confirmed copy whose other copy has the work done, hold a metadata-only one. false = the scan and the report only. Default true. |
+| `waitDays` | How long a held copy waits for its other copy, in days from when the scan first saw the pair; after that it is released by itself while the other copy still has no transcript. Clamped to [0, 365]; default 7. |
+| `dateWindowDays` | The metadata stage: two videos are candidates when their recorded dates (the channel's title rule, else the upload date) are at most this many days apart. Clamped to [0, 7]; default 1. |
+| `durationToleranceSeconds` | The metadata stage: runtimes agree within max(this, `durationToleranceRatio` × the longer). Clamped to [0, 3600]; default 120. |
+| `durationToleranceRatio` | See `durationToleranceSeconds`. Clamped to [0, 0.5]; default 0.02. |
+| `withinChannels` | Also pair copies inside one member channel (one channel holding two upload series of the same streams). Report only: the lanes never act on a pair inside one channel. Default false. |
+
+Default:
+
+```json
+[]
+```
+
## `privacy`
What the editor's and umtool's pages SHOW of this machine (demo epic D4): local paths with the home directory as `~` or masked, the hostname as a fixed word, private sites left out of the pickers, e-mail addresses masked, and the operator's own display aliases in the source mirror's scrub format. Display only — nothing stored, logged, sent to a job or written to a record changes, and copy buttons copy the real path. Every default is today's behaviour: with the block absent or at its defaults the pages are byte-identical. `archilyzer privacy audit` checks the rendered pages against a denylist. Set with `pnpm ops settings --json '{"patch":{"privacy":{"displayPaths":"home"}}}'`. See PrivacySettings and common/lib/privacy/.
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -1,6 +1,20 @@
# Changelog
## [Unreleased]
+- **One stream archived from two sources is transcribed and given speakers once (source groups, slice 1).**
+ - New setting `sourceGroups`, empty by default: an ordered list of channels that hold the same recordings, the
+ preferred source first. `pnpm ops settings --json '{"patch":{"sourceGroups":[{"id":"…","channels":["<preferred>",
+ "<fallback>"]}]}}'`.
+ - `pnpm ops copies-scan --json '{"group":"…"}'` pairs the members' videos by recorded date and runtime, then by their
+ words where both have a cue file, into `transcripts/copies/<group>.json` (never published). Each pair says how it
+ was matched (confirmed by text, metadata only, partial) and its evidence. A second scan that finds nothing new
+ leaves the file as it was.
+ - The transcription and Speakers lanes skip a text-confirmed copy when the other copy's work is done and readable,
+ and hold a metadata-only match, with its reason, until the wait ends (`waitDays`, default 7) or `pnpm ops
+ copies-release` releases it. The copy that already has a transcript keeps it whatever the order. A lane whose
+ only work is held copies says so ("copies-held"), and `pnpm ops get copies` lists each skip and hold.
+ - Downloads, files, records and the published sites are unchanged, and no time is mapped between copies. Removing
+ the group, or a channel from it, restores the lanes at once.
- **umtool: the gap mark's border is the deck's accent colour.**
- The operator picked variant B. The border is drawn in the deck's accent, the colour of the deck's accent rule
and the dots in its source line, at full opacity. The box behind the text is near-black at 90 %, and the text
diff --git a/editor/app/api/ops/_copies.test.ts b/editor/app/api/ops/_copies.test.ts
@@ -0,0 +1,79 @@
+// Run with:
+// pnpm -C editor exec tsx --test "app/api/ops/_copies.test.ts"
+//
+// `pnpm ops get copies`, `pnpm ops copies-scan` and `pnpm ops copies-release`
+// (lane cross-source-dupes, slice 1) against the route handlers over a temp
+// corpus: the refusals before any job, the report, the release. The scan
+// itself is common/controller/copies.test.ts's. Every channel is invented.
+import { test } from "node:test";
+import assert from "node:assert/strict";
+import { mkdir, readFile, writeFile } from "node:fs/promises";
+import path from "node:path";
+import { callGet, callPost, setupOpsCorpus } from "./_testCorpus";
+
+const corpus = await setupOpsCorpus(null);
+const { GET } = await import("./copies/route");
+const { POST: SCAN } = await import("./copies-scan/route");
+const { POST: RELEASE } = await import("./copies-release/route");
+test.after(() => corpus.cleanup());
+
+const GROUP = { id: "stream-copies", channels: ["pref-chan", "mirror-chan"] };
+
+async function channels() {
+ for (const slug of GROUP.channels) {
+ await corpus.writeChannelConfig(slug, { url: `https://www.youtube.com/@${slug.replace(/-/g, "")}` });
+ await mkdir(path.join(corpus.transcripts, "channels", slug, "data"), { recursive: true });
+ }
+}
+
+test("get copies: no group is an empty report; an unknown group is a 404", async () => {
+ await corpus.writeSettings({ minFreeDiskGB: 0 });
+ const r = await callGet(GET!, "http://localhost/api/ops/copies");
+ assert.equal(r.status, 200, JSON.stringify(r.body));
+ assert.deepEqual(r.body.groups, []);
+ assert.deepEqual(r.body.lanes, {});
+ assert.equal((await callGet(GET!, "http://localhost/api/ops/copies?group=nope")).status, 404);
+ assert.equal((await callGet(GET!, "http://localhost/api/ops/copies?other=1")).status, 400);
+});
+
+test("copies-scan refuses before any job: no group, an unknown group, too few channels", async () => {
+ await corpus.writeSettings({ minFreeDiskGB: 0 });
+ assert.equal((await callPost(SCAN!, {})).status, 400);
+ const unknown = await callPost(SCAN!, { group: "stream-copies" });
+ assert.equal(unknown.status, 400);
+ assert.match(unknown.body.error!, /no source group "stream-copies"/);
+ await corpus.writeSettings({ minFreeDiskGB: 0, sourceGroups: [GROUP] });
+ const short = await callPost(SCAN!, { group: "stream-copies" });
+ assert.match(short.body.error!, /needs two of its channels/);
+ assert.equal((await callPost(SCAN!, { group: "stream-copies", extra: 1 })).status, 400);
+ assert.deepEqual(await corpus.listJobIds(), []);
+});
+
+test("get copies with a group, and copies-release writes the one releases file", async () => {
+ await corpus.writeSettings({ minFreeDiskGB: 0, sourceGroups: [GROUP] });
+ await channels();
+ const r = await callGet(GET!, "http://localhost/api/ops/copies?group=stream-copies&pairs=1");
+ assert.equal(r.status, 200, JSON.stringify(r.body));
+ const [g] = r.body.groups as { id: string; scan: unknown; channels: { slug: string; rank: number; inCorpus: boolean }[]; list: unknown[] }[];
+ assert.equal(g.id, "stream-copies");
+ assert.equal(g.scan, null, "no scan yet");
+ assert.deepEqual(g.channels.map((c) => [c.slug, c.rank, c.inCorpus]), [["pref-chan", 0, true], ["mirror-chan", 1, true]]);
+ assert.deepEqual(g.list, []);
+ assert.deepEqual(Object.keys(r.body.lanes as object).sort(), ["backfill", "transcription"]);
+
+ const bad = await callPost(RELEASE!, { group: "stream-copies", video: "no-slash" });
+ assert.equal(bad.status, 400);
+ assert.equal((await callPost(RELEASE!, { group: "other", video: "mirror-chan/m1" })).status, 404);
+ const ok = await callPost(RELEASE!, { group: "stream-copies", videos: ["mirror-chan/m1", "mirror-chan/m2"], note: "listened" });
+ assert.equal(ok.status, 200, JSON.stringify(ok.body));
+ assert.deepEqual(ok.body.released, ["mirror-chan/m1", "mirror-chan/m2"]);
+ const undo = await callPost(RELEASE!, { group: "stream-copies", video: "mirror-chan/m1", undo: true });
+ assert.deepEqual(undo.body.released, ["mirror-chan/m2"]);
+ const file = JSON.parse(await readFile(path.join(corpus.transcripts, "copies", "stream-copies.releases.json"), "utf8"));
+ assert.equal(file.released["mirror-chan/m2"].note, "listened");
+ const again = await callGet(GET!, "http://localhost/api/ops/copies");
+ assert.deepEqual((again.body.groups as { released: string[] }[])[0].released, ["mirror-chan/m2"]);
+ await writeFile(path.join(corpus.transcripts, "copies", "stream-copies.releases.json"), "{broken");
+ const broken = await callGet(GET!, "http://localhost/api/ops/copies");
+ assert.deepEqual((broken.body.groups as { released: string[] }[])[0].released, [], "an unreadable releases file releases nothing");
+});
diff --git a/editor/app/api/ops/copies-release/route.ts b/editor/app/api/ops/copies-release/route.ts
@@ -0,0 +1,41 @@
+import { NextResponse } from "next/server";
+import { getPaths } from "yt-dlp-transcript-common/lib/paths";
+import { getSettings } from "yt-dlp-transcript-common/lib/settings";
+import { COPIES_RELEASE_BODY_KEYS, parseCopiesReleaseBody } from "yt-dlp-transcript-common/controller/copiesScan";
+import { updateCopiesReleases } from "yt-dlp-transcript-common/lib/copies/file-server";
+import { OpsInputError, ops, opsFail } from "../_lib";
+
+export const dynamic = "force-dynamic";
+
+// POST { group, video: "<channel>/<dir>" | videos: [...], undo?, note? }
+// -> { ok, group, released: ["<channel>/<dir>", ...] }
+//
+// A PERSON'S RELEASE (lane cross-source-dupes, slice 1): the transcription
+// and Speakers lanes treat each named video as they did before its source
+// group existed — a held copy (a metadata-only match, or one waiting on its
+// preferred copy) and a skipped one alike are queued again by their lane's
+// own rules. `undo: true` takes the release back. Written to
+// `transcripts/copies/<group>.releases.json`, the one writer, under its lock;
+// the scan never touches it. Synchronous.
+export async function POST(request: Request) {
+ return ops(request, COPIES_RELEASE_BODY_KEYS, async (body) => {
+ let parsed;
+ try {
+ parsed = parseCopiesReleaseBody(body);
+ } catch (e) {
+ throw new OpsInputError((e as Error).message);
+ }
+ const settings = getSettings();
+ if (!settings.sourceGroups.some((g) => g.id === parsed.group)) {
+ return opsFail(
+ `no source group "${parsed.group}" — settings.sourceGroups names ${settings.sourceGroups.map((g) => g.id).join(", ") || "none"}`,
+ 404,
+ );
+ }
+ const file = await updateCopiesReleases(getPaths().transcriptsDir, parsed.group, parsed.videos, {
+ undo: parsed.undo,
+ ...(parsed.note ? { note: parsed.note } : {}),
+ });
+ return NextResponse.json({ ok: true, group: parsed.group, released: Object.keys(file.released) });
+ });
+}
diff --git a/editor/app/api/ops/copies-scan/route.ts b/editor/app/api/ops/copies-scan/route.ts
@@ -0,0 +1,26 @@
+import { getPaths } from "yt-dlp-transcript-common/lib/paths";
+import { getSettings } from "yt-dlp-transcript-common/lib/settings";
+import { COPIES_SCAN_BODY_KEYS, enqueueCopiesScan } from "yt-dlp-transcript-common/controller/copiesScan";
+import { jobResponse, ops } from "../_lib";
+
+export const dynamic = "force-dynamic";
+
+// POST { group, dryRun? } -> { ok: true, jobId }
+//
+// The copies scan (lane cross-source-dupes, slice 1) as a `copies-scan` job
+// on its own queue: a source group's channels (settings.sourceGroups) paired
+// video by video — recorded dates at most `dateWindowDays` apart and runtimes
+// that agree, then the words where both copies have a cue file — into
+// `transcripts/copies/<group>.json`, each pair confirmed (by text), metadata
+// only or partial, with its evidence. No media, no network. A scan that finds
+// what the file already says leaves it as it was. `dryRun: true` reads and
+// matches the same and writes nothing. Refused before any job for an unknown
+// group or one with fewer than two of its channels here. The log ends
+// `@@copies-scan {group, dryRun, unchanged, file?, channels, missing?, totals}`.
+//
+// AN ADAPTER: the refusals are the controller's (controller/copiesScan.ts).
+export async function POST(request: Request) {
+ return ops(request, COPIES_SCAN_BODY_KEYS, async (body) =>
+ jobResponse(await enqueueCopiesScan(body, { paths: getPaths(), settings: getSettings() })),
+ );
+}
diff --git a/editor/app/api/ops/copies/route.ts b/editor/app/api/ops/copies/route.ts
@@ -0,0 +1,46 @@
+import { getPaths } from "yt-dlp-transcript-common/lib/paths";
+import { getSettings } from "yt-dlp-transcript-common/lib/settings";
+import { computeLeafPending } from "yt-dlp-transcript-common/controller/autoRunner";
+import { copiesReport } from "yt-dlp-transcript-common/controller/copiesScan";
+import { COPY_LANES } from "yt-dlp-transcript-common/controller/copiesLane";
+import { opsFail } from "../_lib";
+import { readRoute } from "../_read";
+
+export const dynamic = "force-dynamic";
+
+// GET /api/ops/copies[?group=<id>][&pairs=1] — `pnpm ops get copies [<group>]`
+//
+// THE COPIES REPORT (lane cross-source-dupes, slice 1), read only: each source
+// group (settings.sourceGroups) — its channels in order of preference, whether
+// the lanes act on it, its last scan (`transcripts/copies/<id>.json`: when,
+// the totals), its pairs by link (confirmed by text, metadata only, partial,
+// inside one channel), what the fallback copies of confirmed recordings hold
+// (seconds, and audio bytes through tier links — null with the reason when a
+// channel's media cannot be read now), and the released videos. `pairs=1`
+// adds every pair with its evidence. `lanes` is what the transcription and
+// Speakers lanes skip and hold RIGHT NOW, each video with its reason: the
+// same computeLeafPending the console polls. Writes nothing.
+export async function GET(request: Request) {
+ return readRoute(request, ["group", "pairs"], async (q) => {
+ const settings = getSettings();
+ const group = q.get("group");
+ const pairs = q.get("pairs");
+ if (pairs !== null && pairs !== "1") return opsFail('"pairs" takes 1');
+ if (group !== null && !settings.sourceGroups.some((g) => g.id === group)) {
+ return opsFail(
+ `no source group "${group}" — settings.sourceGroups names ${settings.sourceGroups.map((g) => g.id).join(", ") || "none"}`,
+ 404,
+ );
+ }
+ const paths = getPaths();
+ const groups = await copiesReport(paths, settings, { group, pairs: pairs === "1" });
+ const lanes: Record<string, unknown> = {};
+ if (settings.sourceGroups.some((g) => g.lanes)) {
+ for (const lane of COPY_LANES) {
+ const r = await computeLeafPending(lane, paths);
+ lanes[lane] = r.copies ?? { skipped: 0, held: 0, head: [] };
+ }
+ }
+ return { groups, lanes };
+ });
+}
diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs
@@ -371,6 +371,10 @@ const GETTERS = {
// The saved lookouts (settings.lookouts) and what the store holds for each:
// the latest run, how many of its ideas wait for a verdict.
lookouts: (id) => (id ? `/api/ops/lookouts?id=${encodeURIComponent(id)}` : "/api/ops/lookouts"),
+ // The source groups' copies report (settings.sourceGroups, lane
+ // cross-source-dupes): each group's scan, pairs and what the lanes skip and
+ // hold now; with a group id, that group and every pair with its evidence.
+ copies: (group) => (group ? `/api/ops/copies?group=${encodeURIComponent(group)}&pairs=1` : "/api/ops/copies"),
// One lookout's latest run (or the one --run names) whole — its window, the
// selection it read, calls, seconds, ideas, what was dropped — and its run
// queued or running now.
@@ -436,6 +440,7 @@ const GET_ARG_OPTIONAL = new Set([
"render-mode",
"speakers",
"lookouts",
+ "copies",
]);
// The flags each noun takes beyond the shared ones; any other is refused.
@@ -789,6 +794,12 @@ const ACTIONS = [
// creator's channels its config's mirror.of names ({slug, dryRun?}), into
// transcripts/mirrors/<slug>.json, as a mirror-scan job.
"mirror-scan",
+ // SOURCE GROUPS (lane cross-source-dupes): a group's channels paired video
+ // by video into transcripts/copies/<group>.json ({group, dryRun?}), as a
+ // copies-scan job; and a held or skipped copy released to its lanes again
+ // ({group, video | videos, undo?, note?}), synchronous.
+ "copies-scan",
+ "copies-release",
// RECURRING REPORTS (umtool R5): a living report or a dated series on a
// cadence the editor keeps ({action: list | create | update | pause |
// resume | delete | tick-now | reset-triage, …}); tick-now is a
@@ -854,6 +865,9 @@ export const FRAME_SCAN_RESULT_MARKER = "@@frame-scan ";
// The same for a mirror scan (MIRROR_SCAN_RESULT_MARKER in
// common/controller/mirrorScan.ts).
export const MIRROR_SCAN_RESULT_MARKER = "@@mirror-scan ";
+// The same for a copies scan (COPIES_SCAN_RESULT_MARKER in
+// common/controller/copiesScan.ts).
+export const COPIES_SCAN_RESULT_MARKER = "@@copies-scan ";
// The same for a remote listing (REMOTE_LISTING_RESULT_MARKER in
// common/controller/remoteListing.ts).
export const REMOTE_LISTING_RESULT_MARKER = "@@remote-listing ";
@@ -1127,6 +1141,7 @@ export function parseArgs(argv) {
...(action === "bench-verdicts" ? { resultMarker: BENCH_VERDICTS_RESULT_MARKER } : {}),
...(action === "frame-scan" ? { resultMarker: FRAME_SCAN_RESULT_MARKER } : {}),
...(action === "mirror-scan" ? { resultMarker: MIRROR_SCAN_RESULT_MARKER } : {}),
+ ...(action === "copies-scan" ? { resultMarker: COPIES_SCAN_RESULT_MARKER } : {}),
...(action === "lookout-run" ? { resultMarker: LOOKOUT_RUN_RESULT_MARKER } : {}),
...(action === "find-clips" ? { resultMarker: FIND_CLIPS_RESULT_MARKER } : {}),
...(action === "live-clip" ? { resultMarker: LIVE_CLIP_RESULT_MARKER } : {}),
@@ -1226,6 +1241,7 @@ export function usage() {
" pnpm ops get cleanup <slug>",
" pnpm ops get speakers",
" pnpm ops get lookouts [<id>]",
+ " pnpm ops get copies [<group>]",
" pnpm ops get lookout-run <id> [--run <runId>]",
" pnpm ops get remote-listing <slug> [--wait-timeout <seconds>]",
" pnpm ops get transcript <videoId> [--slug <slug>]",
@@ -1390,6 +1406,15 @@ export function usage() {
" <id>/), the latest run (when, window, model, calls, seconds, ideas), how",
" many of that run's ideas have no verdict yet, and the verdicts given.",
" Reads settings and the store only, never a channel's videos.",
+ "get copies [<group>] is the source groups' copies report (settings.sourceGroups,",
+ " SETTINGS.md), read only: each group's channels in order of preference,",
+ " whether the lanes act on it, its last scan (transcripts/copies/<group>.json:",
+ " when, the totals), its pairs by link (confirmed by text, metadata only,",
+ " partial, inside one channel), what the fallback copies of confirmed",
+ " recordings hold (seconds; audio bytes through tier links, null with the",
+ " reason when a channel's media cannot be read now) and the released videos;",
+ " and `lanes`: what the transcription and Speakers lanes skip and hold right",
+ " now, each video with its reason. With <group>, every pair and its evidence.",
"get lookout-run <id> [--run <runId>] is one lookout's latest run (or the",
" one named), whole: its window, the selection it read, calls, seconds,",
" the reading counts (read, reused from fresh notes, failed), its ideas and",
@@ -3006,6 +3031,29 @@ export function usage() {
" with @@mirror-scan {slug, dryRun, file?, of, missing?, window, videos,",
" matched, byStatus, byPlatform, creatorRemoved: {inWindow, held, byChannel}}.",
"",
+ 'copies-scan pairs a source group\'s channels video by video: {"group",',
+ ' "dryRun"?} -> {jobId}. The group is settings.sourceGroups\' (an ordered',
+ " list of channels holding the same recordings, the preferred source first;",
+ " pnpm ops settings sets it). Two videos are candidates when their recorded",
+ " dates are at most dateWindowDays apart; where both have a cue file their",
+ " words decide (40 phrases probed, the largest set at one consistent offset:",
+ " 8 or more confirmed, 4-7 partial, fewer not a pair), and where one has no",
+ " words agreeing runtimes make a metadata-only pair. No media, no network.",
+ " Written to transcripts/copies/<group>.json (private: never published),",
+ " each pair with its link, its evidence and when it was first seen; a scan",
+ " that finds what the file says leaves it as it was. With the group's lanes",
+ " on, the transcription and Speakers lanes skip a confirmed copy whose other",
+ " copy has the work done and hold a metadata-only one (get copies says each",
+ " one's reason). dryRun writes nothing. The log ends with @@copies-scan",
+ " {group, dryRun, unchanged, file?, channels, missing?, totals}.",
+ "",
+ 'copies-release releases copies to their lanes: {"group", "video":',
+ ' "<channel>/<dir>" | "videos": [...], "undo"?, "note"?} -> {group,',
+ " released}. A released video is queued by its lanes as if it had no source",
+ " group, whether it was held (a metadata-only match, or waiting on its",
+ " preferred copy) or skipped; undo takes the release back. Written to",
+ " transcripts/copies/<group>.releases.json, which the scan never touches.",
+ "",
'report-schedule keeps a recurring report on a cadence the editor ticks:',
' {"action": "list" | "create" | "update" | "pause" | "resume" | "delete" |',
' "tick-now" | "reset-triage" | "learn" | "unlearn" | "promote-alias" |',
diff --git a/scripts/archilyzer-ops.test.mjs b/scripts/archilyzer-ops.test.mjs
@@ -8,6 +8,7 @@ import test from "node:test";
import {
FIND_CLIPS_RESULT_MARKER,
LOOKOUT_RUN_RESULT_MARKER,
+ COPIES_SCAN_RESULT_MARKER,
REMOTE_LISTING_RESULT_MARKER,
TRANSCRIBE_RESULT_MARKER,
TTS_RESULT_MARKER,
@@ -1192,3 +1193,18 @@ test("watch-trending posts its body; its help says a watch runs only on a fresh
assert.match(usage(), /none while a trending read or capture of ANY\n\s+library waits its turn/);
assert.match(usage(), /pause it until the operator switches it on again/);
});
+
+// Lane cross-source-dupes: the copies scan is a job whose --wait prints its
+// result line, the release a synchronous POST, the report a read.
+test("copies-scan and copies-release are POSTs; get copies reads the report, one group with its pairs", () => {
+ const scan = parseArgs(["copies-scan", "--json", '{"group":"stream-copies","dryRun":true}', "--wait"]);
+ assert.equal(scan.path, "/api/ops/copies-scan");
+ assert.equal(scan.resultMarker, COPIES_SCAN_RESULT_MARKER);
+ assert.equal(COPIES_SCAN_RESULT_MARKER, "@@copies-scan ");
+ const release = parseArgs(["copies-release", "--json", '{"group":"stream-copies","video":"mirror-chan/m1"}']);
+ assert.equal(release.path, "/api/ops/copies-release");
+ assert.deepEqual(release.body, { group: "stream-copies", video: "mirror-chan/m1" });
+ assert.equal(parseArgs(["get", "copies"]).path, "/api/ops/copies");
+ assert.equal(parseArgs(["get", "copies", "stream-copies"]).path, "/api/ops/copies?group=stream-copies&pairs=1");
+ assert.match(usage(), /get copies \[<group>\]/);
+});
diff --git a/settings.json.example b/settings.json.example
@@ -423,6 +423,7 @@
"afterSync": false,
"items": []
},
+ "sourceGroups": [],
"privacy": {
"displayPaths": "full",
"hideHost": false,