Conversation
Two namespaces, and one package that answers the same question for both:
what is the canonical identity of a thing on a platform?
Reddit needed only a name. It publishes real RSS, so a subreddit resolved
down the ordinary path and landed as an untyped row at a slug of its own —
which is how 50,099 of them ended up filed among the blogs, 41% of the
crawl queue. They are not moved or renamed: the migration gives them an
identity, /r/programming answers, and /{slug} keeps working for every link
already pointing at it.
X needed the rest. It publishes nothing, so posts are collected through a
provider stack — RSSHub, then Teapot, then the official API — with session
rotation, cooldowns, failover and spend caps. The provider appears in no
public URL, so the collection method can be replaced under a live
subscriber without their reader noticing.
The design decision worth stating: a social source is an ordinary row in
`feeds`, not the parallel `sources`/`items` pair the PRD sketches. That
pair already exists here, carrying dedupe, backoff, interval learning,
keyword extraction, FTS, alerts, sitemaps and five syndication formats —
so an X post reaches /topics/*.rss beside a blog post with no code in the
topic path that knows X exists.
- packages/social: canonicalisation for both platforms; X providers,
session pool, registry with failover, post normalisation
- migration: social_network/social_ref/social_config on feeds, provider
and session health tables (no credentials: those stay in the
environment), and a deterministic backfill of the existing subreddits
- crawl: a third ingestion path beside fetch and scrape, on a five-minute
floor rather than the directory's hourly one
- web: /r, /r/<sub>, /r/u/<user>, /x, /x/<handle>, /x/<handle>/replies,
/x/<handle>/media, /x/list/<id>, /x/search, /x/status — each with
.rss/.atom/.json/.md, canonical tags, and an offer to add what is not
here yet
- rivers now answer If-None-Match with a 304, computed before the ad
fetch so an unchanged feed never meters an impression it did not deliver
Not built: the /admin/x buttons of §34. There is no notion of an
administrator in this codebase to guard them with, and shipping a kill
switch anyone can pull is worse than not shipping one. X_ENABLED and
X_PRIMARY_PROVIDER cover it without a code deploy; /x/status is the
read-only half.
64 new tests, all 12 packages green under Node 22 and 24.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q6QEgpuS4MLamogXtr2ZX6
ralyodio
marked this pull request as ready for review
August 29, 2026 12:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reddit now lives under
/r/and X under/x/, and X is collected through areplaceable provider stack rather than not existing.
The two halves, and why they are different sizes
Reddit needed a name, not a mechanism. It publishes real RSS, so a subreddit
already resolves down the ordinary path — and lands as an untyped row at a slug
of its own among the blogs. That is how 50,099 of them got here, 41% of the crawl
queue. The migration gives each an identity (
r:sub:programming) and/r/programminganswers. Nothing is moved, renamed or deleted:
/{slug}keeps working for everylink already pointing at it, and the
/r/address is the canonical one.X needed the rest of it. X publishes nothing, so a timeline has to be
collected and mirrored:
Failover is per attempt and the order is fixed; three failures in a row set a
provider aside, one success clears it. Sessions rotate least-recently-used with
per-state cooldowns, and a rate limit, an auth failure, a provider outage and a
missing account are four different things that get four different responses.
The provider appears in no public URL.
/x/OpenAI.rssis the same addresswhichever of the three filled it, so the collection method can be replaced under
a live subscriber without their reader noticing. There is a test that greps the
rendered document for provider names.
The design decision worth arguing with
The PRD sketches a
sources+itemspair (§20). That pair already exists here— it is
feeds+feed_items, carrying dedupe, backoff, interval learning,keyword extraction, FTS, alerts, sitemaps and five syndication formats. So a
social source is an ordinary row in
feedswith two extra columns, andcrawlFeedgains a third ingestion path beside
resolveandscrape.The payoff is §30 and AC-8 for free: an X post reaches
/topics/*.rssbeside ablog post, and there is no line in the topic path that knows X exists.
source_kindwas the obvious column and is deliberately unused — it carries aCHECK constraint, and SQLite cannot widen one without rebuilding a thirty-column
table with a dozen indexes against 300k rows on a single-writer database.
What is here
packages/social— canonicalisation for both platforms, X providers, sessionpool, registry, post normalisation. No database client; the stores are injected.
social_network/social_ref/social_config,x_provider_state,x_sessions, and a two-pass backfill of the existing subreddits. Nocredential column, and no room for one:
auth_token/ct0are a full loginand stay in the environment, so a leaked dump carries none.
directory's hourly one.
/r,/r/<sub>,/r/u/<user>,/x,/x/<handle>,/replies,/media,/x/list/<id>,/x/search,/x/status; each in.rss,.atom,.jsonand.md. A source not in the directory yet gets an offer to add itrather than a 404.
If-None-Matchwith a 304 — computed before the ad fetch, soan unchanged feed never meters an impression it did not deliver.
Failure behaviour
Nothing in this path can empty a feed. Items are written only on success, so an
upstream outage leaves yesterday's posts exactly where they were and the public
route goes on serving them (§40, AC-5). A rate limit, a provider outage and a
missing X runtime all reschedule without touching a health column — otherwise
markCrawlFailure's ten-strike rule would retire the whole X directory over anafternoon with no clue why.
Not built
The
/admin/xbuttons of §34 — disable a provider, clear a cooldown, force arefresh. This codebase has no notion of an administrator to guard them with, and
shipping a kill switch anyone can pull is worse than not shipping one.
X_ENABLEDandX_PRIMARY_PROVIDERcover the two that matter without a codedeploy.
/x/statusis the read-only half and is where those buttons go.Also honest about one limit: both unofficial providers keep their own logged-in
sessions by default, so the pool has nothing to hand them unless the deployment
exposes a per-request parameter. Nothing here guesses at that parameter's name —
guessing would mean putting a live cookie on a query string somebody's instance
might log.
Verification
fail 0) under Node 24 and Node 22 (CI's version).pnpm buildcompiles; every new route registers.and the backfill checked against the URL shapes the bulk import actually
produced — including that the canonical row wins a duplicate regardless of
insert order.
304on amatching ETag and
200on a stale one, canonical tags pointing at/r/and/x/, and no provider name anywhere in a public document.X_ENABLEDdefaults tofalse, so merging this collects nothing until it isswitched on.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q6QEgpuS4MLamogXtr2ZX6