| … | … | @@ -0,0 +1,214 @@ |
| 1 | # Wiredove Topic-Based Architecture Research |
| 2 | |
| 3 | **Date:** 2026-01-30 |
| 4 | **Status:** Proposal / Research |
| 5 | |
| 6 | ## Overview |
| 7 | |
| 8 | Analysis of wiredove's dual-transport architecture and proposal for hashtag-based topic rooms. |
| 9 | |
| 10 | ## Current Architecture |
| 11 | |
| 12 | Wiredove uses a **dual-transport** message system: |
| 13 | |
| 14 | ``` |
| 15 | ┌─────────────────────┐ |
| 16 | │ network_queue.js │ |
| 17 | │ (central router) │ |
| 18 | └─────────┬───────────┘ |
| 19 | │ |
| 20 | ┌───────────────┴───────────────┐ |
| 21 | │ │ |
| 22 | ▼ ▼ |
| 23 | ┌─────────────────┐ ┌─────────────────┐ |
| 24 | │ WebSocket │ │ Trystero │ |
| 25 | │ (websocket.js) │ │ (gossip.js) │ |
| 26 | └────────┬────────┘ └────────┬────────┘ |
| 27 | │ │ |
| 28 | ▼ ▼ |
| 29 | ┌─────────────────┐ ┌─────────────────┐ |
| 30 | │ pub.wiredove.net│ │ WebRTC Rooms │ |
| 31 | │ (relay/archive)│ │ (P2P discovery) │ |
| 32 | └─────────────────┘ └─────────────────┘ |
| 33 | ``` |
| 34 | |
| 35 | ### Transport 1: WebSocket (Relay) |
| 36 | |
| 37 | - **File:** `websocket.js` |
| 38 | - **Endpoint:** `wss://pub.wiredove.net/` |
| 39 | - **Purpose:** Centralized relay and archive |
| 40 | - **Behavior:** Stores everything, always online, no topic filtering |
| 41 | |
| 42 | ### Transport 2: Trystero (P2P Gossip) |
| 43 | |
| 44 | - **File:** `gossip.js` |
| 45 | - **Room:** `makeRoom('wiredovev1')` - single global room |
| 46 | - **Purpose:** Direct browser-to-browser gossip via WebRTC |
| 47 | - **Behavior:** Only reaches online peers in the same room |
| 48 | |
| 49 | ### Message Queue |
| 50 | |
| 51 | - **File:** `network_queue.js` |
| 52 | - **Behavior:** Routes messages to BOTH transports simultaneously |
| 53 | - Handles retries, deduplication, cooldowns |
| 54 | |
| 55 | ## Key Code References |
| 56 | |
| 57 | ### connect.js (startup) |
| 58 | ```javascript |
| 59 | export const connect = async () => { |
| 60 | makeWs('wss://pub.wiredove.net/') // WebSocket relay |
| 61 | await startHttpGossip('https://pub.wiredove.net') // HTTP fallback |
| 62 | makeRoom('wiredovev1') // P2P room (single global) |
| 63 | send('evSFOKnXaF9ZWSsff8bVfXP6+XnGZUj8XNp6bca590k=') // Hardcoded follow |
| 64 | } |
| 65 | ``` |
| 66 | |
| 67 | ### gossip.js (P2P rooms) |
| 68 | ```javascript |
| 69 | const room = joinRoom({appId: 'wiredovetestnet', password: 'iajwoiejfoiwajfe'}, pubkey) |
| 70 | ``` |
| 71 | |
| 72 | ### network_queue.js (dual send) |
| 73 | ```javascript |
| 74 | // Lines 101-108: Send to both transports |
| 75 | if (wsReady) { |
| 76 | sendToTarget('ws', item.msg) |
| 77 | item.sent.ws = true |
| 78 | } |
| 79 | if (gossipReady) { |
| 80 | sendToTarget('gossip', item.msg) |
| 81 | item.sent.gossip = true |
| 82 | } |
| 83 | ``` |
| 84 | |
| 85 | ## Proposal: Hashtag-Based Topic Rooms |
| 86 | |
| 87 | ### Current Model: Follow-based |
| 88 | |
| 89 | - Follow pubkeys (people) |
| 90 | - Join P2P room keyed by pubkey |
| 91 | - Receive ALL posts from followed users |
| 92 | |
| 93 | ### Proposed Addition: Topic-based |
| 94 | |
| 95 | - Subscribe to hashtags (topics) |
| 96 | - Join P2P rooms keyed by hashtag |
| 97 | - Receive posts with that hashtag from ANYONE |
| 98 | |
| 99 | ### Implementation Approach |
| 100 | |
| 101 | ```javascript |
| 102 | // Current - single global room |
| 103 | makeRoom('wiredovev1') |
| 104 | |
| 105 | // Proposed - topic-specific rooms |
| 106 | makeRoom('#hypercore') |
| 107 | makeRoom('#pear-git') |
| 108 | makeRoom('#wirecore') |
| 109 | ``` |
| 110 | |
| 111 | ### Benefits |
| 112 | |
| 113 | 1. **Scoped P2P gossip** - Only receive relevant messages over WebRTC |
| 114 | 2. **Relay unchanged** - Still stores everything, clients filter by hashtag |
| 115 | 3. **Additive** - Doesn't break follow model, runs alongside it |
| 116 | 4. **Use cases:** |
| 117 | - Project changelogs/release notes |
| 118 | - Community discussions by topic |
| 119 | - Reducing noise in main feed |
| 120 | |
| 121 | ### Concerns to Address |
| 122 | |
| 123 | 1. **Room fragmentation** - Too many rooms = fewer peers per room |
| 124 | 2. **Discovery** - How to find/list available topics? |
| 125 | 3. **Spam** - Topics could be flooded without moderation |
| 126 | 4. **Client complexity** - Managing multiple room subscriptions |
| 127 | |
| 128 | ## Question for evbogue |
| 129 | |
| 130 | **Subject: Topic-based rooms in Wiredove/ANProto?** |
| 131 | |
| 132 | Looking at the dual-transport architecture (WebSocket to pub.wiredove.net + Trystero rooms for P2P), I'm curious about extending the room model. |
| 133 | |
| 134 | Currently: |
| 135 | - `makeRoom('wiredovev1')` - single global P2P room |
| 136 | - WebSocket relay stores/forwards everything |
| 137 | |
| 138 | Would it make sense to have **hashtag-based Trystero rooms**? |
| 139 | |
| 140 | ```javascript |
| 141 | // Current |
| 142 | makeRoom('wiredovev1') |
| 143 | |
| 144 | // Proposed - join topic-specific P2P rooms |
| 145 | makeRoom('#hypercore') |
| 146 | makeRoom('#pear-git') |
| 147 | ``` |
| 148 | |
| 149 | This way: |
| 150 | 1. Clients only receive P2P gossip for topics they care about |
| 151 | 2. Relay still stores everything (no changes needed) |
| 152 | 3. Clients can filter what they pull from relay by hashtag |
| 153 | |
| 154 | The P2P layer becomes topic-scoped while the relay remains a global archive. |
| 155 | |
| 156 | Any interest in this direction? Or concerns about fragmenting the P2P gossip? |
| 157 | |
| 158 | --- |
| 159 | |
| 160 | ## Recent Wiredove Updates (2026-01-30) |
| 161 | |
| 162 | Pulled latest changes from evbogue repos: |
| 163 | |
| 164 | ### Wiredove Changes (13 files) |
| 165 | |
| 166 | 1. **Moderation System** (`moderation.js` - NEW) |
| 167 | - Mute authors (hide posts, local only) |
| 168 | - Block authors (purge content + prevent sync) |
| 169 | - Hide specific posts by hash |
| 170 | - Keyword filtering (muted words) |
| 171 | |
| 172 | 2. **Performance Improvements** |
| 173 | - No longer re-verifies message integrity on every render |
| 174 | - Concurrent rendering (6 at a time) with queue |
| 175 | - IntersectionObserver for lazy loading |
| 176 | |
| 177 | 3. **HTTP Fallback** |
| 178 | - Polls `pub.wiredove.net/gossip/poll` when WebSocket fails |
| 179 | - 5 second interval |
| 180 | |
| 181 | 4. **IndexedDB Migration** |
| 182 | - One-time migration from CacheKV to IndexedDB |
| 183 | |
| 184 | ### APDS Changes (9 files) |
| 185 | |
| 186 | 1. **Share Button** (`share/share-button.js` - NEW) |
| 187 | - Embeddable "Share on ANProto" button |
| 188 | - Posts directly to pub.wiredove.net |
| 189 | - Stores keypair in IndexedDB |
| 190 | |
| 191 | 2. **Events UI** (`events/index.html` - mockup) |
| 192 | |
| 193 | 3. **HTTP API** - First endpoints in serve.js |
| 194 | |
| 195 | 4. **Blocking Functions** - `purgeAuthor()` for moderation |
| 196 | |
| 197 | ### ANProto |
| 198 | |
| 199 | No changes (already up to date) |
| 200 | |
| 201 | --- |
| 202 | |
| 203 | ## Related Files |
| 204 | |
| 205 | - `docs/WIREDOVE_ANALYSIS.md` - Original wiredove analysis |
| 206 | - `lib/wirecore-apds.js` - Our APDS implementation with Hypercore backend |
| 207 | - `relay/wirecore-relay.js` - Our relay with bridge to pub.wiredove.net |
| 208 | |
| 209 | ## Next Steps |
| 210 | |
| 211 | 1. [ ] Send question to evbogue about topic-based rooms |
| 212 | 2. [ ] Prototype hashtag parsing in composer |
| 213 | 3. [ ] Test multi-room Trystero performance |
| 214 | 4. [ ] Design topic subscription UI |