Skip to content

obbpr - #113

Draft
mmattbtw wants to merge 336 commits into
mainfrom
obbpr
Draft

obbpr#113
mmattbtw wants to merge 336 commits into
mainfrom
obbpr

Conversation

@mmattbtw

@mmattbtw mmattbtw commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

This is all of teal's open work in one PR again. The stacked split (#194–#243) made review harder rather than easier, so everything is folded back into obbpr. It's a fast-forward: no commits were rewritten. 183 commits, ~600 files.

What's in it

  • Appview and ingestion. Aqua XRPC appview; Cadet live Jetstream ingestion with network backfill, identity updates, account lifecycle, and durable retries; stable fm.teal.* namespaces validated as AT Protocol lexicons.
  • Social. Posts, replies, likes, reposts, playlists, follows, notifications, post and listen permalinks, and AT URI routes.
  • Music. Artist and album pages with complete discographies, ordered tracklists, canonical cover art, artist imagery, catalog normalization, and listening stats and leaderboards.
  • Redesign (formerly feat(api): power the redesign with Today, reactions, taste match, and listening calendar #238–feat(amethyst): Explore shows what teal is listening to, and every screen joins the redesign #243). teal now opens on what your friends are listening to right now.
    • New lexicons and endpoints: emoji reactions on plays and posts, four profile favourites, getToday, getReactions, getTasteMatch, getListeningCalendar, plus listening context on posts.
    • Native tab bars on iOS and Android and a frosted sidebar on the web. Shared pages push onto the current tab.
    • Every screen sits on a backdrop that blends the blurred covers currently on screen, with content on frosted panels.
    • Today: a swipeable deck of friends' listening with group moments (mutuals, everyone on teal, trending), one-tap reactions, a collapse once you've seen it, and song posts with circle context.
    • Profiles: a listening fingerprint made of cover crops, four favourites, a month of covers, and taste match.
    • Song, artist, and album pages with cover heroes; Explore discovery shelves.
    • NativeWind v5 (pinned RC 5.0.0-rc.1) and Tailwind 4, TanStack Query, PRODUCT.md and DESIGN.md.
  • Rewrite of the app. The redesign had restyled about 16,000 lines of old screens rather than replacing them, so Amethyst was rebuilt from a blank Expo root.
    • Every route was rewritten on a small design system in components/ds/: page shell, glass panels, text, buttons, choices, fields, tabs, notices, and dialog.
    • Screens load data through TanStack Query, and logic from the old screens moved into tested lib/ modules (top stats, compose, playlists, music, cross-posting, profile records). lib/ and the auth store were ported unchanged.
    • Song and album logging are now one Add a listen screen, and /manual-listens redirects to it. Posts show reactions in place of like and repost buttons.
    • The old screens, shadcn UI kit, legacy colour tokens, and display fonts are deleted (20,050 lines).
    • Commits: 7b51f60 (rebuild), 18a368a (swap), then council fixes through 41a11e4.

Verification

  • cargo test -p aqua -p cadet passes, including the ignored database test for the new endpoints run against local Postgres.
  • pnpm lex:validate passes.
  • pnpm typecheck passes.
  • The app unit tests pass (352 passed, 8 skipped). That includes a contrast test on the tokens the app uses and tests for alpha-era posts and playlists, cover sizes, and MusicBrainz outages.
  • pnpm --filter=@teal/amethyst build:web exports.
  • The redesign was checked against live local Jetstream data at desktop and phone widths, light and dark.

Not verified

  • No iOS or Android simulator build.
  • Signed-in flows weren't tested in a browser; they need the public tunnel. Reviewers read that code instead.
  • Unused dependencies (@rn-primitives, class-variance-authority, bottom-sheet, the old fonts) are still in package.json. Pruning them is a follow-up.
  • cargo clippy -D warnings fails on 30 async_trait errors that main's toolchain already reports. None are in new code.

Web QA
A three-model council reviewed the web app at 1440, 1024 and 390 wide, in light and dark. The fixes are in commits a0705ed through e49cc84:

  • Most posts on Today opened "Unsupported Teal link". Older posts keep the fm.teal.alpha.feed.social.post collection in their URI, and now route correctly.
  • Switching tabs in the browser left earlier tabs painted underneath and still reachable by keyboard. Inactive tabs are now hidden and inert. The selected tab stays visible under sign-in.
  • Row thumbnails asked the Cover Art Archive for sizes it doesn't serve, which redirected to originals (62 MB for one album). Albums with art only on the release group showed blank.
  • Keyboard focus is now visible everywhere, tabs and toggles announce their state, and secondary text meets AA contrast on the backdrop. Legacy tokens resolve to the redesign tokens, so older screens share one tint and pill buttons.
  • Loading and error states no longer show raw errors or a placeholder profile, and failures offer a retry.

Follow-ups:

  • Returning to Today after a deep-linked post can leave did/rkey in the URL. This predates the redesign.
  • The listen and track heroes lack the release-group cover fallback that Cover has.
  • The listen, track, playlist, onboarding, settings and stamp pages share the redesign's tokens but still have their old layouts.

Earlier council review (app rewrite)

Rewrite rounds: 4. Sol's round 3 didn't run because Codex hit a usage limit, so its round 4 covered everything since round 2.

Delegate Round 1 Round 2 Round 3 Round 4
GPT-6.1 Sol 6.5/10 7/10 no score 9/10
Claude Opus 5.5 6.5/10 7.5/10 8.5/10 8.5/10
DeepSeek V4.1 Flash 7/10 7.5/10 8/10 9/10

Earlier web QA of the redesign, before the rewrite (5 rounds):

Delegate Round 1 Round 2 Round 3 Round 4 Round 5
GPT-6.1 Sol 6/10 8/10 9/10 8.5/10 9/10
Claude Opus 5.5 5/10 7/10 6/10 8.5/10 9/10
DeepSeek V4.1 Flash 6/10 7.5/10 8/10 8.5/10 9/10

Codebase review and fixes (a8b6ddd..1d2d22a)
A whole-repo review and fix pass, 24 commits:

  • Security
    • Production compose no longer publishes Postgres or Garnet; Aqua and Satellite bind to loopback.
    • Playlist items are filtered to the owner and current collaborators.
    • importRepo records only import the publisher's own repo, at most once per 6 hours.
    • A listen edit can't rename a shared MusicBrainz artist, release or recording.
    • The unauthenticated stub CAR routes are removed.
    • Outbound fetches in Aqua and Cadet go only to public, pinned addresses, with no redirects and with timeouts.
    • Links from records open only http(s) URLs, on all three apps.
  • Data loss
    • Listen edits store the new CID and originUri.
    • Alpha plays get durable retries.
    • The status service no longer skips failed events, and skips unstorable ones instead of stalling.
    • CAR imports fail visibly on bad records.
    • Duplicate follows are kept through social_follow_records (new migration, backfilled).
    • Profile, status and social writes take the account lock and skip deactivated accounts.
    • A failed handle lookup no longer clears a stored handle.
    • Partial album saves keep the saved tracks and the remaining times.
  • Sign-in
    • Android signs in as a native OAuth client (/android-client-metadata.json).
    • iOS no longer restores a signed-out session or signs out on auth-server 5xx/429 responses.
  • Quality
    • oxlint (the anti-slop rules) is installed; pnpm lint passes repo-wide and runs in CI.
    • External JSON is parsed with zod.
    • Rich text and bulk edits are shared in @teal/client.
    • Amethyst's dead web/iOS branches and dependencies are removed.
    • Stale files are removed.
  • Ops: the release workflow builds the tagged commit, the pre-commit hook no longer stages excluded hunks, and Satellite's duplicate refresh is removed.
  • Behaviour change: fuzzy catalog consolidation now runs only when CADET_CONSOLIDATION_INTERVAL_SECS is set.

Verified for this pass: workspace clippy with -D warnings; cargo test for aqua, cadet and status-api, including the ignored DB tests against local Postgres; client tests (367 passed); pnpm typecheck; pnpm lint; the web build; the iOS simulator build. Android sign-in on a device is still unverified (in todo.md), as are the deferred performance items listed there.

Council review

Codebase review, rounds: 5. Opus's round 3 hit the Claude usage limit, so its round 4 covered everything since round 2.

Delegate Round 1 Round 2 Round 3 Round 4 Round 5
Claude Opus 5.5 5.5/10 7.5/10 no score 8.5/10 9.5/10
GPT-6.1 Sol 6/10 7/10 8/10 9/10 10/10

mmattbtw added 30 commits June 5, 2026 16:53
Added migration to remove 6,816 duplicate plays (same CID, different rkeys) and a unique constraint on (did, cid) to prevent future duplicates. Updated feed_play ingestor to check for existing plays before inserting, gracefully skipping duplicates.
Previously rocketman::handler only advances the cursor when its
Mutex<Option<u64>> is already Some(_); cadet initialised it from
load_cursor() which returns None on a fresh start (or after a Garnet
restart). The cursor then stayed None forever, the 60s store loop never
fired, and every subsequent restart resumed jetstream from "live",
silently dropping anything published during the disconnect window.

Replace load_cursor() with resolve_startup_cursor() which falls back to
the current wall-clock microseconds so the handler can keep advancing,
clamps stored cursors older than the 12h replay window so we don't
chase history jetstream no longer retains, and resets future-dated
cursors. Mirror every store_cursor() write to the local file so the
cursor survives Redis wipes, and bind cadet to a persistent named
volume at /var/lib/cadet for the file mirror.

Adds unit tests for the resume, fresh-start, and stale-cursor paths and
serialises the cursor tests with a tokio Mutex so cargo's parallel
runner can't race on the shared env vars.
- compose: stop publishing unauthenticated Garnet and Postgres on the host;
  map Satellite to the port it listens on (3001).
- cadet: listen edits now store the new CID and the record's originUri;
  legacy alpha plays get the same durable retry as stable plays; CAR import
  dispatches reactions and fails visibly when any record fails.
- satellite: drop its unlocked duplicate of Cadet's materialized-view refresh
  (the scheduler was never started anyway) and its unwrap/expect startup.
- teal-cli: publicKeyMultibase carries the secp256k1 multicodec prefix.
- release workflow: build the commit the requested tag points at, from the
  workspace root, and only for Dockerfiles that exist.
- pre-commit hook no longer re-stages files that had unstaged hunks;
  setup-sqlx.sh runs migrations from the repo root.
They were unauthenticated, /api/car/fetch pulled up to 256 MB from any PDS
per request, and both always failed to store the import. CAR imports go
through Aqua's CLI and Cadet's Redis queue; /api/car/job-status remains.
…rator

Any account can publish a playlistItem that points at someone else's
playlist. Items and item counts are now filtered by playlist membership when
read, so removed collaborators' items drop out too.
Android asked for a /app-return/<scheme> redirect that no published metadata
allowed and no route handled, and the auth session waited on a hard-coded
loopback URL. It now uses a native client document served by the web app at
/android-client-metadata.json, redirecting to the origin's reversed-host
scheme (as iOS does), registers that scheme in app.config.js, and returns the
auth session on the same URI. The scheme rule lives in @teal/client.
- iOS: a token refresh that finishes after sign-out can no longer write its
  tokens back to the Keychain, and an auth-server outage or rate limit during
  refresh no longer signs the user out (only a refused grant does).
- status: a failed Jetstream event is retried and then replayed from the last
  saved cursor instead of being skipped while later cursors are saved.
- aqua: profile and handle backfills take Cadet's per-account lock and skip
  deactivated accounts, so a slow fetch can't recreate a purged profile.
- cadet: an existing MusicBrainz artist, release, or recording keeps its first
  indexed name; a later listen can only fill a missing discriminant. Before,
  renaming one listen's album relabelled that release for everyone.
- client: renaming a track or release on a listen (single or bulk edit) now
  clears the MBIDs that no longer match, and unchanged artists keep their
  MBIDs instead of every edit stripping them.
- cadet: refresh the stale play-ingestion DB test (canonical collection URI,
  full musicServiceUri) and have it cover the new CID and originUri writes.
- Regenerate the SQLx offline cache; the removed entries were unused.
…s/ lockfile

The edge is Caddy (compose.yaml) and the Cargo workspace and Cross.toml live
at the repo root; nothing referenced these.
- cadet: an importRepo record can only queue an import of its own account.
- cadet: fuzzy catalog consolidation (which repoints plays and deletes rows on
  similar names) only runs when CADET_CONSOLIDATION_INTERVAL_SECS is set.
- cadet: identity events update known accounts instead of adding a profile
  row for every DID on the network; duplicate follow records no longer fail.
- cadet: only the profile's self record can replace or delete it, and a
  DID-document handle is kept only when it resolves back to the DID.
- cadet/aqua: private-address checks cover IPv4-mapped IPv6 and CGNAT; Aqua's
  CAR download uses the address-pinned client, and getRepoTopReleases runs at
  most two repo downloads at a time.
- compose: Aqua and Satellite publish on loopback only.
- Listen links open only http(s) URLs on web and Android (safeHttpUrl in
  @teal/client); rich-text links use the same check.
- DID document and handle lookups (which also run during web SSR) no longer
  follow redirects, time out after 8s, and refuse non-public did:web hosts.
- aqua: getProfiles/getPlays decode their repeated query params (they
  rejected every request), cap them at 25, and getPlays returns the latest
  100; /.well-known/did.json 404s instead of publishing a made-up key; main
  uses anyhow instead of Result<(), String>, unwrap, and expect.
- iOS: Keychain writes update in place instead of delete-then-add.
- web: other viewers reuse the listen page's server-loaded query; playlist
  edits refresh the owner's playlist list.
- Manual listens are written in applyWrites batches of at most 200.
- CI lints every TypeScript file with oxlint; `pnpm fix` runs oxlint --fix
  instead of an unrelated 'biome' npm package.
- Remove dead files (teal-cli dev command, cadet/sql, duplicate target.sh)
  and correct the project layout in AGENTS.md.
- cadet: DID documents and CAR downloads go through one public-address,
  pinned-DNS, no-redirect, time-limited client (net.rs), closing the redirect
  and rebinding gaps Aqua's fix left in Cadet.
- cadet: profile, status, profile-status, and social writes take the account
  lock and skip deactivated accounts, so a slow CAR import can't recreate
  purged data.
- cadet: CAR imports fail when repo records can't be read, and skip profile
  records whose rkey isn't self, as live ingestion does.
- cadet: every follow record is kept in social_follow_records (migration with
  backfill); deleting one leaves the follow while another record backs it.
- Manual listens: a failure after some batches saved raises PartialSaveError;
  web and Android deselect the saved tracks, and iOS now batches the same way,
  so retrying doesn't log them twice.
- status: an event that can never be stored (a missing field, or Postgres
  rejecting its data, such as \u0000 in jsonb) is logged and skipped instead of
  being replayed forever and stopping every status update behind it.
- cadet: a handle lookup that fails (outage, not yet indexed) keeps the stored
  handle instead of clearing it; the lookup has a timeout. Repeated importRepo
  records queue at most one import per account every 6 hours.
- iOS: links open only for http(s) URLs, and renaming a track or release in the
  listen editor clears the MusicBrainz IDs it no longer matches, as web and
  Android do.
- client: the identity-lookup timeout also covers reading the body, and a
  rich-text facet that ends before it starts is ignored.
- The pre-commit hook and .pre-commit-config.yaml run oxlint instead of the
  removed Biome.
- cadet: social record deletes take the account lock, so deleting one backing
  record of a follow can't interleave with a concurrent write of another.
- cadet: an importRepo claim lasts 60s and becomes the 6h cooldown only after
  the job is queued, so a dropped connection can't suppress imports with
  nothing queued (no Lua: Garnet runs scripts only with --lua).
- Album logging on web, Android, and iOS: after a partial save, a retry starts
  the remaining tracks at the first unsaved track's time instead of rebuilding
  the timeline from the original start.
The datetime field holds local minutes, so restarting the remaining tracks
from it dropped seconds, and during the repeated DST hour could move them an
hour. Web and Android now keep the exact time while the form still shows it.
Deleting one backing record of a follow repoints the follow at another, but
the cleanup also deleted the "followed you" notification and the re-insert
didn't recreate it. The notification now moves with the follow.
Jetstream pings every 30s, and to_text() returns the ping payload, so the
identity, account and commit checks logged a parse error on every ping.
Many listens exist in both play collections: a client scrobbled them live
to fm.teal.alpha.feed.play and a later import wrote them again as
fm.teal.feed.play records, a few minutes apart. Both were indexed, so the
listen counted twice, and since alpha plays share the stable URI an alpha
write or delete could also replace or remove a stable row.

Plays now record their source collection. An alpha record never
overwrites or deletes a stable row, an alpha play with a stable copy of
the same track within 10 minutes is skipped, and a stable play removes
an alpha copy already stored.
…mport

pnpm backfill now runs tab (tangled.org/pds.dad/tab), which asks Lightrail
for every repo with Teal plays, profiles or statuses in both the stable
and alpha namespaces, fetches them from their PDSes, and follows live
changes over Jetstream. The tab-backfill consumer acknowledges each event
after storing it, so a rerun resumes, and spreads records over workers by
DID so large repos don't serialize the whole backfill.

The sequential lightrail-backfill binary and its scripts are removed.
Routing records to workers by DID put a large repo's whole backfill on one
worker, so the backfill ran at about one query at a time. Tab already
holds a repo's live events until its earlier events are acknowledged, and
Cadet locks each account around play writes, so workers now share one
queue. The consumer also runs as a release build with 16 workers.
…uses

A play listing the same artist twice violated the artist-link primary key
and failed on every attempt. Early alpha statuses wrote time and expiry as
Unix-second strings, which failed to parse; they are converted to
datetimes in both the live and CAR import paths.
Some alpha clients (retrievify) wrote artists as ["Name"] instead of
[{"artistName": "Name"}], so every such play failed to parse. Live
ingestion and CAR import now share one parse_play that repairs that shape
and the fractional durations the CAR path already handled.
A client wrote mbid:release-group:<uuid> into recordingMbId, which failed
UUID parsing and dropped the whole play. MBIDs that are not bare UUIDs are
now dropped during cleanup, like empty ones, and the play is stored.
piper's backfill wrote playedTime as 2026-04-03T18:56:16:00Z, which failed
to parse and dropped the play. The extra trailing field is removed when
the rest is an exact UTC time.
Some alpha clients wrote playedTime as Unix seconds or milliseconds in a
string, which failed to parse and dropped the play. Those convert to UTC
datetimes alongside the stray-field repair.
Some alpha plays store playedTime as a JSON integer of Unix seconds rather
than a string; it converts like the string form.
Manual-entry clients wrote playedTime as a local time with no zone, at
times without seconds. Those plays failed to parse and were dropped; they
are now read as UTC, which keeps the listen at the cost of a possible
offset of the listener's zone.
played_time comes from the record and was stored as given. The stats and listening windows only have a lower bound (played_time >= NOW() - interval), so a future-dated play stayed inside every recent window until its date passed. Cap it at the indexer clock plus five minutes of skew.

Tested the cap in isolation against time 0.3.41. Full workspace not built locally (generated lexicon types need the pnpm toolchain).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AcLYwupyDZ6b9ThgjwKUb3

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants