Commit dca8830
feat(pds): implement firehose WebSocket event stream (#4)
* feat(pds): implement firehose WebSocket event stream
Implements Phase 4 of the Edge PDS plan - the firehose event stream that enables federation with the Bluesky network.
**Core Implementation:**
- Sequencer class for commit event log management
- WebSocket hibernation API handlers in AccountDO
- DAG-CBOR frame encoding (header + body)
- Event broadcasting to connected clients
- Cursor-based backfill and validation
- SQLite firehose_events table for event persistence
**XRPC Endpoints:**
- GET /xrpc/com.atproto.sync.subscribeRepos?cursor={seq}
**Testing:**
- 6 new firehose tests (event sequencing, cursor validation, backfill)
- 42 additional tests covering authentication, concurrency, error handling
- All 48 tests passing
**Database Schema:**
- firehose_events table with autoincrement seq, event_type, payload, created_at
- Integrated into existing SqliteRepoStorage initialization
The relay can now subscribe to this PDS and sync commits in real-time.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* docs: update CLAUDE.md and EDGE_PDS_PLAN.md to reflect Phase 4 completion
- Updated test count from 28 to 48 tests (16 storage + 26 XRPC + 6 firehose)
- Added firehose implementation notes to CLAUDE.md
- Marked Phase 4 as completed in EDGE_PDS_PLAN.md
- Updated XRPC endpoints list to include subscribeRepos
- Documented firehose architecture and event flow
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix(pds): resolve CORS and WebSocket serialization issues
- Add CORS middleware using Hono's cors helper for all XRPC endpoints
- Fix WebSocket serialization error by using stub.fetch() instead of RPC
- Add fetch() handler to AccountDurableObject for WebSocket upgrades
- Fix CBOR frame decoding using @atproto/lex-cbor decodeAll()
- Add test scripts (test-firehose.js, create-post.js, load-env.js)
- Add TESTING.md with comprehensive testing documentation
- Update CLAUDE.md and EDGE_PDS_PLAN.md with implementation notes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent a5f322b commit dca8830
14 files changed
Lines changed: 2967 additions & 1154 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
3 | 19 | | |
4 | 20 | | |
5 | 21 | | |
6 | 22 | | |
7 | | - | |
| 23 | + | |
8 | 24 | | |
9 | 25 | | |
10 | 26 | | |
| |||
64 | 80 | | |
65 | 81 | | |
66 | 82 | | |
67 | | - | |
| 83 | + | |
68 | 84 | | |
69 | 85 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 86 | + | |
| 87 | + | |
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
| |||
86 | 97 | | |
87 | 98 | | |
88 | 99 | | |
89 | | - | |
90 | | - | |
91 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
92 | 104 | | |
93 | 105 | | |
94 | 106 | | |
95 | 107 | | |
96 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
97 | 136 | | |
98 | 137 | | |
99 | 138 | | |
100 | | - | |
101 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
0 commit comments