upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/explanation/grasp-05-archive.md148
-rw-r--r--docs/reference/configuration.md76
2 files changed, 224 insertions, 0 deletions
diff --git a/docs/explanation/grasp-05-archive.md b/docs/explanation/grasp-05-archive.md
new file mode 100644
index 0000000..e43a87e
--- /dev/null
+++ b/docs/explanation/grasp-05-archive.md
@@ -0,0 +1,148 @@
1# GRASP-05 Archive Mode
2
3**Purpose:** Understand archive/mirror/backup functionality
4**Audience:** Operators and developers
5
6---
7
8## What It Does
9
10GRASP-05 enables ngit-grasp to accept repository announcements that **don't list your relay**, allowing you to run an archive, mirror, or backup service.
11
12**Standard GRASP-01:** Announcement must list your service → You host it (read/write)
13**GRASP-05 Extension:** Announcement matches your whitelist → You archive it (read-only)
14
15## Why It Exists
16
17### Problem
18In GRASP-01 strict mode, you can only host repositories whose maintainers explicitly list your relay. This prevents:
19- Creating backup archives of critical projects without maintainer cooperation
20- Building comprehensive mirrors of the Nostr Git ecosystem
21- Providing disaster recovery for projects that might disappear
22
23### Solution
24Archive mode relaxes the "must list service" requirement for whitelisted repositories, enabling passive mirroring while maintaining read-only guarantees.
25
26## How It Works
27
28### Three Whitelist Formats
29
30| Format | Example | Archives |
31|--------|---------|----------|
32| `<npub>` | `npub1alice...` | All repos from Alice |
33| `<npub>/<identifier>` | `npub1bob.../linux` | Only Bob's linux repo |
34| `<identifier>` | `bitcoin-core` | Any bitcoin-core repo (⚠️ any pubkey) |
35
36**Configuration:**
37```bash
38# Specific repos (safest)
39NGIT_ARCHIVE_WHITELIST=npub1torvalds.../linux,npub1satoshi.../bitcoin
40
41# All repos from trusted maintainers
42NGIT_ARCHIVE_WHITELIST=npub1alice...,npub1bob...
43
44# Archive everything (⚠️ storage risk)
45NGIT_ARCHIVE_ALL=true
46```
47
48### Validation Priority
49
50Announcements are checked in this order:
51
521. **Lists your service?** → `Accept` (GRASP-01, read/write)
532. **Is author a maintainer?** → `AcceptMaintainer` (multi-maintainer, read/write)
543. **Matches archive config?** → `AcceptArchive` (GRASP-05, read-only)
554. **None of the above** → `Reject`
56
57This ensures GRASP-01 compliant repos are always writable, even if they match the archive whitelist.
58
59### Storage Model
60
61Archived repos use the same directory structure as hosted repos:
62```
63<git_data_path>/
64 npub1alice.../
65 hosted-repo.git/ # Lists your service (writable)
66 archived-repo.git/ # Whitelisted (read-only)
67```
68
69**No flags or metadata** - archive status determined dynamically from config + announcement contents.
70
71### Full Sync
72
73Archived repositories trigger complete GRASP-02 sync:
74- ✅ Nostr events (PRs, issues, patches)
75- ✅ Git data via purgatory
76- ✅ Same validation as hosted repos
77
78Archive mode is a **complete mirror**, not just git-only backup.
79
80## Security Considerations
81
82### 1. Archive-All Mode (Dangerous)
83
84**Don't use `NGIT_ARCHIVE_ALL=true` unless:**
85- You have unlimited storage/bandwidth
86- You trust the relay network
87- You've implemented monitoring
88
89**Attack vector:** Anyone can publish announcements → unlimited storage consumption.
90
91### 2. Identifier-Only Format (Risky)
92
93```bash
94NGIT_ARCHIVE_WHITELIST=bitcoin-core # Matches ANY pubkey!
95```
96
97Malicious users can publish fake repos with popular identifiers. Use `<npub>/<identifier>` for high-value archives.
98
99### 3. Npub Validation
100
101Invalid npubs → server fails to start (fail-fast). Identifiers aren't validated (any string allowed).
102
103## Operational Guide
104
105### Start Small
106
107```bash
108# Day 1: One critical repo
109NGIT_ARCHIVE_WHITELIST=npub1torvalds.../linux
110
111# Week 1: Add trusted maintainers
112NGIT_ARCHIVE_WHITELIST=npub1alice...,npub1bob...
113
114# Month 1: Consider popular identifiers (with monitoring)
115NGIT_ARCHIVE_WHITELIST=npub1alice...,bitcoin-core
116```
117
118### Monitor Growth
119
120Watch for:
121- Storage consumption rate
122- Purgatory git fetch failures
123- Bandwidth usage spikes
124
125### Whitelist Changes
126
127**Current:** Static config - edit `.env`, restart server
128**Future:** REST API for dynamic management (no restart)
129
130## Comparison: Hosted vs Archived
131
132| Aspect | Hosted (GRASP-01) | Archived (GRASP-05) |
133|--------|-------------------|---------------------|
134| Announcement must list you | ✅ Required | ❌ Whitelisted instead |
135| Git pushes | ✅ Accepted | ❌ Rejected (read-only) |
136| GRASP-02 sync | ✅ Full sync | ✅ Full sync |
137| Relay discovery | ✅ Listed | ❌ Not listed |
138| Use case | Hosting workspace | Backup/mirror |
139
140## Related Documentation
141
142- [Configuration Reference](../reference/configuration.md) - `NGIT_ARCHIVE_*` options
143- [GRASP-05 Spec](https://gitworkshop.dev/danconwaydev.com/grasp/05.md) - Protocol specification
144- [GRASP-02 Sync](./grasp-02-proactive-sync.md) - How sync works
145
146---
147
148_Part of the [ngit-grasp explanation documentation](./)_
diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md
index bdd832f..52418ad 100644
--- a/docs/reference/configuration.md
+++ b/docs/reference/configuration.md
@@ -498,6 +498,82 @@ NGIT_REJECTED_COLD_INDEX_EXPIRY_SECS=1209600
498 498
499--- 499---
500 500
501### GRASP-05 Archive Configuration
502
503These options enable archive/mirror/backup mode per the GRASP-05 specification.
504
505#### `NGIT_ARCHIVE_ALL`
506
507**Description:** Accept all repository announcements regardless of whether they list this instance
508**Type:** Boolean
509**Default:** `false`
510**Required:** No
511
512**Examples:**
513
514```bash
515# Enable archive-all mode (⚠️ WARNING: Storage risk)
516NGIT_ARCHIVE_ALL=true
517
518# Disable (default - GRASP-01 strict mode)
519NGIT_ARCHIVE_ALL=false
520```
521
522**Security Warning:** When enabled, any repository can be mirrored to this relay, potentially causing storage and bandwidth exhaustion. Only enable if you have unlimited resources and trust the relay network.
523
524**Notes:**
525
526- Archived repositories are read-only (pushes rejected)
527- Full sync enabled (both git data and Nostr events)
528- Takes precedence over whitelist (accepts everything)
529
530---
531
532#### `NGIT_ARCHIVE_WHITELIST`
533
534**Description:** Comma-separated list of repositories/pubkeys/identifiers to archive
535**Type:** String (comma-separated)
536**Default:** (empty)
537**Required:** No
538
539**Formats:**
540
541- `<npub>` - Archive all repos from this pubkey
542- `<npub>/<identifier>` - Archive specific repo from specific pubkey
543- `<identifier>` - Archive repos with this identifier from any pubkey
544
545**Examples:**
546
547```bash
548# Archive all repos from Alice
549NGIT_ARCHIVE_WHITELIST=npub1alice23
550
551# Archive specific repos
552NGIT_ARCHIVE_WHITELIST=npub1alice23/linux,npub1bob23/bitcoin-core
553
554# Archive by identifier (any pubkey)
555NGIT_ARCHIVE_WHITELIST=bitcoin-core,linux,rust
556
557# Mixed formats
558NGIT_ARCHIVE_WHITELIST=npub1alice23...,npub1bob23.../linux,bitcoin-core
559```
560
561**Validation:**
562
563- Npub entries are validated at startup (invalid npub = server fails to start)
564- Identifier entries accept any string
565- Whitespace is trimmed
566- Empty entries are ignored
567
568**Security Notes:**
569
570- Identifier-only format (`bitcoin-core`) matches ANY pubkey
571- Use `npub/identifier` format for high-value archives
572- Whitelist is static (restart required to change)
573- Future: Dynamic management via API
574
575---
576
501### Logging Configuration 577### Logging Configuration
502 578
503#### `RUST_LOG` 579#### `RUST_LOG`