# Cookie refresh alerts — one state per service, one banner on the dashboard Operator, 2026-10-21 (after Rumble embeds 403'd mid-fetch and cleared once rumble.com was opened in Firefox): "make this state a first class feature for all sources that shows an alert on the dash that cookies need to be refreshed for that service, either rumble, odysee, or KF". ## What happened (the case this answers) A `fetch-windows` job for the Huck timeline stopped twice with `stopped: network`. Rumble answered `[RumbleEmbed] : Unable to download JSON metadata: HTTP Error 403: Forbidden` on some embeds and not others. Nothing in the editor said why; the fix was the operator opening rumble.com in Firefox (fresh `cf_clearance`), after which the same windows fetched. Today `classifyDownloadFailure` files a bare 403 as "network" (`common/lib/availability.ts`), the backoff stores only `{until, fails}` (`common/jobs/platformBackoff.ts`), and the Kiwi Farms block lives per channel (`needsCookies` in `fetchPosts.ts`) — no service-level "your session is stale". ## Shape **State** — a service-keyed record, its own small file `/.service-sessions.json` (`common/lib/serviceSessions.ts`, atomic write, coerce-tolerant): `{ [service]: { since, lastSeen, count, kind: "embed-403"|"bot-check"|"challenge"|"check-page", evidence: {jobId?, channel?, videoId?, line}, clearedAt? } }`. Services: `rumble`, `youtube`, `odysee`, `kiwifarms` (any xenforo host, keyed by host), `archive.today`. Not "hold", not `needsCookies`, not "session" alone (naming hazards: all taken). **Signals** (a classifier beside `isBotCheck` in `availability.ts`, exported, unit-tested on real stderr): - Rumble: the RumbleEmbed JSON-metadata 403, on 2 different videos in a row (a removed page 403s too — one is not enough). Odysee: its Cloudflare 403/"Just a moment" signature (collect a real sample first; if none exists yet, ship the hook with the YouTube/Rumble ones and add Odysee's pattern when one is seen). - YouTube: the bot check ("Sign in to confirm you're not a bot") — today a rate_limit; also record it here. - Kiwi Farms / xenforo: `classifyForumPage` → `challenge` (already `needsCookies=true` per channel) → also the service record. - archive.today: `ArchiveRefusal "challenge"` → the record, its action "Connect archive session" (existing flow). **Clearing** — automatic on the next clean request for that service: `recordPlatformClean` (`common/jobs/downloadBackoff.ts`) and the forum/archive success paths; manual "Dismiss" too. A cleared alert keeps `clearedAt` for a day so the dashboard can say "Rumble cookies OK again — re-run the 2 jobs it stopped". **Surfaces** - Dashboard (`DashboardCockpit`, top slot like `FirstRunPanel`): a banner per stale service — "Rumble needs fresh cookies: open rumble.com in Firefox (2 embed 403s since 17:02, job fetch-windows …)" with **Recheck** (one cheap probe request through the service's own path; clears on success) and **Re-run stopped jobs** (the jobs the alert stopped, via job retry) once clear. New view `cookieAlerts` (`common/views/cookieAlerts.ts`, `VIEW_NAMES`, `/api/view`), polled SLOW. - A failing job's log line names it: "stopped: Rumble cookies look stale — open rumble.com in Firefox, then Recheck". - `archilyzer doctor`: a "service cookies" section; `pnpm ops get services` (read) and `pnpm ops recheck-service {"service"}` (COMMANDS.md regenerated). - The channel page's existing per-channel `needsCookies` stays; it links to the service banner. ## Tests and gates Unit: classifier on captured stderr (Rumble embed 403 vs removed-page 403, YouTube bot check, KF challenge HTML, 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` (8: 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), `common/controller/recheckServiceCookies.test.ts` (3: Rumble's probe argv and both answers, a forum page, archive.today), `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). - Found on the way (e2e): a job started at once inside a server action whose page then re-rendered threw from its own `safeRevalidate` ("used revalidatePath … during render") after its work was done, and ended `failed` — the re-run batch did. `editor/app/lib/safeRevalidate.ts` now skips that like a missing store (+ unit test); the cookie actions do not revalidate at all. ## X's banner and the timer (2026-10-31, branch `lane/cookie-alerts-1031`) Operator, 23:35: "add banner cookie refresh indicator for X like we have for Rumble and also make Rumble trigger on a timer so we can be more proactive." - **X like Rumble.** X was already a service (plans/pacing-guard.md), but its banner rose only on a challenge; an X job refused for an old jar said so only in its own error. Now the fresh-jar refusal raises X's banner (kind `jar-age`, "press Refresh cookies (or Connect X account) on /settings — with the browser login, open x.com in "), with the jar's age read from disk under it; it does not itself refuse X jobs, clears when a job passes on a fresh jar, and Recheck re-reads the age (no request). gallery-dl's lines are classified in `social/xGalleryDlSignals.ts`: AuthRequired / AuthenticationError / "Could not authenticate you" / 401 / API 403 / a locked account = `auth-failure` (blocking, worded "a login failure"); 429 / rate limit = pacing, never an alert; protected / blocked / suspended / NSFW / a twimg.com media 403 = one account, not the login (before, "authorization" and a bare "403" substring raised the blocking alert for these). - **Rumble on a timer.** `controller/serviceCookieTimer.ts`, `settings.serviceCookies` (180 min, 0 off, `probeServices: ["rumble"]`). One tick: X's jar re-read (X jobs queued on an old jar raise jar-age); every raised alert with something to ask rechecked once; each probe service idle for the interval asked once for its last clean video — a Rumble 403 confirmed once on `lastGood.prev` (a different video) ≥ 1 min (jittered) later, two different videos raise it. Skipped while a job is queued or running on `platform:

` / `clips:

`, while cooling or held, while a recheck runs, or when the service answered cleanly within the interval. Never retried. Not on an idle boot or the e2e test server. Decisions: - jar-age is raised on DEMAND (a refused X job, or X jobs queued), not whenever the jar is past the limit: X work is manual and the jar is refreshed only for a session, so an always-on banner would be up nearly always and learned to be ignored. - The browser login's age (Firefox's auth_token `lastAccessed`) is SHOWN (`get services` → `x`, and the timer raises jar-age on it when X jobs are queued), but the fresh-jar rule still does not refuse on it — that rule's scope (profile only) is unchanged. - A Rumble probe that 403s on the last clean video makes a SECOND request (the previous, different clean video) rather than raising on one — the two-videos rule stands; that is the most a tick asks of one service.