Atmospheric upvotes and link aggregation
README.md

upvote.at #

Atmospheric Upvotes

Approach #

Data lives in the atmosphere #

Ideally, this app is entirely a client that displays upvotes in the Atmosphere.

Link posting is irrelevant and doesn't need its own lexicon because the upvote records serve as a "post" of the link. This gives us a number of things for free:

  • Upvotes are universal. You don't need to upvote on upvote.at for upvote.at to surface users' engagement. If an upvote exists publicly in the Atmosphere, we get it.
  • Your domain is your aura. Rather than the user getting credit for whatever's being posted, the origin of the link being upvoted gets the credit. This shifts the focus to content rather than to karma farming by racing to be the first to post something.
  • History is persistent. If a link gets 50,000 upvotes 20 years ago and then it gets shared again, all the history of engagement with that link will persist and we can fine-tune how that's surfaced through the front-end with different views of the data.

The site currently implements this by:

  • Writing an at.upvote.signal record to a user's PDS
  • Every URL has one submission
    • This is a fundamentally different approach to other link aggregators
    • It is our responsibility to figure out how to surface new upvotes and decay old upvotes in a way that is respectful to new interest while still persisting the historical engagement
  • A link's upvotes are one single number, the "submission" is simply the earliest upvote.

Some useful technical details #

Here's a ton of technical details that have been written out as I've developed the app. There's some duplication, mostly just trying to get the information down. I'll make a pass at cleaning it up later.

  • This app relies on HappyView as its AppView.
    • HAPPYVIEW_KEY is the public browser/OAuth client key. Server reads prefer a separate confidential HAPPYVIEW_SERVER_KEY plus HAPPYVIEW_SERVER_SECRET, keeping boot/index traffic in a different rate-limit bucket from interactive browser sessions. HAPPYVIEW_URL selects the instance (default https://happyview.upvote.at).
  • The /settings page's bot-authorization controls point at upbot via the UPBOT_URL env var (src/lib/server/upbot.ts). After browser auth settles, a same-origin proxy asks whether upbot holds a stored grant for the viewer DID; this is stored-session state, not a fresh validation against the PDS. The page offers authorization or deauthorization from that answer and rechecks when the popup tab returns focus or visibility. Upbot's boolean status endpoint is intentionally unauthenticated and read-only. It does not allow direct cross-origin browser reads (no CORS), but it is enumerable by DID from a server; deauthorization remains protected by its ownership-checking OAuth flow. UPBOT_URL is unset by default so the controls only show where the bot is deployed. Upbot's own PUBLIC_URL must match it; see that repo's README.
  • Identity is entirely client-side (src/lib/auth.svelte.ts, via @happyview/oauth-client-browser); see authentication for the full flow.
    • The browser provisions a DPoP keypair from HappyView, runs the standard atproto OAuth flow with your own PDS using that key (PKCE, with the pushed authorization request bound to the key's thumbprint), and registers the session, refresh token included, back with HappyView. The browser keeps only the SDK's own storage rows: the DPoP key, the access token, and the granted scopes.
    • HappyView owns the session from then on: it refreshes the upstream token itself (single-flight, per session) and finds our session by the DPoP key's thumbprint, so the access token the browser stored at login keeps working for as long as the grant lives. The browser holds no second copy of the tokens, because two refresh owners would rotate the same refresh token out from under each other, and every transient failure would have to be read as a dead session. Only a definitive "this session is gone" answer from HappyView, or clicking log out, ends a session.
  • Comment mention autocomplete in both Markdown and rich text uses Waow typeahead through /api/mentions/typeahead. TYPEAHEAD_URL selects the provider independently of APPVIEW_URL; its default is https://typeahead.waow.tech. A bare @ waits for a handle prefix before contacting the provider.
  • The feed is built by aggregating signals in src/lib/server/signals.ts
    • Raw aggregation includes comment votes so comment points and voters can be joined from the same records. Link surfaces use the narrowed aggregateLinkSubjects() view, preventing a comment AT URI from becoming a link card or trending candidate.
  • Display filtering (src/lib/server/filters.ts) happens inside that aggregation, which the feed, the by-day view, and profile pages all read through, so a filtered signal never reaches any surface:
    • Two generic lists, seeded from comma-separated env vars so production can filter without a deploy: FEED_FILTER_SUBJECTS (partial subject URIs, matched as prefixes, so https://spam.example.com covers every path under it and at://did:plc:x/ covers one repo's records) and FEED_FILTER_DIDS (accounts whose signals never display).
    • Plus one structural rule seeded from the Public Suffix List (via the psl package): an http(s) subject is filtered unless its hostname carries a PSL-listed public suffix and a registrable domain under it. A bare suffix (github.io), an unregistered TLD (foo.invalid, localhost), or a raw IP address names nothing anyone can register, so it never displays; a user page under a private-section suffix (someone.github.io) is a registrable domain and passes.
    • Filtering is display-side only: the at.upvote.signal records stay untouched in their authors' repos.
  • There are three feeds. Ranking happens in the browser (src/lib/feeds.ts), and the routes share one page via the optional [[feed=feed]] param (matcher in src/params/feed.ts). The feeds are:
    • hot (/, points decayed by submission age)
    • new (/new, newest submission first)
    • top (/top, most points ever, with ties decided by recency)
  • /leaderboard publishes the standings for both record types: who holds the most at.upvote.signal records and who holds the most at.upvote.comment records. Both are counted from indexes the feeds already keep: the signal index above, and the same body-free global comment-edge scan that counts a link's replies (loadCommentAuthorCounts in src/lib/server/comments.ts). The page therefore adds no third crawl of the network, only identity resolution for the published slice. Places are competition ranks over the whole network (equal totals share a place), assigned before the board is truncated; the browser then drops muted accounts without renumbering anyone. A comment board whose global scan has never completed says it is unavailable rather than publishing a partial ranking.
  • Subjects describe themselves, and display metadata is resolved at index load (src/lib/server/subjects.ts) then cached in memory. None of it is persisted, so a restart loses nothing that can't be resolved again.
    • at-uri subjects resolve in batched reads through HappyView's published at.upvote.getRecords query (index-first on the instance, fetching through to the repo's resolved authority on a miss; this server never discovers or contacts a PDS)
  • Embed rendering
    • a web-URL subject is fetched with SSRF guards and titled from its OpenGraph tags (og:title, then twitter:title, then <title>), with og:description/og:image rendered when the page offers them
    • Rich embeds render natively from records:
      • An app.bsky.feed.post record subject shows the post itself (text, images, video, external link).
      • A standard.site document subject renders as an article, not a quoted box.
        • No inner frame: a publication kicker (icon, name, reading time, a per-card cover toggle, and a small hostname ↗ that is the card's only link out), the title in the site's own type, and the author byline.
        • Clicking the card opens the in-place reader; linking out is secondary.
        • Content is normalized server-side (src/lib/server/docContent.ts) from the platform unions the network publishes, plus the spec's plaintext textContent fallback, into blocks the reader renders (headings, styled text with facets, quotes, lists, code, images, rules, and one sanitized HTML fragment); the browser fetches blocks lazily via /api/doc/[uri] so feed payloads stay lean.
          • Block unions map block by block onto the reader's own: blog.pckt.content, pub.leaflet.content, app.offprint.content (callouts become quotes wearing their emoji, task lists carry their boxes as text, image grids and carousels unroll, bookmarks become their title linking out, math shows its source) and is.logue.content (website cards become their title linking out; a record embed, the shape logue's documents take in practice, links to the record). Blob images go through the same CDN URL as a post's; embeds, polls, buttons and iframes are widgets and don't cross.
          • Markup unions go through the article markup pipeline (src/lib/server/articleMarkup.ts): Markdown from at.markpub.markdown (flavor picks GFM or CommonMark, front matter is stripped, textBlob overflow isn't fetched), net.commoninternet.lichen.content.markdown (text) and site.standard.content.markdown (text or value, both seen on the network; neither has a published schema), and rendered HTML from org.wordpress.html. Markdown renders with the comment pipeline's parser and highlighter, then both go through the comment sanitizer with a wider allowlist (headings, images, figures, tables, task-list checkboxes): scripts, styles, frames, forms, event handlers and non-http(s) URLs never survive, links open away from the reader, images load lazily without a referrer, and a source over 512 KiB falls back to textContent. The reader renders the resulting fragment the way a comment's HTML is rendered.
  • Profiles (record + handle) arrive batched via the published at.upvote.getProfiles query.
  • Profile activity includes:
    • upvoted links
    • authored comments
    • pages the account saved on Semble, with the collections they filed them in. loadProfileSavePage pages them through at.upvote.getSembleSaves's did selector, streamed with the comments and paged by /api/profile/[did]/saves. Each save renders the page's own LinkRow under its Semble context line, keyed by the subject an upvote on it targets, so a saved Bluesky post or standard.site document shows as that record, with its points and a working vote. A save of a page the account also upvoted joins that row rather than repeating it.
    • articles the account recommended on standard.site. loadProfileRecommendPage pages them through at.upvote.getStandardSiteRecommends's did selector, streamed alongside the saves and paged by /api/profile/[did]/recommends; each renders the document's own LinkRow under a "recommended on standard.site" context line.
    • submitted AT records whose URI authority is the profile's DID, across all collections. Authored records appear at their first visible submission time and only once even when the author also upvotes them. They carry the real voters and points; authorship does not add an upvote or inflate the profile's upvoted count. This is derived from the signal index, so existing submissions are included without a backfill. Comment records remain in comment activity.
  • HappyView handles writes of the at.upvote.signal record into your repo.
  • Upvote toggles call the published at.upvote.toggleSignal procedure on HappyView with a DPoP proof.
  • A link nobody has upvoted can still be shown, and upvoted, where something outside the signal index vouches for it. It is an UnsubmittedLinkCard (src/types/feed.ts) with no voters and no upvote times, and its first upvote is its submission: LinkRow sends it through submitUrl, so it passes the submit box's gates and normalization. A profile's Semble saves and discussions that outlived their upvotes use it today.
    • Feeds, ranking, and the leaderboard take LinkCard only, so the types keep unsubmitted cards off every ranked surface. Mute projection treats a native zero as a card, not as a crowd the viewer muted away.
    • Sources that know a page by a different key than an upvote does meet on one subject through canonicalSubjects (src/lib/server/subjects.ts). An at-uri gets its DID authority, and a web URL becomes the post its client path names or the record its page verifiably claims, falling back to itself. (The claim the metadata read already verifies is kept as the cache entry's canonical.)
    • LinkRow counts the viewer's own vote before a fresh load arrives, from their signals against the card's voters. A vote on a profile refreshes only the first page of each activity stream and keeps older pages the viewer already loaded.
  • Link discussions live at /link/[subject]. at.upvote.createComment writes a 5,000-grapheme Markdown record, at.upvote.deleteComment removes exactly one caller-owned record without cascading to replies, and at.upvote.getComments reads one subject's direct children while the app walks the guarded tree. Scores come from signals targeting each comment's AT URI. Markdown is sanitized before rendering and fenced code is syntax-highlighted. A subject with no upvotes has a page only when a comment or a Semble save vouches for it (anything else 404s, so the route never fetches an arbitrary URL on request); it renders as an unsubmitted card and carries noindex until its first upvote.
  • A link page has an "Elsewhere in the Atmosphere" section under the card: what other atproto apps hold about the link, an article's own Bluesky post first, then one block per source that found people. Link cards glance at the same sources: after a card's upvoters, the people who saved it elsewhere appear in a dashed, orbit-marked pill (ElsewherePile.svelte) that links to the link page's #elsewhere section. It is shaped to read as a different crowd from the upvote facepile, since those marks are never points.
    • The front page renders every glance it already holds with the cards (peekElsewhereSummaries in src/lib/server/elsewhere.ts, seeded through loadFeedLinksWithGrace into each LinkRow's elsewhereSeed, at no request), so a warm server's piles paint with the HTML rather than after hydration. The footer reserves the pill's height so a pile that lands later never moves the list.
    • A card without a seed asks in batches, one POST /api/elsewhere/summaries per page of up to 30 cards (src/lib/elsewhereSummaries.svelte.ts), with a subject that has no upvotes spending the caller's cold-work allowance on a miss. Where the instance serves it, a page's glances are one HappyView request: at.upvote.getElsewhereSummaries answers up to 40 subjects at once with each crowd source's distinct-people count and newest six per subject (src/lib/server/elsewhereSummaryWalks.ts, cached per key like the walks below and served stale while a fresh batch lands behind it; the link page's section keeps the per-source walks, which list everyone and their cards), and the page's people are identified in one profile join. An instance that answers BatchUnavailable (no raw SQL) is asked again half an hour later, and meanwhile every glance reads the per-source walks.
    • Either way a glance never waits on a walk. Every subject's read starts at once, and after one shared 100 ms deadline (ELSEWHERE_SUMMARY_WAIT_MS) the request answers what has settled and names the rest pending with a retryAfterMs sized to the line ahead of the walk already out for them. A subject whose sources would have to go upstream while the scheduler has no headroom (24 or more non-idle reads queued or in flight, about twelve seconds of the shared two-a-second budget, or a 429 cooldown) is left pending without a walk. A subject whose shown people are still being identified is pending too, never shown by DID; someone whose profile read failed shows by DID until the fifteen-second failure window passes.
    • The card asks again after the server's hint, or after 1, 1, 2, 3, 5, 8, 13, then 20 seconds, for two and a half minutes (what a cold server needs to walk a page). Past that it leaves the glance unknown rather than settling for "nothing", and asks once more when the tab is next looked at.
    • Cached answers are served either way, and the front page's are kept warm. Once a feed generation's cards have their metadata, warmElsewhereSummaries reads every card's crowds in hot order, first screenful first (one batched request per 40 keys, or two subjects at a time through the per-source walks, each waiting for the scheduler to have headroom). It renews any walk due to expire within the next generation (ELSEWHERE_WARM_HORIZON_MS, six minutes) so a front-page walk runs out during a warming pass instead of on a viewer's request. Warming does not wait on profile joins: a walk's newest six people are identified in the background as it lands.
    • The section is always present, heading included: a ghost source card while it asks (also the server render), then the sources, a quiet empty note when none found anything, or a retry when the lookup failed (ElsewhereSection.svelte, every state in Storybook under Elsewhere in the Atmosphere). The browser fetches /api/elsewhere/[subject] lazily after the page is up (Elsewhere.svelte); the server runs every source side by side and drops any that fails or finds nothing (src/lib/server/elsewhere.ts), and each source renders its own block inside the shared ElsewhereSource.svelte frame.
    • A new source adds a loader, a variant of ElsewhereSourceDto, a case in peopleOf (where the card glance finds its people), a peek for the server render, a source in the batched query's Lua, and a block.
    • The card glance counts each person once across sources (someone who saved a page and recommended it is one face), dated by their newest mark; when a source's walk stopped at its bound the count is a floor and says so. The pill's label names each source's verb ("3 people saved or recommended this elsewhere in the Atmosphere").
    • Every source's per-subject walk cache is createElsewhereWalkCache (src/lib/server/elsewhereWalks.ts): found and empty walks in separate bounded halves (a walk that found someone is served for fifteen minutes, "nobody" for thirty for a record and an hour for a web page, since most links have nothing elsewhere), one shared flight per subject, the cold-work admit gate asked only before a walk goes out for a subject nothing is cached for, and short retry windows for a failed walk against long ones for an instance that does not serve the source's query yet. An expired walk is served as it stands while a fresh one lands behind it (stale-while-revalidate, only while the scheduler has headroom), so a reader waits on a round trip only for a subject this process has never walked. In development the entries are pinned on globalThis (src/lib/server/devCache.ts) so a Vite reload of a server module keeps them.
    • A walk is cached the moment it lands; who its people are is joined per read (joinElsewherePeople, waiting at most five seconds for their handles and avatars, with their badges settling behind), and only as far as the read shows. A card's glance identifies each source's newest six (a batch of profiles is one HappyView request, so a crowd of a hundred recommenders would otherwise cost a card ten reads every few minutes), while the section, which lists everyone, joins them all.
    • A walk is one request per subject per source, and a source never asks about a subject it cannot serve. Only a site.standard.document (or a page that proved it is one) asks standard.site, Standard Reader, and Bluesky, and Bluesky only when the document's record names a post (bskyPostRef, kept on its metadata); only a subject with a web home asks Glean; a Bluesky post asks Semble alone.
    • The first source is Semble: who has saved the page, and into which collections, shown the way the link card shows upvoters (the Upvoters.svelte facepile, expanding to every saver linked to their upvote.at profile, with the collections they filed it in linking out to Semble, and the latest and first save times).
      • Semble's public network.cosmik.card, collectionLink, and collection records are indexed on the HappyView instance by this repo's own record triggers. Each URL card is keyed by the same canonical web subject a signal uses (web_subject_key in the Lua is a mirror of src/lib/server/webSubject.ts, held to one shared table of cases by webSubject.spec.ts) and, wherever it can be told without reading the page, by the at:// subject the URL names (atSubject: a post link from any Bluesky client in POST_CLIENT_HOSTS carries its post's at-uri, the convergence normalizeSubject applies to a submitted post link, and a card whose URL is itself an at:// record URI is indexed by that URI alone), so a save of a Bluesky post meets the post's signals.
      • at.upvote.getSembleSaves joins a subject's cards (selected by web key, or by at-uri) with the collections they were filed in. Each link is one request, as it is for standard.site: a web page asks by its URL, a Bluesky post by its at-uri alone (the index derives a post's at-uri from its link in any Bluesky client, so the post's URL would find nothing more), and any other record by its at-uri plus, in the same request (url), the web URL its metadata states (webHomeFor, how a standard.site document's page is saved, since only the page claims the record; a record with no web home, whose metadata's only URL is a record browser's, asks by its at-uri alone).
      • The server reads one page of at most 25 cards (counts past it are floors, marked "+") through the scheduler and caches the result per subject (src/lib/server/semble.ts); its block is SembleSaves.svelte.
      • Saves are display-only: every save links out to its card and collection on Semble, a save is never a point and never touches ranking, and an instance that does not serve the query yet answers as "nobody saved this" with a long retry window rather than an error.
    • The second source is standard.site: who recommended an article (site.standard.graph.recommend, written mostly by Leaflet) from any standard.site app. A recommend names its site.standard.document by at-uri, so only a document's link page (or card) asks, and every other subject costs this source nothing. The recommend records are indexed network-wide on the HappyView instance by this repo's record triggers, and at.upvote.getStandardSiteRecommends lists them newest first for one document or one recommender. The server reads one page of at most 100, folds duplicate records into one recommender, and caches the walk per subject (src/lib/server/standardSite.ts); its block is StandardSiteRecommends.svelte, the same facepile of readers linking to their upvote.at profiles. Display-only, like Semble: a recommend is never a point.
    • The third is Standard Reader: who read a standard.site article there (app.standard-reader.read) and who saved it for later (app.standard-reader.bookmark). Both name the document by at-uri, so only documents ask; this repo's record triggers index both collections, and at.upvote.getStandardReaderMarks answers one page of both, newest first, with truncated when either had more. The server folds a reader's marks into one person carrying every kind they left (src/lib/server/standardReader.ts); the block (StandardReaderMarks.svelte) says "3 read · 1 bookmarked" over one facepile.
    • The fourth is Glean, an RSS reader on atproto: who liked the page (at.glean.like). A like names the article by URL, so the triggers key each like by the same canonical web subject a signal uses, plus a loose key with tracking parameters stripped (utm_*, fbclid, gclid, and friends; loose_subject_key, held byte-identical across its copies by webSubject.spec.ts), and at.upvote.getGleanLikes reads both. A web page asks by its URL and a document by the page URL its metadata states (src/lib/server/glean.ts, GleanLikes.svelte); a post, and a record with no web home, asks nothing, since neither is an article anyone reads in a feed reader. Semble's card triggers store the same loose key, so a save of a link with a campaign tag meets the plain link.
    • The fifth, shown first in the section as "Author's Bluesky Post", is the article's own post: the one app.bsky.feed.post a standard.site document names in its bskyPostRef. Nothing indexes posts (far too many); at.upvote.getBlueskyDiscussion reads the document (from the index, or its PDS), then asks the public Bluesky AppView (BLUESKY_APPVIEW_URL overrides it) for that post alone, and answers its text and engagement counts (src/lib/server/bluesky.ts, BlueskyDiscussion.svelte, which quotes it and links to it in the viewer's chosen client). A document without a bskyPostRef shows nothing, and that answer is held for an hour rather than the usual fifteen minutes: a document names its post in its own record, set when its author shares it (usually right after publishing) or never, so it changes about as often as the document is edited. The post view comes with its author's handle and avatar, so the author is shown as the AppView names them and costs no profile read. The post is the author's own word rather than anyone's mark on the article, so this source has no people: it never joins a card's glance, and a link whose only source is its post shows no pile.
    • A source that could not be asked (its read failed, or the instance does not serve its query yet) is named under the section ("Couldn't check Glean just now.") rather than silently read as "nobody", and the link page's own card shows its glance too, pointing down to the section. npm run elsewhere:verify -- <document at-uri> compares every source's HappyView answer for one article with Constellation's network-wide backlink counts and fails where HappyView counts fewer accounts: the check for a collection that was never registered or backfilled.
  • An article card's publication line shows how many accounts subscribe to the publication (site.standard.graph.subscription, indexed by this repo's triggers). at.upvote.getStandardSiteSubscriptions counts a publication's distinct subscribers itself when asked (count=true: one COUNT(DISTINCT did) over its index through db.raw, or a keyset walk of up to 5,000 rows where raw SQL is unavailable), so one request answers for a publication with hundreds. Cards batch their publications into POST /api/publications/summaries (src/lib/publicationSummaries.svelte.ts, on the same batching and busy-scheduler pending rules as the Elsewhere glances), and cards from one publication share its count. With PUBLIC_STANDARD_SITE_WRITES=true, a signed-in viewer also gets a recommend pill (in the byline and at the end of the in-place reader) and a subscribe control after the count: src/lib/standardSiteSocial.svelte.ts calls the at.upvote.toggleRecommend / toggleSubscription procedures, which write or delete the TID-keyed record in the viewer's own repo as Leaflet does, reads the viewer's own records once per session for the pressed state, and then asks POST /api/standard-site/invalidate to forget the server's cached count so the Elsewhere pile and the subscriber count re-read with the change. The flag stays off until every HappyView client registration allows the two extra scopes (see docs/authentication.md).
  • Mentions use standard app.bsky.richtext.facet byte ranges with a stable DID. The composer resolves visible handles before writing and ignores inline/fenced code; /notifications calls the authenticated at.upvote.getNotifications query, whose recipient is always the OAuth caller and never a request parameter.
  • Account mutes use Bluesky's native private app.bsky.graph.muteActor, unmuteActor, and paginated getMutes lexicons, called through HappyView's service proxy: the browser sends them to the instance with an atproto-proxy: did:web:api.bsky.app#bsky_appview header and HappyView relays them through the viewer's PDS as the viewer, so no authenticated browser-to-PDS call is involved. They are AppView state, not public repo records. The browser projects the resulting DID set before feed ranking/thread construction: muted votes are removed and aggregates recomputed, native content and comments by muted authors are hidden, muted comment subtrees disappear, and mention notification URIs are discarded before server hydration. Activity fails closed until the complete private mute collection has loaded (with retry/reconnect UI on failure), and gated server-rendered rows plus their native-lazy media stay out of layout until the viewer-specific projection has replaced them. Shared server caches remain viewer-independent.
  • Account blocks are projected the same way, but come from two reads. The viewer's own app.bsky.graph.block records are public repository records, listed with a public, unauthenticated com.atproto.repo.listRecords straight off the viewer's PDS (the same read the settings record uses; nothing authenticated ever goes from the browser to a PDS), so they need no rpc: scope, no XRPC-proxy allowlist entry, and no fresh login; the walk is capped at 100 pages of 100 and fails closed past that rather than truncating, and activity fails closed until it and the mute read have completed, with the notice's one retry re-running both. Subscribed block lists and accounts that block the viewer are never materialized: a popular block list holds tens of thousands of members, HappyView's app.bsky.graph.listitem index only holds what it has seen since the lexicon was registered (hv:sync requests no backfill), and reading it live stalled for 13 s behind the firehose ingest in September 2026, failing every viewer closed. Instead each activity surface asks Bluesky's public AppView app.bsky.graph.getRelationships about the accounts it is about to show (voters and authors, 30 per request, the same call the following and mutuals feeds already rank by) and hides any account the answer marks blocking/blockingByList or blockedBy/blockedByList (src/lib/blockGate.svelte.ts). A row renders only once every account on it is confirmed, confirmed edges accumulate so a growing feed never re-hides what it has cleared, and a batch the AppView cannot answer leaves those rows hidden behind an inline retry. Blocked-by is applied too, because Bluesky shows neither side the other's content. The union of mutes, direct blocks, and the surface's gate feeds every projection (auth.hiddenDids plus gate.blocked), while the mute control keeps reading the mute set alone. HappyView is never asked to index the network's block graph, and this app never writes a block.
  • The server's only jobs are:
    • rendering the public view
    • keeping a small cache of HappyView's index, read through the published at.upvote.getSignals query:
      • a TTL-gated full pull of everyone's signals when rendering (so the feed reflects the network, not just this process's visitors)
      • a per-account re-pull after writes (POST /api/index/refresh)
    • resolving display metadata (subjects, profiles, verifications) from the Atmosphere on demand, cached in memory
    • holding the materialized verifier index (every trusted verifier's app.bsky.graph.verification records, via at.upvote.getVerifierRecords) so the record path of any account's badges is an in-memory lookup. The index lives only in process memory. It is warmed alongside the feed at boot, refreshed behind renders on a staggered long clock, and published only after every trusted verifier has either answered or has a last-known answer. A partial refresh retries only the failed verifier repos.
    • resolving Eurosky's published trusted-verifier list live while seeding each process from the last complete snapshot in src/lib/verifiers.json; failed or malformed refreshes keep serving that snapshot/current generation instead of collapsing to the Eurosky anchor
    • serving the small JSON routes the browser reads the display metadata through (/api/signals/[did], /api/verification/[did], the batched /api/verification the following/followers modal's badges use, and /api/subjects for submit-box normalization)
  • Submit-box normalization converges equivalent inputs onto one subject:
    • The Public Suffix List rule above gates submission first: POST /api/subjects 400s an http(s) link whose domain can't exist on the public web before normalization spends any network on it, and a subject the display filters would hide can't be submitted either. upbot submits through the same endpoint, so the bot inherits the gate. (Loopback hosts are allowed only when the server is wired to the local atproto dev environment, mirroring the SSRF guard's allowance.)
    • at:// URIs pass through (handle authorities resolved to DIDs)
    • Discovery tags
      • The primary detection is the at-tags proposal: <meta name="at:canonical" content="at://…"> names the record(s) a page canonically is, repeated tags forming an array. Any collection can be claimed this way, not just the ones we special-case.
      • Two pre-proposal tags are still read as fallbacks, and both are deletable from extractAtUriClaims (src/lib/server/subjects.ts) once at:canonical adoption makes them redundant:
        • the Social App forks' post tag (<link rel="alternate" href="at://…">)
        • the standard.site tag (<link rel="site.standard.document" href="at://…">)
      • Discovery tags are controlled by the submitted page, so every claim is verified before it's trusted (otherwise any page could wear another author's byline), dispatched on the claim's collection:
        • an app.bsky.feed.post claim's own /profile/<actor>/post/<rkey> path must resolve to the claimed record's author and rkey (post records don't state their web URL, so the path is the proof)
        • any other claim's record must independently rebuild the submitted URL: a site.standard.document through its publication, everything else through the record's own url field, so records that state no web home can never be claimed
      • A page gets at most 5 claims verified per read, so a hostile page can't spend unbounded network.
    • Any other http(s) URL is its own subject, fragment stripped.
    • Claim detection also runs at display time (a web-URL subject's page is fetched for its OpenGraph tags anyway), so an at.upvote.signal record whose subject is a raw post or article URL (written by another client, or by hand) still renders as a native embed, since the convergence otherwise only happens for links submitted through this app.
  • We emit the at-tags discovery tag ourselves: a profile page carries <meta name="at:canonical" content="at://<did>"> (src/lib/components/Meta.svelte), so other at-tags consumers can converge an upvote.at profile URL onto the identity it renders.
  • In dev, browse at http://127.0.0.1:5173; the server canonicalizes localhost onto the IP literal because browser storage is origin-scoped and the OAuth loopback redirect always returns to 127.0.0.1.

Structured logging #

Logs are newline-delimited JSON. LOG_LEVEL controls server output and defaults to info in production and warn elsewhere; PUBLIC_LOG_LEVEL controls browser output and defaults to warn. Both accept debug, info, warn, or error.

Server events cover request completion/failure, API validation/rate-limit/upstream failures, HappyView retries, cache/index refreshes, feed builds, and startup warmups. Browser events cover auth/session recovery, settings synchronization, login failures, the block read's outcome (auth.blocks_loaded), and completed writes (upvote, submit, comment create/delete, follow, mute, and unmute). Write events and the block read use stable operation, outcome, category, optional HTTP status, and durationMs fields.

Every server request receives a UUID requestId; request-level, same-origin API, and HappyView upstream events reuse it so one request can be correlated without logging its URL or body. Each upstream attempt also gets its own request ID and records the workload, priority, shared queue depth, cooldown, and safe rate-limit metadata. Retry attempts are debug events; only final exhaustion is a warning. The shared sanitizer drops credentials, headers, bodies, free-form messages, DIDs, handles, subjects, URIs, URLs, tokens, and similar identifiers; it also reduces thrown errors to stable categories. Canonical timestamp, level, and event fields cannot be overridden by caller-provided data.

Longer notes on technical details, challenges, and design decisions #

The detection method the discussion at https://discourse.atprotocol.community/t/mapping-web-pages-to-canonical-at-records/904 was reaching for is the at-tags proposal's at:canonical meta tag, which we consume first (see discovery tags above). The per-platform link tags remain as fallbacks until the Social App forks and standard.site emit at:canonical themselves; when they do, the legacy patterns in extractAtUriClaims are the only code to delete. Verification stays ours either way: the proposal standardizes how a page states its records, not how a consumer decides to believe it.

The public Bluesky AppView is used for what only it can answer: its computed verification view on getProfiles, plus the follow/follower count aggregates and (for the badge endpoint's lean path) a current handle without a display-data walk. That is a deliberate, permanent decision - I'd love to just rely on HappyView, but unfortunately the aggregate number of Bluesky is strangely implemented.

Bluesky's trusted-verifier set isn't published as records, so "verified via Bluesky" can only be recomputed from a curated roster that drifts: a verifier Bluesky removes would keep counting here until the roster refreshed, showing badges Bluesky has revoked.

The AppView read is always current with Bluesky's real trusted set and validity rules (which also invalidate on displayName changes, not just handle changes), batched 25 accounts per call. Blacksky and Eurosky verifications resolve entirely through HappyView's record path: the server materializes every trusted verifier's whole record output (at.upvote.getVerifierRecords) into one subject-keyed index. Cold feed-sized requests stay unresolved instead of launching one at.upvote.getVerifications query per subject; the compatibility fallback is single-flight per DID and reserved for bounded foreground lookups. Eurosky's published membership refresh is atomic and stale-on-error, with a checked-in last-known-good snapshot refreshed by npm run update-verifiers; the HappyView list query is constrained to the list owner's repo before filtering membership. Bluesky's org is the only verifier platform we implement through a computed view.

All server-side HappyView traffic passes through one process-wide scheduler. Requests are paced and concurrency-bounded, a 429 installs a shared Retry-After cooldown with jitter, queued waits honor abort signals, and foreground work runs ahead of verifier-index refreshes. This coordinates a burst instead of letting each caller independently retry into the same bucket.

Profile batches allow 60 seconds overall for queueing, requests, and retries, with a separate 15-second network timeout starting at each dispatch.

A getProfiles call costs one unit of the shared bucket however many DIDs it carries, but the instance performs sequential PDS and bidirectional handle lookups for each of them, so a batch carries up to ten DIDs: enough to keep a normal batch (0.3-0.8 s a DID) inside its timeout, while a slow spell, which trips it at any size past a couple, shrinks batches to two DIDs for five minutes (createBatchSizer in src/lib/server/happyViewBatching.ts; getRecords reads fill the query's 25-uri cap on the same terms, with a 15-second attempt budget, shrinking to five).

The DIDs and at-uris every caller asks for in one turn of the event loop go out together (createMicrotaskBatcher), so a feed's chunks, each card's own join, and the authors a landed batch of records introduces share as few queries as they fit, and a feed build starts one read for all of its records and voters up front. A record whose earlier read failed is read alone, so a repository its authority cannot serve does not fail its neighbours again on every retry. The periodic cache.stats log carries the batch sizes in force (profileBatch, recordBatch).

HappyView failure logs include attemptCount and queueDurationMs; transport failures also include failurePhase (queue or request) so a local queue timeout can be distinguished from a slow upstream request. A profile batch that fails outright (a slow spell tripping the attempt timeout, a 5xx, exhausted 429 retries) caches nothing, unlike a negative answer. The rows waiting on those identities would otherwise keep their ghosts until the next five-minute feed generation, so the feed's metadata retry revisits them on the next load once 15 seconds have passed since the failure (isProfileRetryDue in src/lib/server/identity.ts), the same way it revisits failed subject reads.

Blobs come from the public Bluesky CDN: display-only content the app never reasons about, loaded browser-side as <img src>, resolvable for any repo's blobs by did+cid (BLOB_URL_TEMPLATE swaps the image host in one move; the local dev environment uses it to serve blobs from the dev PDS).

Production needs two HappyView registrations: a public browser client for OAuth and a confidential server client for read-only rendering/index work. The public client registration must allow the exact scopes served by /client-metadata.json, including comment-record deletion and the audience-qualified rpc:app.bsky.graph.muteActor, unmuteActor, and getMutes permissions. Changing the metadata alone is insufficient because HappyView validates the negotiated token scopes against its registered client. Existing browser sessions predate these permissions and need one fresh login before comment deletion and the mute control become available. Production also needs the instance's XRPC proxy to relay those three mute RPCs as the caller: in the HappyView dashboard under System, XRPC Proxy, or PUT /admin/settings/xrpc-proxy with {"mode":"allowlist","nsids":["app.bsky.graph.getMutes","app.bsky.graph.muteActor","app.bsky.graph.unmuteActor"],"routing":"serviceproxy"}. Under the default authority routing HappyView forwards them anonymously, Bluesky answers 401, and every signed-in viewer sees the mutes-blocked notice with a retry; nobody is logged out for it. The block projection adds nothing to this checklist: it reads public records off the viewer's PDS and the instance's own at.upvote.getListMembers query, so it works under either routing, needs no scope, and turns on for every existing session without a fresh login.

After changing the browser client ID, redirect, origin, or scope set, verify the deployed metadata against the exact HappyView key used by that environment. With an admin token in the local .env, Railway can inject the remaining staging values without printing them:

railway run --service upvote.at --environment staging npm run oauth:verify

The check is read-only and fails if the checked-out scope constant, deployed metadata, runtime client key, or HappyView registration differ. Authorization servers may cache client metadata; scope changes therefore need a two-phase rollout with at least the authorization server's cache TTL between publishing the expanded metadata and requesting it, or a new versioned client ID registered in HappyView.

Lexicons #

Lexicons are stored in the upvote.at/lexicons repo and define how the system works.

The app mostly relies on the at.upvote.signal record, a signal that can be toggled on or off. The other lexicons are mostly queries and procedures that read and write the data the app needs.

HappyView XRPC Lua scripts #

Copies of the Lua scripts our HappyView instance runs are versioned in happyview/. We try to use the display name inside of HappyView as the filename, appended with the appropriate file extension (.lua).

  • xrpc.query:at.upvote.getSignals.lua: the query handler that lists indexed signals newest first, optionally filtered by account.
  • xrpc.query:at.upvote.resolveDid.lua: the query handler that resolves a DID to its current, bidirectionally verified handle.
  • xrpc.query:at.upvote.getVerifications.lua: the query handler that lists indexed verification records naming a subject.
  • xrpc.query:at.upvote.getVerifierRecords.lua: the query handler that lists indexed verification records a verifier has issued (the by-repo twin of the above).
  • xrpc.query:at.upvote.getListMembers.lua: the query handler that lists indexed listitem records belonging to a list.
  • xrpc.query:at.upvote.getProfiles.lua: the batched profile handler: one index read for the whole batch, then per DID one read of its DID document and one com.atproto.identity.resolveHandle check, plus a direct-to-PDS fetch-through for a record the index lacks (not HappyView's own indexed dispatcher; the script's comments say why). The DID document serves both halves: its #atproto_pds service is the PDS the miss path reads, and its alsoKnownAs is the handle claim the resolveHandle check confirms, the same rule resolveDid applies; the script does not nest that query, which would re-read every document a second time.
  • xrpc.query:at.upvote.getRecords.lua: the batched record handler: one index read for the whole batch (db.raw over the record index, one db.get per uri where that is unavailable) with a direct-to-PDS fetch-through per miss, each repo's PDS resolved once per batch.
  • xrpc.query:at.upvote.getComments.lua: lists raw direct children for a link or comment subject; its paginated all=true mode returns body-free { uri, subject, validation } edges so the app can aggregate total per-link comment counts in one scan. That scan pages by keyset (no sort, so a deep page costs no more than the first) and reads no cids; subject/did pages stay sorted newest first and fill any missing cid with one batched db.raw read (one db.get per row where raw SQL is unavailable), and uris resolves its up to 25 records in one batched read the same way. While an instance is still running a pre-all registration, the app detects its HTTP-200 InvalidRequest response and falls back to cached, subject-scoped discussion walks, including nested replies. The versioned countable-v1 attestation covers HappyView's URI, subject, byte-size, non-whitespace, datetime, and facet checks. To keep this graph bounded without embedding Unicode's evolving UAX #29 tables in Lua, v1 conservatively accepts at most 5,000 Unicode scalar values (with CRLF counted once): it never counts text over the app's 5,000-grapheme limit, but an exotic otherwise-valid comment containing more than 5,000 scalars joined into at most 5,000 graphemes can be omitted from the displayed total.
  • xrpc.query:at.upvote.getNotifications.lua: authenticated mention feed derived from validated DID facets; the recipient comes only from caller_did. Both index streams are narrowed in the database before Lua verifies anything (signals by a LIKE prefix on the subject's authority, comments by a LIKE on the facets' JSON text for the caller's DID), so a page costs one query per stream plus one first-signal lookup per authored subject; a cursor issued before the comment narrowing continues unfiltered, and an instance that refuses the facet filter falls back to the plain scan.
  • record.create:at.upvote.signal.lua, record.update:at.upvote.signal.lua, record.delete:at.upvote.signal.lua: the triggers that index, re-index, and remove signals as the firehose reports repo changes.
  • record.create:at.upvote.comment.lua, record.update:at.upvote.comment.lua, record.delete:at.upvote.comment.lua: validate and maintain the network-wide comment index.
  • record.create:network.cosmik.card.lua, record.update:network.cosmik.card.lua, record.delete:network.cosmik.card.lua: index Semble URL cards as compact rows: {subjectKey, atSubject?, createdAt} for an http(s) URL, keyed by upvote.at's canonical web subject, and {atSubject, createdAt} for a card URL that is itself an at:// record URI (Semble types the field as a plain uri), which has no web key. web_subject_key mirrors src/lib/server/webSubject.ts (WHATWG parsing as Node performs it, fragment dropped) and is repeated byte-for-byte in the update trigger and the query, since scripts cannot require each other; src/lib/server/webSubject.spec.ts runs the Lua and the TypeScript against one table of cases and fails if the copies drift. at_subject_of derives atSubject with no page fetch, mirroring normalizeSubject's offline paths: a URL keyed to a host in POST_CLIENT_HOSTS with the path /profile/<actor>/post/<rkey> becomes at://<did>/app.bsky.feed.post/<rkey>, and an at:// card URL becomes its canonical record URI. A DID actor or authority costs nothing; a handle costs one com.atproto.identity.resolveHandle (pcall-guarded, so a failed lookup only leaves atSubject off, or skips an at:// card, which has nothing else to be keyed by), a handful a month at Semble's ~13K cards. Lua cannot import the Aturi waypoints catalog src/lib/server/postClientHosts.ts derives its hosts from, so the block carries a static, sorted copy of the list; src/lib/server/postClientHosts.spec.ts fails when that list differs from the app's set (a catalog upgrade that adds a client means adding it to the Lua too) or when the block's three copies (both card triggers and the query) drift. NOTE cards, and URL cards neither function can key (IDN, IP-literal, and percent-encoded hosts the mirror declines rather than risk a wrong key; malformed or unresolvable at:// URLs), are not indexed.
  • record.create:network.cosmik.collectionLink.lua, record.update:network.cosmik.collectionLink.lua, record.delete:network.cosmik.collectionLink.lua: index the edges that file a card into a collection as {cardUri, collectionUri, addedAt} rows.
  • record.create:network.cosmik.collection.lua, record.update:network.cosmik.collection.lua, record.delete:network.cosmik.collection.lua: index collection names, and nothing else, so saves can be labelled.
  • xrpc.query:at.upvote.getSembleSaves.lua: lists Semble saves newest first (pages of at most 25 cards), either everyone's saves of one subject (subject, for a link page) or one account's saves of every subject (did, for a profile). Each save names the subject it saved, and each card's collections are joined through the saver's own repo (Semble files a card from the repo that holds it).
    • A request is two index reads: one db.query for the cards (every key it asks in one OR filter group) and one db.raw self-join of happyview_records that reads the page's links through the savers' repos, ranked in SQL to five per card, with each collection's row joined for its name. An instance without db.raw (or whose raw read fails, which retires the path for the script's lifetime) joins the structured way instead: one db.query per saver for all their cards on the page, plus one memoized db.get per distinct collection. One whose db.query takes no filter group reads key by key and card by card.
    • A subject is either an http(s) URL, normalized with web_subject_key and matched against subjectKey, or an at:// record URI with a DID authority, canonicalized offline by at_subject_of and matched against atSubject (a handle authority is refused rather than resolved). Each save's subject is the row's web key, or its at-uri for an at:// card, and a save also carries atSubject whenever its row has one, whichever selector found it.
    • An at:// subject may bring a url, the page its record lives at: both keys are read in the same request and the answer is one page, both keys' cards newest first and cut to limit, with truncated saying whether either had more (no cursor).
    • A card filed in several collections is one save per collection; totals are the app's, from one page per link. The script's header flags what has not been verified against a live instance: that filter/sort name trigger-stored row fields the way getComments relies on, and that a query lexicon's upload can carry its target collection's backfill.
  • xrpc.query:at.upvote.getElsewhereSummaries.lua: a page of link cards' "Elsewhere in the Atmosphere" glances in one request: for up to 40 subjects, each crowd source's distinct-people count and newest few markers, one db.raw statement per source (a VALUES table of the subjects' keys joined to the rows carrying them, ROW_NUMBER() per subject over each person's newest mark); answers BatchUnavailable wherever raw SQL cannot serve it, and the app walks subject by subject instead.
  • record.create:site.standard.graph.recommend.lua, record.update:site.standard.graph.recommend.lua, record.delete:site.standard.graph.recommend.lua: index standard.site recommends (about 2K a month network-wide) as compact {document, createdAt?} rows, keeping only records whose document is a site.standard.document at-uri with a DID authority; an update that stops naming one removes the row.
  • xrpc.query:at.upvote.getStandardSiteRecommends.lua: lists standard.site recommends newest first (pages of at most 100), either everyone's recommends of one document (document, a DID-authority site.standard.document at-uri, for a link page) or one account's recommends of every document (did, for a profile), each naming its record, its recommender (always the record URI's authority), and its document. Its schema lives in the upvote.at/lexicons repo, not under ./lexicons. Totals are the app's: one page of 100 per document.
  • xrpc.procedure:at.upvote.toggleSignal.lua: the procedure that toggles an upvote on or off.
  • xrpc.procedure:at.upvote.createComment.lua: writes a validated comment into the authenticated caller's repository.
  • xrpc.procedure:at.upvote.deleteComment.lua: deletes one canonical comment URI only when its authority is the authenticated caller DID; it never cascades into replies.
  • xrpc.procedure:at.upvote.toggleFollow.lua: the procedure that toggles a follow on or off. It delete_local()s its own write immediately: follow state belongs to the caller's PDS, and the local follow collection stays out of ingestion (see the record.index filter below).
  • record.index:app.bsky.graph.follow.lua skips persistent follow ingestion while allowing delete events to remove old rows. toggleFollow reads the caller's PDS with pagination, verifies remote deletion, and removes its temporary local rows. Keep this filter in every script sync.
  • job.run:cull-follow-records.lua is a parked legacy culler; nothing should enqueue it. Existing backlogs use the native happyview.delete-collection job after the ingestion filter is verified. The old SQLite boolean-decoding limitation is fixed in the current runtime; do not restore automatic custom-culler scheduling.
  • xrpc.procedure:at.upvote.putSettings.lua: the procedure that upserts a viewer's settings record. Flags, in its own comments, the assumptions it makes about this instance's scripting API that haven't been verified against real HappyView docs yet; read those before deploying it.

These are mirrors of the live scripts running in HappyView and are documented here for reference and reuse by others.

To upload all supported local lexicons and Lua scripts with HappyView's admin API:

HAPPYVIEW_ADMIN_TOKEN=hv_... npm run hv:sync

The command expects the lexicon repo at the normal sibling path ../lexicons, with ./lexicons supported as a fallback for a combined checkout. Set HAPPYVIEW_LEXICON_DIR to an absolute path or a path relative to this app repo to use a different layout. Validate both inputs without contacting HappyView first:

npm run hv:sync -- --dry-run

The sync searches nested directories, validates every lexicon, rejects duplicate IDs and XRPC scripts without matching schemas, and lists the upload inventory in dry-run mode. All Lua scripts are uploaded first, followed by shared definitions, record schemas, and endpoints. Endpoint target collections are included on every upload; the first upload of the signal and comment record lexicons requests their initial backfill.

HappyView subscribes to (and backfills) only collections it has a record lexicon for, whatever a trigger or query names. Every other app's collection this repo indexes through its own record.* triggers (Semble's network.cosmik.*, standard.site's site.standard.graph.recommend and .subscription, Standard Reader's app.standard-reader.read and .bookmark, Glean's at.glean.like) is therefore registered as a network lexicon, fetched from its authority's published schema. After the uploads the sync lists the instance's lexicons and, for each such collection it lacks, registers it (POST /admin/network-lexicons) and starts a backfill of the collection (POST /admin/backfill), once; a collection already registered is left alone. Without that, a collection's triggers never fire and its query answers "nobody" (how eleven recommends once went missing from a link page). Uploading a job script does not enqueue the job.

A trigger change reaches only the records indexed after it lands. Card rows stored before the card triggers derived atSubject stay keyed by subjectKey alone (a save of a Bluesky post link keeps only its web key, which no post's page asks for, so it does not meet the post's at-uri), and rows stored before they derived looseKey never match a link's tracking-free form, until network.cosmik.card is backfilled again. hv:sync does not do that: the getSembleSaves upload requests the card backfill only when it creates the lexicon (its first revision), and re-uploading the scripts re-indexes nothing. After syncing the updated triggers, start a network.cosmik.card backfill from the HappyView dashboard; it pays one pcall-guarded resolveHandle per handle-actor post card, once. Whether a backfill re-runs the trigger over records the index already holds has not been verified against a live instance; if it skips them, those rows gain atSubject only as their cards are next updated.

Every record and shared-definition lexicon is synced. Query and procedure lexicons are synced when a matching Lua handler exists. Currently setSignal, setFollow, getCommentEdges, and normalizeSubject are skipped and reported: the first three have no runtime implementation, and normalization runs in the website's server route. Registering these schemas alone would enable generic endpoint behavior that does not satisfy their contracts.

The command uses HAPPYVIEW_URL (defaulting to https://happyview.upvote.at) and also loads an ignored .env file when present. The admin token is distinct from HAPPYVIEW_KEY: it needs lexicons:create and scripts:manage, plus backfill:create when installing the signal and comment lexicons for the first time. Never commit the token.

TODOs #

Supporting projects #

  • Another medium-shot project I'd like to create is a number of ways to upvote without going to the website:
    • Chrome extension that you can click and it will upvote the link you're on.
    • A bookmarklet that you can click and it will upvote the link you're on.
    • An iOS shortcut that you can share to and it will upvote the link you shared.
  • Implement labeler processing for the feed:
    • Labelers that apply to the default feed
    • Leverage labelers within the built-in feeds (hot / new / top)
    • Let users create custom feeds with custom labeler choices

Development #

Once you've created a project and installed dependencies with npm install (or pnpm install or yarn), start a development server:

# install dependencies
npm install

# run the development environment
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open

You'll want to set up a .env file with the following variables:

HAPPYVIEW_URL=https://happyview.upvote.at

# Public client used by browser OAuth. This hvc_ key is intentionally exposed
# to the browser and must be registered as a public client.
HAPPYVIEW_KEY=hvc_public_client

# Confidential client used only by server-side reads. Give it the required
# query scopes and keep the hvs_ secret in the deployment secret store.
HAPPYVIEW_SERVER_KEY=hvc_server_client
HAPPYVIEW_SERVER_SECRET=hvs_server_secret

# Optional: where upbot (the separate bot repo that upvotes through mention
# replies) is deployed. Powers the authorization status and authorize /
# deauthorize controls on /settings; leave unset to hide those controls.
UPBOT_URL=<upbot's PUBLIC_URL, e.g. https://upbot.upvote.at>

# Optional: display filters (src/lib/server/filters.ts), applied at the one
# aggregation choke point every surface reads through. Comma-separated;
# partial subject URIs match as prefixes. Links whose domain has no
# registered public suffix are always filtered (and refused at submit).
FEED_FILTER_SUBJECTS=<partial subject URIs, e.g. https://spam.example.com>
FEED_FILTER_DIDS=<DIDs whose signals never display>

# Optional: the recommend and subscribe controls on standard.site article
# cards. Adds two write scopes to every login, so leave it unset until every
# HappyView client registration allows them, then roll out "metadata" before
# "true" (docs/authentication.md).
PUBLIC_STANDARD_SITE_WRITES=<unset, metadata, or true>

Storybook #

Use Storybook when building or reviewing UI in isolation:

npm run storybook       # http://127.0.0.1:6006
npm run build-storybook # verify the static catalog builds

The toolbar switches between the app's dark, light, and Pride themes and between reduced and full motion. It starts with reduced motion so visual comparisons are deterministic. Theme tokens, bundled fonts, the page backdrop, and shared animations all come from src/lib/styles/theme.css, which the app and Storybook both import. Reusable controls and layout utilities live in src/lib/styles/primitives.css; rendered Markdown, editor content, syntax highlighting, and mention-menu rules live in src/lib/styles/content.css. Change those shared sources (or the production component itself), not a story-only copy.

The catalog includes production-backed references for application navigation, primary actions, the comment composer and rich editor, mentions, notifications, profile headers, settings controls, feeds, links, and comments. Shared fixtures live in src/lib/fixtures; src/stories/fixtures.ts re-exports them for the stories that already import it.

Local AT Protocol environment #

npm run dev runs against the real network (HappyView, plus the public Bluesky AppView for its verification view), but Vite skips its speculative first-render warm-up unless HAPPYVIEW_URL names a loopback host. To develop against a fully local network instead, start the AT Protocol dev environment (scripts/atproto-dev-env.ts):

npm run dev:atproto

It boots a real PLC directory and a real PDS via @atproto/dev-env, creates fixture accounts holding real records (profiles, verifications, signals, and a standard.site publication + document with a real cover blob), and serves local stand-ins for every service the app consumes; HappyView's published at.upvote.getSignals/at.upvote.getVerifications/at.upvote.getVerifierRecords/ at.upvote.getListMembers/at.upvote.getProfiles/at.upvote.getRecords/ at.upvote.getComments/at.upvote.getNotifications queries indexed live from the PDS, its on-demand com.atproto.repo.getRecord/com.atproto.identity.resolveHandle proxying, the published at.upvote.resolveDid query, blob bytes (the BLOB_URL_TEMPLATE target), the appview's verification-carrying profile read, and the fixture subjects as real web pages with OpenGraph titles. It also exposes authenticated, private in-memory stand-ins for app.bsky.graph.muteActor, unmuteActor, and getMutes; /test/reset clears that state along with the repository fixtures. The block read needs no stand-in: the dev PDS answers com.atproto.repo.listRecords itself and the environment already serves at.upvote.getListMembers. Those stand-ins verify endpoint behavior through the harness's legacy bearer sessions. They do not emulate the production browser's DPoP nonce flow, the PDS atproto-proxy hop, or PDS-to-AppView service authentication; those transport rules are covered by isolated client tests instead. Point a dev server at it with the same env the E2E suite uses (see the webServer block in playwright.config.ts):

ATPROTO_DEV_ENV=1 HAPPYVIEW_URL=http://127.0.0.1:2581 APPVIEW_URL=http://127.0.0.1:2581 \
TYPEAHEAD_URL=http://127.0.0.1:2581 \
BLOB_URL_TEMPLATE='http://127.0.0.1:2581/blob?did={did}&cid={cid}' npm run dev

There's probably some things I've not documented yet. Either feel free to open an issue, submit a PR, or ping me on Bluesky at @bnb.im.

Build #

To create a production version of your app:

npm run build

You can preview the production build with npm run preview.

The build targets adapter-node because the app's caches are in-memory and warmed once at boot (src/hooks.server.ts), and concurrent feed builds coalesce, all of which assumes one long-lived server process. Deploy the app as a Node.js server (node build); a serverless target would cold-start every request and silently defeat the caching.

Production HTML is gzip-compressed when the browser accepts it, with each chunk flushed so deferred feed data still streams. Static assets use adapter-node's precompressed files. Stylesheets below 32 KiB are inlined in the HTML to avoid blocking CSS requests on a cold visit. The OAuth SDK loads on demand: visitors with completely empty local and session storage can browse without it; login, OAuth callbacks, any existing storage, and cross-tab account changes use the full session flow.

The feed gives cold metadata 80 ms, then streams candidate rows while keeping unresolved cards as ghosts. Each card appears once its subject content and display identities are available; optional badges, counts, and images continue loading independently. URL fallbacks whose authors have not been discovered remain hidden for viewers with mutes or blocks. Profiles publish per display batch (up to ten DIDs); display and Bluesky badge requests have separate freshness/failure clocks. The initial feed renders 30 rows, with "load more" applying after mute and block filtering and ranking across the complete candidate list. Candidate/voter data still travels to the browser so hot, new, daily top, following, and mutuals keep their existing ranking semantics.

All runtime application caches are held in process memory. Feed generations and verifier records serve their last successful in-memory values during background refreshes. There are no feed or verifier cache files, and the former FEED_CACHE_PATH and VERIFIER_INDEX_CACHE_PATH variables are ignored. A fresh process rebuilds from upstream records; no writable cache directory or persistent volume is needed.

Any cache a request can add a key to is bounded, because a visitor can name a subject or a DID this process has never seen, and without a bound every answer, negative ones included, would stay until restart. BoundedMap (src/lib/server/boundedMap.ts) caps them by entry count, evicting in insertion order; the caches real pages keep reading refresh an entry on read. Negative answers live in their own smaller map beside the positive one, so a stream of invented keys only churns that half and can never evict the metadata the feed renders from: subjects 20,000 resolved and 5,000 failed, document bodies 500, profiles 20,000 resolved and 5,000 empty, profile failures 5,000, the handle index 20,000, and each Elsewhere source's walks 5,000 that found someone and 5,000 that did not. Eviction only costs a refetch.

Work a request can only cause by naming something unfamiliar also spends a per-client allowance, allowColdWork in src/lib/server/coldWork.ts (60 units a minute): a link page or Elsewhere lookup for a subject with no upvotes, a profile for a DID with no cached profile and nothing in the signal index, or a handle the index can't answer. Answers the app already has never charge it. Past it, the link and profile routes answer 429 without any upstream call, and the Elsewhere section answers from cache or as empty. The reader route (/api/doc) serves only documents the process already knows. Subject path parameters longer than 8,192 bytes (MAX_SUBJECT_BYTES, the submit box's and HappyView getComments' limit) are refused before any work. Semble and standard.site lookups for a link page run at background priority in the HappyView scheduler, and the server's scheduler sheds new non-foreground requests once its queue is full (see src/lib/rateLimit.ts).

The allowance, like every other per-client limit here, keys on getClientAddress(), which only names the client once ADDRESS_HEADER (and XFF_DEPTH, for X-Forwarded-For) describe the proxies in front of the app. Until then every visitor shares one allowance. The first requests of each process log request.client_address_shape, which says which headers the proxies set, without logging any address; see .env.example.

cache.stats is logged every five minutes with each cache's size, eviction counts, the HappyView queue depth and shed count, and the heap in megabytes (src/lib/server/cacheStats.ts).

Settings renders cached verifier membership and handle hints immediately, then refreshes names separately. Returning browsers begin downloading the OAuth module during module evaluation. A restored session gets exactly one liveness probe (GET /oauth/sessions/{did}) before it is published. Profile decoration, own-signal reconciliation, settings, the mute read, and the block read all overlap once it is. Validated account controls can appear while activity remains hidden until the complete mute and block sets are known.

To inspect loading, record a browser Performance trace or inspect performance.getEntriesByType('measure').filter(entry => entry.name.startsWith('upvote.')). The latest measurement per stage is retained, exposed as upvote.<stage>: auth.sdk (the SDK download), auth.restore (the SDK's init(), a local restore or the callback exchange), auth.session (the liveness probe), auth.mute_page (each mute page), auth.mutes (the whole mute read), auth.block_page (each page of the block record listing), auth.blocks (the whole block read), feed.data_ready, feed.first_visible, and settings.first_visible. Enabling browser info logging also emits page.load_stage with stage and duration, without identifiers or credentials. First-visible measurements include navigation time; compare signed-in reloads, settings navigation, and returning to a tab as well as anonymous visits.

The first full signal scan takes priority over background verifier work; later scans serve stale memory while refreshing. Concurrent subject lookups share pending work per URI.

Each process owns its in-memory cache and scheduler. Do not share one client bucket across server and browser traffic: configure the confidential server client variables above.

The public comment preview, mention lookup, and notification helpers use SvelteKit's getClientAddress() for per-client throttling. When the Node.js server is behind a trusted reverse proxy, configure adapter-node to read the address header that proxy overwrites. For a single trusted proxy hop, that is typically ADDRESS_HEADER=x-forwarded-for and XFF_DEPTH=1; increase XFF_DEPTH to the exact trusted hop count when more proxies sit in front of the app (production runs behind Cloudflare and Railway's edge, likely two hops: read the request.client_address_shape event before choosing, as .env.example describes). Only enable this when the proxy strips client-supplied forwarding headers, since trusting an arbitrary X-Forwarded-For value would let clients bypass the limits. Without these settings, adapter-node falls back to the direct socket address, which is appropriate when the Node.js server is exposed directly.

Testing #

There are six suites:

  • HappyView contract tests (happyview/tests/) execute the versioned Lua handlers and triggers with Fengari, and are the only suite besides the live one that runs the production Lua (the local AT Protocol environment reimplements these endpoints in TypeScript). They run one process per happyview/tests/*.spec.lua through scripts/run-happyview-specs.ts, which fails the run unless every spec exits 0 and ends with its passed N line (Fengari exits 0 after an uncaught Lua error(), so a trigger that fails to load would otherwise pass silently; a new spec runs without being wired anywhere). They cover input validation and limits, output shapes against the published lexicons, cursor pagination (notifications' composite cursor included), error names, batched record classification plus the list-member and verification-query constraints, including exact bounded DID guards before an index query runs, and the comment record triggers' indexing, redaction, and tombstone rules. They also cover the Semble index: the card, collection-link, and collection triggers and the getSembleSaves join (its one-read db.raw statement in both SQL dialects, and the structured reads it falls back to, retired path by path, on an instance without db.raw or filter groups; getStandardReaderMarks and getGleanLikes are held to the same fast path and fallbacks, and getElsewhereSummaries to its one statement per source, its bound placeholders, and its BatchUnavailable answers), and the standard.site recommend triggers and getStandardSiteRecommends selectors (the shared URL normalizer is additionally run against the app's own in src/lib/server/webSubject.spec.ts, and the static post-client host list behind atSubject is held to the app's POST_CLIENT_HOSTS in src/lib/server/postClientHosts.spec.ts). Fengari's integers are 32-bit, so handler arithmetic that can pass 2³¹ (datetime epochs) is written as float.
  • Unit tests use Vitest for the domain modules in src/lib/server/ (signals, subjects, identity, verification, comment validation/Markdown) and the browser modules (utils, graph, feeds, upvotes, comment creation/sorting/notifications, follow, the client half of verification, and friends; every *.spec.ts under src/). Fast, no network, no browser; outbound calls (the AppView pulls through at.upvote.getSignals in signals.spec.ts, record/handle resolution in subjects.spec.ts, profile lookups in identity.spec.ts) are mocked.
  • E2E tests use Playwright and exist in e2e/, covering the logged-out surface of every route end-to-end plus a small visual regression suite, all against the local AT Protocol environment above, so every rendered handle, title, and badge traces back to a real record in the dev PDS. A signed-in session is reachable where a test needs one, through the returning-viewer fixture (e2e/loading-viewer.ts), which seeds the SDK's own session row and answers the instance locally; the settings page's bot authorization controls are covered that way, including the link built for each status answer and the retry offered when that answer never arrives. Only completing a real PDS consent screen stays out of reach.
  • Loading tests run the production app with filesystem writes denied and an in-memory fixture of 5,000 signals. They check cold settings/feed paint, warm and expired-cache rendering, and signed-in mute gating.
  • Lighthouse tests audit the seeded homepage, login, and settings pages against a fresh production build using a separate local AT Protocol fixture. They enforce 95 for performance and 100 for accessibility, best practices, and SEO, using Lighthouse's default mobile simulation. The budgets live in e2e/lighthouse.spec.ts. CI takes three samples per page and checks the median performance score; the other categories must meet their floors in every sample. Navigation/audit errors always fail.
  • Live login tests (e2e/live/, playwright.live.config.ts) are the only suite that touches the real network. A dedicated test account on Bluesky's PDS (bsky.social) signs in the way a viewer does: the handle form, the SDK's handle resolution and pushed authorization request, the provider's own sign-in and consent pages, the callback, the token exchange, and registration with the production HappyView instance. Per account the suite checks the browser holds only the SDK's session row (no refresh token, none of the retired design's keys) for the DID the handle really resolves to, that the mute gate resolves against the real instance (the outcome, ready or blocked, is recorded as a test annotation), that a reload restores the session through HappyView's liveness probe, that the private routes open, that a settings change lands on the account's PDS as at.upvote.settings through HappyView's putSettings, and that logging out revokes the session (a 2xx DELETE /oauth/sessions/<did>) and clears storage. Credentials come from BSKY_TEST_ACCOUNT_* (see .env.example); a bare username gets the provider's handle domain appended. Without them npm run test:live skips with a message so npm test stays runnable; the live workflow sets LIVE_E2E_REQUIRED=1 so a missing account fails there. Before any login, the runner (scripts/live-e2e-preflight.ts) asks HappyView to accept HAPPYVIEW_KEY and stops with HappyView's own error if it doesn't, since an unset or unregistered key otherwise shows up only as every login failing with the app's generic "session service isn't available" notice. The suite records no trace and no video (both would capture the provider's sign-in submission), attaches the provider page's accessibility snapshot when a provider step fails, and attaches the app's redacted browser events on any failure. Every test logs out, including after a failure, so no real grant is left behind.
# HappyView Lua contracts
npm run test:happyview

# unit tests
npm run test:unit        # watch mode
npm run test:unit -- --run   # single run

# e2e tests; first time only, download a browser:
npx playwright install chromium

npm run test:e2e         # headless run (auto-starts the atproto dev env and the dev server)
npm run test:e2e:ui      # Playwright's interactive UI, great for debugging

# Production loading with application filesystem writes denied
npm run test:loading

# Lighthouse (uses the same Chromium download; builds and starts the app)
npm run test:lighthouse
CI=true npm run test:lighthouse # three samples per page, matching CI
npx playwright show-report lighthouse-report

# Live logins with the real test account (needs BSKY_TEST_ACCOUNT_* in .env;
# skips when unset). Starts its own dev server on 4181 (LIVE_E2E_PORT) wired
# to the real network.
npm run test:live
npm run test:live:ui                      # Playwright's UI, real logins included
LIVE_BASE_URL=https://staging.example npm run test:live  # against a deployed origin instead
npx playwright show-report playwright-report/live

# the fast half of the above, concurrently: lint, types, unit, HappyView (~13s)
npm run verify

# everything: HappyView, unit coverage, E2E, loading, Lighthouse, then live logins; run before a release
npm test

Lighthouse requires Node.js 22.19 or newer; the project's pinned Node.js 24 version is supported. Each audit saves HTML and JSON files under lighthouse-results/ and attaches them to the separate lighthouse-report/ Playwright report, including when a score fails. These generated directories are ignored by Git. The production server uses port 4180 (LIGHTHOUSE_PORT to override), and the fixture uses ports 2681-2683 (LIGHTHOUSE_FIXTURE_PORT sets the first port). The suite refuses to reuse running servers so fixture changes cannot affect the scores. Performance scores vary with machine load; inspect the report before changing a budget.

The E2E workflow runs the Playwright suite on the same triggers. Nothing downloads a browser there, because @playwright/test has no install script, so it takes Chromium from Nixery and points playwright.config.ts at it through PLAYWRIGHT_CHROME_PATH (LIGHTHOUSE_CHROME_PATH also works, so the loading suite's variable keeps working); local runs leave both unset and use Playwright's own download. The image has no /etc/fonts/fonts.conf, so fontconfig starts with no configuration and no fonts, and that Chromium then drops everything Playwright types into a text field (fill() leaves it empty, and a required field blocks its form's submit with no event anyone can observe); the workflow lists dejavu_fonts and writes a one-directory fontconfig config of its own, exported as FONTCONFIG_FILE, before the suite runs. It takes the fixture's better-sqlite3 binary prebuilt, never compiled on the runner (see below). It runs with --ignore-snapshots: the committed baselines are named *-chromium-darwin.png, Playwright looks for *-chromium-linux.png on CI and would fail on every one, so the visual specs still execute and still catch a crash or a broken render, but pixel comparison stays a local check until Linux baselines are generated on the CI image. The suite reaches no network outside the local fixture, so this workflow needs no secrets.

The independent Lighthouse workflow runs on pushes to main, pull requests targeting main, and manual runs. It uses Nixery's Node.js 24 and Chromium, selected via LIGHTHOUSE_CHROME_PATH, with the same dejavu_fonts plus FONTCONFIG_FILE setup as the E2E workflow: with no font at all a page still serves and audits, but every text box lays out at zero size, so the pre-audit check reports the seeded rows' titles as hidden, and navigating to /settings, which names font families, closes the whole browser. Score summaries and failing audit names appear in the CI log. Local runs normally use Playwright's downloaded Chromium. These are repeatable local-fixture budgets, not measurements of production network latency or the full production feed.

Neither workflow compiles the fixture's SQLite binding on the runner. The dev environment's PDS uses better-sqlite3, a native addon, and npm ci --ignore-scripts leaves it without a binary, so the install step runs npm rebuild better-sqlite3, whose install script downloads the project's prebuilt Linux binary. The workflows used to compile one instead (with gcc, gnumake, python3, gnused and gnugrep in dependencies), and that compile is now poison: Node.js 24.19 changed the header-only ObjectWrap class every such addon inherits from so that each wrapped object registers an environment cleanup hook and removes it in its destructor, and V8 runs those destructors from a garbage-collection task on an idle event loop where Node has no current environment, so the process aborts with Assertion failed: (env) != nullptr in RemoveEnvironmentCleanupHook. In the E2E suite that took about nine minutes of resets to hit, after which every test failed on POST /api/test/reset (the route now names the unreachable fixture URL when that happens). The prebuilt binary predates that header. The compiler toolchain is gone from dependencies on purpose: if the prebuild download ever fails, the step fails right there instead of quietly compiling a binary that crashes later. Local runs are unaffected, since npm ci installs the prebuilt binary for your platform.

Spindle's workflow timeout (15 minutes on tangled.org at the time of writing) covers the Nix install and the suite together; a run of the E2E suite in which every test retries twice is what overruns it, a passing run is well inside.

The live workflow runs the live login suite on the same triggers, with Nixery's Chromium selected via PLAYWRIGHT_CHROME_PATH and the same dejavu_fonts plus FONTCONFIG_FILE setup as the E2E workflow, without which the handle never reaches the login form and every test reports a login that never left the page. Because nothing but the log leaves the runner, the suite prints what an attachment would hold when a test fails: the redacted browser events (the app's auth.* lines, uncaught exceptions, navigations, and every API call with its status), and for a login that never left the page, whether the form is still busy, whether the handle is still in the field, and the accessibility tree of the page. It needs five repository secrets (Settings > Secrets, never the workflow's environment: block, which is public): the account pair, plus two HappyView clients registered only for CI. HAPPYVIEW_KEY is tangled (ci), a public client whose client_id_url is http://127.0.0.1:4181/client-metadata.json with no allowed origins and scopes byte-identical to OAUTH_SCOPE, because HappyView rebuilds the loopback client_id it refreshes with out of every token of the registered scope string. HAPPYVIEW_SERVER_KEY and HAPPYVIEW_SERVER_SECRET are tangled (ci server), a confidential client scoped to atproto com.atproto.repo.getRecord for the dev server's own reads. That pair is not optional: without it the server falls back to the public key and the feed's server-side reads share one rate bucket with the browser's login traffic, which showed up as login-start failures and stalled page loads when it was tried. Using CI-only clients also means a leak is contained: revoke those two registrations and nothing that serves upvote.at changes.

LIVE_BASE_URL points the same suite at a deployed origin instead of starting a server, which needs that origin's /client-metadata.json registered with its HappyView (npm run oauth:verify). Each run makes two real logins and revokes every one at the end, so the account never accumulates grants; the settings record on the test account flips between hot and new on every run.

Who can reach those secrets #

Spindle hands a repository's secrets to a pipeline only when the pipeline's source repo is the repository itself, and it starts a pull-request pipeline only for branch-based pull requests (spindle/tapclient.go ignores patch-based and fork-based ones outright; spindle/engine/engine.go skips secrets for any untrusted source). Pushing a branch to this repo needs write access, and the manual trigger checks the same push permission, so a pull request from a stranger runs no pipeline and is handed nothing. The people who can read these secrets are exactly the people who can already push here: the workflow that runs is the one on the PR's own head commit, so a collaborator can always change it. Spindle masks known secret values (and their base64 forms) in the persisted logs, which stops an accidental echo, not a deliberate one.

The practical consequences, and why the suite is built the way it is:

  • Keep CI credentials distinct from production ones so revoking is cheap. The only production credential in the store is RAILWAY_PRODUCTION_TOKEN, a Railway project token that can deploy to production and nothing else, and it is there because the deploy has to run somewhere with the code checked out.
  • Never add a secret to a workflow environment: block. Spindle injects secrets into every step on its own, and a name listed there is public and shadows a missing secret with the literal string $NAME (scripts/live-e2e.ts refuses to run when it sees one).
  • Every workflow in a pipeline receives every secret, which is why test.yml names the suites it runs one by one instead of calling npm test: that chain ends with the live logins and the Lighthouse audit, both of which have their own workflow, so running it there would duplicate the audit and start a second live run logging in as the same account at the same time. LIVE_E2E_SKIP=1 is the escape hatch if a workflow ever does need the whole chain.

Continuous integration #

Six workflows in .tangled/workflows/ run on pushes to main, pull requests targeting main, and manual dispatch: lint (ESLint, svelte-check, the two script/e2e tsc projects, and a Storybook build), test (HappyView contracts and unit coverage), e2e, lighthouse, live, and deploy (staging). They are separate workflows because spindle runs a pipeline's workflows in parallel, so a slow audit never delays the lint result. A seventh, deploy-production.yml, answers only to manual dispatch and is never part of a push or pull-request pipeline; see Deploying.

Each one's push constraint carries a paths filter so a documentation-only push runs nothing. Three things about that filter are easy to get wrong, and two of them fail silently:

  • It is an allowlist, not an ignore list. Spindle runs the workflow when at least one changed file matches (matchesAnyFile in workflow/def.go), and its glob dialect (doublestar) has no negation, so the filter cannot say "everything but the README": it has to name every part of the tree CI can observe. A new top-level directory that nobody adds to the lists stops triggering CI, and nothing reports it.
  • It must stay off the pull_request constraint. Spindle builds the pull-request pipeline without a changed-file list (spindle/tapclient.go constructs workflow.Compiler with only Trigger), and an empty list matches no pattern, so paths under event: ['pull_request'] does not narrow the workflow: it stops it running on pull requests entirely, with no error anywhere.
  • Manual dispatch ignores it. Workflow.Match returns true for a manual trigger before any constraint is evaluated, so a workflow a filter skipped can always be re-run by hand from the pipeline page.

scripts/ci-paths.spec.ts is the guard for all three. It parses the workflows, fails if a pull_request constraint ever grows a paths key, fails if the workflows' lists drift apart, and fails if git ls-files turns up a tracked file that matches neither the lists nor its own documented set of paths CI cannot observe (this README, docs/, editor config, the git hook). Adding a directory to that second set is how a workflow legitimately stops running for a path; a final test keeps that set from being widened until it swallows the repository.

Deploying #

Every push to main deploys to the Railway staging environment through deploy.yml.

Deploys to production are manual, via executing deploy-production.yml on Tangled.

Before pushing #

npm run verify runs the four checks that need no browser, no local AT Protocol fixture, and no network (ESLint, the type checks, the unit suite, and the HappyView contracts) as concurrent processes over the same read-only tree. That takes about 13 seconds, against roughly 37 sequentially. Output is buffered per task and printed on completion, so a failure is not interleaved with three other streams.

It is not a substitute for npm test: a change that only breaks a rendered page, a Lighthouse budget, or a real login passes verify and fails the full chain.

.githooks/pre-push runs it before every push. It is not installed by cloning:

npm run hooks:install                  # points core.hooksPath at .githooks
git config --unset core.hooksPath      # removes it
git push --no-verify                   # skips it once

A few things worth knowing before adding to the E2E suite:

  • The suite's data lives in the dev environment's PDS as real records; the app's caches (src/lib/server/{signals,subjects,identity,verification}.ts) are in-memory Maps shared by every request the dev server handles. Tests that need a known starting point call resetDatabase() from e2e/helpers.ts, which hits a dev-only POST /api/test/reset endpoint: the dev environment reconciles the PDS records to the fixture (or deletes them all), and the caches are cleared so renders re-read everything through the production code paths. The route 404s in a production build, and refuses to run on a server not wired to the dev environment (ATPROTO_DEV_ENV=1): a dev server pointed at the real network can never be "reset". Because of the shared state, playwright.config.ts pins workers: 1.
  • E2E tests never touch the internet: every service the app consumes is served locally from the dev PDS. That keeps the suite fast and deterministic, in CI as well as locally, while it still exercises the real resolution pipelines (index hydration, on-demand record fetches through the HappyView-shaped proxy, blob serving, OpenGraph titles, verification backlinks and handle-match validation).
  • Most E2E scenarios exercise logged-out behavior. Loading regressions also run the real browser SDK with synthetic session credentials and intercepted broker responses, including a delayed final mute page. The broader logged-in flows are unit-tested (subject normalization and metadata resolution in subjects.spec.ts, index hydration in signals.spec.ts, the browser-side toggle in upvotes.spec.ts, follows in follow.spec.ts). The real login itself, and everything HappyView does for a registered session, is the live suite's job; keep it to reads plus the account's own settings record, since anything it writes is a real record on a real PDS (an upvote from a test account would show up in the production feed).
  • The live suite lives under e2e/live/ so the offline config's testIgnore keeps it out of npm run test:e2e; new live scenarios go there and get their credentials through liveAccount() in e2e/live/accounts.ts, never from a literal. The provider pages are driven by accessible role and name (authorizeAtProvider), which is what to update if a provider redesigns its sign-in or consent screen; the failure attachment shows the new screen.
  • Screenshot baselines (e2e/**/*-snapshots/) are committed, but are sensitive to the OS/fonts they were generated on. If CI starts failing visual tests that look fine locally, regenerate the baselines on the same platform CI uses (e.g. via the official Playwright Docker image) rather than just re-running --update-snapshots on your own machine:
    docker run --rm -v "$PWD":/work -w /work mcr.microsoft.com/playwright:v1.61.1-noble \
      npx playwright test --update-snapshots