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
The task registry was module-global, so tasks registered by an app with
federation enabled would also run under an app without it (and break
the "federation off registers nothing" guarantee depending on order).
Tasks now live on each app (app.extensions["worker_tasks"]);
register_task/register_periodic take the app, and the worker runs the
current app's tasks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
- /api/v1/federation/settings (GET, PATCH): sharing on/off, visibility
(followers-only default), follow approval, discoverable/indexable,
display name and bio, plus the read-only handle and URLs
- /api/v1/federation/profiles/<name>: public profile for the UI page,
only for users sharing
- ActivityPub endpoints documented under an ActivityPub tag
- docs/openapi.json is now exported with every optional module on
(python -m scrobbler.openapi.export); the drift test and route checks
cover both a federation-off and a federation-on app
- Boundary: federation may use scrobbler.api.get_api to register its
blueprint; the checker proves other scrobbler.api modules stay off
limits
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
Registered only when federation is enabled:
- WebFinger (acct: and actor-URL resources, the instance actor, CORS *)
- host-meta, NodeInfo discovery and 2.1 (counts users sharing)
- /users/<name>: the Person actor for ActivityPub clients, a redirect to
the UI profile page for browsers (for any name, so redirects don't
reveal accounts); outbox/followers/following collections
- /actor: the instance Application actor
- Inboxes accept (202) and count deliveries; size-limited; processing
arrives in phase 2. Actors advertise manual approval until then.
- Unknown and non-sharing users get byte-identical 404s; all IDs come
from FEDERATION_BASE_URL, never the request
- Federation metrics: lookups, sharing changes, inbox deliveries
- scrobbler.__version__ joins the core's public surface for NodeInfo
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
- federation_settings (per user; off, followers-only, not discoverable
by default) and federation_keys (RSA-2048; NULL user = instance
actor), on the federation migration branch
- Private keys encrypted at rest with Fernet, keyed by HKDF-SHA256 from
FEDERATION_KEY_SECRET (now required, 32+ chars, never printed)
- Keys are created when a user first enables sharing and never
regenerated; sharing.shared_user() treats unknown and non-sharing
users identically
- One flask-smorest Api per app (get_api(app)), so apps with and
without federation never share an OpenAPI spec
- Test fixtures for a second, federation-enabled app on the same DB
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
Static checks (ast, so imports inside functions and relative imports
count): nothing outside scrobbler.federation imports it except
create_app; federation.protocol imports no framework or scrobbler code;
the rest of federation uses only the core's public surface (events,
extensions, worker, services, api.decorators, schemas). The checker is
itself tested against deliberate violations and permitted imports.
Runtime checks: with federation off no federation views, event
receivers or worker tasks exist; enabling it needs a bare domain and
an https base URL.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW