Archilyzer · Source

archilyzer

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

commit f4c80ae6906a226d4484051e89521ecb5008a044
parent bad168820c5e4011d050c006b931e51d8a7ac9d9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 11:13:47 -0500

lookouts: ops twins -- cancel a lookout's run by its id, read its last run whole, --wait prints the run's line

- `pnpm ops lookout-run --json '{"id"}'` is Run now (the job, item 1),
  and `--wait` prints its @@lookout-run line (resultMarker).
- `{"id", "cancel": true}` cancels the lookout's queued or running run
  and answers the job ids (`[]` when none); the reading notes it wrote
  are kept, so the next run continues from them. Nothing else rides
  with "cancel".
- `pnpm ops get lookout-run <id> [--run <runId>]` (GET
  /api/ops/lookout-run): the latest run, or the one named, whole --
  window, selection, calls, seconds, reading counts, ideas, what was
  dropped -- null before the first, and the lookout's run queued or
  running now. An unknown lookout or run is a 404, a malformed run id a
  400. --run is a get flag of this noun only.

COMMANDS.md regenerated; CHANGELOG bullets for the run and these twins.

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

Diffstat:
MCOMMANDS.md | 8+++++++-
Meditor/CHANGELOG.md | 1+
Meditor/app/api/ops/_lookouts.test.ts | 34+++++++++++++++++++++++++++++++++-
Meditor/app/api/ops/lookout-run/route.ts | 44++++++++++++++++++++++++++++++++++++++++++--
Mscripts/archilyzer-ops.mjs | 23+++++++++++++++++++++--
Mscripts/archilyzer-ops.test.mjs | 22++++++++++++++++++++++
6 files changed, 126 insertions(+), 6 deletions(-)

diff --git a/COMMANDS.md b/COMMANDS.md @@ -227,7 +227,7 @@ Drives a running editor over HTTP (`/api/ops/*`, the same actions its pages run) | `find-clips` | find-clips runs the clip finder's chain for ONE video as one job: {"slug", "id", "target"? (the cut's seconds), "segment"? (one umtool found, "s2"), "project"? (the umtool project a run makes), "whilePaused"?, "dryRun"?}. Persist the source video, the corpus transcript, word timings (data/&lt;id&gt;/words.json), the chat replay (YouTube), diarization — each step skipped when its output exists, named in the log — then umtool's clip finder (POST UMTOOL\_URL/api/report/clips {mode: "new"}), followed to the end. "whilePaused": true runs this one video past the holds: the two transcriptions during a pause-all on a worker the pause alone switched off, and its diarization in the job when the backfill lane is held. "dryRun": true answers each step's plan and starts nothing. With --wait the result — {project, url, created, segments: \[{id, from, to, why}\], steps} — is printed on stdout. | `pnpm ops find-clips --json '{"slug":"demo-yt","id":"<videoId>","dryRun":true}'`<br>`pnpm ops find-clips --json '{"slug":"demo-yt","id":"<videoId>","target":600}' --wait`<br>`pnpm ops find-clips --json '{"slug":"demo-yt","id":"<videoId>","segment":"s2","whilePaused":true}' --wait` | | `fetch-chat-backlog` | fetch-chat-backlog fetches a channel's stream chats after its downloads: {"slug", "dryRun"?, "limit"?, "queueKey"?} — every held video whose metadata says it was a stream (live\_status was\_live / post\_live) and whose chat is not here, newest first, one at a time through fetch-chat's pass with the batch downloads' gap between two, as one fetch-chat-backlog job on the platform's download queue; a raw replay already here is only normalized. It stops on a rate limit, a held platform, three failures in a row, a drain or "limit" chats; a re-run skips the chats here and the streams known to have none (chat-backlog.json), and a restart resumes it. The download lane queues it by itself (25 a run) for a channel whose "chat" is "later" once it has nothing left to download. "dryRun": true counts from the disk and starts nothing: chats, normalizeOnly, have, settled, notStreams, ids (the first 50). | `pnpm ops fetch-chat-backlog --json '{"slug":"demo-yt","dryRun":true}'` | | `x-run` | x-run fetches several X posts channels IN SEQUENCE as ONE job on X's queue: {"channels": \[slug, ...\]} in that order, each a fetch-posts sync new of at most 200 posts ("limit": N, 1-200, caps it lower), X's queue gap (pacing.jobGapSeconds.twitter) between two channels. Before EACH channel the jar is checked again: once it is past social.x.maxCookieAgeMinutes (or the X alert is up) the run stops and the rest are DEFERRED until the next refresh. It never refreshes the jar: Refresh cookies on /settings, then {"resume": "&lt;run id&gt;"} runs the deferred channels (the console's Resume; a Retry of the job is the same). One run at a time; refused before a job on a stale jar (a new run's channels are kept, deferred). An interrupted run is not resumed on boot: it ends deferred. Answers {jobId, run}; get x-run follows it. The log ends with @@x-run {id, status, stopped?, counts, summary}. | `pnpm ops x-run --json '{"channels":["example-x","other-x"]}'`<br>`pnpm ops x-run --json '{"resume":"xr-01J…"}'` | -| `lookout-run` | lookout-run runs a saved lookout (settings.lookouts), or lists what it would read. {"id", "dryRun": true, "days"?, "maxVideos"?, "until"?: "YYYY-MM-DD"} is the list: every video of its channels whose AIR date (release\_timestamp, else timestamp, in the lookout's timeZone — not the UTC upload\_date) falls in the window; a duplicate upload of one recording, and a stream's cut-down, folded into it (each named, with why and its score); the longest maxVideos recordings read and the rest listed as skipped for the cap; under minSeconds and no transcript yet listed too. A local media library channel or a slug this archive does not hold is named in "refused". Answers {plan: {window, counts, read, skipped, refused, estimate}}: readCalls is one per transcript chunk, priced once a run has been measured. Synchronous, reads text only, writes nothing. Without "dryRun" it is the RUN, a lookout-run job on draft:local: {"id", "days"?, "maxVideos"?, "until"?, "model"?, "maxCalls"?}. The same list, made at the job's turn, read by the local model one chunk a call (every call through the GPU arbiter, after render mode, in the job's model log) into each video's private reading-notes.json; the notes grouped into ideas of at least two located, dated moments; the run written to transcripts/.lookouts/&lt;id&gt;/runs/. A video whose notes are fresh is not read again, so a cancelled run's next start continues where it stopped. maxCalls caps the reading calls (default 400; past it the run ends partial). Refused with lookouts off (settings.lookouts.enabled), the lookout route not local (model names a local one), a run of it already queued or running, a damaged verdicts.json, or under 3 GB of free memory at its turn. --wait prints the log's @@lookout-run line. | `pnpm ops lookout-run --json '{"id":"example-week","dryRun":true}'`<br>`pnpm ops lookout-run --json '{"id":"example-week","dryRun":true,"days":3,"until":"2026-11-10"}'`<br>`pnpm ops lookout-run --json '{"id":"example-week"}' --wait` | +| `lookout-run` | lookout-run runs a saved lookout (settings.lookouts), or lists what it would read. {"id", "dryRun": true, "days"?, "maxVideos"?, "until"?: "YYYY-MM-DD"} is the list: every video of its channels whose AIR date (release\_timestamp, else timestamp, in the lookout's timeZone — not the UTC upload\_date) falls in the window; a duplicate upload of one recording, and a stream's cut-down, folded into it (each named, with why and its score); the longest maxVideos recordings read and the rest listed as skipped for the cap; under minSeconds and no transcript yet listed too. A local media library channel or a slug this archive does not hold is named in "refused". Answers {plan: {window, counts, read, skipped, refused, estimate}}: readCalls is one per transcript chunk, priced once a run has been measured. Synchronous, reads text only, writes nothing. Without "dryRun" it is the RUN, a lookout-run job on draft:local: {"id", "days"?, "maxVideos"?, "until"?, "model"?, "maxCalls"?}. The same list, made at the job's turn, read by the local model one chunk a call (every call through the GPU arbiter, after render mode, in the job's model log) into each video's private reading-notes.json; the notes grouped into ideas of at least two located, dated moments; the run written to transcripts/.lookouts/&lt;id&gt;/runs/. A video whose notes are fresh is not read again, so a cancelled run's next start continues where it stopped. maxCalls caps the reading calls (default 400; past it the run ends partial). Refused with lookouts off (settings.lookouts.enabled), the lookout route not local (model names a local one), a run of it already queued or running, a damaged verdicts.json, or under 3 GB of free memory at its turn. --wait prints the log's @@lookout-run line. {"id", "cancel": true} cancels its queued or running run (answers the job ids; the notes read so far are kept). | `pnpm ops lookout-run --json '{"id":"example-week","dryRun":true}'`<br>`pnpm ops lookout-run --json '{"id":"example-week","dryRun":true,"days":3,"until":"2026-11-10"}'`<br>`pnpm ops lookout-run --json '{"id":"example-week"}' --wait`<br>`pnpm ops lookout-run --json '{"id":"example-week","cancel":true}'` | ### Usage, flags and environment @@ -254,6 +254,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 lookout-run <id> [--run <runId>] pnpm ops get remote-listing <slug> [--wait-timeout <seconds>] pnpm ops get transcript <videoId> [--slug <slug>] pnpm ops get coverage <slug> @@ -352,6 +353,11 @@ 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 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 + what was dropped and why; null before the first. With it, the lookout's + run queued or running now ({jobId, status}). get cleanup <slug> is one channel's /cleanup row: what each sweep would reclaim (they overlap — never add them), what holds the rest, and the failed-transcriptions count. measured: false means unknown, not zero. diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## [Unreleased] +- **A lookout run can be cancelled by the lookout's name, and its last run read whole.** `pnpm ops lookout-run --json '{"id":"…","cancel":true}'` cancels that lookout's queued or running run (the reading notes it wrote are kept, so the next run picks up from them), and `pnpm ops get lookout-run <id> [--run <runId>]` shows the latest run, or the one named: its window, what it read, the calls and seconds, how much was read now or reused, the ideas, and what was dropped and why — with the run of that lookout running now, if any. `--wait` on a run prints its result line. - **Lookouts run: the local model reads what the dry run lists and answers with video ideas, and a stopped run continues where it stopped.** `pnpm ops lookout-run --json '{"id":"…"}'` (no `dryRun`) is a `lookout-run` job on the local model's queue: it makes the same list the dry run shows at its turn and reads exactly that, one call per transcript chunk. What the model finds is kept in a private `reading-notes.json` beside each video's transcript, written after every call, so a cancelled or interrupted run's next start reads only what is left, and a week already read is not read again. Every quote is found word for word in the transcript by code, or dropped; the notes are grouped into ideas of at least two dated moments, with an idea that cites an invented moment, only one, or none dropped and counted; a moment the model thinks is read aloud or a played clip becomes a caveat to check by ear. The calls wait for transcription and for render mode, are in the job's Model log, and the model is unloaded at the end; the run does not start under 3 GB of free memory, nor while lookouts are off (`settings.lookouts.enabled`, off by default). It runs on the local model only for now (a new `lookout` task in `settings.generation.routes`: local in the balanced and local presets). The run, its ideas and what was dropped are written to `transcripts/.lookouts/<id>/runs/`, never published. - **A local sweep's topic labels and section headings never attribute, a refresh keeps the local sweep's settings, and a revision keeps a speaker-neutral report neutral.** A heading the model wrote was kept unless it held one of a few words, and was never checked against the quotes, so a section could be headed "Main Actress's Comments" over quotes none of them hers, or "Fan Reactions"; a label could still say "acolyte writer blames filon" or "his love of the show" when the quote held those words. A label and a heading are now noun-phrase topics, read word by word against closed lists: no personal or possessive pronoun, no word of saying, thinking, feeling or judging in any of its forms (comments, reaction, response, statement, accusation, criticism, blames, hates, loves, admission, lying, defending, …), no "is / was / has / been" or contracted verb, no person-role in the possessive ("the showrunner's …"), no host's name — and every word found in the section's quotes, labels or titles, or the question. A heading that fails is written by code from its quotes' labels; the question's topic, the fallback label and the report's title, goes through the same rules. A recurring **refresh** of a report on the local route swept the new recordings in the old drafted-sentence form with no read-aloud check; it now uses `generation.localSweep`. A **revision** of a speaker-neutral report keeps its lines code's (a line is not rewritten; an added finding's line is written again from its recording's title and date and its checked topic), refuses a heading, a title or a summary that attributes, and keeps each claim's `check by ear` flag, which it used to lose. In the drafted-sentence form, a quote marked to check by ear is meaning-checked last, so it no longer takes the place of an unmarked one in the check's budget. The read-aloud patterns run in linear time: one of them took over a second on 40 letters of transcript and never returned on 60. In the **Model log**, each of these is said on the call it came from: an extract's quote "dropped: read aloud: <cue>", "kept: … flagged: check by ear (read-aloud cue: …)" or "kept: … label refused: <reason> — the run's topic used"; the grouping's heading "rewritten: heading refused: <reason> — replaced by “…” (written by code)"; a refused topic on the terms call; each meaning check kept, rewritten, dropped or flagged; and a local revision's ops applied or refused with code's reason. - **A local model's sweep no longer says who said it: code writes each finding around the quote, and a quote that may be read aloud is marked to check by ear.** A sweep on the `local` route (a small model on this machine) wrote "Jeremy says …" over words the host was reading out — a tweet, a headline, a review — because nothing in an automatic transcript marks a quotation and a small model cannot tell the reading from the speaking. Its findings are now written by code as `In <recording's title> (<date>), on <topic>: "<quote>"`, with the citation and the link: the model only copies the quote and names its topic in a few words, and a topic that names the speaker, says who thinks what, or uses words found nowhere around the quote is replaced by the question's topic. The report's title is written the same way, and it says where the words are, not whose they are. Before a quote is kept, code also looks at the transcript around it for signs of reading aloud — a tweet, likes and retweets read out, an article or headline being introduced, "it says", "he writes", "according to", a clip, a chat message, the host named in the third person. Such a quote goes to a last section, **To check by ear**, its line starting `Check by ear:` and its claim carrying the flag `check by ear: may be read aloud`; it can be left out instead. The signs are patterns, so a headline read with nothing announcing it is not caught: the section is where to listen first, not a guarantee about the rest. Both are settings (`generation.localSweep.claimForm`: `neutral` or `sentence`, the earlier drafted sentence with its meaning check; `generation.localSweep.readAloud`: `flag`, `drop` or `off`), set with `archilyzer gen local-sweep [--form …] [--read-aloud …]` or on umtool's **Settings → Generation**. Sweeps by Claude (Claude Code or the API) are not changed. diff --git a/editor/app/api/ops/_lookouts.test.ts b/editor/app/api/ops/_lookouts.test.ts @@ -13,7 +13,8 @@ import { callGet, callPost, setupOpsCorpus } from "./_testCorpus"; const corpus = await setupOpsCorpus(null); const { GET } = await import("./lookouts/route"); -const { POST } = await import("./lookout-run/route"); +const { POST, GET: GET_RUN } = await import("./lookout-run/route"); +const { writeLookoutRun } = await import("yt-dlp-transcript-common/lib/lookoutStore"); test.after(() => corpus.cleanup()); const LOOKOUTS = { @@ -102,3 +103,34 @@ test("lookout-run refuses before reading anything: lookouts off, an unknown look assert.equal(none.status, 400); assert.match(String(none.body.error), /names no channels/); }); + +test("get lookout-run: the latest run whole, or the one named; cancel answers the jobs it cancelled", async () => { + await corpus.writeSettings({ minFreeDiskGB: 0, lookouts: LOOKOUTS }); + const none = await callGet(GET_RUN!, "http://localhost/api/ops/lookout-run?id=example-week"); + assert.equal(none.status, 200, JSON.stringify(none.body)); + assert.equal(none.body.run, null); + assert.deepEqual(none.body.running, []); + const run = (runId: string, title: string) => ({ + version: 1, lookoutId: "example-week", runId, startedAt: "2026-11-11T12:00:00.000Z", endedAt: "2026-11-11T12:10:00.000Z", + status: "done" as const, window: { from: "2026-11-09", to: "2026-11-11", days: 3, timeZone: "UTC" }, model: "stub-local:1b", + calls: 3, seconds: 9, selection: null, ideas: [], note: title, + }); + await writeLookoutRun({ transcriptsDir: corpus.transcripts }, run("20261110T120000Z-aaaa", "older")); + await writeLookoutRun({ transcriptsDir: corpus.transcripts }, run("20261111T120000Z-bbbb", "newer")); + const latest = await callGet(GET_RUN!, "http://localhost/api/ops/lookout-run?id=example-week"); + assert.equal((latest.body.run as { note: string }).note, "newer"); + const named = await callGet(GET_RUN!, "http://localhost/api/ops/lookout-run?id=example-week&run=20261110T120000Z-aaaa"); + assert.equal((named.body.run as { note: string }).note, "older"); + assert.equal((await callGet(GET_RUN!, "http://localhost/api/ops/lookout-run?id=example-week&run=20261109T120000Z-cccc")).status, 404); + assert.equal((await callGet(GET_RUN!, "http://localhost/api/ops/lookout-run?id=example-week&run=../x")).status, 400); + assert.equal((await callGet(GET_RUN!, "http://localhost/api/ops/lookout-run?id=nope")).status, 404); + assert.equal((await callGet(GET_RUN!, "http://localhost/api/ops/lookout-run")).status, 400); + assert.equal((await callGet(GET_RUN!, "http://localhost/api/ops/lookout-run?id=example-week&x=1")).status, 400); + + const cancel = await callPost(POST!, { id: "example-week", cancel: true }); + assert.equal(cancel.status, 200, JSON.stringify(cancel.body)); + assert.deepEqual(cancel.body.cancelled, [], "nothing running: nothing cancelled"); + assert.equal((await callPost(POST!, { id: "example-week", cancel: true, days: 2 })).status, 400); + assert.equal((await callPost(POST!, { id: "nope", cancel: true })).status, 404); + assert.deepEqual(await corpus.listJobIds(), []); +}); diff --git a/editor/app/api/ops/lookout-run/route.ts b/editor/app/api/ops/lookout-run/route.ts @@ -4,8 +4,10 @@ import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { isIsoDate } from "yt-dlp-transcript-common/lib/lookout"; import { LOOKOUT_MAX_DAYS, LOOKOUT_MAX_MAX_VIDEOS, lookoutById } from "yt-dlp-transcript-common/lib/lookoutSettings"; import { LookoutPlanRefusal, planLookout } from "yt-dlp-transcript-common/controller/lookoutPlan"; -import { LOOKOUT_MAX_CALLS, enqueueLookoutRun } from "yt-dlp-transcript-common/controller/lookoutRun"; +import { LOOKOUT_MAX_CALLS, cancelLookoutRuns, enqueueLookoutRun, lookoutRunJobs } from "yt-dlp-transcript-common/controller/lookoutRun"; +import { LOOKOUT_RUN_ID_RE, listLookoutRunIds, readLookoutRun } from "yt-dlp-transcript-common/lib/lookoutStore"; import { OpsInputError, jobResponse, ops, opsFail, optBool, optPositiveInt, optString, reqString } from "../_lib"; +import { readRoute } from "../_read"; export const dynamic = "force-dynamic"; @@ -37,12 +39,23 @@ export const dynamic = "force-dynamic"; // before any job: lookouts off (settings.lookouts.enabled), the route not // local, a run of this lookout already queued or running, a damaged // verdicts.json. The log ends `@@lookout-run {id, runId, status, …}`. +// +// POST { id, cancel: true } -> { ok: true, cancelled: [jobId, …] }: the +// lookout's queued or running run is cancelled (the reading notes it wrote +// are kept; the next run continues from them). Nothing to cancel is `[]`. +// +// GET ?id=<lookout>[&run=<runId>] -> { ok: true, run, running } — `pnpm ops +// get lookout-run <id> [--run R]`: the latest run (or the one named) whole — +// window, the selection it read, calls, seconds, reading counts, ideas and +// what was dropped — or null before the first; and the lookout's run queued +// or running now ([{jobId, status}]). const MAX_CALLS = LOOKOUT_MAX_CALLS * 5; export async function POST(request: Request) { - return ops(request, ["id", "dryRun", "days", "maxVideos", "until", "model", "maxCalls"], async (body) => { + return ops(request, ["id", "dryRun", "days", "maxVideos", "until", "model", "maxCalls", "cancel"], async (body) => { const id = reqString(body, "id"); const dryRun = optBool(body, "dryRun") === true; + const cancel = optBool(body, "cancel") === true; const days = optPositiveInt(body, "days"); if (days !== undefined && days > LOOKOUT_MAX_DAYS) throw new OpsInputError(`"days" is at most ${LOOKOUT_MAX_DAYS}`); const maxVideos = optPositiveInt(body, "maxVideos"); @@ -55,11 +68,13 @@ export async function POST(request: Request) { const maxCalls = optPositiveInt(body, "maxCalls"); if (maxCalls !== undefined && maxCalls > MAX_CALLS) throw new OpsInputError(`"maxCalls" is at most ${MAX_CALLS}`); if (dryRun && (model !== undefined || maxCalls !== undefined)) throw new OpsInputError('a dry run calls no model: "model" and "maxCalls" are the run\'s'); + if (cancel && Object.keys(body).some((k) => k !== "id" && k !== "cancel")) throw new OpsInputError('"cancel" takes the lookout\'s "id" alone'); const lookouts = getSettings().lookouts; const item = lookoutById(lookouts, id); if (!item) { return opsFail(`no lookout "${id}" — settings.lookouts.items names ${lookouts.items.map((i) => i.id).join(", ") || "none"}`, 404); } + if (cancel) return NextResponse.json({ ok: true, cancelled: cancelLookoutRuns(item.id) }); if (!dryRun) { const out = await enqueueLookoutRun({ id, days, maxVideos, until, model, maxCalls }, { paths: getPaths() }); if (!out.result.ok || !("model" in out)) return jobResponse(out.result); @@ -75,3 +90,28 @@ export async function POST(request: Request) { } }); } + +export async function GET(request: Request) { + return readRoute(request, ["id", "run"], async (q) => { + const id = q.get("id"); + if (!id) return opsFail('"id" names the lookout: ?id=<lookout>'); + const lookouts = getSettings().lookouts; + if (!lookoutById(lookouts, id)) { + return opsFail(`no lookout "${id}" — settings.lookouts.items names ${lookouts.items.map((i) => i.id).join(", ") || "none"}`, 404); + } + const paths = getPaths(); + const asked = q.get("run"); + if (asked !== null && !LOOKOUT_RUN_ID_RE.test(asked)) return opsFail(`"${asked}" is not a lookout run id`); + let run = null; + if (asked !== null) { + run = await readLookoutRun(paths, id, asked); + if (!run) return opsFail(`lookout "${id}" has no run "${asked}"`, 404); + } else { + for (const runId of await listLookoutRunIds(paths, id)) { + run = await readLookoutRun(paths, id, runId); + if (run) break; + } + } + return { run, running: lookoutRunJobs(id) }; + }); +} diff --git a/scripts/archilyzer-ops.mjs b/scripts/archilyzer-ops.mjs @@ -215,6 +215,8 @@ // pnpm ops lookout-run --json '{"id":"example-week","dryRun":true}' // pnpm ops lookout-run --json '{"id":"example-week","dryRun":true,"days":3,"until":"2026-11-10"}' // pnpm ops lookout-run --json '{"id":"example-week"}' --wait +// pnpm ops lookout-run --json '{"id":"example-week","cancel":true}' +// pnpm ops get lookout-run example-week [--run 20261111T120000Z-1a2b] // // --file reads the BODY from a JSON file, which is how a big one gets sent: a // four-thousand-id tag-videos body is written by a script, not typed by a model @@ -325,6 +327,14 @@ 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"), + // 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. + "lookout-run": (id, { jobs }) => { + const q = new URLSearchParams({ id }); + if (jobs.run) q.set("run", jobs.run); + return `/api/ops/lookout-run?${q.toString()}`; + }, // What a channel holds, by date, and its gaps (release 19 A9): each video // dated by its recorded date when the channel has a title rule, else upload. coverage: (slug) => `/api/ops/coverage?slug=${encodeURIComponent(slug)}`, @@ -384,6 +394,7 @@ const GET_ARG_OPTIONAL = new Set([ // The flags each noun takes beyond the shared ones; any other is refused. const GET_FLAGS = { transcript: ["slug"], + "lookout-run": ["run"], channel: ["counts", "leads", "limit"], job: ["tail"], jobs: ["active", "failed", "kind", "slug", "limit"], @@ -830,8 +841,8 @@ export function parseArgs(argv) { } else if (arg === "--active" || arg === "--failed") { jobs[arg.slice(2)] = true; used.add(arg.slice(2)); - } else if (/^--(kind|slug|limit)(=|$)/.test(arg)) { - const [, key, eq] = /^--(kind|slug|limit)(=?)/.exec(arg); + } else if (/^--(kind|slug|limit|run)(=|$)/.test(arg)) { + const [, key, eq] = /^--(kind|slug|limit|run)(=?)/.exec(arg); const raw = eq ? arg.slice(key.length + 3) : argv[++i]; if (raw === undefined || raw === "") { return { error: `--${key} needs a value` }; @@ -1113,6 +1124,7 @@ export function usage() { " pnpm ops get cleanup <slug>", " pnpm ops get speakers", " pnpm ops get lookouts [<id>]", + " pnpm ops get lookout-run <id> [--run <runId>]", " pnpm ops get remote-listing <slug> [--wait-timeout <seconds>]", " pnpm ops get transcript <videoId> [--slug <slug>]", " pnpm ops get coverage <slug>", @@ -1213,6 +1225,11 @@ 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 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", + " what was dropped and why; null before the first. With it, the lookout's", + " run queued or running now ({jobId, status}).", "get cleanup <slug> is one channel's /cleanup row: what each sweep would", " reclaim (they overlap — never add them), what holds the rest, and the", " failed-transcriptions count. measured: false means unknown, not zero.", @@ -1327,6 +1344,8 @@ export function usage() { " the lookout route not local (model names a local one), a run of it", " already queued or running, a damaged verdicts.json, or under 3 GB of", " free memory at its turn. --wait prints the log's @@lookout-run line.", + ' {"id", "cancel": true} cancels its queued or running run (answers the', + " job ids; the notes read so far are kept).", "", 'render-mode gives a render the operator is waiting for the machine:', ' {"on": true, "for"?: "90m" | <minutes>, "note"?} opens a window (default', diff --git a/scripts/archilyzer-ops.test.mjs b/scripts/archilyzer-ops.test.mjs @@ -7,6 +7,7 @@ import assert from "node:assert/strict"; import test from "node:test"; import { FIND_CLIPS_RESULT_MARKER, + LOOKOUT_RUN_RESULT_MARKER, REMOTE_LISTING_RESULT_MARKER, TRANSCRIBE_RESULT_MARKER, TTS_RESULT_MARKER, @@ -638,6 +639,27 @@ test("capture-posts is a POST to its route, named in the usage", () => { // Lane x-console: the X run is a POST to its route whose --wait prints the // run's result line; `get x-run` reads the console, the latest run or one named. +// A lookout (lane/lookout slice 2): run now and cancel are POSTs to +// lookout-run, the run's result printed by --wait; get lookout-run reads the +// latest run or the one --run names. +test("lookout-run: run, dry run and cancel are POSTs, --wait prints the run's line; get lookout-run reads a run", () => { + const run = parseArgs(["lookout-run", "--json", '{"id":"example-week"}', "--wait"]); + assert.equal(run.method, "POST"); + assert.equal(run.path, "/api/ops/lookout-run"); + assert.deepEqual(run.body, { id: "example-week" }); + assert.equal(run.resultMarker, LOOKOUT_RUN_RESULT_MARKER); + assert.equal(LOOKOUT_RUN_RESULT_MARKER, "@@lookout-run "); + assert.deepEqual(parseArgs(["lookout-run", "--json", '{"id":"example-week","cancel":true}']).body, { id: "example-week", cancel: true }); + assert.equal(parseArgs(["get", "lookout-run", "example-week"]).path, "/api/ops/lookout-run?id=example-week"); + assert.equal( + parseArgs(["get", "lookout-run", "example-week", "--run", "20261111T120000Z-1a2b"]).path, + "/api/ops/lookout-run?id=example-week&run=20261111T120000Z-1a2b", + ); + assert.match(String(parseArgs(["get", "lookout-run"]).error), /lookout-run/); + assert.match(String(parseArgs(["get", "lookouts", "--run", "x"]).error), /--run/); + assert.match(usage(), /get lookout-run <id> \[--run <runId>\]/); +}); + test("x-run is a POST to its route with a result marker; get x-run reads the console", () => { const p = parseArgs(["x-run", "--json", '{"channels":["a-x","b-x"],"limit":50}', "--wait"]); assert.equal(p.method, "POST");