- net.py: the only client federation uses, on httpcore (BSD-3-Clause)
with a guarded network backend: https only, every resolved address
must be public (private, loopback, link-local, CGNAT, multicast and
IPv4-mapped forms refused), and the connection goes to the checked
address; 3 redirects max (GET only), 1 MB cap, 10s/20s timeouts
- outbound.py: signed GETs (instance actor, so authorized-fetch servers
answer) and signed POSTs (as the user), trying the configured
signature schemes in order and the next only on a 401
- remote.py + federation_remote_actors: fetch, validate (id matches
URL and host, actor type, inbox on its host, key owned by the actor),
cache for 24h, refresh on demand, 410 marks an actor gone; resolve a
key id to its actor, including standalone key documents
- Config: FEDERATION_SIGNATURE_SCHEMES, FEDERATION_BLOCKED_DOMAINS,
FEDERATION_DELIVERY_CONCURRENCY, and FEDERATION_INSECURE_TESTING
(http and private addresses; only allowed for .test domains)
- Tests against a real local HTTP server, including verifying that our
fetches carry a valid signature
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
- API image (uv multi-stage, non-root, gunicorn, migrations on start,
health check) and UI image (nginx, CSP, config.js rendered from
API_BASE_URL); /healthz documented in OpenAPI
- docker compose runs db, api and ui; the "monitoring" profile adds
Prometheus, postgres-exporter and Grafana, all provisioned from files
- Grafana dashboards: API overview (RED), Last.fm API, Usage, Database
- Prometheus alert rules: API down, error rate, latency, auth failure
spike, ignored scrobbles, DB pool saturation, Postgres down
- Pool checkout gauge counts events (the pool's own counters lag the
checkin event); error ratios show 0 instead of "No data"
- Tests check dashboards and alerts only use metrics that exist
- scripts/generate_traffic.py drives realistic traffic for demos
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
- Flask app factory with env-driven config (.env loaded at import)
- SQLAlchemy models: users, API apps, UI tokens, Last.fm auth tokens,
sessions, scrobbles (deduplicated) and now-playing
- Initial Alembic migration; CI checks migrations match the models
- Prometheus metric definitions, per-endpoint RED hooks with bounded
labels, and a standalone metrics server
- docker compose Postgres with a test database; CI test job runs
against a Postgres service container
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Rename the project to "scrobbler" with a src/ layout (hatchling)
- ruff + pytest dev tooling and a smoke test
- CI workflow (lint, test) that reports every run to ntfy via a
reusable composite action
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>