Archilyzer · Source

archilyzer

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

commit 1fe254be46893ad4052ab6b0f426c7dc425057a8
parent 5f6da8bbf166617253b9ff4fec3b1bc59bf4c1c6
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 21 Oct 2026 18:09:34 -0400

cookie alerts: only replayable jobs are offered for re-run, a Recheck's own job is never recorded; ops tests; the plan's Shipped record

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mcommon/lib/serviceCookies-server.ts | 4+++-
Meditor/app/api/ops/_writes.test.ts | 15+++++++++++++++
Meditor/app/lib/cookieAlerts.ts | 11++++++++---
Mplans/FACTS.md | 5+++--
Mplans/cookie-refresh-alerts.md | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Mscripts/archilyzer-ops.test.mjs | 14++++++++++++++
6 files changed, 92 insertions(+), 6 deletions(-)

diff --git a/common/lib/serviceCookies-server.ts b/common/lib/serviceCookies-server.ts @@ -91,7 +91,9 @@ export async function noteServiceCookieSignal( ctx: Omit<SignalContext, "jobId" | "jobKind"> = {}, opts: { now?: number; browser?: string } = {}, ): Promise<NoteSignalResult | null> { - const job = currentJobContext(); + // A Recheck's own job is not one the alert stopped: it is the question. + const ctxJob = currentJobContext(); + const job = ctxJob?.kind === "recheck-service-cookies" ? undefined : ctxJob; try { const res = await mutate( paths, diff --git a/editor/app/api/ops/_writes.test.ts b/editor/app/api/ops/_writes.test.ts @@ -98,6 +98,21 @@ test("clear-platform-hold refuses a name that is not a platform", async () => { assert.equal(none.status, 400); }); +test("the cookie alert's three writes refuse a name that is not a service; rerun refuses a service with no alert", async () => { + for (const name of ["recheck-service", "dismiss-service", "rerun-service-jobs"]) { + const res = await callPost(await route(name), { service: "you tube/../x" }); + assert.equal(res.status, 400, name); + assert.match(String(res.body.error), /^Not a service: /, name); + const none = await callPost(await route(name), {}); + assert.equal(none.status, 400, name); + const extra = await callPost(await route(name), { service: "rumble", platform: "rumble" }); + assert.equal(extra.status, 400, name); + } + const rerun = await callPost(await route("rerun-service-jobs"), { service: "rumble" }); + assert.equal(rerun.status, 400); + assert.match(String(rerun.body.error), /^Rumble has no cookie alert\./); +}); + test("workers: the op and the ids are checked at the door", async () => { const workers = await route("workers"); const op = await callPost(workers, { op: "restart", ids: ["a"] }); diff --git a/editor/app/lib/cookieAlerts.ts b/editor/app/lib/cookieAlerts.ts @@ -25,12 +25,17 @@ export async function loadCookieAlerts( if (!e.raisedAt) continue; for (const j of e.jobs) ids.add(j.id); } + // Only a job that can be retried (it carries a replay descriptor) is one + // "Re-run stopped jobs" can offer: a lane's unit or a one-off without a spec + // has no status here, so it is never listed as stopped. const statuses = new Map<string, string>(); const registry = getRegistry(); for (const id of ids) { - const live = registry.get(id)?.status; - const status = live ?? (await readJobMeta(paths, id))?.status; - if (status) statuses.set(id, status); + const live = registry.get(id); + const meta = live ? null : await readJobMeta(paths, id); + const status = live?.status ?? meta?.status; + const replayable = Boolean(live?.spec ?? meta?.spec); + if (status && replayable) statuses.set(id, status); } return buildServiceCookieAlerts(state, { now, diff --git a/plans/FACTS.md b/plans/FACTS.md @@ -11521,8 +11521,9 @@ parsed to 0 cues, indexing the video textless) is CLOSED by `200a3105` (transcri runs `fn` inside `runInJobContext({jobId, kind, channelSlug?, onLog, staleServices})`. The recorder adds the job to the entry's `jobs` and, once the alert is up, writes `serviceStoppedLine` into that job's log once per service (`stopped: Rumble cookies look stale — open rumble.com in <browser>…, then Recheck on the dashboard.`); a job that - then FAILS repeats it after its `[error]` line. "Stopped jobs" = the entry's jobs whose status (registry, else - `.meta.json`) is failed or cancelled. + then FAILS repeats it after its `[error]` line. "Stopped jobs" = the entry's jobs that carry a replay descriptor + (`spec`) and whose status (registry, else `.meta.json`) is failed or cancelled. A `recheck-service-cookies` job is + never recorded against the alert. - **Recheck** (`common/controller/recheckServiceCookies.ts`, job kind `recheck-service-cookies` on queue `service-cookies:<service>`): yt-dlp services → `recheckYtdlpArgs` (`--skip-download --print id`, the channel's `channelExtraArgs` with `authRetryCookies`, the window fetch's refusals after them) for `lastGood`, else the diff --git a/plans/cookie-refresh-alerts.md b/plans/cookie-refresh-alerts.md @@ -51,3 +51,52 @@ Unit: classifier on captured stderr (Rumble embed 403 vs removed-page 403, YouTu archive.today check page); state coerce/clear; two-in-a-row rule. Editor e2e: a fake yt-dlp that 403s twice → banner appears with the right text → Recheck with the fake now succeeding → banner clears, "re-run" offered. Docs: OPERATING.md (recipe), FACTS. Full gates + editor restart (operator rule: no ask, mind the memory gate). + +## Shipped (2026-10-21, branch `lane/cookie-alerts`) + +What: a cookie refresh alert per service — Rumble, YouTube, Odysee, archive.today and each forum host — raised +where the app already meets the service, shown as a banner at the top of the dashboard with Recheck, Dismiss and +(once clear) Re-run stopped jobs; the stopped job's log names the cause and the fix; `archilyzer doctor` has a +"service cookies" section; `pnpm ops get services`, `recheck-service`, `dismiss-service`, `rerun-service-jobs`. + +Files: +- `common/lib/serviceCookies.ts` (pure: signal classifier, rules, coercion, the view builder, the sentences), + `common/lib/serviceCookies-server.ts` (the file, the locked writer, the yt-dlp / forum / archive.today hooks), + `common/lib/jobContext.ts` (the running job as an AsyncLocalStorage; `runManagedFunction` wraps every `fn`). +- Hooks: `ytdlp/runOneYtdlp.ts` (`observe`), its callers `downloadOneManaged`, `fetchWindowManaged`, + `fetchCopyManaged`, `refreshVideoMetadata`, `fetchLiveChat`; `metadataScan`, `checkAvailability`, `runYtdlp`'s + enumeration; `controller/fetchPosts.ts`; `lib/archives/archiveTodayClient.ts` (`observe` dep) + + `lib/archives/index.ts`; Connect forum/archive session actions. +- `common/controller/recheckServiceCookies.ts` + job kind `recheck-service-cookies`. +- Editor: `app/lib/cookieAlerts.ts`, view `cookieAlerts`, `components/dashboard/CookieAlertsPanel.tsx`, + `operations/serviceCookiesActions.ts`, `api/ops/{services,recheck-service,dismiss-service,rerun-service-jobs}`; + the forum channel panel's needsCookies note links the dashboard. `bin/doctor.ts` "service cookies". +- Docs: OPERATING.md ("Cookies gone stale"), COMMANDS.md (regenerated), plans/FACTS.md, editor CHANGELOG. + +Tests: `common/lib/serviceCookies.test.ts` (15: the real Rumble samples — `lib/__fixtures__/rumble-*.log`, scrubbed — +the two-videos rule, a removed page's and a media 403, the same video twice, the streak broken by a clean request, +the pending TTL, YouTube's bot check, Odysee with and without Cloudflare's words, clearing/pruning, coercion, the +view), `common/lib/serviceCookies-server.test.ts` (10: the job's log line, the yt-dlp hook both ways, no-op writes, +the lock, a torn file, Kiwi Farms' challenge page, archive.today's check page through the client and its fake, +dismiss/rerun, Recheck for Rumble and a forum), `bin/doctor.test.ts`, `scripts/archilyzer-ops.test.mjs`, +`editor/app/api/ops/_writes.test.ts`, `editor/app/api/view/[name]/route.test.ts`, and e2e +`editor/e2e/cookie-alerts.spec.ts` (fake yt-dlp `embed403` → two 403s → banner → Recheck stale → fresh cookies → +Recheck clean → "OK again — re-run the 1 job it stopped" → Re-run → the batch finishes `done`). + +Decisions (where the plan was refined against the code): +- The file is `.service-cookies.json` and the module `serviceCookies`, not `serviceSessions` — "session" is taken + (forum/archive/X sessions). The view is `cookieAlerts`, as planned. +- The yt-dlp signal is observed in `runOneYtdlp` (every single-video yt-dlp run, opt-in per caller), not at the + `recordDownloadBackoff` call sites — those do not carry stderr. `classifyDownloadFailure` is unchanged: the embed + 403 is still a `network` failure for the backoff; the alert is additional. +- The two-in-a-row rule is kept ACROSS jobs in the state (a pending entry with its distinct videos), not inside + fetch-windows' own streak, so a download lane meeting the 403 on two units raises it too. One video refused twice + (prefetch + download) counts once. +- Clearing: any clean request to the service clears it (`clearedBy: clean`), Recheck (`recheck`), Dismiss + (`dismiss`), a Connect that ended on a cleared page (`connect`). A successful Recheck of a yt-dlp service also + settles the platform's backoff (`recordPlatformClean`), else the re-run would be refused by the cooldown the 403 + streak left. +- "Stopped jobs" = the alert's recorded jobs that carry a replay descriptor and ended failed or cancelled; a + Recheck's own job is never recorded. "OK again" stays a day while there are jobs to re-run, else 15 min. +- Odysee: no real sample exists; the hook needs a 403 AND Cloudflare's challenge words. Widen it when one is seen. +- The forum signal comes from fetchPosts' walk only (not the post capture's login wall). diff --git a/scripts/archilyzer-ops.test.mjs b/scripts/archilyzer-ops.test.mjs @@ -824,6 +824,20 @@ test("the archival writes are POSTs to their routes, each named in the usage", ( assert.match(usage(), /"publish", "enabled"\?, "held"\?, "action"\?/); }); +// COOKIE REFRESH ALERTS: the read side and the banner's three buttons. +test("get services is a GET on its route; recheck/dismiss/rerun are POSTs named in the usage", () => { + const g = parseArgs(["get", "services"]); + assert.equal(g.method, "GET"); + assert.equal(g.path, "/api/ops/services"); + assert.match(usage(), /pnpm ops get services/); + for (const action of ["recheck-service", "dismiss-service", "rerun-service-jobs"]) { + const p = parseArgs([action, "--json", '{"service":"rumble"}']); + assert.equal(p.method, "POST", action); + assert.equal(p.path, `/api/ops/${action}`, action); + assert.match(usage(), new RegExp(`^${action} `, "m"), action); + } +}); + // RELEASE 36 LANE A: the clip finder's chain and one video's chat replay. test("fetch-chat and find-clips are POSTs named in the usage; find-clips --wait carries its marker", () => { for (const action of ["fetch-chat", "find-clips"]) {