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
scrobbler.federation
ActivityPub support, kept apart from the rest of the app so it can be changed, replaced
or switched off without touching anything else. Design: docs/design/activitypub.md.
Boundary rules (enforced by tests/test_federation_boundary.py)
-
Nothing outside this package imports it, except
create_app()callingfederation.init_app(app). The core reports what happened through the domain events inscrobbler.events; this package subscribes to them. -
protocol/is pure: no Flask, SQLAlchemy, Werkzeug orscrobblerimports. Signature schemes, vocabulary and document formats live there. -
The rest of this package uses only the core's public surface:
scrobbler.__version__scrobbler.eventsscrobbler.extensions(db)scrobbler.workerscrobbler.services.*scrobbler.api.decoratorsscrobbler.schemas
So no core models and no core metrics; federation defines its own.
-
Off means off. With
FEDERATION_ENABLEDunset,init_appregisters no routes, no event receivers and no worker tasks.
Configuration
| Variable | Meaning |
|---|---|
FEDERATION_ENABLED |
1 to turn federation on (default off) |
FEDERATION_DOMAIN |
Handle domain, normally the web UI's host: users are @name@<domain>. Permanent once anyone follows. |
FEDERATION_BASE_URL |
Public https:// URL actors live under (<base>/users/<name>). Normally the web UI's origin, with the UI's nginx forwarding the ActivityPub paths to the API. |
Migrations
Federation's tables (all prefixed federation_) live in their own Alembic branch,
labelled federation, so they can be changed or dropped without touching core
migrations:
uv run flask --app scrobbler db migrate --head federation@head -m "…" # federation tables
uv run flask --app scrobbler db migrate --head core@head -m "…" # everything else
uv run flask --app scrobbler db upgrade heads # apply both branches
When generating a federation migration, check it only touches federation_* tables.
Autogenerate compares all models, so core changes would otherwise leak into it.