upleb.uk

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

summaryrefslogtreecommitdiff
path: root/PLAN.md
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-26 20:38:49 +0530
committerYour Name <you@example.com>2026-05-26 20:38:49 +0530
commit7b1b36b8c7e448d1d170c8c6e1f88bb766163fbb (patch)
tree51fa521b7856423ce586077e5e3b045af3694220 /PLAN.md
parente435f7d7b4ad4e4b1d3c21c35df5f41ffd642376 (diff)
Fix push_target remote reuse and non-fatal per-repo errors
- git_mirror: reuse existing push_target remote via remote_set_url instead of failing on 'remote already exists' on subsequent cycles - mirror_cycle: catch per-repo errors instead of propagating with ? so one failed clone doesn't abort the remaining 87 repos - Add PLAN.md with bug tracking checklist
Diffstat (limited to 'PLAN.md')
-rw-r--r--PLAN.md119
1 files changed, 25 insertions, 94 deletions
diff --git a/PLAN.md b/PLAN.md
index 2664d51..ab1ea9f 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -1,94 +1,25 @@
1# GRASP Mirror Daemon — Implementation Plan 1# grasp-mirror Bugfix Plan
2 2
3A Rust daemon that discovers repos from watched npubs and mirrors git data + Nostr events across all known GRASP servers for redundancy. 3## Bugs Identified from VPS Logs
4 4
5## Phase 1: Core (MVP) 5### Bug 1: `remote 'push_target' already exists`
6 6- **Location**: `src/git_mirror.rs:137`
7### Infrastructure 7- **Cause**: `repo.remote("push_target", target_url)` creates a new remote every cycle. On subsequent cycles, the bare repo already has a `push_target` remote, so `git2` returns `Exists (-4)`.
8 8- **Fix**: Use `repo.find_remote("push_target")` first. If it exists, call `repo.remote_set_url()` to update the URL. If not, create it.
9- [x] Cargo.toml with dependencies 9
10- [x] Project directory structure 10### Bug 2: Single repo failure aborts entire cycle
11- [x] PLAN.md (this file) 11- **Location**: `src/main.rs:mirror_cycle()` — the `mirror.mirror_repo_to_servers()` call uses `?` which propagates the error and aborts the loop.
12- [ ] config.example.toml 12- **Cause**: When one repo (e.g. `market`) fails to clone from any server, the `?` operator returns early, skipping the remaining ~87 repos.
13- [ ] .env.example 13- **Fix**: Replace `?` with a `match` that logs the error and continues to the next repo. Only the `discover_repos_from_relays` and `persist_discovered_repos` calls should be fatal (if relay queries fail, nothing works).
14- [ ] SQLite migration schema 14
15 15## Checklist
16### Source Modules 16
17 17- [ ] Fix `push_mirror` in `src/git_mirror.rs` — reuse existing `push_target` remote
18- [ ] `config.rs` — TOML config + .env loading, npub parsing, server list 18- [ ] Fix `mirror_cycle` in `src/main.rs` — make per-repo errors non-fatal
19- [ ] `db.rs` — SQLite state tracking (repos, sync status, event dedup) 19- [ ] Rebuild release binary (`cargo build --release`)
20- [ ] `health.rs` — NIP-11 GRASP server verification and health checks 20- [ ] Push updated source to all 9 GRASP servers (`git push origin master`)
21- [ ] `discovery.rs` — Relay subscriptions for kind:30617/10317/30618, repo parsing 21- [ ] Redeploy via Ansible (`ansible-playbook playbooks/30-grasp-mirror.yml`)
22- [ ] `git_mirror.rs` — Bare clone + `git push --mirror` to missing GRASP servers 22- [ ] Verify: `grasp-mirror status` shows repos tracked and sync records
23- [ ] `nostr_mirror.rs` — Forward Nostr events to all GRASP server relays 23- [ ] Verify: `journalctl -u grasp-mirror` shows successful mirror cycles without `already exists` errors
24- [ ] `signing.rs` — Optional: update announcements to include mirrored servers 24- [ ] Verify: spot-check `git ls-remote` against a few GRASP servers for repos from all 3 npubs
25- [ ] `main.rs` — CLI entry point, daemon loop, signal handling 25- [ ] Verify: `https://git.orangesync.tech/api/mirror-health` returns `"status": "ok"`
26
27## Phase 2: Resilience
28
29- [ ] Continuous state sync (watch kind:30618, push new refs to missing servers)
30- [ ] Periodic NIP-11 health checks on all known GRASP servers
31- [ ] Auto-discover new GRASP servers from indexer kind:10317 events
32- [ ] Retry with exponential backoff for failed mirrors
33- [ ] SIGHUP hot-reload of npub list from .env
34
35## Phase 3: Advanced
36
37- [ ] Per-npub / per-repo server allowlists and blocklists
38- [ ] Prometheus metrics endpoint
39- [ ] CLI status subcommand (show mirror health per repo/server)
40- [ ] Web dashboard
41
42## Known GRASP Servers
43
44| Server | Software | GRASP Support |
45|--------|----------|---------------|
46| `relay.ngit.dev` | ngit-grasp 1.1.0 | 01/02/06 |
47| `gitnostr.com` | ngit-grasp 1.0.2 | 01/02/06 |
48| `git.orangesync.tech` | ngit-grasp 0.1.0 | 01/02/05 |
49| `ngit.danconwaydev.com` | ngit-grasp 1.0.2 | 01/02/06 |
50| `git.shakespeare.diy` | ngit-grasp 1.0.1 | 01/02 |
51| `git.upleb.uk` | ngit-grasp 1.0.2 | 01/02 |
52| `grasp.budabit.club` | ngit-grasp 1.0.2 | 01/02 |
53| `git.uid.ovh` | ngit-grasp 1.0.2 | 01/02 |
54| `git.vps.satsnode.xyz` | ngit-grasp 1.0.1 | 01/02 |
55
56## Architecture
57
58```
59┌─────────────────────────────────────────────────────┐
60│ grasp-mirror │
61│ │
62│ ┌────────────────┐ ┌─────────────────────────┐ │
63│ │ Discovery │ │ Mirror Engine │ │
64│ │ ──────────── │ │ ──────────────────── │ │
65│ │ • Index relay │────▶│ For each repo: │ │
66│ │ • GRASP relays│ │ 1. git clone --bare │ │
67│ │ • kind:30617 │ │ from any source │ │
68│ │ • kind:10317 │ │ 2. git push --mirror │ │
69│ │ • kind:30618 │ │ to missing servers │ │
70│ │ │ │ 3. Republish nostr │ │
71│ └────────────────┘ │ events to all relays │ │
72│ └─────────────────────────┘ │
73│ ┌────────────────┐ ┌─────────────────────────┐ │
74│ │ Config │ │ State DB (SQLite) │ │
75│ │ ──────────── │ │ ──────────────────── │ │
76│ │ config.toml │ │ • repos seen │ │
77│ │ .env (npubs) │ │ • last sync per server │ │
78│ │ [optional] │ │ • sync status/errors │ │
79│ │ nsec for │ │ • event ids processed │ │
80│ │ signing │ └─────────────────────────┘ │
81│ └────────────────┘ │
82└─────────────────────────────────────────────────────┘
83```
84
85## Data Flow
86
871. **Discovery**: Subscribe to index relay for kind:30617 from watched npubs
882. **Parse**: Extract repo identifier, clone URLs, relay URLs from each announcement
893. **Diff**: Compare clone URLs against known GRASP servers to find missing mirrors
904. **Mirror Git**:
91 - `git clone --bare` from any available clone URL
92 - For each missing GRASP server: publish announcement to its relay (triggers repo creation), then `git push --mirror`
935. **Mirror Nostr**: Forward all related events (issues, comments, state) to all GRASP server relays
946. **Track**: Record mirror status in SQLite, skip already-mirrored repos on restart