110 Commits
Author SHA1 Message Date
mattandClaude Sonnet 5.5 735556bf21 Merge feature/album-art-overrides into main
CI / validate-monitoring (push) Successful in 14s
CI / python-package (push) Successful in 16s
CI / trigger-deploy (push) Successful in 2s
CI / notify (push) Successful in 6s
CI / test (push) Successful in 3m48s
CI / lint (push) Successful in 19s
CI / federation-interop (push) Successful in 1m36s
CI / images (push) Successful in 29s
CI / assets (push) Successful in 1m22s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
v1.4.0
2026-10-06 22:58:11 +01:00
mattandClaude Sonnet 5.5 524b78a075 Document user-uploaded album art in the admin guide
CI / federation-interop (push) Successful in 1m11s
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / lint (push) Successful in 16s
CI / validate-monitoring (push) Successful in 10s
CI / test (push) Successful in 3m55s
CI / assets (push) Skipped
CI / notify (push) Successful in 5s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
2026-10-06 22:31:28 +01:00
mattandClaude Sonnet 5.5 9c84a64d4e Add album art page for uploading, retrying and correcting missing art
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
2026-10-06 22:27:58 +01:00
mattandClaude Sonnet 5.5 bee83cb9f3 Add manual album art panels, usage stats and alerts
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
2026-10-06 22:27:18 +01:00
mattandClaude Sonnet 5.5 87edaafe19 Add album art upload, correction, retry, delete and failures endpoints
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
2026-10-06 22:26:46 +01:00
mattandClaude Sonnet 5.5 a887865f05 Add per-user art overrides: service, worker corrections and metrics
Uploads and queued corrections are stored per user and take precedence over the
global cache; the worker resolves corrections (by MusicBrainz release-group or
corrected search text) ahead of the global queue. Adds upload/correction metrics
and DB gauges for overrides and the unresolved-album backlog.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
2026-10-06 22:25:05 +01:00
mattandClaude Sonnet 5.5 d0b8e1ed22 Add per-user album art override model and migration
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
2026-10-06 22:22:26 +01:00
mattandClaude Sonnet 5.5 48fba1e0e2 Add album art observability metrics, dashboard and alerts
CI / test (push) Successful in 3m37s
CI / python-package (push) Successful in 13s
CI / trigger-deploy (push) Successful in 3s
CI / notify (push) Successful in 5s
CI / lint (push) Successful in 18s
CI / validate-monitoring (push) Successful in 13s
CI / federation-interop (push) Successful in 1m36s
CI / assets (push) Successful in 8s
CI / images (push) Successful in 1m37s
Endpoint result counters, worker resolution/latency/image-size metrics,
per-upstream latency and error counters, cache-status and oldest-pending
gauges, an Album Art Grafana dashboard, and backlog/upstream-error alerts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QHPkt2v797pphGCFKfTFmv
v1.3.2
2026-10-06 21:56:18 +01:00
mattandClaude Sonnet 5 6cd17d7586 Merge fix/album-art-performance into main
CI / python-package (push) Successful in 13s
CI / validate-monitoring (push) Successful in 8s
CI / assets (push) Successful in 7s
CI / images (push) Successful in 29s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 4m27s
CI / federation-interop (push) Successful in 1m9s
CI / notify (push) Successful in 6s
CI / trigger-deploy (push) Successful in 3s
Stops album art lookups from blocking page loads: the art endpoint is
now cache-only (never calls MusicBrainz/Cover Art Archive in the
request path), a background worker task resolves and downloads art
asynchronously, and resolved images are cached on a disk volume
instead of re-fetched on every view.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
v1.3.1
2026-10-06 21:29:23 +01:00
mattandClaude Sonnet 5 83b27d7ba1 Stop album art from blocking page loads
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m39s
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
CI / test (push) Successful in 3m38s
CI / assets (push) Skipped
CI / trigger-deploy (push) Skipped
Root cause: gunicorn runs only 2 sync workers, and GET /api/v1/art/album
did its MusicBrainz + Cover Art Archive work synchronously inside the
request (2-12+ seconds per call, measured). A page with several
uncached albums could tie up the entire application - every endpoint,
every user - for as long as that took. Separately, even an
already-resolved album re-streamed its image bytes live from Cover
Art Archive on every single page view, by the original v1 design.

The endpoint is now cache-only: it reads the album_art table and, if
resolved, a local file, and never touches the network. A cache miss
records a "pending" row and returns 404 immediately - the frontend
already treats 404 as "show the placeholder," so no frontend changes
are needed. A new background worker task (the same claim-with-
FOR-UPDATE-SKIP-LOCKED pattern already used by imports and federation
deliveries) does the actual resolving and downloads the image bytes
to a shared volume, completely decoupled from any request. No
migration needed: AlbumArt.status just gains a new "pending" value.

Verified against the real docker compose stack (not just the test
suite): cold lookups for 5 real albums all returned 404 in well under
0.2s (previously 2-12+s each), the worker resolved all 5 within ~10s
in the background, and resolved art then served in single-digit
milliseconds from the volume, including after a full container
restart (no re-download).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
2026-10-06 21:27:50 +01:00
mattandClaude Sonnet 5 79193fbc8e Merge feature/activitypub-album-art into main
CI / notify (push) Successful in 6s
CI / test (push) Successful in 3m41s
CI / federation-interop (push) Successful in 1m39s
CI / trigger-deploy (push) Successful in 2s
CI / lint (push) Successful in 13s
CI / validate-monitoring (push) Successful in 8s
CI / assets (push) Successful in 8s
CI / python-package (push) Successful in 17s
CI / images (push) Successful in 34s
Attaches cover art to ActivityPub "now playing" posts as a standard
AS2 Image attachment, using the Cover Art Archive URL cached by the
album art feature.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
v1.3.0
2026-10-06 19:19:50 +01:00
mattandClaude Sonnet 5 2b984cca6e Merge feature/album-art into main
CI / lint (push) Successful in 14s
CI / federation-interop (push) Successful in 1m8s
CI / test (push) Successful in 3m54s
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 9s
CI / assets (push) Successful in 8s
CI / images (push) Successful in 26s
Adds album art: MusicBrainz + Cover Art Archive lookup, cached and
proxied through a new /api/v1/art/album endpoint, shown on the song
page, dashboard and history.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
2026-10-06 19:17:43 +01:00
mattandClaude Sonnet 5 44abd70caa Attach cover art to ActivityPub "now playing" posts
CI / test (push) Successful in 3m31s
CI / assets (push) Skipped
CI / trigger-deploy (push) Skipped
CI / lint (push) Successful in 11s
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 9s
CI / federation-interop (push) Successful in 1m38s
Note objects can now carry an optional attachment (an AS2 Image),
which Mastodon and other AP servers render as the post's media. Only
"now playing" posts use it for now - it's the only post type tied to
a single track, and therefore the only one with one unambiguous
album; weekly summaries and milestones aggregate many tracks.

The attachment points straight at the Cover Art Archive URL cached
in AlbumArt, not our own authenticated /api/v1/art/album proxy - a
remote server fetches attachments unauthenticated, and Cover Art
Archive is already public. The lookup happens in the periodic
now-playing worker task, not a request, so a cache-miss MusicBrainz/
Cover Art Archive call adds no request latency.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
2026-10-06 19:16:29 +01:00
mattandClaude Sonnet 5 f106d68921 Fix two album art bugs found in manual browser testing
CI / validate-monitoring (push) Successful in 9s
CI / lint (push) Successful in 11s
CI / federation-interop (push) Successful in 1m37s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 6s
CI / test (push) Successful in 3m24s
- art.js revoked each thumbnail's blob: URL on its own "load" event,
  but the same URL is shared (via the lookup cache) by every
  thumbnail for that album on the page - revoking after the first
  one loaded broke every other <img> still using it. Stop revoking;
  this is a full-page-reload site, so the browser releases the
  memory on navigation anyway.
- .ranking-art/.log-art thumbnails inherited their row's default
  cross-axis alignment (baseline for .ranking, stretch for .log),
  which suits text but left the art sitting high against two-line
  name+artist text. Center them explicitly instead.

Verified in-browser across all four surfaces (song page hero,
dashboard Albums ranking, Recently played, History) with real
MusicBrainz/Cover Art Archive artwork.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Hn2QwS1HRT8tFAzo8ew63
2026-10-06 19:02:53 +01:00
mattandClaude Sonnet 5 dfd2ef868b Show album art on the song page, dashboard and history
CI / validate-monitoring (push) Successful in 9s
CI / lint (push) Successful in 14s
CI / federation-interop (push) Successful in 1m7s
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / test (push) Successful in 3m24s
CI / assets (push) Skipped
CI / trigger-deploy (push) Skipped
New frontend/js/art.js builds a thumbnail that starts as a placeholder
and swaps itself for the real cover once (if) it resolves, fetched
via the new /api/v1/art/album endpoint with the existing bearer-auth
transport and handed to the browser as a blob: object URL (no
query-string tokens, no hotlinking).

Wired into all four places a track/album appears: the song page's
glowing display, the dashboard's "Most played > Albums" list, the
dashboard's "Recently played" list, and the full History page -
Artists/Tracks rankings are left alone.

Also fixes a real reliability gap found during manual testing:
Cover Art Archive's existence check (a HEAD request, redirected
through archive.org) had no retry at all, unlike the MusicBrainz
search next to it, and an occasional slow/flaky response there was
enough to fail a lookup outright. It now retries the same way.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-06 17:14:44 +01:00
mattandClaude Sonnet 5 5bdeeddb0b Add album art backend: MusicBrainz + Cover Art Archive, proxied and cached
New GET /api/v1/art/album?artist=&album= resolves and streams an
album's cover art. Lookups go through MusicBrainz release-group
search then Cover Art Archive's release-group front-image endpoint,
both free and keyless - no setup required by self-hosters. Results
(hits, misses and errors) are cached in a new album_art table keyed
case-insensitively on (artist, album), since Scrobble.mbid can't be
trusted as a release identifier.

The service layer separates resolving where the art is (lookup())
from fetching the bytes (fetch_image()) so a future move to storing
the bytes ourselves only touches the latter.

Also widens the UI's CSP (img-src) to allow blob: URLs, since the
frontend will fetch art with the existing bearer-auth header and
hand the browser a blob: object URL rather than hotlinking.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-06 17:05:57 +01:00
matt 7b169ea807 Merge pull request 'Make "Recently played" rows match the Tracks list style' (#3) from fix/recent-list-style into main
CI / federation-interop (push) Successful in 1m13s
CI / assets (push) Successful in 9s
CI / test (push) Successful in 4m26s
CI / lint (push) Successful in 14s
CI / validate-monitoring (push) Successful in 10s
CI / images (push) Successful in 37s
CI / trigger-deploy (push) Successful in 2s
CI / python-package (push) Successful in 18s
CI / notify (push) Successful in 6s
Reviewed-on: #3
v1.2.2
2026-10-06 13:45:57 +01:00
mattandClaude Sonnet 5 457e051828 Make "Recently played" rows match the Tracks list style
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 12s
CI / federation-interop (push) Successful in 1m15s
CI / test (push) Successful in 3m18s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / validate-monitoring (pull_request) Successful in 9s
CI / lint (pull_request) Successful in 14s
CI / federation-interop (pull_request) Successful in 1m14s
CI / images (pull_request) Skipped
CI / assets (pull_request) Skipped
CI / trigger-deploy (pull_request) Skipped
CI / notify (pull_request) Successful in 7s
CI / trigger-deploy (push) Skipped
CI / test (pull_request) Successful in 4m38s
CI / python-package (pull_request) Skipped
Stack the track above a muted artist line and link each row to its
song page, consistent with how the "Most played > Tracks" list
already looks and behaves. Scoped with a new .log-stacked modifier
so history.html and the song page's own history list (which share
the base .log classes) are unaffected.

Verified manually in-browser: rows render stacked and link to the
right song page, and history.html's layout is unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-06 13:30:30 +01:00
matt 25a7ac7a20 Merge pull request 'Feature/song page design' (#2) from feature/song-page-design into main
CI / notify (push) Successful in 5s
CI / lint (push) Successful in 14s
CI / federation-interop (push) Successful in 1m15s
CI / images (push) Successful in 32s
CI / trigger-deploy (push) Successful in 2s
CI / assets (push) Successful in 8s
CI / test (push) Successful in 4m24s
CI / validate-monitoring (push) Successful in 10s
CI / python-package (push) Successful in 17s
Reviewed-on: #2
v1.2.1
2026-10-05 15:59:46 +01:00
mattandClaude Sonnet 5 ae24c4a00e Redesign the song page around the dashboard's front-panel look
CI / validate-monitoring (push) Successful in 11s
CI / lint (push) Successful in 17s
CI / federation-interop (push) Successful in 1m40s
CI / assets (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 6s
CI / federation-interop (pull_request) Successful in 1m10s
CI / images (pull_request) Skipped
CI / assets (pull_request) Skipped
CI / notify (pull_request) Successful in 6s
CI / test (push) Successful in 3m16s
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / validate-monitoring (pull_request) Successful in 9s
CI / lint (pull_request) Successful in 18s
CI / test (pull_request) Successful in 4m33s
CI / python-package (pull_request) Skipped
CI / trigger-deploy (pull_request) Skipped
Previously the song page was a plain heading, a bare metadata list
and a history log. Now it gets its own moment on the glowing
amber display, reusing the dashboard's .panel/.display/.readouts/
.spectrum components verbatim: the track name lit up like a
now-playing display, play/first-played/last-played readouts, and a
90-day per-track play-activity chart.

Extracted the segmented spectrum chart out of dashboard.js into a
shared frontend/js/spectrum.js so both pages use the same renderer;
the dashboard's own output is unchanged.

Verified manually in-browser: the panel renders correctly, an
artist name with a slash round-trips, the not-found and
no-query-params states render into the panel, and the dashboard's
spectrum chart is pixel-for-pixel unchanged after the extraction.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-05 15:36:34 +01:00
mattandClaude Sonnet 5 86bf9fd302 Add daily play counts to the song detail endpoint
Scopes listen_counts() to a single artist/track, the same way
recent() was scoped for song history, so the song page can drive a
per-track activity chart over the last 90 days.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-05 15:33:06 +01:00
matt bef41fc2cc Merge pull request 'Feature/song lookup' (#1) from feature/song-lookup into main
CI / validate-monitoring (push) Successful in 8s
CI / federation-interop (push) Successful in 1m38s
CI / assets (push) Successful in 8s
CI / images (push) Successful in 29s
CI / trigger-deploy (push) Successful in 3s
CI / notify (push) Successful in 5s
CI / test (push) Successful in 3m45s
CI / lint (push) Successful in 13s
CI / python-package (push) Successful in 16s
Reviewed-on: #1
v1.2.0
2026-10-05 14:58:37 +01:00
mattandClaude Sonnet 5 e1704b0b54 Apply ruff formatting to test_tracks.py
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / lint (pull_request) Successful in 15s
CI / federation-interop (push) Successful in 1m45s
CI / images (pull_request) Skipped
CI / assets (pull_request) Skipped
CI / notify (pull_request) Successful in 5s
CI / test (push) Successful in 4m4s
CI / validate-monitoring (pull_request) Successful in 8s
CI / notify (push) Successful in 6s
CI / test (pull_request) Successful in 4m12s
CI / python-package (pull_request) Skipped
CI / trigger-deploy (pull_request) Skipped
CI / federation-interop (pull_request) Successful in 1m39s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-05 14:21:10 +01:00
mattandClaude Sonnet 5 88b53df909 Add song lookup UI: search a song and view its history + metadata
New song.html shows a song's aggregated metadata and full play
history (paginated), reached from the dashboard via a debounced
search box or by clicking a track in the "Most played" list.

Verified manually in-browser: search, click-through from Most played
(including an artist name with a slash), the not-found and
no-query-params states, and the pager.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-05 14:20:55 +01:00
mattandClaude Sonnet 5 d2f457a84d Add song lookup API: search a track and get its play history + metadata
New GET /api/v1/me/tracks/search finds songs by track or artist name;
GET /api/v1/me/tracks returns a song's aggregated metadata (album,
duration, mbid, etc. - most common non-null value per field) plus its
paginated scrobble history, identified by artist+track query params
since there's no normalized Track model.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-05 14:14:11 +01:00
mattandClaude Sonnet 5 50e2360d14 Fix a Monday-morning-flaky weekly preview test
CI / images (push) Successful in 22s
CI / trigger-deploy (push) Successful in 2s
CI / federation-interop (push) Successful in 1m36s
CI / assets (push) Successful in 8s
CI / validate-monitoring (push) Successful in 8s
CI / python-package (push) Successful in 13s
CI / lint (push) Successful in 15s
CI / test (push) Successful in 3m11s
CI / notify (push) Successful in 5s
test_preview_weekly_reflects_the_week_in_progress hardcoded its
scrobble at noon UTC on "this week's Monday", but the preview window
is [week start, now) - so it failed for real whenever CI ran before
noon UTC on a Monday (as it just did in run 624). Use now - 1 minute
instead, which is always inside the window regardless of what time
the test runs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
v1.1.0
2026-09-28 11:27:45 +01:00
mattandClaude Sonnet 5 b307b11440 Add an Albums column to the dashboard's Most played pane
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 12s
CI / federation-interop (push) Successful in 1m38s
CI / test (push) Failing after 3m7s
CI / notify (push) Successful in 5s
Top albums were already available from the API (/me/top/albums, same
shape as artists/tracks) but never surfaced in the UI. Reuses the
existing renderRanking() helper; the charts grid is auto-fit, so the
third column drops in with no CSS changes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-28 11:19:53 +01:00
mattandClaude Sonnet 5 dfdb5285da Split docs into an admin guide and a user guide
CI / lint (push) Successful in 16s
CI / federation-interop (push) Successful in 1m41s
CI / python-package (push) Skipped
CI / assets (push) Successful in 9s
CI / images (push) Successful in 1m32s
CI / validate-monitoring (push) Successful in 8s
CI / test (push) Successful in 3m12s
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 6s
Renames deploy.md -> admin-guide.md and usage.md -> user-guide.md, and expands
each with content aimed squarely at its audience: the admin guide gains an
upgrade procedure, a restore procedure, an nginx+certbot TLS example, and a
troubleshooting section built from real issues hit during manual testing
(CORS_ORIGINS vs UI_BASE_URL, the sharing nav's browser-cache lag, and
mastodon.social's negative WebFinger caching); the user guide gains a getting-
started section and a matching end-user-facing troubleshooting section.
setup.md is unchanged apart from updated cross-links.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-28 00:23:56 +01:00
mattandClaude Sonnet 5 df8a114a0c ci: trigger ScrobbledDeploy on semver tag releases
CI / validate-monitoring (push) Successful in 8s
CI / federation-interop (push) Successful in 1m8s
CI / lint (push) Successful in 13s
CI / trigger-deploy (push) Skipped
CI / test (push) Successful in 3m15s
CI / python-package (push) Skipped
CI / assets (push) Successful in 9s
CI / images (push) Successful in 34s
CI / notify (push) Successful in 5s
After images publish for a v* tag, call the Gitea API to dispatch
ScrobbledDeploy's deploy workflow with the released version, so a
tagged release automatically redeploys the app tier.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-27 14:17:58 +01:00
mattandClaude Sonnet 5 d90a42046e Merge feature/activitypub: ActivityPub federation (phases 0-4)
CI / test (push) Successful in 3m38s
CI / python-package (push) Successful in 17s
CI / federation-interop (push) Successful in 1m25s
CI / validate-monitoring (push) Successful in 17s
CI / lint (push) Successful in 20s
CI / assets (push) Successful in 7s
CI / images (push) Successful in 34s
CI / notify (push) Successful in 5s
Followable from Mastodon and other fediverse apps: discoverable
profiles, followers, weekly summaries, milestones, now playing (a
live profile field plus opt-in posts), and the web UI and settings
for all of it. Off by default at the server level, and off per user
until they turn sharing on.

Verified with a GoToSocial container in CI on every push throughout,
and with a manual pass against a real Mastodon account and
activitypub.academy over a public HTTPS tunnel before this merge.

See docs/design/activitypub.md and the phase-by-phase design docs
alongside it for the full design and build history.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
v1.0.0
2026-09-26 23:51:28 +01:00
mattandClaude Sonnet 5 b941a17e07 Split docs into deploy, setup and usage guides
CI / validate-monitoring (push) Successful in 8s
CI / test (push) Successful in 3m13s
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m10s
CI / images (push) Skipped
CI / notify (push) Successful in 5s
README had grown into one long file covering deployment, local
development and end-user features together. Split into:

- docs/deploy.md: running a real instance - images, configuration,
  putting it behind TLS (with a minimal Caddy example and the
  CORS_ORIGINS/UI_BASE_URL distinction the last session's manual test
  found the hard way), monitoring, backups, releases.
- docs/setup.md: working on the code - local dev environment,
  migrations, tests, the manual fediverse test, CI/CD.
- docs/usage.md: accounts and apps, connecting a player, importing
  history, sharing on the fediverse.

README is now a short overview and quick start that links to the
three, plus the existing API reference and federation/design docs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 23:46:48 +01:00
mattandClaude Sonnet 5 9ca2ace854 Manual tunnel test: two real bugs found and fixed, docs marked done
CI / test (push) Successful in 4m10s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / notify (push) Successful in 5s
CI / lint (push) Successful in 11s
CI / federation-interop (push) Successful in 1m38s
CI / validate-monitoring (push) Successful in 8s
CI / python-package (push) Skipped
Ran the manual pass with a real Mastodon account through a cloudflared
tunnel - the one gap every phase doc had flagged as outstanding before
merging. WebFinger, actor resolution, follow/unfollow/approve/block,
a forced weekly summary posting and deleting, and the now-playing
profile field appearing/clearing all worked correctly against
mastodon.social and activitypub.academy.

Two real bugs found along the way, both fixed here:

- docker-compose.yml hardcoded the api/worker services' CORS_ORIGINS
  to UI_BASE_URL. Pointing UI_BASE_URL at the tunnel host (needed for
  federation's own identity) silently changed which browser origins
  the API accepted, blocking the operator's own localhost:8080 UI -
  .env's own CORS_ORIGINS setting had no effect, since the compose
  file never referenced it. Now its own variable, same default.
- TestConfig wasn't isolating UI_BASE_URL/CORS_ORIGINS from a
  developer's .env, so the same local change broke six tests that
  assert on http://localhost:8080 URLs - the same class of gap an
  earlier session found and fixed for FEDERATION_ENABLED/
  LASTFM_API_KEY. Pinned alongside them.

Marked the manual pass done in each phase doc (1-4) and the overview.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 23:42:58 +01:00
mattandClaude Sonnet 5 9f7ada682c Docs for phase 4: now playing (step 8)
CI / lint (push) Successful in 12s
CI / test (push) Successful in 3m23s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / validate-monitoring (push) Successful in 9s
CI / federation-interop (push) Successful in 1m41s
CI / notify (push) Successful in 6s
README: the Sharing page's Now playing section, its three modes and
their throttles.

federation/README.md: now_playing.py added to the publishing
plug-ins list (with a note on why it's not quite the same shape as
weekly.py/milestones.py - a periodic scan covering both the profile
push and the opt-in post, rather than an event receiver), actors.py
added to the layout table, and the worker tasks / interop sections
updated for federation.now_playing and the new profile-field check.

docs/design/activitypub-phase4.md marked done, with the two points
where implementation diverged from the written plan (the key-hashing
fix and the now_playing_mode privacy gate).

docs/openapi.json unchanged - still current from step 4.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 17:32:20 +01:00
mattandClaude Sonnet 5 9883111fa1 Now-playing interop check (phase 4, step 7)
CI / validate-monitoring (push) Successful in 9s
CI / test (push) Successful in 3m33s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m37s
CI / notify (push) Successful in 5s
CI / python-package (push) Skipped
Extends the GoToSocial driver's second phase: run.sh seeds a
now-playing track alongside the scrobble it already seeds for the
weekly summary; the driver turns now_playing_mode on via the settings
API, then polls GoToSocial's own stored copy of the account (not a
fresh resolve() fetch) for a "Now playing" field, confirming the
periodic Update(Person) push actually reached and updated their cache
- not just that we sent something.

Verified against a real GoToSocial 0.22.1 container locally before
pushing:
    Now playing: 'Interop Now Playing by Interop Artist'
    All post interop checks passed

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 17:29:31 +01:00
mattandClaude Sonnet 5 f3d2b5d578 Dashboard panel for profile updates (phase 4, step 6)
CI / validate-monitoring (push) Successful in 8s
CI / test (push) Successful in 3m33s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / notify (push) Successful in 1m20s
CI / federation-interop (push) Successful in 1m8s
CI / lint (push) Failing after 2m10s
CI / python-package (push) Skipped
One new panel on the Federation dashboard's existing Posts row:
profile updates/min by result (sent/throttled). now_playing posts
already show up in the Posts / min by kind panel from phase 3, under
kind="now_playing" - no changes needed there.

No new alert: unlike weekly summaries, now playing is opt-in and most
instances will have nobody using it, so there's no "should always be
producing something" baseline to alert on the way
FederationWeeklySummariesMissing does.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 17:24:17 +01:00
mattandClaude Sonnet 5 f04e53a972 Web UI for now playing (phase 4, step 5)
CI / lint (push) Successful in 21s
CI / federation-interop (push) Successful in 1m21s
CI / test (push) Successful in 4m2s
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / validate-monitoring (push) Successful in 14s
CI / assets (push) Skipped
CI / notify (push) Successful in 6s
Sharing page gets a "Now playing" section: off / show on profile /
show on profile and post, as a single choice matching the settings
column - generalised sharing.js's visibility-only radio-group handling
to a small RADIO_GROUPS list so now_playing_mode reuses the same fill/
save logic rather than adding a second special case.

Public profile API and profile.html gain a live "now playing" field,
sourced from the same actors.now_playing_text() the actor document
uses and gated the same way (now_playing_mode off means never showing
it, whatever's actually playing).

Refactored actors.py along the way: now_playing_field() takes settings
directly and does its own off-mode gating, rather than build_document()
doing it externally - one place decides whether the field is shown,
reused by the actor document, the push Update, and now the public
profile API.

Verified by hand in a real browser: settings round-trip through the
Sharing page's new radio group, the public profile page shows "Now
playing: Reckoner by Radiohead" once now_playing_mode is on, and the
raw actor document (curl, Accept: application/activity+json) carries
the same PropertyValue attachment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 17:22:02 +01:00
mattandClaude Sonnet 5 515acae233 Settings API and schema for now_playing_mode (phase 4, step 4)
CI / test (push) Successful in 3m39s
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m8s
CI / assets (push) Skipped
CI / validate-monitoring (push) Successful in 40s
now_playing_mode was already in sharing.EDITABLE (step 1), so
_settings_body() was already returning it - but SharingSettingsSchema
never declared the field, so marshmallow was silently dropping it from
every response. Same class of gap phase 3 hit with timezone/
post_weekly_summary/post_milestones.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 17:15:51 +01:00
mattandClaude Sonnet 5 ba30d5cb15 Now-playing publisher and worker task (phase 4, step 3)
CI / validate-monitoring (push) Successful in 8s
CI / federation-interop (push) Successful in 1m7s
CI / python-package (push) Skipped
CI / lint (push) Successful in 11s
CI / test (push) Successful in 3m15s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / notify (push) Successful in 6s
publishing/now_playing.py: a periodic scan (federation.now_playing,
every 30s) that pushes a throttled Update(Person) for the profile
field (5 minutes) and, for users opted into posts, publishes a Note
after a track's been playing 30+ seconds (throttled to 30 minutes),
deleting the previous now-playing post once the new one is confirmed
published - not before, so a failed publish never leaves a user with
none showing. Reuses publishing.publish()/delete_post() unchanged;
now_playing is just another post kind.

Fixed a real bug before it ever ran against Postgres: the key
(artist/track/started_at) was going straight into federation_posts.key
(VARCHAR(64)), which routinely overflows for real track and artist
names. Hashed instead - it's an idempotency token, not something
anyone needs to read.

New metric scrobbler_federation_profile_updates_total{result}; posts
already get scrobbler_federation_posts_total{kind="now_playing",...}
for free from the existing publish() instrumentation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 17:13:10 +01:00
mattandClaude Sonnet 5 9ab8bd8e03 Fix: never show now-playing when now_playing_mode is off
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m7s
CI / images (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 9s
CI / test (push) Successful in 3m3s
CI / assets (push) Skipped
CI / python-package (push) Skipped
now_playing_field() read core's now_playing table unconditionally, so
a user who never turned federation's now-playing feature on at all
would still leak what they're currently listening to on their public
actor document, since core's now_playing table is populated for every
user regardless of federation settings.

Found while designing step 3 (the periodic push task): querying only
sharing users with now_playing_mode != "off" made me notice
build_document() itself had no equivalent guard, and the existing
tests happened not to catch it (they only combined "nothing playing"
with "mode off", and "something playing" with "mode on"). Added the
missing combination - something playing, mode off - to both the
actors.py unit tests and the web-level actor route test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 17:06:55 +01:00
mattandClaude Sonnet 5 c38e2e392a Update(Person) vocabulary and the live now-playing actor field (phase 4, step 2)
CI / federation-interop (push) Successful in 1m47s
CI / notify (push) Successful in 6s
CI / validate-monitoring (push) Successful in 15s
CI / test (push) Successful in 3m51s
CI / python-package (push) Skipped
CI / lint (push) Successful in 16s
CI / images (push) Skipped
CI / assets (push) Skipped
vocab.update() wraps a document as an Update, addressed explicitly
(unlike undo(), which derives `to` from the undone activity - an actor
document has no `to` of its own).

New actors.py builds the actor document body, shared by GET /users/<u>
(live) and the coming Update(Person) push (throttled) so both render
the same shape without web.py depending on the worker-side module or
vice versa. now_playing_field() reads core's get_now_playing()
directly - never federation's own throttled push state - so a fetch
always shows the truth, whatever the last proactive push said.

GET /users/<u> now includes a "Now playing" PropertyValue attachment
whenever something unexpired is playing, and omits it otherwise.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 17:03:04 +01:00
mattandClaude Sonnet 5 cb8f9c997e Settings column and now-playing state table (phase 4, step 1)
CI / validate-monitoring (push) Successful in 7s
CI / test (push) Successful in 3m5s
CI / images (push) Skipped
CI / notify (push) Successful in 6s
CI / federation-interop (push) Successful in 1m9s
CI / lint (push) Successful in 13s
CI / assets (push) Skipped
CI / python-package (push) Skipped
federation_settings gains now_playing_mode (off/profile/posts,
default off), validated in sharing.update() the same way visibility
is. New federation_now_playing table: one row per user, tracking what
we've last told the fediverse (profile_key/profile_updated_at,
post_key/post_posted_at) - separate from core's now_playing table,
which is what's actually playing right now.

Verified the migration both ways against the local dev database: full
downgrade to base and back up to heads on both branches, not just a
single-step round trip.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 16:57:34 +01:00
mattandClaude Sonnet 5 7d86bad929 Plan for ActivityPub phase 4 (now playing)
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 9s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m6s
CI / test (push) Successful in 2m57s
Resolves the overview doc's last open decision: now playing builds
both options it described, not one or the other - the profile field
(recommended default, live on every GET, throttled Update(Person) push
every 5 minutes) plus a separate opt-in for actual posts (min 30s
played, throttled to one every 30 minutes, previous post deleted when
the next goes out).

No event receiver or pending-checks queue like milestones needed: a
plain periodic scan (federation.now_playing, every 30s) is simplest
here, since the throttle windows are minutes-long and there's no
history to react to retroactively - unlike milestones, now playing
only ever reflects what's playing right now.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 16:54:00 +01:00
mattandClaude Sonnet 5 e0423d04bc Docs for phase 3: what gets posted, the publishing plug-ins (step 11)
CI / lint (push) Successful in 16s
CI / validate-monitoring (push) Successful in 8s
CI / federation-interop (push) Successful in 1m8s
CI / test (push) Successful in 2m55s
CI / assets (push) Skipped
CI / notify (push) Successful in 6s
CI / images (push) Skipped
CI / python-package (push) Skipped
README: the fediverse section now describes what's actually posted
(weekly summaries, milestones) and their settings, instead of pointing
at "still being built"; notes now playing is the one piece left.

federation/README.md: a new Publishing section explains the plug-in
shape (base.py owns idempotent publish/delete/fan-out; each kind -
weekly.py, milestones.py - only decides when to post and what to say),
so adding a third kind later means adding a module, not touching
base.py. Worker tasks and layout tables updated for federation.weekly,
federation.milestones and cli.py. Interop section covers the new post
check.

docs/design/activitypub-phase3.md marked done, following the precedent
from phases 1-2's own docs, with the three points where implementation
diverged from the written plan (the top-10-needs-a-real-top-10 fix,
post_now() as a separate window computation, and post_page_url()
needing the username).

docs/openapi.json unchanged - still current from step 8.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 16:44:32 +01:00
mattandClaude Sonnet 5 860d4d0f93 Admin post-weekly command and GoToSocial post interop checks (phase 3, step 10)
CI / lint (push) Successful in 13s
CI / test (push) Successful in 2m56s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / notify (push) Successful in 6s
CI / validate-monitoring (push) Successful in 8s
CI / federation-interop (push) Successful in 1m8s
CI / python-package (push) Skipped
`flask federation post-weekly --user <name> --now` posts a user's
summary for the week still in progress immediately, ignoring the
Monday-09:00 gate - for operators, and so the interop test can produce
a real post without waiting on calendar time. Backed by a new
weekly.post_now(), sharing _post_for_window() with the normal
check_and_post() path so both go through the same has_post/empty-week/
publish logic; only the window (this week so far, vs. the last gated
one) differs.

Extends the GoToSocial interop driver to a second phase: run.sh seeds
one scrobble directly (the driver container has no way to sign a
Last.fm-API request, and doesn't need one just to seed data), triggers
the CLI command via `docker compose exec api`, then re-runs the driver
with --check-posts to confirm the post reaches the already-following
GoToSocial account's home timeline as `private` (followers-only, our
default) with the expected content, deletes it via the existing
DELETE /posts/{id} API, and confirms it disappears from GoToSocial's
timeline too. The main flow now ends by re-following instead of the
previous test's decline, so the post-check phase has a follower to
check against.

Verified end to end against a real GoToSocial 0.22.1 container locally
before pushing (scripts/interop/run.sh), not just left to CI:
    private post: '<p><strong>My week in music: 1 play</strong></p>...'
    All post interop checks passed

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 16:40:34 +01:00
mattandClaude Sonnet 5 de1519a066 Metrics, dashboard and alert for posts (phase 3, step 9)
CI / images (push) Skipped
CI / assets (push) Skipped
CI / federation-interop (push) Successful in 59s
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 2m53s
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
New counters: scrobbler_federation_posts_total{kind,visibility},
post_deletions_total{reason} (manual vs sharing_off), and
milestone_checks_total / weekly_total{result}, each incremented at a
single point (publish()/_delete(), and a thin public wrapper around
each module's check_and_post()) rather than at every call site.

Federation dashboard gains a "Posts" row: posts/min by kind and
visibility, deletions/min by reason, and weekly/milestone checks by
result - the same shape as the existing rows, so a stalled worker (all
zero) looks the same as one with nothing to do (all "disabled"/"none").

New alert FederationWeeklySummariesMissing, on scrobbler_worker_tasks_total
rather than the new weekly_total metric: weekly_total only increments
once check_all() reaches a real sharing user, so on a quiet instance
with nobody sharing yet it would sit at zero forever and false-alarm
immediately. worker_tasks_total counts every periodic run regardless of
whether there was anyone to check, matching the same pattern already
used by ImportWorkerDown and FederationInboxBacklog.

Verified deploy/prometheus/alerts.yml and prometheus.yml with promtool
(via the prom/prometheus image, matching CI's validate-monitoring job).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 16:31:16 +01:00
mattandClaude Sonnet 5 0acce9b948 API and web UI for posts, previews and post settings (phase 3, step 8)
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / federation-interop (push) Successful in 1m0s
CI / test (push) Successful in 2m53s
CI / assets (push) Skipped
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / notify (push) Successful in 5s
/api/v1/federation gains:
  - GET /posts, DELETE /posts/{id}: manage your own posts from the UI.
  - GET /preview/weekly: what the weekly summary would say right now, for
    the week still in progress - never posted or stored. Backed by a new
    weekly.preview() and schedule.current_week_start().
  - GET /profiles/{username}/posts/{post_uuid} (public, unauthenticated):
    backs the UI's post page, which can't itself speak ActivityPub.

Settings gain timezone/post_weekly_summary/post_milestones, already
present in sharing.EDITABLE since phase 3 step 2 but never added to
SharingSettingsSchema, so the API was silently dropping them from
responses. timezone validates against the same is_valid_timezone() the
service layer uses, with a dedicated marshmallow validator.

Fixed a real gap found while wiring the post page: ids.post_page_url()
took a username but never put it in the URL, so post.html would have
had no way to know whose post to look up. It's now ?u=<username>&id=<uuid>.

Sharing page gets a "What to post" section (weekly summary and
milestones toggles, a timezone field with a browser-supplied IANA
datalist where Intl.supportedValuesOf exists, and a live preview).
New posts.html lists a user's posts with delete (mirroring followers.js's
confirm-before-destructive-action pattern); new post.html is the public
landing page for a post's `url`, reached by browsers redirected from the
raw ActivityPub endpoint.

Verified by hand against a local dev server and a real browser: sign in,
enable sharing, preview and publish, list and delete a post, and follow
the ActivityPub redirect through to the public post page and its 404
after deletion - fixed one bug found this way (the preview box was
collapsing the summary's line breaks).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 16:24:35 +01:00
mattandClaude Sonnet 5 d4f3607eef Page the outbox and serve individual posts (phase 3, step 7)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 1m10s
CI / test (push) Successful in 2m47s
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / federation-interop (push) Successful in 1m1s
CI / images (push) Skipped
CI / notify (push) Successful in 5s
GET /users/<u>/outbox is now a real OrderedCollection pointing at
paged OrderedCollectionPages of 20 Creates, newest first - public and
unlisted posts only, since it's unauthenticated. Adds
publishing.outbox_page() for the query and publishing.find_by_note_id()
to look a post up by its Note's id (the two ActivityPub ids a post has
- the wrapping Create's and the embedded Note's - were already
generated independently in publish(); finding by the Note's id reuses
the existing JSONB-path query pattern already established by
activities.undo_block(), rather than adding a new column just for this
lookup).

GET /users/<u>/posts/<uuid> serves that Note for public and unlisted
posts; followers-only and deleted posts 404 (they reach followers by
delivery instead); a browser without an ActivityPub Accept is
redirected to the UI post page unconditionally, before any lookup,
matching actor()'s existing reasoning that a 404-vs-302 difference
must never be usable to probe which posts exist.

Documents both endpoints in federation/openapi.py and regenerates
docs/openapi.json (test_every_api_route_is_documented already enforces
this on every new federation route, so it can't wait for the docs
step at the end of the phase).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 13:37:38 +01:00
mattandClaude Sonnet 5 6fd028d108 Trim artist-plays milestone thresholds to match the phase 3 plan
CI / test (push) Successful in 3m6s
CI / assets (push) Skipped
CI / lint (push) Successful in 14s
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 1m3s
CI / validate-monitoring (push) Successful in 8s
CI / federation-interop (push) Successful in 1m2s
The plan specifies 100/500/1k for an artist's plays; 2500 and 5000 had
crept in beyond that.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 12:25:26 +01:00
mattandClaude Sonnet 5 c3a8233e73 Add federation milestones: scrobble-count, artist-plays, top-10 entries
CI / validate-monitoring (push) Successful in 9s
CI / federation-interop (push) Successful in 1m1s
CI / lint (push) Successful in 15s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / test (push) Successful in 3m7s
CI / notify (push) Failing after 2m31s
Adds publishing/milestones.py: one post per check, in priority order
(scrobble count > top-10 entry > artist plays), each threshold marked
done the first time it's reached so it's never posted twice. A live
scrobble queues a per-user FederationPendingCheck row (collapsing
repeats so the event receiver stays fast); the new federation.milestones
worker task drains it, requeuing to the back of the queue on failure
rather than retrying immediately, since a milestone check is a pure DB
read with no external server to fail against.

Enabling sharing, and finishing an import, call set_baseline() instead
of a live check: every threshold already passed is marked done without
posting, so history already on file never produces a burst of
retroactive "milestone" posts. Wired into sharing.update()'s
enable-toggle branch with a local import, mirroring farewell_user()'s
existing precedent for the same sharing<->federation-internals
circularity.

A top-10 entry now requires the user to actually have TOP_N distinct
artists first - caught by a test with unpatched thresholds, where every
first play of a new artist was trivially "entering an empty top 10".

Fixes test_federation_boundary.py's off-means-off check: blinker
signals are process-wide, so once any app in the test process enables
federation the milestone receivers stay connected for the rest of the
run regardless of which app is "current" - there's no per-app scoping
to introspect. Replaced the receiver-absence assertion with a
behavioural one (firing an event through the off app's own context is
a no-op), and kept the existing per-app-scoped view/worker checks as
they were.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 12:24:04 +01:00
mattandClaude Sonnet 5 0766c09fb3 Weekly summary task (phase 3, step 5)
CI / validate-monitoring (push) Successful in 10s
CI / lint (push) Successful in 16s
CI / federation-interop (push) Successful in 1m2s
CI / test (push) Successful in 2m40s
CI / images (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / assets (push) Skipped
protocol/schedule.py (pure): target_week(now_utc, tz) resolves to
exactly one Monday-Sunday week — the most recent one whose Monday
09:00-local posting gate has passed — computed via wall-clock
arithmetic in the user's own zone so it's correct across a DST change
(a week can be 6h23/7h01 of real time, never silently 7 flat days).
Because it's a pure function of "now", a worker that was down for
weeks naturally catches up with one post, not a backlog. Also
resolve_timezone()/is_valid_timezone() for a settings field that can
otherwise crash a task or silently do nothing forever.

protocol/content.py (pure): the small HTML subset shared by every post
kind (p, strong, em, ol, li), with escaping split from formatting so a
hostile artist/track name can't inject markup.

publishing/weekly.py: build_content() (the template) and
check_and_post()/check_all() (the federation.weekly periodic task,
every 15 minutes). An empty week is simply never posted, and — since
the target week only ever advances — never reconsidered either, with
no separate marker needed. has_post() lets the common "already posted
this week" pass skip the stats queries entirely.

Core: accounts.get_user(id) (federation needs it and can't import the
User model directly); sharing.EDITABLE and update() gain
timezone/post_weekly_summary/post_milestones, with the same
now-not-later validation visibility already had.

Tested: the DST week and gate boundaries against real computed
reference dates (not guessed ones — one guess was wrong and the test
caught it before it shipped), hostile/emoji/RTL names in the template,
and the full task against a real database (empty vs non-empty weeks,
posting twice, disabled settings, a worker down for weeks, a bad
stored timezone not stopping other users).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 12:02:02 +01:00