Commit Graph
29 Commits
Author SHA1 Message Date
mattandClaude Opus 5.5 098eab025f Generic background worker (phase 0, step 2)
CI / lint (push) Failing after 38s
CI / test (push) Successful in 46s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / validate-monitoring (push) Successful in 8s
CI / notify (push) Successful in 5s
scrobbler/worker.py runs tasks that modules register: queue tasks
(called while they report work) and periodic tasks. A failing task is
logged, counted, rolled back and doesn't stop the others. Imports are
now just a registered task plus a periodic stall check.

- `flask worker` replaces `flask imports worker` (kept as an alias);
  compose uses the new command
- scrobbler_worker_tasks_total{task,outcome} and a Worker tasks panel
  on the Usage dashboard
- WORKER_METRICS_PORT (IMPORT_WORKER_METRICS_PORT still honoured)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 19:57:25 +01:00
mattandClaude Opus 5.5 59ff1bdfa0 Domain events for optional modules (phase 0, step 1)
CI / test (push) Successful in 48s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 9s
CI / notify (push) Successful in 5s
scrobbler/events.py defines blinker signals sent after commit:
scrobbles_stored (newly stored plays only, source scrobble/import),
now_playing_changed (track or None) and import_finished. A receiver
that raises is logged and skipped, so optional modules can't break
scrobbling or imports. store_chunk now reports which plays it stored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 19:54:27 +01:00
mattandClaude Opus 5.5 247c94a79c Plan for ActivityPub phase 0 (groundwork)
CI / test (push) Successful in 44s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / notify (push) Successful in 5s
Step-by-step plan: domain events, a generic worker with imports moved
onto it, the empty federation module and config, separate Alembic
branches, and boundary tests enforcing the module rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 19:52:39 +01:00
mattandClaude Opus 5.5 5d71116613 ActivityPub design: build in-house as one replaceable module
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 9s
CI / lint (push) Successful in 14s
CI / test (push) Successful in 49s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
- Settles build vs buy: write it ourselves (Scrobbler is BSD-3-Clause;
  the Python library option is AGPL)
- New "Module structure" section: everything in scrobbler.federation,
  a pure protocol/ subpackage for spec-dependent code, pluggable
  signature schemes/inbox handlers/post kinds, core → federation only
  via blinker domain events, own federation_* tables in a separate
  Alembic branch, generic task worker, and boundary tests enforcing it
- Adds a groundwork phase 0 and updates the open decisions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 19:48:04 +01:00
matt caf1d3c2f8 Merge branch 'main' into feature/activitypub 2026-09-25 19:47:16 +01:00
mattandClaude Opus 5.5 373efbcb2d License under BSD 3-Clause
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 44s
CI / python-package (push) Skipped
CI / assets (push) Successful in 10s
CI / images (push) Successful in 1m31s
CI / notify (push) Successful in 5s
Adds LICENSE, the licence expression and file in the package metadata,
an OCI licence label on both images, and a Licence section in the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 19:47:06 +01:00
mattandClaude Opus 5.5 d2c71d50f1 Design proposal: ActivityPub federation
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 44s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 7s
Research write-up for making Scrobbler users followable from the
fediverse: protocol pieces (WebFinger, actor, inbox, signatures in both
draft-cavage and RFC 9421, delivery), what gets posted (weekly summary,
milestones, now playing), build-vs-library, data model, security,
testing against GoToSocial, phased plan and open decisions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 19:36:45 +01:00
mattandClaude Opus 5.5 e40a074a64 Import page in the web UI, worker service and import monitoring
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 43s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
- New Import page: upload an export (with upload progress) or, when the
  server has a Last.fm API key, import straight from a Last.fm username;
  jobs list with live progress, counts, errors and cancelling
- docker compose runs the import worker from the API image; the API
  image no longer sets PROMETHEUS_MULTIPROC_DIR (gunicorn.conf.py does,
  and other commands must not inherit multiprocess mode)
- Prometheus scrapes the worker; Usage dashboard gains an Imports row;
  ImportWorkerDown and ImportJobsWaiting alerts
- README and .env.example document imports and LASTFM_API_KEY

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
v0.2.0
2026-09-25 15:10:15 +01:00
mattandClaude Opus 5.5 eebd7b8730 Imports API: upload exports, pull from Last.fm, follow progress
CI / assets (push) Successful in 8s
CI / images (push) Successful in 31s
CI / notify (push) Successful in 6s
CI / validate-monitoring (push) Successful in 9s
CI / lint (push) Successful in 13s
CI / test (push) Successful in 47s
CI / python-package (push) Skipped
- /api/v1/imports/options lists the available sources; `lastfm` only
  appears when the server has a Last.fm API key
- POST /imports/file (multipart; format detected or forced with
  ?format=), POST /imports/lastfm, GET /imports, GET /imports/{id},
  POST /imports/{id}/cancel
- Upload size limit (IMPORT_MAX_BYTES, default 200 MB) with a 413
- Documented in OpenAPI under the Imports tag

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 15:04:15 +01:00
mattandClaude Opus 5.5 6fc9d91fa2 History imports: parsers, import jobs and the import worker
CI / test (push) Successful in 41s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / assets (push) Successful in 8s
CI / python-package (push) Skipped
CI / images (push) Successful in 28s
CI / notify (push) Successful in 7s
- Import jobs (import_jobs table): uploaded exports stored gzipped,
  processed by `flask imports worker`, which claims jobs with
  SKIP LOCKED, inserts in chunks with progress, supports cancelling and
  re-queues jobs whose worker died
- CSV: lastfm-to-csv (no header) or any header-labelled CSV/TSV with
  comma, semicolon or tab delimiters; several date formats and Unix
  seconds/milliseconds
- JSON: pages of user.getRecentTracks (e.g. lastfm.ghan.nl), a single
  recenttracks response, or a flat list; gzipped files accepted
- Last.fm API pull (only when LASTFM_API_KEY is set): pages through
  user.getRecentTracks up to the job's creation time, rate limited,
  with retries and resume
- Imports keep plays older than 14 days, skip empty/future ones and
  dedupe against existing history
- Import metrics and pending/running job gauges

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 15:02:31 +01:00
mattandClaude Opus 5.5 e29abe05dd Rename the Python distribution to scrobby
CI / assets (push) Successful in 8s
CI / images (push) Successful in 31s
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 12s
CI / test (push) Successful in 36s
CI / python-package (push) Skipped
`scrobbler` on public PyPI is an unrelated project, so installing with
PyPI as an extra index could pick up the wrong package. The import name
stays `scrobbler`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 14:58:29 +01:00
mattandClaude Opus 5.5 40f1974f3d CI: upload assets with POST (overwrites) and correct content types
CI / python-package (push) Successful in 11s
CI / images (push) Successful in 27s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 12s
CI / test (push) Successful in 36s
CI / assets (push) Successful in 6s
CI / notify (push) Successful in 5s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
v0.1.0
2026-09-25 14:33:49 +01:00
mattandClaude Opus 5.5 a461fcdcef Include README in the API image build (it is now the package readme)
CI / assets (push) Failing after 4s
CI / images (push) Successful in 39s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 36s
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 14:31:37 +01:00
mattandClaude Opus 5.5 c44f7ec722 Publish images, assets and the Python package from CI
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 37s
CI / python-package (push) Skipped
CI / assets (push) Successful in 8s
CI / images (push) Failing after 21s
CI / notify (push) Successful in 5s
- Pushes to main and v* tags publish only after every check passes:
  API and UI images to the ProGet Docker feed, the OpenAPI spec,
  dashboards and Prometheus config to the asset feed
- v* tags also publish the wheel/sdist to the ProGet PyPI feed
- The version comes from the tag (main builds: <version>+g<sha>) and
  __version__ reads it from package metadata
- One ntfy notification per run summarising every job that ran and
  the image tags published

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 14:29:49 +01:00
mattandClaude Opus 5.5 d7c6830cf7 pylast end-to-end compatibility test and README
CI / validate-monitoring (push) Successful in 6s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 39s
CI / notify (push) Successful in 5s
- Serves the app over HTTPS with a throwaway certificate and drives it
  with pylast: web-auth sign-in, now playing, single and batch
  scrobbles (non-ASCII too), recent tracks, top artists, play count,
  and Last.fm error codes surfacing as pylast WSError
- README: architecture, running with compose, configuration, connecting
  players, development workflow, monitoring and CI/CD

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 14:28:17 +01:00
mattandClaude Opus 5.5 0a1685e80e CI: validate Prometheus config, alert rules and dashboards
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 35s
CI / notify (push) Successful in 5s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 14:26:36 +01:00
mattandClaude Opus 5.5 ea705589f1 Monitoring stack, containers and dashboards
CI / lint (push) Successful in 9s
CI / test (push) Successful in 36s
CI / notify (push) Successful in 5s
- 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
2026-09-25 14:26:19 +01:00
mattandClaude Opus 5.5 faa74871a5 Metrics: database timing, pool state, DB-backed gauges, gunicorn
CI / lint (push) Successful in 11s
CI / test (push) Successful in 39s
CI / notify (push) Successful in 5s
- Statement latency by operation and connection-pool gauges via
  SQLAlchemy events
- Users, active users (1h/24h/7d) and now-playing gauges computed at
  scrape time, cached for 60s, from a NullPool engine that is safe in
  the gunicorn master; exports nothing (not an error) if the DB is down
- gunicorn.conf.py: multiprocess metrics aggregated across workers and
  served by the master on METRICS_PORT, stale files cleared at start,
  dead workers marked
- Tests cover labels, in-flight gauge, DB metrics, the collector and a
  real two-worker gunicorn aggregation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 14:15:30 +01:00
mattandClaude Opus 5.5 89f8589424 OpenAPI: document the Last.fm API and commit the exported spec
CI / lint (push) Successful in 10s
CI / test (push) Successful in 30s
CI / notify (push) Successful in 5s
- /2.0/ and /api/auth/ are described from the Last.fm method registry:
  method enum, per-method parameter tables, auth requirements, notes,
  request schemas and XML example responses
- Readable tags (Auth, Apps, Sessions, Tokens, Stats, Last.fm)
- docs/openapi.json is exported with `flask openapi write`; tests fail
  if it drifts from the code, if any route is undocumented, or if a UI
  route is missing its bearer-auth security declaration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 14:13:47 +01:00
mattandClaude Opus 5.5 b509cd2b60 Web UI: static HTML/CSS/JS frontend, hosted separately from the API
CI / lint (push) Successful in 9s
CI / test (push) Successful in 31s
CI / notify (push) Successful in 5s
- Plain HTML + vanilla JS modules, no build step; talks to /api/v1 with
  a bearer token and only ever inserts server data as text
- Overview: now-playing dot-matrix display with live progress, totals,
  30-day plays meter, top artists/tracks by period, recent plays
- History (paged, grouped by day), Apps (create/delete, reveal/copy
  keys, player setup details), Sessions (revoke), sign-in approval page
  for the Last.fm desktop auth flow, sign in and registration
- Light and dark themes, responsive to phone widths, vendored fonts
  (SIL OFL) so the UI has no third-party requests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 14:11:37 +01:00
mattandClaude Opus 5.5 0d49311848 Listening stats: Last.fm user.* methods and /api/v1/me
CI / lint (push) Successful in 12s
CI / test (push) Successful in 30s
CI / notify (push) Successful in 5s
- Stats service shared by both APIs: recent scrobbles, top artists,
  albums and tracks over Last.fm periods, per-day/week/month counts
  (with empty days filled) and totals
- Case-insensitive grouping that displays the most common spelling
- user.getInfo, user.getRecentTracks (now playing first, from/to),
  user.getTopArtists/Albums/Tracks with Last.fm paging attributes
- /api/v1/me: now-playing, recent, top/{artists,albums,tracks},
  counts and summary

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 14:05:20 +01:00
mattandClaude Opus 5.5 2702815a1e Scrobbling and now-playing
CI / lint (push) Successful in 12s
CI / test (push) Successful in 27s
CI / notify (push) Successful in 5s
- track.scrobble: batches of up to 50 (array params or a single track),
  Last.fm ignore rules (empty artist/track, too old, too new), duplicate
  submissions accepted but stored once
- track.updateNowPlaying: upserted per user, expiring after the track's
  duration; cleared when the same track is scrobbled
- Scrobble result, ignore reason, batch size, lag and now-playing metrics

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 14:02:42 +01:00
mattandClaude Opus 5.5 7622f7433a Last.fm auth: mobile sessions and the desktop token flow
CI / test (push) Successful in 25s
CI / notify (push) Successful in 5s
CI / lint (push) Successful in 9s
- auth.getMobileSession (username + password), auth.getToken and
  auth.getSession with Last.fm error codes 4/14/15
- /api/auth/ redirects clients' approval links to the web UI's
  approve page; /api/v1/tokens lets the UI show and approve a token
- Tokens expire after an hour, are single use and bound to their app
- The legacy md5 authToken form is deliberately unsupported (it needs
  unsalted password hashes)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 14:01:12 +01:00
mattandClaude Opus 5.5 e026e56ee3 UI REST API: accounts, bearer auth, API apps, sessions, OpenAPI docs
CI / lint (push) Successful in 14s
CI / test (push) Successful in 28s
CI / notify (push) Successful in 5s
- flask-smorest API under /api/v1 with a uniform JSON error shape;
  spec at /api/openapi.json, Swagger UI at /api/docs, ReDoc at /api/redoc
- Register/login/logout/me with hashed, expiring bearer tokens,
  documented as an OpenAPI bearer security scheme
- API application and client-session management endpoints
- CORS restricted to the configured UI origin(s)
- Flask no longer serves static files: it is API-only
- Login and registration metrics

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 13:59:59 +01:00
mattandClaude Opus 5.5 9af8a4be8b Last.fm API core: signatures, XML/JSON responses and dispatcher
CI / test (push) Successful in 21s
CI / lint (push) Successful in 45s
CI / notify (push) Successful in 5s
- /2.0/ dispatcher backed by a method registry that declares each
  method's params and signature/session requirements
- api_sig verification per the Last.fm auth spec
- XML (default) and Last.fm-style JSON rendering, including error shapes
  and HTTP statuses per error code
- Last.fm request, error and auth-failure metrics with bounded labels

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 13:57:36 +01:00
mattandClaude Opus 5.5 ae8d3b65db CI: pin uv so setup doesn't depend on the GitHub API
CI / lint (push) Successful in 11s
CI / test (push) Successful in 23s
CI / notify (push) Successful in 4s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 13:56:04 +01:00
mattandClaude Opus 5.5 98c8f2e824 App factory, data model, initial migration and HTTP metrics
CI / lint (push) Successful in 9s
CI / test (push) Failing after 22s
CI / notify (push) Successful in 5s
- 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>
2026-09-25 13:55:04 +01:00
mattandClaude Opus 5.5 606348800b Allow CI to be run manually
CI / lint (push) Successful in 10s
CI / test (push) Successful in 10s
CI / notify (push) Successful in 5s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 13:51:58 +01:00
mattandClaude Opus 5.5 ccc0e0d416 Project skeleton with Gitea CI and ntfy notifications
CI / lint (push) Successful in 11s
CI / test (push) Successful in 12s
CI / notify (push) Successful in 4s
- 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>
2026-09-25 13:46:26 +01:00