Skip to content

Fetch nothing an ad blocker would refuse, and lighten the dashboard - #18

Merged
antoine-debroye merged 8 commits into
mainfrom
ad/audit-tier5-ui
Oct 9, 2026
Merged

antoine-debroye merged 8 commits into
mainfrom
ad/audit-tier5-ui

Conversation

@antoine-debroye

Copy link
Copy Markdown
Collaborator

Why

Tier 5 of the October audit (doc/audit-2026-10-09.md): U13, U21, U22 (partial), U23 and P9. Stacked on #17. This is the last PR of the audit.

What changed

  • U13 — nothing the pages fetch carries a word an ad blocker matches. 1.9.1 fixed class and id names; the XHR and <audio> paths still said /ad-panel, /ad-detect, /adverts, /api/ad-segments/…/sample.mp3, and a blocked request fails silently. Every /ui/… fragment path and the page now use a cuts vocabulary (/shows/:slug/cuts, /ui/shows/:slug/cuts-panel, /ui/episodes/:id/cuts, …); the two sample clips are served at /api/cuts/segments|anchors/:id/sample.mp3 and the templates use those; the old /api/ad-* routes stay for scripts, and /shows/:slug/adverts 301s. adblock-names.test.js now also checks every URL rendered by the templates, built in pages.js/events.js/adverts-view.js, written in app.js, and seen on served pages — and was shown to fail when one rename was reverted. The visible page name stays "Adverts".
  • P9 — a lighter dashboard. A 400 px cover thumbnail route (/media/:slug/:token/cover-400.jpg, token-checked, cached under /data/.covers/ per cover ETag, full cover served if the thumbnail cannot be made) is used by the cards: 3.7 KB instead of 24 KB per card on the test cover, far more on real art. "Rescan all" swaps the grid once instead of fetching every card; the dashboard uses stats.forShows() (two grouped queries) instead of per-show rollups, with a test that its numbers equal the old presenter's.
  • U21 — the ledger search replaces the URL instead of pushing history; the first tap on a transcript word selects that word, not everything to the end; the sidebar says "All N shows…" when it has cut the list; "All shows" on the episode page is now "Show statistics".
  • U23 — one name: "Follow a feed" (page, crumb, title, Settings row); the episode page's h1 is the episode's title with "Edit episode" as the small label; one danger-button class; .form-actions on the cuts settings Save; .muted defined; one formatClock for the four m:ss copies, formatBytes identical on both sides, and the transcript's "decided on" day in the instance's zone rather than the server's.
  • U22 — eleven colour tokens replace 56 hard-coded hex values (same values, same look); fourteen dead CSS rules and three duplicate blocks removed, each grep-proved unused first. No dark mode, by design; the ~95 inline style attributes were left alone.

How it was verified

  • npm test: 1428 pass, 0 fail (stacked on Pin what the build fetches, poll a share once not twice, and boot lighter #17; includes a follow-up commit giving the thumbnail maker the lazy sharp loader the merge with Pin what the build fetches, poll a share once not twice, and boot lighter #17 had left it without). New: the extended ad-blocker URL test, 12 dashboard tests (thumbnail dimensions, headers, token check, ETag suffix + 304, cache replacement on a new cover, unreadable-cover fallback, presentShows equals presentShow, no per-show stats calls, grid SSE attributes, sidebar count, naming, 301), scan-event fan-out (a 3-show sweep = 1 grid event, 0 card events), zone-aware decided-day, formatClock, history replace vs push, /api/cuts/… bytes equal /api/ad-….
  • ./test/acceptance/run.sh selfpod:tier5-ui: 63 passed, 0 failed against the stacked image.
  • Driven in a real browser: the Cuts page end to end (settings, Check now, ▶ sample at the new URL loading audio, Remove, Teach a jingle, Forget), the episode page cuts card and transcript taps, the dashboard thumbnail decoded at 400×400 with a 304 on revalidate, one grid fetch per Rescan all, the Follow a feed page with search typing not growing history.

🤖 Generated with Claude Code

antoine-debroye and others added 8 commits October 9, 2026 17:51
…ns out on a password change

Tier 2 of the October audit: the security findings that matter under
SelfPod's threat model, where the shows folder is a share other people can
write to and the admin UI sits behind a public tunnel hostname.

- Every sharp decode now stops at 40 megapixels, at the header. A 60 KB PNG
  of one colour declaring 16000x16000 decodes to a gigabyte, the scanner
  decodes sidecars on its own on every scan, and the result was a crash loop
  with no banner. The scan log now says the image was too large rather than
  "could not be read", and a cover upload gets the same sentence.
- The sign-in page and the anonymous half of /api/status show only the
  permission banners. The others name a show's title or a followed feed's
  host, which feeds-private-by-token should not hand to whoever finds the
  hostname.
- Changing the password signs every other session out, keeping only the one
  that made the change. The reset script already did this; the UI did not.
- A sign-in regenerates the session id (belt and braces; nothing was
  exploitable).
- The account-level login backoff is capped at a minute, and a per-source
  backoff carries the five-minute wait instead, so a stranger holding the
  URL can no longer keep the owner locked out by guessing once every few
  minutes. A throttled attempt answers 429 with Retry-After, not 401.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…tier 4, U1–U20)

Items U1–U12 and U14–U20 of doc/audit-2026-10-09.md §4.

Broken or silent actions: Remove/Delete from the episode's own page re-targeted
a table that page does not have, so nothing happened; the four Subscription
status buttons posted into a redirect the XHR swallowed; the password-changed
toast put hx-swap-oob on the toast itself and arrived as bare text. Each now
answers with HX-Redirect and a flash, or a real toast, and Stop following asks
first. Every decision, teach, check, rescan and settings control is held and
shows a ring while its request is out (hx-indicator / hx-disabled-elt /
hx-sync), htmx:sendError is reported, and a 401 with HX-Redirect no longer
flashes an error on its way to sign-in. Check now and the three Teach routes
start the pass and answer at once on the htmx path; the plain form still waits.

Background refreshes: a swap the page asked for itself (sse:, load, script) is
held while a field inside it is focused or dirty and taken once it is not; a
<details> someone toggled keeps its state across swaps; the stream's re-render
of a target with a user request in flight is dropped, which removes the double
render after every decision.

Phone: the topbar actions wrap under the breadcrumb below 640px; the access log
and both statistics tables stack with data-label column names (thead kept for
screen readers); 44px targets on coarse pointers, with the cut bar's tap area
on a wrapper so the track keeps its 14px. Contrast: --accent-2 for button fills
and text-sized accent, --ink-soft for muted text that carries information.

Also: the SSE scan-progress strip is the same partial as the clicked one, with
its polling backstop; keyboard focus is put back after swaps and modal closes;
error toasts persist and are alerts, others scale with length, mouseleave
resumes; Settings switches get accessible names, card titles are h2, refused
fields carry aria-invalid/aria-describedby, the breadcrumb marks the current
page, a refused sign-in focuses the password; new-show no longer pre-fills the
page title and keeps what was typed; upload success is green; the dashboard is
highlighted in the sidebar (and the sidebar's aria-current, rendered through the
escaping tag, is now a real attribute); settings toggles and inline saves say
they saved; the cut pill links to the episode page.

A date at the start of a filename (YYYY-MM-DD, with -, _, . or nothing) is the
episode's publish date at midnight in TZ on first sight, unless the mtime already
falls on that day; undated files keep the mtime; a rescan never touches pub_date.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Check now and Teach now start a pass and answer at once, so the request no
longer holds the pass open. The test harness closed the database under a
pass that was still cutting an episode, and the test process then sat on a
handle it could never release — the suite hung at exit, sometimes.

The pipeline gains idle(), which resolves once nothing is running or
queued, and both harnesses await it before closing anything.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… it has already done

Audit tier 3 (P1-P6) and X2.

P1: reading, hashing and decoding an episode — to fingerprint it or to hand a
window of it to the recogniser — now runs in the audio worker that already held
the corpus searches. The main thread hands over a gated path and writes down what
comes back; typed arrays are transferred, not copied, and the fingerprint is byte
for byte what the main thread produced. Measured on an hour of audio: a 10 ms
timer fired 10,046 ms late inline and 1 ms late with the worker. A worker that
crashes or wedges past its timeout fails that episode loudly and is restarted.

X2: fingerprinting, listening and cutting all go through one gate that resolves
the path inside the show folder, stats it, and refuses a link out of the folder,
anything that is not an ordinary file, and anything over 768 MB — before a byte is
read, and again on the open descriptor. A refusal is a banner naming the file and
one line in the pass's activity entry.

P2: the detectors run only when their inputs or the catalogue content changed
since the last pass (a per-show key the pipeline keeps in memory, plus a counter
every owner action bumps). The jingle is located only in episodes whose
fingerprint is newer than their hit row; fingerprints are read lazily, a header
only where timing is all that is needed; the held-episode count is one GROUP BY.
A taught boundary links to the jingle within the pass instead of the next one.

P3: the two sample routes read only the frames they play, through a per-file
frame table built by a chunked walk proven frame-for-frame equal to readFrames;
the trimmer hashes and streams the cut's parts rather than concatenating a copy.

P4: @fastify/compress 9.2.1 for HTML, CSS, JS and JSON, in the web and API
contexts only; audio and the pre-compressed feed are untouched, and request
bodies are never inflated.

P5/P6: session not rolling; PRAGMA optimize on close and daily; journal_size_limit;
hoisted prepares; migration 012 indexing the advert tables' foreign keys.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…pisode, a fair comparison, and a whole-page show filter

Tier 5 of the October audit, the statistics half.

- Local midnight was an hour out on clock-change days in Sydney, Auckland,
  Lord Howe and Santiago: the zone's offset was probed once, at a moment on
  the far side of the change. A second probe lands it, and a day with no
  midnight (Chile springs forward at 00:00) starts at its first instant.
  Every day of a year in eight zones is now checked.
- media_access no longer cascades away with the episode (migration 013
  rebuilds the table), so deleting an episode leaves the show's and the
  instance's totals alone. The log says "An episode since deleted".
- The previous period is measured to the same point as today is into this
  one (prevTo), so a morning no longer reads as a slump; the card says so.
- A show filter on the statistics page scopes the cards, chart and tables,
  with a note and a way back to every show.
- "Failed requests" counts failures of every kind, as the failures-only log
  always did; bytes and episodes fetched stay audio-only.
- The CSV is streamed in batches with no ceiling, instead of stopping at
  fifty thousand rows while the page promised every one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…hter (audit tier 5, X6/X8/P7/P8)

X6 — supply chain. Every GitHub Action is pinned to a commit with the release in a
comment; the workflow token is read-only except for the publish jobs. Both Dockerfiles
pin node:22-alpine and the two nvidia/cuda images by digest, and fetch whisper.cpp by
the commit b4938 pointed at rather than the tag. Each pin says how to bump it.

X8 — TRUST_PROXY. `true` (the default, as before), `false`, or a list of addresses
and CIDR ranges passed to Fastify's trustProxy, so an operator whose port 8080 is
reachable from the LAN can stop a client there setting X-Forwarded-* itself. A list
with a bad entry drops it and warns; a list with nothing usable trusts nobody and
warns, never silently everybody. Unit tests prove the parsing and what Fastify does
with each value; an integration test proves it reaches the real app through the
Secure flag on the session cookie.

P7 — boot and runtime. sharp and qrcode are loaded on first use (a shared loader for
sharp, so the two services load it once); the entrypoint chowns node_modules only
when its owner is wrong, and the image ships it owned by the default ids, so a default
run never walks the 4,500 files; in polling mode the watcher polls at the rescan
interval instead of min(rescan, 60 s) on top of the rescan, and says so in the log
and status. The whisper probe at boot is left as it was. Boot to "listening" on this
Mac: 812/236/230 ms before, 535/223/221 ms after; the covers module import went from
~26 ms to 5 ms and qr.js from 9 ms to 0.

P8 — image size. WHISPER_MODELS chooses which models are baked in (default both, so
the published image is unchanged) and WHISPER_DEFAULT_MODEL must be one of them or
the build refuses with a plain sentence; the smoke test proves every binary with the
smallest model shipped. better-sqlite3's SQLite source and the seven other platforms'
prebuilt binaries are removed before the native-module check, which now proves the
module loads with only what is kept. 868 MB → 833 MB (717 MB with one model).

npm test: 1388 pass. Acceptance (selfpod:tier5-infra on port 8299): 63 passed, 0 failed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…audit tier 5, U13, U21–U23, P9)

1.9.1 renamed what a filter list hides by name; the addresses the Adverts page
fetches were still named after adverts, and uBlock Origin and AdGuard block a
request by its path just as they hide an element by its name — silently. The
page is now /shows/:slug/cuts (301 from /adverts for bookmarks), every /ui/
fragment it uses is named for cuts, jingles and boundaries, and the clips the
▶ and the rule players fetch come from /api/cuts/…, with the /api/ad-* routes
kept for scripts. adblock-names.test.js now refuses a banned word in any
hx-get/hx-post/src/href/action/sse-swap value a template renders, in any URL
literal in app.js, and on the served pages — it fails when one rename is
reverted.

Dashboard: cards load a 400 px copy of the cover, made once per cover ETag and
kept under /data/.covers, served with the cover's headers and token check and
falling back to the full cover when it cannot be made; Rescan all swaps the
grid once on scan-finished-all rather than one card per show (the scanner's
per-show events carry parentScanId, and a card listens for show-scanned-<id>,
sent only for a standalone scan); and the page uses stats.forShows() through a
presentShows() batch rather than four queries per show.

Smaller: the ledger search replaces the address instead of pushing a history
entry per keystroke (HX-Trigger tells the search box from the selects); the
first tap on a transcript word selects that word alone; the sidebar offers
"All N shows…" past eight; "Show statistics" rather than "All shows";
"Follow a feed" on the page, its crumb and in Settings; the episode page is
headed by the episode's title; one .btn-danger; .form-actions on the cut
settings; .muted defined; one formatClock() in lib/dates.js with an identical
client copy and a consistent formatBytes; formatDay in the instance zone; the
repeated hex colours tokenised in :root and the dead rules the audit listed
removed, each proved unused first.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The thumbnail route was written against an eager `sharp` import that the
infra tier had just replaced with a lazy loader; merged, the call threw a
ReferenceError inside the try, and the catch served the full cover — a
thumbnail that would never have existed, with nothing to say so.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@antoine-debroye
antoine-debroye changed the base branch from ad/audit-tier5-infra to main October 9, 2026 22:29
@antoine-debroye
antoine-debroye merged commit 2c5f389 into main Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant