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
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