newsfeed

← Home · ~/newsfeed · updated 1 month ago

newsfeed

One page a day: every new US local news story, as a single stream ordered by $P(\text{weird})$, the weirdest and most shocking first.

"shelf the existing newsfeed. i want literally just a single stream of articles in order of $P$. updated daily. never show the same article twice: if it surfaced yesterday, don't show it today or any day after." (Mark, 2026-10-12)

Pipeline

./newsfeed.py run runs five stages, once a day at 08:00 under launchd.

Stage Code What it does
Fetch fetchers/, pacing.py Every outlet in outlets/outlets.csv (RSS, news sitemap, the stories linked off its homepage, or a Google News site: query), paced per platform.
Dedup dedup.py, semantic_dedup.py Canonical URL, fuzzy title, then semantic clustering; one lead per story.
Date dating.py A lead its fetcher could not date (a homepage story with no date in its card or URL) has its page read for the publisher's article:published_time or JSON-LD datePublished, which replaces the first-seen stamp; a page naming none, or not answering, keeps the lead out of this run. Then every lead older than max_story_age_days (30) by its publisher's date is dropped.
Score weird.py One Jev noul question per lead, "a weird or shocking real story?", in any language: $P(\text{weird}) \in [0, 1]$, one call a headline so its neighbors cannot sway it, about \$2.35 per 100k headlines. Violent, sexual, gross and inappropriate stories count in a headline's favor; routine news scores low. Scored once, cached on the row.
Stream newsfeed.py, stream.py, render.py, deliver.py Drop every lead ever shown, sort by $P$, drop any of the top retold_depth (700) that Jev reads as a retelling of a story above it or of the top retold_shown (300) already shown, publish all the rest, and record every one in shown. The page embeds the first 100 in English and fetches the rest; it is ~/www/newsfeed.html plus a dated copy in ~/www/newsfeed/.

The pool is every lead fetched in the last recency_cutoff_hours (36), so a story missed by one run is still a candidate the next day.

Never twice

shown holds every key a delivered item answers to: its canonical_url, its resolved_url, and title: plus its normalized title. A lead matching any key is dropped before scoring. Nothing prunes shown. Migration v13 seeded it from every item the old digests delivered.

The page

One row per story: the headline linking to the article, the outlet's host under it in gray. Riff's type scale (14px on the Mac, 16px on iOS), light and dark.

The page carries the run's first 100 rows and fetches the rest 100 at a time from webpage-server's /api/newsfeed/rows?run=&offset=&limit=, which calls stream.rows. It asks for the next chunk as soon as one is shown, so the reader never waits on it. A headline not in English is translated by Haiku 5.5 at low effort (claude-haiku-5-5) the first time a chunk carrying it is asked for, and translations caches the answer. Haiku runs as a one-shot riff-task run session on the Claude subscription, never the pay-per-token API, about 6 s a chunk. The first chunk is translated at publish.

CLI

Command Does
./newsfeed.py run The full pipeline.
./newsfeed.py run --dry-run Everything except publishing and recording shown; writes /tmp/newsfeed-preview.html with every row inline and untranslated.
./newsfeed.py preview Renders the stream from leads already scored, with no fetch and no Jev calls; prints the top ten.
./newsfeed.py fetch <source> One source as JSONL.
./newsfeed.py healthcheck Last run's fetched / deduped / scored / shown counts and Jev cost.
./weird.py probe Re-asks eight reference headlines to catch drift in Jev's answers.

Configuration

~/.config/newsfeed/config.toml and sources.toml, templated in examples/. Top-level keys: recency_cutoff_hours, max_story_age_days, max_run_seconds, shortlink_hosts; tables [delivery], [weird] (with retold_depth and retold_shown, which sum to at most 1000 titles, the most one Jev call's state holds), [local], [fetch], [prune] (with delivered_days, 60), [dedup]. Jev needs TYPESAFE_API_KEY in ~/.env; Haiku needs the riff marketplace's task plugin installed and claude logged in to the subscription.

selectolax is pinned below 1.0: 1.0 drops the Modest backend googlenewsdecoder 0.2.1 imports, and without it every Google News wrapper stays unresolved. fetchers/homepage.py parses homepages with its lexbor backend.

Deployment

./install.sh copies the config templates (never over existing ones), creates the state, log, and archive directories, and loads com.mark.newsfeed.plist. ./verify.sh runs the test suite.

Kept for webpage-server

~/webpage-server/webpage-server.py on mini imports stream.py for /api/newsfeed/rows, and for its article reader tts.py, article_stream.py, elevenlabs_stream.py, article_rewrite.py, gnews_resolve.py, url_resolve.py, render.render_article with templates/article.html.j2, and the db.py log helpers. The pipeline does not use them.