docs: documentation review for v2.14.0

Architecture, README, standards, CLAUDE.md, settings reference, indexes,
backlog, release plans and CHANGELOG checked against the code at v2.14.0:
backfeed, notifications, counts line and web actions documented; test
policy (changed area locally, full suite in CI); stale versions, statuses
and links fixed; legacy and superseded docs moved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PhilandClaude Opus 5.5 committed 2026-11-10 14:51:57 -07:00
1 parent caa66f7bb1
commit ceef048003
46 files changed
+476 -216

No files matched your search

+55 -27
View File
@@ -1,6 +1,6 @@
# StarPunk Architecture Overview
**Version**: 2.10.1 (2026-11-03)
**Version**: 2.14.0 (2026-11-10)
**Status**: Current. Describes the system as it is in the code today.
## Purpose
@@ -10,7 +10,9 @@ owner) writes short notes, which are published as microformats2-marked HTML
pages and as RSS, Atom and JSON feeds. The site takes part in the IndieWeb:
it accepts posts from Micropub clients, issues its own IndieAuth tokens for
them, sends and receives Webmentions, pushes feed updates with WebSub, and
crossposts (POSSE) to GoToSocial, Bluesky and Threads.
crossposts (POSSE) to GoToSocial, Bluesky and Threads. Responses to those
crossposts are pulled back and shown on the note (backfeed), and the owner
can be notified of new responses.
Guiding principle: "every line of code must justify its existence". It is a
single Flask application with server-side rendering, SQLite and plain files.
@@ -39,6 +41,9 @@ Key decisions:
[ADR-067](../decisions/ADR-067-micropub-update-delete.md) (Micropub update/delete),
[ADR-068](../decisions/ADR-068-likes-and-reposts.md) (likes and reposts),
[ADR-071](../decisions/ADR-071-websub.md) (WebSub),
[ADR-072](../decisions/ADR-072-remove-metrics-dashboard.md) (metrics dashboard removed),
[ADR-073](../decisions/ADR-073-backfeed.md) (backfeed),
[ADR-074](../decisions/ADR-074-notifications.md) (notifications),
[ADR-057](../decisions/ADR-057-media-attachment-model.md) and
[ADR-058](../decisions/ADR-058-image-optimization-strategy.md) (media),
[ADR-034](../decisions/ADR-034-full-text-search.md) (search),
@@ -70,8 +75,9 @@ Key decisions:
│ starpunk.db │ │ OIDC provider, IndieAuth │
│ notes/*.md │ │ client pages, webmention │
│ media/ │ │ sources/targets, WebSub │
│ logs/, locks │ │ callbacks, GoToSocial, │
└────────────────┘ │ Bluesky, Threads │
│ avatars/ │ │ callbacks, GoToSocial, │
│ logs/, locks │ │ Bluesky, Threads, avatars, │
└────────────────┘ │ notifications (Apprise) │
└─────────────────────────────┘
```
@@ -127,12 +133,16 @@ wait for outbound network calls; the workers make them later.
| `reply_context.py` | Fetches and caches the post a reply responds to |
| `webmention_sender.py` | Extracts links from rendered notes and queues outgoing webmentions |
| `webmention_processor.py` | Validates incoming webmentions: fetch source, parse mf2, classify, sanitise content |
| `webmention_worker.py` | Background thread working the incoming and outgoing webmention queues |
| `webmention_worker.py` | Background thread working the incoming and outgoing webmention queues; also runs avatar upkeep and the notification sweep |
| `webmention_queries.py` | Webmention queries for display and moderation |
| `webmention_ssrf.py` | SSRF-safe fetcher: public-address checks, pinned connections, manual redirects, size and time limits |
| `websub.py` | WebSub publisher (discovery headers and links, `content_version`, queueing) and hub request handling |
| `websub_worker.py` | Background thread: verification of intent, content delivery, publish pings to an external hub |
| `syndication.py` | POSSE clients (Mastodon API/GoToSocial, Bluesky, Threads), reconcile logic, syndication worker |
| `syndication.py` | POSSE clients (Mastodon API/GoToSocial, Bluesky, Threads), reconcile logic, syndication worker (its loop also calls `backfeed.process_due()`) |
| `backfeed.py` | Backfeed: reads responses to crossposts from the silos, stores them as webmentions, schedules checks and backfills |
| `avatars.py` | Saves response authors' avatars as 96 px WebP files in `avatars/`; fills missing ones and removes unused ones |
| `notifications.py` | Notifications through Apprise: the sweep of new responses and immediate problem messages |
| `csrf.py` | CSRF tokens (HMAC of the session cookie) for admin forms, logout and the IndieAuth consent |
| `rate_limiter.py` | In-memory sliding-window rate limiter |
| `errors.py` | Central error handlers |
| `feeds/` | `rss.py` (feedgen), `atom.py`, `json_feed.py`, `opml.py`, `negotiation.py` (Accept header), `cache.py` (LRU + TTL feed cache with ETags) |
@@ -144,7 +154,7 @@ wait for outbound network calls; the workers make them later.
| Blueprint | File | Paths |
|-----------|------|-------|
| `public` | `public.py` | `/`, `/note/<slug>`, `/tag/<tag>`, `/likes`, `/media/<path>`, feeds, `/opml.xml` |
| `public` | `public.py` | `/`, `/note/<slug>`, `/tag/<tag>`, `/likes`, `/media/<path>`, `/avatars/<name>`, feeds, `/opml.xml` |
| `auth` | `auth.py` | `/auth/login` (GET, POST), `/auth/callback`, `/auth/logout` (POST) |
| `indieauth` | `indieauth.py` | `/.well-known/oauth-authorization-server`, `/auth/authorize` (GET, POST), `/auth/authorize/approve`, `/auth/token` (GET, POST), `/auth/revoke` |
| `micropub` | `micropub.py` | `/micropub` (GET, POST), `/micropub/media` (POST), `/media` (POST, legacy alias) |
@@ -163,20 +173,20 @@ Jinja2 templates live in `templates/`: public pages, `admin/`, `partials/`
reposts and bookmarks) and one page per HTTP error. `templates/base.html`
carries the discovery links (`rel=micropub`, `indieauth-metadata`,
`authorization_endpoint`, `token_endpoint`, `webmention`, `hub`/`self`, `me`,
feeds). Static assets are one stylesheet (`static/css/style.css`) and one
script (`static/js/preview.js`, the Markdown preview in the admin editor).
Everything works without JavaScript.
feeds). Static assets are one stylesheet (`static/css/style.css`); admin
pages have small inline scripts. Everything works without JavaScript.
## Public URL surface
| Path | Purpose |
|------|---------|
| `/` | Home page: recent published notes (h-feed); likes are kept off it |
| `/note/<slug>` | Note permalink (h-entry), with approved webmentions and reply context |
| `/note/<slug>` | Note permalink (h-entry), with approved responses (webmentions and backfed silo responses), a counts line with web actions, and reply context |
| `/tag/<tag>` | Notes with a tag |
| `/likes` | Likes |
| `/search`, `/api/search` | Full-text search page and JSON API |
| `/media/<path>` | Uploaded images and their variants |
| `/avatars/<name>` | Saved copies of response authors' avatars |
| `/feed` | Feed chosen by the `Accept` header (RSS by default; `Vary: Accept`) |
| `/feed.rss`, `/feed.atom`, `/feed.json` | RSS 2.0, Atom 1.0, JSON Feed 1.1 |
| `/feed.xml` | Legacy alias of `/feed.rss` |
@@ -191,8 +201,15 @@ Everything works without JavaScript.
| `/admin/webmentions`, `/admin/webmentions/<id>`, `…/action`, `…/bulk-action` | Webmention moderation |
| `/admin/tokens`, `/admin/tokens/<id>/revoke` | Issued IndieAuth tokens |
| `/admin/syndication/<id>/retry` | Retry a failed crosspost |
| `/admin/syndication/<id>/check` (POST) | Check one crosspost for responses now |
| `/admin/backfeed/backfill` (POST) | Check every crosspost for responses once (backfill) |
| `/admin/notifications/test` (POST) | Send a test notification |
| `/admin/health` | Full diagnostics (JSON): database, pool statistics, filesystem, disk |
| `/health` | Public liveness check (`{"status": "ok", "version": …}`); `?detailed=true` requires login |
| `/dev/login` | Development login; only when `DEV_MODE=true` |
`/`, `/tag/<tag>` and `/likes` show each note's response counts, linking to
its responses (v2.13.4).
## Background workers
@@ -202,9 +219,9 @@ coordinated through the data volume:
| Thread | Started when | Coordination | Work |
|--------|--------------|--------------|------|
| Webmention worker (`webmention_worker.py`) | `WEBMENTION_WORKER_ENABLED` and not testing | Non-blocking `fcntl.flock` on `webmention-worker.lock` next to the database. Only the holder works the queues; the others try again each poll interval. The OS releases the lock if the holder dies, and the new holder resets rows stuck in `sending`. | Validates received webmentions; discovers endpoints and sends queued outgoing webmentions, with retries; saves response avatars (v2.13.0); sends notifications of new responses (v2.14.0, `notifications.py`, ADR-074) |
| Webmention worker (`webmention_worker.py`) | `WEBMENTION_WORKER_ENABLED` and not testing | Non-blocking `fcntl.flock` on `webmention-worker.lock` next to the database. Only the holder works the queues; the others try again each poll interval. The OS releases the lock if the holder dies, and the new holder resets rows stuck in `sending`. | Validates received webmentions; discovers endpoints and sends queued outgoing webmentions, with retries; saves missing response avatars every 10 minutes and removes unused ones weekly (v2.13.0); sweeps new responses into notifications and sets `webmentions.notified_at` (v2.14.0, `notifications.py`, ADR-074) |
| WebSub worker (`websub_worker.py`) | `WEBSUB_ENABLED` and not testing | Same pattern with `websub-worker.lock` | Verifies subscription intents, delivers topic content (signed with `X-Hub-Signature` when the subscriber gave a secret), retries, expires leases; pings an external hub instead if `WEBSUB_HUB_URL` is set |
| Syndication worker (`syndication.py`) | At least one crosspost target configured, and not testing | No file lock. Rows in `syndications` are claimed with a 5-minute `claimed_until` lease by an atomic `UPDATE`, so any process may work a row but only one at a time; a `version` column keeps edits made during a send. Threads token refreshes are serialised with a lock file next to `threads_token.json`. | Creates, updates or deletes the remote post for each (note, target) pair; up to 8 attempts. Then backfeed: checks copies for responses (v2.13.0, `backfeed.py`, ADR-073) |
| Syndication worker (`syndication.py`) | At least one crosspost target configured, and not testing | No file lock. Rows in `syndications` are claimed with a 5-minute `claimed_until` lease by an atomic `UPDATE`, so any process may work a row but only one at a time; a `version` column keeps edits made during a send. Threads token refreshes are serialised with a lock file next to `threads_token.json`. | Creates, updates or deletes the remote post for each (note, target) pair; up to 8 attempts. Then, only when `BACKFEED_ENABLED`, backfeed: checks copies for responses, each claimed with a `backfeed_claimed_until` lease (v2.13.0, `backfeed.py`, ADR-073) |
All workers run inside an app context, are daemon threads (they end with the
process) and sleep for their poll interval when there is nothing to do. Under
@@ -225,9 +242,12 @@ Content is kept in files and everything else in SQLite, both under
- **Media**: `media/YYYY/MM/<uuid>.<ext>` plus `<uuid>_<variant>.<ext>`
variants, staged in `media/.tmp/` while being processed.
- **Database**: `starpunk.db` (WAL mode): note metadata, tags, media records,
sessions, IndieAuth codes and tokens, webmentions and the outgoing queue,
syndications, WebSub subscriptions and queues, caches (author h-card, reply
sessions, IndieAuth codes and tokens, webmentions (including backfed silo
responses, marked by `origin` and `remote_id`) and the outgoing queue,
syndications (with backfeed state and silo-only counts), WebSub subscriptions and queues, caches (author h-card, reply
contexts), the FTS5 index and `site_state`. See [database.md](database.md).
- **Avatars**: `avatars/<sha256>.webp`, saved copies of response authors'
avatars (v2.13.0); they can be re-fetched, so losing them is harmless.
- **Other files**: `logs/starpunk.log` (rotating), worker lock files,
`threads_token.json`, and `debug/` for failed uploads when
`DEBUG_SAVE_FAILED_UPLOADS=true`.
@@ -279,20 +299,28 @@ their credentials are set. The full list with defaults is in
- **Author h-card** (`author_profile`, 24 hours) and **reply contexts**
(`reply_contexts`) are cached in the database.
- The webmention worker caches endpoint discovery results in memory.
- **Response avatars** are saved once as files named by the SHA-256 of the
source URL and served from `/avatars/<name>` with
`Cache-Control: public, max-age=604800` (one week).
## Security posture
- **Outbound requests (SSRF)**: fetches of URLs that come from outside
(webmention sources and targets, endpoint discovery, reply contexts, WebSub
callbacks, remote Micropub photos, IndieAuth client pages, crosspost link
cards) are checked first: every address the host resolves to must be public
(private, loopback, link-local, CGNAT, multicast and reserved ranges are
refused). Every fetch of a user-supplied URL (webmentions, reply contexts,
WebSub, remote Micropub photos, IndieAuth client pages and, since v2.11.0,
crosspost link cards) uses the fetcher in `webmention_ssrf.py`: it follows
redirects by hand and re-checks each hop, connects to the address it
checked (no second DNS lookup) and limits response size (1 MB by default)
and total time. `DEV_MODE` relaxes the checks for local testing.
- **Outbound requests (SSRF)**: every fetch of a URL that comes from
outside (webmention sources and targets, endpoint discovery, reply
contexts, WebSub callbacks, remote Micropub photos, IndieAuth client pages,
crosspost link cards since v2.11.0, response avatars since v2.13.0) goes
through the fetcher in `webmention_ssrf.py`. Every address the host
resolves to must be public (private, loopback, link-local, CGNAT,
multicast and reserved ranges are refused); it follows redirects by hand
and re-checks each hop, connects to the address it checked (no second DNS
lookup) and limits response size (1 MB by default) and total time.
`DEV_MODE` relaxes the checks for local testing. Exceptions: avatars on
the site's own `GOTOSOCIAL_URL` host are fetched directly, as the
crossposting client does, since behind the same proxy it may resolve to an
internal address (v2.13.1); Bluesky CDN avatars are fetched from the
account's PDS with `com.atproto.sync.getBlob`, itself through the safe
fetcher. Apprise notifications go to the owner-configured `NOTIFY_URLS`,
outside the safe fetcher.
- **HTML sanitising**: rendered notes (Markdown or HTML sent by a Micropub
client) and webmention content are cleaned with nh3 allow-lists; search
highlighting escapes everything except `<mark>`.
@@ -327,4 +355,4 @@ their credentials are set. The full list with defaults is in
---
**Last Updated**: 2026-11-03 (v2.12.0)
**Last Updated**: 2026-11-10 (v2.14.0)