Federation module skeleton and its own migration branch (phase 0, steps 3-4)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 12s
CI / test (push) Successful in 50s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s

- scrobbler.federation with init_app() as its only entry point, called
  from create_app(); does nothing unless FEDERATION_ENABLED
- FederationConfig validates FEDERATION_DOMAIN (bare host) and
  FEDERATION_BASE_URL (https) when enabled, with clear errors
- federation/protocol/ package for pure, framework-free protocol code
- Package README with the boundary rules, configuration and migration
  workflow; .env.example lists the settings (off)
- Alembic: existing history labelled `core`; new empty `federation`
  branch root (depends on the core users table). Everything upgrades
  `heads` (entrypoint, CI, tests); tests check both branches apply and
  that federation can be removed without touching core

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
mattandClaude Opus 5.5 committed 2026-09-25 19:59:47 +01:00
1 parent 098eab025f
commit c79c42ee00
13 files changed
+212 -6

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
"""ActivityPub federation: optional, self-contained, replaceable.
The rest of Scrobbler only calls `init_app(app)` (from `create_app`) and sends domain
events (`scrobbler.events`). Everything else about federation lives in this package;
see README.md here and docs/design/activitypub.md.
With FEDERATION_ENABLED off (the default) `init_app` registers nothing: no routes, no
event receivers, no worker tasks.
"""
import logging
from flask import Flask
from scrobbler.federation.config import FederationConfig
log = logging.getLogger(__name__)
def init_app(app: Flask) -> None:
config = FederationConfig.from_mapping(app.config)
app.extensions["federation"] = config
if not config.enabled:
return
log.info("federation enabled: handles @user@%s, actors at %s", config.domain, config.base_url)
# Phase 1 onwards registers routes, event receivers and worker tasks here.