Commit Graph
11 Commits
Author SHA1 Message Date
mattandClaude Sonnet 5 515acae233 Settings API and schema for now_playing_mode (phase 4, step 4)
CI / test (push) Successful in 3m39s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / lint (push) Successful in 13s
CI / validate-monitoring (push) Successful in 40s
CI / federation-interop (push) Successful in 1m8s
now_playing_mode was already in sharing.EDITABLE (step 1), so
_settings_body() was already returning it - but SharingSettingsSchema
never declared the field, so marshmallow was silently dropping it from
every response. Same class of gap phase 3 hit with timezone/
post_weekly_summary/post_milestones.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 17:15:51 +01:00
mattandClaude Sonnet 5 0acce9b948 API and web UI for posts, previews and post settings (phase 3, step 8)
CI / test (push) Successful in 2m53s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m0s
CI / notify (push) Successful in 5s
/api/v1/federation gains:
  - GET /posts, DELETE /posts/{id}: manage your own posts from the UI.
  - GET /preview/weekly: what the weekly summary would say right now, for
    the week still in progress - never posted or stored. Backed by a new
    weekly.preview() and schedule.current_week_start().
  - GET /profiles/{username}/posts/{post_uuid} (public, unauthenticated):
    backs the UI's post page, which can't itself speak ActivityPub.

Settings gain timezone/post_weekly_summary/post_milestones, already
present in sharing.EDITABLE since phase 3 step 2 but never added to
SharingSettingsSchema, so the API was silently dropping them from
responses. timezone validates against the same is_valid_timezone() the
service layer uses, with a dedicated marshmallow validator.

Fixed a real gap found while wiring the post page: ids.post_page_url()
took a username but never put it in the URL, so post.html would have
had no way to know whose post to look up. It's now ?u=<username>&id=<uuid>.

Sharing page gets a "What to post" section (weekly summary and
milestones toggles, a timezone field with a browser-supplied IANA
datalist where Intl.supportedValuesOf exists, and a live preview).
New posts.html lists a user's posts with delete (mirroring followers.js's
confirm-before-destructive-action pattern); new post.html is the public
landing page for a post's `url`, reached by browsers redirected from the
raw ActivityPub endpoint.

Verified by hand against a local dev server and a real browser: sign in,
enable sharing, preview and publish, list and delete a post, and follow
the ActivityPub redirect through to the public post page and its 404
after deletion - fixed one bug found this way (the preview box was
collapsing the summary's line breaks).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 16:24:35 +01:00
mattandClaude Sonnet 5 d4f3607eef Page the outbox and serve individual posts (phase 3, step 7)
CI / federation-interop (push) Successful in 1m1s
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 1m10s
CI / test (push) Successful in 2m47s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
GET /users/<u>/outbox is now a real OrderedCollection pointing at
paged OrderedCollectionPages of 20 Creates, newest first - public and
unlisted posts only, since it's unauthenticated. Adds
publishing.outbox_page() for the query and publishing.find_by_note_id()
to look a post up by its Note's id (the two ActivityPub ids a post has
- the wrapping Create's and the embedded Note's - were already
generated independently in publish(); finding by the Note's id reuses
the existing JSONB-path query pattern already established by
activities.undo_block(), rather than adding a new column just for this
lookup).

GET /users/<u>/posts/<uuid> serves that Note for public and unlisted
posts; followers-only and deleted posts 404 (they reach followers by
delivery instead); a browser without an ActivityPub Accept is
redirected to the UI post page unconditionally, before any lookup,
matching actor()'s existing reasoning that a 404-vs-302 difference
must never be usable to probe which posts exist.

Documents both endpoints in federation/openapi.py and regenerates
docs/openapi.json (test_every_api_route_is_documented already enforces
this on every new federation route, so it can't wait for the docs
step at the end of the phase).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 13:37:38 +01:00
mattandClaude Sonnet 5 b16ba116c4 Publishing core: post, fan out, delete (phase 3, step 4)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 13s
CI / federation-interop (push) Successful in 1m1s
CI / test (push) Successful in 2m26s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
federation/publishing/base.py:
- publish(user_id, username, kind, key, text=, html=): idempotent —
  refuses (returns None, doesn't post) if the user has stopped sharing
  or a post with that key already exists, including when two worker
  passes race (caught as a duplicate-key error at commit, not raised).
  Builds Note + Create addressed from the user's current visibility,
  stores both, and fans out one delivery per distinct accepted
  follower's inbox (shared inbox preferred).
- delete_post(user_id, username, post): sends Delete(Tombstone) to the
  same followers and tombstones the row; a no-op if already deleted.
  Addressed by the post's own visibility at the time it was posted,
  not the user's current setting.
- delete_all_for(user_id, username): deletes every live post, for
  turning sharing off.

Wired into PATCH /settings: turning sharing off now deletes every live
post *before* rejecting followers (reject_all removes the followers
that accepted_inboxes() needs). The phase 2 farewell-actor mechanism
already covers these deliveries with no changes, since it just checks
for any pending delivery on the user's activities.

Small supporting changes: activities.store() made public (used from
publishing now, not just activities.py's own narrow helpers);
followers.accepted_inboxes() for fan-out; ids.py gains
followers_url/note_url/post_page_url; sharing.settings_for()'s unsaved
default object now sets every field a caller might read, not just the
ones the old callers happened to need.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-26 11:51:06 +01:00
mattandClaude Opus 5.5 b93cfea5b3 Interop with a real GoToSocial server, and the fixes it found (phase 2, step 8)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 2m16s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
scripts/interop/run.sh brings up Scrobbler (API, worker, UI behind a
throwaway-TLS Caddy) and GoToSocial 0.22.1 on a private .test network,
creates a GoToSocial user, drives its sign-in/OAuth screens for a token,
and checks: lookup by handle, follow accepted, unfollow, manual approval
and approve, remove, block and unblock, and decline.

Found and fixed along the way:
- Keys whose id is a path serving the actor (GoToSocial's
  <actor>/main-key) weren't resolved; now all three publishing styles
  are handled
- An Undo of an older Follow arriving after a newer Follow removed the
  new follower; an Undo now only removes the Follow it names (and Undo
  referencing a Follow by id is understood)
- Rejects embedded the Follow, which some servers (GoToSocial) match by
  account pair, so a late Reject could cancel a newer request; Rejects
  now reference the Follow by id
- Unblocking didn't tell the other server; it now sends Undo(Block)
- Actors publish an (empty) featured collection, which Mastodon and
  GoToSocial fetch

GoToSocial 0.22.1 ignores Reject for already-accepted follows (a TODO
in its code, fixed on its main branch); the removal check on its side
is skipped until a release has it (GTS_REJECT_ENDS_FOLLOWS=1 enables).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 22:11:39 +01:00
mattandClaude Opus 5.5 a90cd14f59 Manage followers from the API and web UI (phase 2, step 6)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 11s
CI / notify (push) Successful in 6s
CI / test (push) Successful in 2m4s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
- /api/v1/federation: list followers and requests, approve (Accept),
  decline or remove (Reject), block (Block, and future follows are
  refused), list and remove blocks; settings report follower counts
- The actor now reflects the user's real follow-approval setting and
  the followers collection its accepted count
- Turning sharing off sends every follower a Reject and forgets them;
  while those are being delivered the actor stays fetchable with just
  its key (no name or bio) so other servers can verify them, and
  WebFinger already says not found
- Web UI: a Followers page (requests with Approve/Decline, followers
  with Remove/Block behind a confirm step, blocked accounts with
  Unblock; remote names shown as plain text only), follower counts on
  the Sharing page, and a confirmation before turning sharing off
  when that would remove followers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 21:42:29 +01:00
mattandClaude Opus 5.5 f312c4b577 Inbox: intake and verified processing of follows (phase 2, step 4)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 14s
CI / test (push) Successful in 1m57s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
Intake (in the request, no network): size, content type and shape
checks, blocked domains refused (403), duplicates acknowledged once,
then stored and answered 202.

Processing (federation.inbox worker task):
- verify the HTTP signature with either scheme, as of when it arrived,
  using the cached key and refreshing the sender once on failure (key
  rotation); a deleted account's Delete still verifies from cache
- the signer must be the activity's actor and the activity id must be
  on the actor's host
- handlers: Follow (accept, or pending with manual approval; repeat
  follows re-accepted; blocked accounts rejected), Undo of a Follow
  (only by the same actor), Delete of an actor, Update of an actor;
  anything else recorded
- items being processed are marked, retried on transient failures,
  re-queued if a worker dies, and pruned after 30 days

Outgoing Accept/Reject/Block activities are stored with stable ids and
queued per inbox for the delivery task (next step). Public activities
are fetchable at /activities/<uuid>. Metrics for inbox activities and
signature checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 21:29:55 +01:00
mattandClaude Opus 5.5 0b10469514 Sharing settings API, public profiles and ActivityPub docs (phase 1, step 4)
CI / lint (push) Successful in 12s
CI / test (push) Successful in 1m5s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / validate-monitoring (push) Successful in 7s
CI / notify (push) Successful in 5s
- /api/v1/federation/settings (GET, PATCH): sharing on/off, visibility
  (followers-only default), follow approval, discoverable/indexable,
  display name and bio, plus the read-only handle and URLs
- /api/v1/federation/profiles/<name>: public profile for the UI page,
  only for users sharing
- ActivityPub endpoints documented under an ActivityPub tag
- docs/openapi.json is now exported with every optional module on
  (python -m scrobbler.openapi.export); the drift test and route checks
  cover both a federation-off and a federation-on app
- Boundary: federation may use scrobbler.api.get_api to register its
  blueprint; the checker proves other scrobbler.api modules stay off
  limits

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
2026-09-25 20:26:33 +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 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 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