trails/apps/journal
Ullrich Schäfer 105659df7c
feat(journal): inbound federation replay defense
Task group 2 of federation-hardening. The narrow inbox
(Follow/Undo/Accept/Reject) had no replay protection — only Create(Note)
did, via the activities.remote_origin_iri unique constraint. A remote
redelivering a signed follow-graph activity would re-run its side
effects.

- New `federation_processed_activities` table (activity IRI PK,
  received_at + index). Additive, so drizzle-kit push creates it; no
  hand-written migration needed.
- `federation-replay.server.ts`: `markInboundActivityProcessed` does an
  insert-or-drop (ON CONFLICT DO NOTHING RETURNING) and reports whether
  the IRI is fresh; `sweepProcessedActivities` deletes rows > 30 days old
  (signature date-freshness already rejects older replays).
- Each inbox listener drops a duplicate before side effects. The
  follow-graph handlers are idempotent, so a handler failure whose retry
  is later dropped as a duplicate can't corrupt state.
- `federation-dedup-sweep` job (daily 04:30 UTC) runs the TTL sweep.

Verified: db + journal typecheck + lint clean; drizzle-kit push creates
the table; replay integration test (fresh-vs-duplicate + 30-day sweep)
green against real Postgres; journal unit suite 355 passing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 22:07:30 +02:00
..
app feat(journal): inbound federation replay defense 2026-07-13 22:07:30 +02:00
public Add favicons, apple-touch-icons, and Chrome DevTools JSON 2026-03-29 10:35:03 +02:00
.env.example feat(journal): Garmin activity import — provider, webhook pipeline, backfill (§1–5) 2026-06-07 17:47:22 +02:00
Dockerfile fix(journal): copy serve-static.ts into the runtime image 2026-06-25 09:23:15 +02:00
package.json build(deps): bump the production group across 1 directory with 35 updates 2026-07-13 09:29:56 +02:00
react-router.config.ts feat(journal): Fedify spike — WebFinger + actor objects behind FEDERATION_ENABLED 2026-06-06 14:15:27 +02:00
serve-static.test.ts fix(journal): don't crash the process on a malformed request URL 2026-06-24 15:41:26 +02:00
serve-static.ts fix(journal): don't crash the process on a malformed request URL 2026-06-24 15:41:26 +02:00
server.ts feat(journal): inbound federation replay defense 2026-07-13 22:07:30 +02:00
tsconfig.json Fix planner production server + use .ts extensions everywhere 2026-03-25 01:41:33 +01:00
vite.config.ts Pre-warm Vite dep discovery for the journal dev server 2026-04-26 19:51:39 +02:00
vitest.config.ts fix(journal): don't crash the process on a malformed request URL 2026-06-24 15:41:26 +02:00