diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-08 00:26:51 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-08 00:26:51 +0000 |
| commit | 543d9e66dd44b70ed467c61635e6c8056fef8555 (patch) | |
| tree | 99783725680e3f1d4c88699777746bc3ea9fa806 /README.md | |
| parent | c67ebe6f33bfa191f17eb0df24d3ee18092c74e1 (diff) | |
docs: update docs with sync and purgatory and git data sync
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 256 |
1 files changed, 205 insertions, 51 deletions
| @@ -2,6 +2,21 @@ | |||
| 2 | 2 | ||
| 3 | A [GRASP](https://gitworkshop.dev/danconwaydev.com/grasp) (Git Relays Authorized via Signed-Nostr Proofs) implementation in Rust. | 3 | A [GRASP](https://gitworkshop.dev/danconwaydev.com/grasp) (Git Relays Authorized via Signed-Nostr Proofs) implementation in Rust. |
| 4 | 4 | ||
| 5 | ## What's New π | ||
| 6 | |||
| 7 | **Full GRASP-02 Implementation Complete!** | ||
| 8 | |||
| 9 | ngit-grasp now features a sophisticated proactive sync system that automatically discovers relays, syncs events using NIP-77 negentropy, and hunts for missing git data across clone URLs. Key highlights: | ||
| 10 | |||
| 11 | - β¨ **NIP-77 Negentropy**: Efficient set reconciliation with automatic REQ+EOSE fallback | ||
| 12 | - β¨ **Intelligent Purgatory**: Auto-fetches missing git data from clone URLs (500ms for synced events, 3min for user pushes) | ||
| 13 | - β¨ **Multi-Maintainer First-Class**: Pushed git data automatically syncs to all maintainer repositories | ||
| 14 | - β¨ **Smart Throttling**: Respectful rate limiting (5 concurrent, 30/min per domain) with exponential backoff | ||
| 15 | - β¨ **Live & Historic Sync**: Real-time event streaming plus daily full reconciliation | ||
| 16 | - β¨ **Connection Health**: Exponential backoff, rate limit detection, dead relay handling | ||
| 17 | |||
| 18 | See [GRASP-02 Proactive Sync](docs/explanation/grasp-02-proactive-sync.md) and [Purgatory Git Data Sync](docs/explanation/grasp-02-proactive-sync-purgatory-git-data.md) for details. | ||
| 19 | |||
| 5 | ## Overview | 20 | ## Overview |
| 6 | 21 | ||
| 7 | `ngit-grasp` is a Rust-based implementation of the GRASP protocol, which enables decentralized Git repository hosting with Nostr-based authorization. This implementation combines: | 22 | `ngit-grasp` is a Rust-based implementation of the GRASP protocol, which enables decentralized Git repository hosting with Nostr-based authorization. This implementation combines: |
| @@ -14,16 +29,26 @@ Unlike the reference implementation ([ngit-relay](https://gitworkshop.dev/npub15 | |||
| 14 | 29 | ||
| 15 | ## Status | 30 | ## Status |
| 16 | 31 | ||
| 32 | **Production Ready** - Full GRASP-01 and GRASP-02 implementation with comprehensive test coverage. | ||
| 33 | |||
| 17 | ## Key Features | 34 | ## Key Features |
| 18 | 35 | ||
| 19 | - **Pure Rust Implementation**: Single binary, no external dependencies beyond Git itself | 36 | - **Pure Rust Implementation**: Single binary, no external dependencies beyond Git itself |
| 20 | - **Integrated Authorization**: Push validation happens inline during the Git receive-pack operation | 37 | - **Integrated Authorization**: Push validation happens inline during the Git receive-pack operation |
| 21 | - **GRASP-01 Compliant**: Core service requirements for Git hosting with Nostr authorization | 38 | - **GRASP-01 Compliant**: Core service requirements for Git hosting with Nostr authorization |
| 22 | - **Extensible Architecture**: Designed to support GRASP-02 (Proactive Sync) and GRASP-05 (Archive) extensions | 39 | - **GRASP-02 Proactive Sync**: Sophisticated relay-to-relay event and git data synchronization |
| 40 | - **NIP-77 Negentropy**: Efficient set reconciliation with automatic fallback to REQ+EOSE | ||
| 41 | - **Live & Historic Sync**: Real-time event streaming plus catch-up for past events | ||
| 42 | - **Smart Throttling**: Respectful rate limiting (5 concurrent, 30/min per domain) with exponential backoff | ||
| 43 | - **Multi-Maintainer First-Class**: Internal sync of pushed git data across all maintainer repositories | ||
| 44 | - **Intelligent Purgatory**: Auto-fetches missing git data from clone URLs when events arrive first | ||
| 45 | - **Discovery-Driven**: Dynamically connects to relays listed in repository announcements | ||
| 23 | - **Developer-Friendly**: Built with modern Rust async patterns using tokio and actix-web | 46 | - **Developer-Friendly**: Built with modern Rust async patterns using tokio and actix-web |
| 24 | 47 | ||
| 25 | ## Architecture Highlights | 48 | ## Architecture Highlights |
| 26 | 49 | ||
| 50 | ### Inline Authorization (GRASP-01) | ||
| 51 | |||
| 27 | The key architectural decision is **inline authorization** rather than Git hooks: | 52 | The key architectural decision is **inline authorization** rather than Git hooks: |
| 28 | 53 | ||
| 29 | - Vendored and customised `git-http-backend` crate provides low-level access to the Git protocol | 54 | - Vendored and customised `git-http-backend` crate provides low-level access to the Git protocol |
| @@ -38,9 +63,50 @@ This approach provides: | |||
| 38 | - **Tighter integration**: Shared state between Git and Nostr components | 63 | - **Tighter integration**: Shared state between Git and Nostr components |
| 39 | - **Easier testing**: Pure Rust unit and integration tests | 64 | - **Easier testing**: Pure Rust unit and integration tests |
| 40 | 65 | ||
| 66 | ### Sophisticated Sync System (GRASP-02) | ||
| 67 | |||
| 68 | The proactive sync implementation is production-grade with advanced features: | ||
| 69 | |||
| 70 | **NIP-77 Negentropy with Intelligent Fallback:** | ||
| 71 | |||
| 72 | - Attempts efficient set reconciliation via NIP-77 for full syncs | ||
| 73 | - Automatically falls back to REQ+EOSE with pagination when negentropy unavailable | ||
| 74 | - Combines live subscriptions (`limit:0`) with historic catch-up | ||
| 75 | |||
| 76 | **Multi-Layer Filter Strategy:** | ||
| 77 | |||
| 78 | - **Layer 1**: Repository announcements and maintainer lists (connection-level) | ||
| 79 | - **Layer 2**: Events tagging repositories (a/A/q tags, batched per 100 repos) | ||
| 80 | - **Layer 3**: Events tagging root events (e/E/q tags, batched per 100 IDs) | ||
| 81 | |||
| 82 | **Connection Health Management:** | ||
| 83 | |||
| 84 | - Exponential backoff for failed connections (5s β 1 hour) | ||
| 85 | - Rate limit detection with 65-second cooldown | ||
| 86 | - Dead relay handling (24h+ failures β minimal retry) | ||
| 87 | - Quick reconnect (<15min) vs fresh start (>15min or daily) | ||
| 88 | |||
| 89 | **Intelligent Purgatory with Active Git Data Hunting:** | ||
| 90 | |||
| 91 | - Events without git data held in-memory for 30 minutes | ||
| 92 | - **User events**: 3-minute delay (expect git push to follow) | ||
| 93 | - **Synced events**: 500ms delay (batch burst arrivals, then hunt immediately) | ||
| 94 | - Proactively fetches missing data from clone URLs every 2 minutes | ||
| 95 | - Respectful throttling: 5 concurrent, 30 requests/min per domain | ||
| 96 | - Round-robin fairness across repositories | ||
| 97 | - Auto-release when data arrives, auto-expire after 30 minutes | ||
| 98 | |||
| 99 | **First-Class Multi-Maintainer Support:** | ||
| 100 | |||
| 101 | - Git data pushed to one maintainer's repo automatically syncs to all other maintainers | ||
| 102 | - Shared object databases for storage efficiency (planned) | ||
| 103 | - Seamless collaboration without manual coordination | ||
| 104 | |||
| 105 | See [GRASP-02 Proactive Sync](docs/explanation/grasp-02-proactive-sync.md) for full architectural details. | ||
| 106 | |||
| 41 | ## GRASP Compliance | 107 | ## GRASP Compliance |
| 42 | 108 | ||
| 43 | ### GRASP-01 (Core Service Requirements) | 109 | ### GRASP-01 (Core Service Requirements) β |
| 44 | 110 | ||
| 45 | - β NIP-01 compliant Nostr relay at `/` | 111 | - β NIP-01 compliant Nostr relay at `/` |
| 46 | - β Accepts NIP-34 repository announcements and state events | 112 | - β Accepts NIP-34 repository announcements and state events |
| @@ -50,12 +116,25 @@ This approach provides: | |||
| 50 | - β Support for `refs/nostr/<event-id>` for PRs | 116 | - β Support for `refs/nostr/<event-id>` for PRs |
| 51 | - β CORS support for web-based Git clients | 117 | - β CORS support for web-based Git clients |
| 52 | - β NIP-11 relay information document | 118 | - β NIP-11 relay information document |
| 53 | 119 | - β **Purgatory**: Events without git data held for 30 minutes, auto-released when data arrives | |
| 54 | ### GRASP-02 (Proactive Sync) - Planned | 120 | |
| 55 | 121 | ### GRASP-02 (Proactive Sync) β | |
| 56 | - π Proactive event sync from listed relays | 122 | |
| 57 | - π Proactive Git data sync from listed clone URLs | 123 | - β **Relay Discovery**: Automatically connects to relays listed in repository announcements |
| 58 | - π PR data fetching and serving | 124 | - β **Event Sync**: Proactive sync from discovered relays using NIP-77 negentropy with REQ+EOSE fallback |
| 125 | - Live subscriptions (`limit:0`) for real-time event streaming | ||
| 126 | - Historic sync with automatic pagination for large result sets | ||
| 127 | - Daily full reconciliation to detect drift | ||
| 128 | - Connection health tracking with exponential backoff | ||
| 129 | - β **Git Data Sync**: Automatic fetching of missing git data from clone URLs | ||
| 130 | - Smart timing: 3min delay for user events, 500ms for synced events | ||
| 131 | - Respectful throttling: 5 concurrent requests, 30/min per domain | ||
| 132 | - Round-robin fairness across repositories | ||
| 133 | - Exponential backoff with fresh start on new events | ||
| 134 | - β **Multi-Maintainer Support**: Pushed git data automatically synced to all maintainer repositories | ||
| 135 | - β **Comprehensive Monitoring**: Prometheus metrics for sync health, bandwidth, and relay status | ||
| 136 | |||
| 137 | **See**: [GRASP-02 Proactive Sync](docs/explanation/grasp-02-proactive-sync.md) and [Purgatory Git Data Sync](docs/explanation/grasp-02-proactive-sync-purgatory-git-data.md) | ||
| 59 | 138 | ||
| 60 | ### GRASP-05 (Archive) - Planned | 139 | ### GRASP-05 (Archive) - Planned |
| 61 | 140 | ||
| @@ -64,53 +143,52 @@ This approach provides: | |||
| 64 | 143 | ||
| 65 | ## Roadmap | 144 | ## Roadmap |
| 66 | 145 | ||
| 67 | ### Purgatory | 146 | ### GRASP-02 Enhancements |
| 68 | 147 | ||
| 69 | State events / PR / PR Update events without git data should be accepted with msg: "won't be served until git data arrives" or "in puratory awaiting git data" and not served by the main relay. | 148 | **Proactive Sync Plus:** |
| 70 | When the git data arrives, they get released from puratory. If git data doesn't arrive within 1 day, the events get deleted. | ||
| 71 | 149 | ||
| 72 | This ensures the grasp serve only serves these events when it can provide the git data to support them. | 150 | - π Scan read/write relays of repo/PR/Patch/Issue authors for related comments |
| 151 | - π Stricter anti-spam mechanisms for author relay events | ||
| 152 | - π Periodic scanning of relays in User Grasp Lists for announcements listing our relay | ||
| 73 | 153 | ||
| 74 | Why this is useful: | 154 | ### Data Efficiency |
| 75 | 155 | ||
| 76 | 1. owner submits updated state event but loses connectivity before sending the new git data. The relay causing ngit-cli to fail to clone and other clients to show a warning that the git servers state doesn't align with nostr as relays only serve the latest state event (as its addressable). | 156 | **Git Object Deduplication:** |
| 77 | a. clients could be made more resilient if they know older versions of the state event served by a grasp server relate to the state they are currently storing. | ||
| 78 | b. if clients just start using grasp servers (instead of other relays) then they will always be able to find the git data related to the latest versin of the event servered by a grasp server | ||
| 79 | 157 | ||
| 80 | 2. serving PR events where the git data isn't accessable isn't useful. | 158 | - π Shared object database across repositories |
| 159 | - π Use `GIT_ALTERNATE_OBJECT_DIRECTORIES` or `.git/objects/info/alternates` | ||
| 160 | - π Significant storage savings for multi-maintainer repositories | ||
| 81 | 161 | ||
| 82 | ### GRASP-02 (Proactive Sync) | 162 | ### Monitoring & Observability |
| 83 | 163 | ||
| 84 | - rust-nostr client websocket connection to other grasp servers listening for our repo. | 164 | ngit-grasp exposes comprehensive Prometheus metrics at `/metrics` for: |
| 85 | - negentropy catchup | ||
| 86 | - look for missing data (from state or PR / PR update) then try and fetch from other grasp servers. for efficency look for it from other repos (ie repos of other maintainers). Do this on new state event / PR / PR update evnet and on a timer for events we know we don't have the data for. | ||
| 87 | 165 | ||
| 88 | #### Proactive Sync + | 166 | **Git Operations:** |
| 89 | 167 | ||
| 90 | . look for announcement events on other relays / grasp servers that list our service. | 168 | - Clone/fetch/push rates and bandwidth |
| 91 | . look on read/write relays of repo / PR / Patch / Issue author to get related comments. pass through stricter anti SPAM mechanism? | 169 | - Authorization results (accepted/rejected) |
| 170 | - Top N repositories by bandwidth | ||
| 92 | 171 | ||
| 93 | ### Data effiency | 172 | **Nostr Events:** |
| 94 | 173 | ||
| 95 | dedupe git data = shared object database or (GIT_ALTERNATE_OBJECT_DIRECTORIES or .git/objects/info/alternates) | 174 | - WebSocket connections (active, unique IPs, flagged abusers) |
| 175 | - Events received, stored, rejected by kind | ||
| 176 | - Purgatory status (events waiting for git data) | ||
| 96 | 177 | ||
| 97 | ### Monitoring | 178 | **Sync Health (GRASP-02):** |
| 98 | 179 | ||
| 99 | ngit-grasp exposes Prometheus metrics at `/metrics` for connection tracking, Git operations, and Nostr events. | 180 | - Per-relay connection status and health states |
| 181 | - Event sync rates and bandwidth | ||
| 182 | - Git data fetch attempts and success rates | ||
| 183 | - Domain throttling metrics | ||
| 100 | 184 | ||
| 101 | **Configuration Options:** | 185 | **Configuration Options:** |
| 102 | 186 | ||
| 103 | | Option | CLI Flag | Environment Variable | Default | | 187 | | Option | CLI Flag | Environment Variable | Default | |
| 104 | |--------|----------|---------------------|---------| | 188 | | -------------------------- | --------------------------------------------- | ------------------------------------------------ | ------- | |
| 105 | | Metrics enabled | `--metrics-enabled` | `NGIT_METRICS_ENABLED` | `true` | | 189 | | Metrics enabled | `--metrics-enabled` | `NGIT_METRICS_ENABLED` | `true` | |
| 106 | | Connection abuse threshold | `--metrics-connection-per-ip-abuse-threshold` | `NGIT_METRICS_CONNECTION_PER_IP_ABUSE_THRESHOLD` | `10` | | 190 | | Connection abuse threshold | `--metrics-connection-per-ip-abuse-threshold` | `NGIT_METRICS_CONNECTION_PER_IP_ABUSE_THRESHOLD` | `10` | |
| 107 | | Top N repos | `--metrics-top-n-repos` | `NGIT_METRICS_TOP_N_REPOS` | `10` | | 191 | | Top N repos | `--metrics-top-n-repos` | `NGIT_METRICS_TOP_N_REPOS` | `10` | |
| 108 | |||
| 109 | **Key Metrics:** | ||
| 110 | - WebSocket connections (active, unique IPs, flagged abusers) | ||
| 111 | - Git operations (clone/fetch/push rates, bandwidth, authorization results) | ||
| 112 | - Nostr events (received, stored, rejected by kind) | ||
| 113 | - Top N repositories by bandwidth | ||
| 114 | 192 | ||
| 115 | **Privacy:** IP addresses are never exposed in metrics - only aggregate counts. | 193 | **Privacy:** IP addresses are never exposed in metrics - only aggregate counts. |
| 116 | 194 | ||
| @@ -154,6 +232,7 @@ This a useful feature of other git servers. | |||
| 154 | ```bash | 232 | ```bash |
| 155 | # install ngit | 233 | # install ngit |
| 156 | curl -Ls https://ngit.dev/install.sh | bash | 234 | curl -Ls https://ngit.dev/install.sh | bash |
| 235 | |||
| 157 | # Clone the repository | 236 | # Clone the repository |
| 158 | git clone nostr://danconwaydev.com/relay.ngit.dev/ngit-grasp | 237 | git clone nostr://danconwaydev.com/relay.ngit.dev/ngit-grasp |
| 159 | cd ngit-grasp | 238 | cd ngit-grasp |
| @@ -164,6 +243,8 @@ nix develop -c cargo build --release | |||
| 164 | # Configure | 243 | # Configure |
| 165 | cp .env.example .env | 244 | cp .env.example .env |
| 166 | # Edit .env with your settings | 245 | # Edit .env with your settings |
| 246 | # Required: NGIT_DOMAIN=your-domain.com | ||
| 247 | # Optional: NGIT_SYNC_BOOTSTRAP_RELAY_URL=wss://relay.example.com | ||
| 167 | 248 | ||
| 168 | # Run | 249 | # Run |
| 169 | nix develop -c cargo run --release | 250 | nix develop -c cargo run --release |
| @@ -172,6 +253,14 @@ nix develop -c cargo run --release | |||
| 172 | nix develop -c cargo test --lib | 253 | nix develop -c cargo test --lib |
| 173 | ``` | 254 | ``` |
| 174 | 255 | ||
| 256 | **What happens on startup:** | ||
| 257 | |||
| 258 | - Git HTTP server starts on configured bind address | ||
| 259 | - Nostr relay begins accepting WebSocket connections | ||
| 260 | - If bootstrap relay configured, sync system connects and discovers repositories | ||
| 261 | - Purgatory system activates, ready to hunt for missing git data | ||
| 262 | - Prometheus metrics exposed at `/metrics` | ||
| 263 | |||
| 175 | **Don't have Nix?** See [Getting Started Tutorial](docs/tutorials/getting-started.md) for alternative setup methods. | 264 | **Don't have Nix?** See [Getting Started Tutorial](docs/tutorials/getting-started.md) for alternative setup methods. |
| 176 | 265 | ||
| 177 | ## Configuration | 266 | ## Configuration |
| @@ -200,6 +289,8 @@ NGIT_OWNER_NPUB=npub1... ngit-grasp --domain relay.example.com | |||
| 200 | 289 | ||
| 201 | ### Configuration Options | 290 | ### Configuration Options |
| 202 | 291 | ||
| 292 | #### Core Settings | ||
| 293 | |||
| 203 | | Option | CLI Flag | Environment Variable | Default | | 294 | | Option | CLI Flag | Environment Variable | Default | |
| 204 | | ----------------- | --------------------- | ------------------------ | -------------------------------------------- | | 295 | | ----------------- | --------------------- | ------------------------ | -------------------------------------------- | |
| 205 | | Domain | `--domain` | `NGIT_DOMAIN` | (required) | | 296 | | Domain | `--domain` | `NGIT_DOMAIN` | (required) | |
| @@ -211,6 +302,24 @@ NGIT_OWNER_NPUB=npub1... ngit-grasp --domain relay.example.com | |||
| 211 | | Bind address | `--bind-address` | `NGIT_BIND_ADDRESS` | `127.0.0.1:8080` | | 302 | | Bind address | `--bind-address` | `NGIT_BIND_ADDRESS` | `127.0.0.1:8080` | |
| 212 | | Database backend | `--database-backend` | `NGIT_DATABASE_BACKEND` | `lmdb` | | 303 | | Database backend | `--database-backend` | `NGIT_DATABASE_BACKEND` | `lmdb` | |
| 213 | 304 | ||
| 305 | #### GRASP-02 Sync Settings | ||
| 306 | |||
| 307 | | Option | CLI Flag | Environment Variable | Default | | ||
| 308 | | ------------------------- | --------------------------------------- | ------------------------------------------ | --------------- | | ||
| 309 | | Bootstrap relay | `--sync-bootstrap-relay-url` | `NGIT_SYNC_BOOTSTRAP_RELAY_URL` | (optional) | | ||
| 310 | | Base backoff | `--sync-base-backoff-secs` | `NGIT_SYNC_BASE_BACKOFF_SECS` | `5` seconds | | ||
| 311 | | Max backoff | `--sync-max-backoff-secs` | `NGIT_SYNC_MAX_BACKOFF_SECS` | `3600` (1 hour) | | ||
| 312 | | Disconnect check interval | `--sync-disconnect-check-interval-secs` | `NGIT_SYNC_DISCONNECT_CHECK_INTERVAL_SECS` | `60` seconds | | ||
| 313 | | Disable negentropy | `--sync-disable-negentropy` | `NGIT_SYNC_DISABLE_NEGENTROPY` | `false` | | ||
| 314 | | Batch window | N/A | `NGIT_SYNC_BATCH_WINDOW_MS` | `5000` ms | | ||
| 315 | |||
| 316 | **Sync Notes:** | ||
| 317 | |||
| 318 | - **Bootstrap relay**: Optional starting point for relay discovery. System automatically discovers additional relays from repository announcements. | ||
| 319 | - **Backoff settings**: Controls exponential backoff for failed connections (`base * 2^(failures-1)`, capped at max). | ||
| 320 | - **Negentropy**: Can be disabled for testing REQ+EOSE fallback behavior. | ||
| 321 | - **Batch window**: Self-subscriber batches events for this duration before triggering sync filters. | ||
| 322 | |||
| 214 | ### Database Backends | 323 | ### Database Backends |
| 215 | 324 | ||
| 216 | - `lmdb`: LMDB backend (default, persistent, general purpose) | 325 | - `lmdb`: LMDB backend (default, persistent, general purpose) |
| @@ -227,9 +336,24 @@ export NGIT_DOMAIN=gitnostr.com | |||
| 227 | export NGIT_OWNER_NPUB=npub1... | 336 | export NGIT_OWNER_NPUB=npub1... |
| 228 | export NGIT_BIND_ADDRESS=0.0.0.0:8080 | 337 | export NGIT_BIND_ADDRESS=0.0.0.0:8080 |
| 229 | export NGIT_DATABASE_BACKEND=lmdb | 338 | export NGIT_DATABASE_BACKEND=lmdb |
| 339 | |||
| 340 | # Optional: Enable proactive sync from a bootstrap relay | ||
| 341 | export NGIT_SYNC_BOOTSTRAP_RELAY_URL=wss://relay.damus.io | ||
| 342 | |||
| 343 | # Optional: Tune sync behavior | ||
| 344 | export NGIT_SYNC_BASE_BACKOFF_SECS=5 # Start backoff at 5 seconds | ||
| 345 | export NGIT_SYNC_MAX_BACKOFF_SECS=3600 # Cap backoff at 1 hour | ||
| 346 | |||
| 230 | ngit-grasp | 347 | ngit-grasp |
| 231 | ``` | 348 | ``` |
| 232 | 349 | ||
| 350 | **Production Tips:** | ||
| 351 | |||
| 352 | - Set `NGIT_SYNC_BOOTSTRAP_RELAY_URL` to a well-connected relay for initial repository discovery | ||
| 353 | - The system will automatically discover and connect to additional relays listed in repository announcements | ||
| 354 | - Monitor sync health via Prometheus metrics at `/metrics` | ||
| 355 | - Purgatory will automatically fetch missing git data from clone URLs | ||
| 356 | |||
| 233 | ### Example: Development | 357 | ### Example: Development |
| 234 | 358 | ||
| 235 | ```bash | 359 | ```bash |
| @@ -331,11 +455,11 @@ ngit-grasp/ | |||
| 331 | βββ src/ | 455 | βββ src/ |
| 332 | β βββ main.rs # Entry point, server setup | 456 | β βββ main.rs # Entry point, server setup |
| 333 | β βββ lib.rs # Library exports | 457 | β βββ lib.rs # Library exports |
| 334 | β βββ config.rs # Configuration | 458 | β βββ config.rs # Configuration (core + sync settings) |
| 335 | β βββ git/ | 459 | β βββ git/ |
| 336 | β β βββ mod.rs # Git module + repository operations | 460 | β β βββ mod.rs # Git module + repository operations |
| 337 | β β βββ handlers.rs # Git HTTP handlers | 461 | β β βββ handlers.rs # Git HTTP handlers |
| 338 | β β βββ authorization.rs # Push validation logic | 462 | β β βββ authorization.rs # Push validation logic (checks DB + purgatory) |
| 339 | β β βββ protocol.rs # Git protocol encoding | 463 | β β βββ protocol.rs # Git protocol encoding |
| 340 | β β βββ subprocess.rs # Git subprocess management | 464 | β β βββ subprocess.rs # Git subprocess management |
| 341 | β βββ nostr/ | 465 | β βββ nostr/ |
| @@ -348,30 +472,60 @@ ngit-grasp/ | |||
| 348 | β β βββ state.rs # State event validation + ref alignment | 472 | β β βββ state.rs # State event validation + ref alignment |
| 349 | β β βββ pr_event.rs # PR/PR Update validation | 473 | β β βββ pr_event.rs # PR/PR Update validation |
| 350 | β β βββ related.rs # Forward/backward reference checking | 474 | β β βββ related.rs # Forward/backward reference checking |
| 475 | β βββ sync/ # GRASP-02 Proactive Sync (relay-to-relay) | ||
| 476 | β β βββ mod.rs # SyncManager, main loop, data structures | ||
| 477 | β β βββ algorithms.rs # derive_relay_targets(), compute_actions() | ||
| 478 | β β βββ filters.rs # 3-layer filter building (announcements, repos, events) | ||
| 479 | β β βββ health.rs # RelayHealthTracker (backoff, rate limits) | ||
| 480 | β β βββ relay_connection.rs # RelayConnection, event loop lifecycle | ||
| 481 | β β βββ self_subscriber.rs # SelfSubscriber (batched event discovery) | ||
| 482 | β β βββ metrics.rs # SyncMetrics for Prometheus | ||
| 483 | β βββ purgatory/ # In-memory holding area for events awaiting git data | ||
| 484 | β β βββ mod.rs # Purgatory core (state/PR storage, 30min expiry) | ||
| 485 | β β βββ helpers.rs # State event ref matching, PR lookup | ||
| 486 | β β βββ processing.rs # Unified git data processing (push + sync paths) | ||
| 487 | β β βββ sync/ # Proactive git data fetching | ||
| 488 | β β βββ mod.rs # Public API (enqueue, main loop) | ||
| 489 | β β βββ loop.rs # Sync loop (1s interval, debounced delays) | ||
| 490 | β β βββ functions.rs # Core sync logic (try URLs, handle results) | ||
| 491 | β β βββ queue.rs # SyncQueue (backoff, fresh start on new events) | ||
| 492 | β β βββ throttle.rs # DomainThrottle (5 concurrent, 30/min, round-robin) | ||
| 493 | β β βββ context.rs # SyncContext trait + mock for testing | ||
| 351 | β βββ http/ | 494 | β βββ http/ |
| 352 | β β βββ mod.rs # HTTP module | 495 | β β βββ mod.rs # HTTP module |
| 353 | β β βββ landing.rs # Landing page handler | 496 | β β βββ landing.rs # Landing page handler |
| 354 | β β βββ nip11.rs # NIP-11 relay info document | 497 | β β βββ nip11.rs # NIP-11 relay info document |
| 355 | β βββ metrics/ | 498 | β βββ metrics/ |
| 356 | β βββ mod.rs # Prometheus metrics | 499 | β βββ mod.rs # Prometheus metrics (Git, Nostr, Sync) |
| 357 | β βββ bandwidth.rs # Bandwidth tracking | 500 | β βββ bandwidth.rs # Bandwidth tracking |
| 358 | β βββ connection.rs # Connection tracking | 501 | β βββ connection.rs # Connection tracking |
| 359 | βββ docs/ # Documentation (DiΓ‘taxis framework) | 502 | βββ docs/ # Documentation (DiΓ‘taxis framework) |
| 360 | βββ tests/ # Integration tests | 503 | β βββ explanation/ # Architecture, decisions, GRASP-02 deep-dives |
| 504 | β βββ how-to/ # Deployment, configuration guides | ||
| 505 | β βββ tutorials/ # Getting started, first steps | ||
| 506 | β βββ reference/ # API docs, test strategy | ||
| 507 | βββ tests/ # Integration tests (NIP-01, NIP-34, purgatory) | ||
| 361 | βββ grasp-audit/ # Compliance audit subproject | 508 | βββ grasp-audit/ # Compliance audit subproject |
| 362 | βββ README.md | 509 | βββ README.md |
| 363 | ``` | 510 | ``` |
| 364 | 511 | ||
| 365 | ## Comparison with ngit-relay | 512 | ## Comparison with ngit-relay |
| 366 | 513 | ||
| 367 | | Feature | ngit-relay (Go) | ngit-grasp (Rust) | | 514 | | Feature | ngit-relay (Go) | ngit-grasp (Rust) | |
| 368 | | ------------- | ----------------------------------------- | ----------------------------- | | 515 | | ------------------- | ----------------------------------------- | ---------------------------------------------------- | |
| 369 | | Language | Go | Rust | | 516 | | Language | Go | Rust | |
| 370 | | Components | nginx + git-http-backend + hooks + Khatru | Single integrated binary | | 517 | | Components | nginx + git-http-backend + hooks + Khatru | Single integrated binary | |
| 371 | | Authorization | Pre-receive Git hook | Inline during receive-pack | | 518 | | Authorization | Pre-receive Git hook | Inline during receive-pack | |
| 372 | | Deployment | Docker + supervisord | Single binary | | 519 | | GRASP-01 | β Complete | β Complete | |
| 373 | | Testing | Go tests + shell scripts | Rust unit + integration tests | | 520 | | GRASP-02 Event Sync | β Limited | β Advanced (NIP-77 negentropy + fallback) | |
| 374 | | Performance | Good | Excellent (zero-copy, async) | | 521 | | GRASP-02 Git Sync | β Basic | β Automatic purgatory hunting | |
| 522 | | Multi-Maintainer | β Supported | β First-class (auto-sync across repos) | | ||
| 523 | | Purgatory | β 24-hour expiry | β 30-minute expiry + proactive git data fetching | | ||
| 524 | | Health Tracking | Basic | Advanced (exponential backoff, rate limit detection) | | ||
| 525 | | Deployment | Docker + supervisord | Single binary | | ||
| 526 | | Testing | Go tests + shell scripts | Rust unit + integration tests | | ||
| 527 | | Performance | Good | Excellent (zero-copy, async) | | ||
| 528 | | Monitoring | Basic logs | Comprehensive Prometheus metrics | | ||
| 375 | 529 | ||
| 376 | ## Contributing | 530 | ## Contributing |
| 377 | 531 | ||