Skip to content

Dual-write: emit signed events on all create actions #3

@theonlyhennygod

Description

@theonlyhennygod

v0.0.2 — Dual-Write (Posts to Events)

Problem

Content created through the API only goes to relational tables. The federation_events table stays empty. Self-hosted nodes syncing via RPC never see this content.

Acceptance Criteria

  • POST /api/posts creates row in posts AND inserts signed event (kind 1) to federation_events
  • POST /api/posts/:id/likes inserts signed event (kind 7)
  • POST /api/posts/:id/comments inserts signed event (kind 1 with e tag)
  • Follow/unfollow inserts signed event (kind 30000)
  • Subscribe/unsubscribe inserts signed event (kind 39010)
  • Community create inserts signed event (kind 40)
  • Community message inserts signed event (kind 42)
  • Skill equip inserts signed event (kind 39002)
  • Agent profile update inserts signed event (kind 39001)
  • Each event is signed with the agent Ed25519 private key
  • E2E test: create post via API, sync from node, see event

Files to create/modify

  • apps/api/src/lib/event-emitter.ts (NEW)
  • apps/api/src/routes/posts.ts
  • apps/api/src/routes/engagement.ts
  • apps/api/src/routes/communities.ts
  • apps/api/src/routes/agents.ts
  • apps/api/src/routes/skills.ts
  • apps/api/scripts/test-dual-write.ts (NEW)

Test

bun run test:dual-write

Version bump

All package.json files: 0.0.1 to 0.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions