Updated NOSTR_GIT_DEBUGGING.md to reflect the new auto-announcement workflow: - Added "Auto-Announcement" section explaining the feature - Updated workflow to show simplified process (no manual announcement needed) - Added console log examples for auto-announce success/failure - Kept manual workflow as fallback option - Clarified that repository is auto-announced on first patch creation The guide now reflects the seamless "it just works" experience while still providing debugging information for edge cases.
7.9 KiB
Nostr Git Debugging Guide
Understanding the Problem
Patches are being published successfully but not showing up in NostrHub or other Nostr git clients. This is likely a relay synchronization issue.
How Nostr Git Discovery Works
-
Repository Announcement (Kind 30617)
- Published once per repository (auto-announced on first patch)
- Contains metadata: name, description, clone URLs, relays
- Includes
rtag with earliest unique commit (euc) - Has
dtag with repository identifier - Coordinate:
30617:<pubkey>:<repo-id>
-
Patches (Kind 1617)
- Reference repository via
atag:30617:<pubkey>:<repo-id> - Include
rtag with euc for repository-specific filtering - Published to relays specified in repository announcement
- Reference repository via
-
Discovery Flow
- Client queries for repositories (kind 30617)
- User selects a repository
- Client queries for patches using
#afilter:#a: ["30617:<pubkey>:<repo-id>"]
-
Auto-Announcement (Shakespeare Feature)
- When creating first patch, repository is auto-announced
- Uses configured relay from settings
- Ensures announcement and patch on same relay
- Eliminates manual "Announce Repository" step
The Relay Problem
Key Issue: Events must be on the same relay for discovery to work.
Scenario:
- You're connected to
wss://relay.primal.netin Shakespeare - You announce repository → published to
wss://relay.primal.net - You create patch → published to
wss://relay.primal.net - NostrHub is connected to
wss://relay.nostr.band - NostrHub queries
wss://relay.nostr.band→ finds nothing
Why This Happens:
- Nostr relays don't automatically sync with each other
- Each relay is independent
- Events are only on relays they were explicitly published to
- Relay hints in events are suggestions, not guarantees
Debugging Steps
Step 1: Check Which Relay You're On
In Shakespeare, check the current relay:
- Look at bottom of the page or settings
- Default is
wss://relay.primal.net
Step 2: Verify Repository Announcement
After clicking "Announce Repository", check console logs:
=== ANNOUNCING REPOSITORY ===
Repository ID: git.shakespeare.diy/portfoliux
Owner pubkey: 932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d
Event coordinate: 30617:932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d:git.shakespeare.diy/portfoliux
Published repository announcement to Nostr relays
To verify: Query for kind 30617 with authors=[...] and #d=[...]
Step 3: Verify Patch Can Find Repository
When creating a patch, check console logs:
If repository exists:
Querying for repository announcement with filter: {...}
Repository announcement query returned 1 events ✅ GOOD
Found repository announcement event: {...}
If repository doesn't exist (auto-announce):
Repository announcement query returned 0 events
Repository announcement not found - creating one automatically
Auto-creating repository announcement: {...}
Successfully auto-announced repository ✅ GOOD
If auto-announce fails:
Repository announcement query returned 0 events
Failed to auto-announce repository: <error> ❌ BAD
Step 4: Check NostrHub's Relay
- Open NostrHub (nostrhub.io)
- Check which relay it's using
- Compare with Shakespeare's relay
Solutions
Solution 1: Use Same Relay as NostrHub
- In Shakespeare settings, change relay to match NostrHub
- Common NostrHub relays:
wss://relay.nostr.bandwss://relay.damus.io
- Re-announce repository on this relay
- Create new patch
Solution 2: Publish to Multiple Relays
When announcing repository, add multiple relays:
wss://relay.primal.netwss://relay.nostr.bandwss://relay.damus.io
The announcement event will be published to all of these, and patches will follow.
Solution 3: Use NIP-65 Relay Lists (Future Enhancement)
Proper solution would be to:
- Query user's NIP-65 relay list
- Publish repository announcements to all user's read/write relays
- Patches automatically go to same relays
Verifying Success
Check Repository is Discoverable:
- Open NostrHub
- Go to Repositories page
- Look for your repository
- If found → announcement is on correct relay ✅
Check Patches are Discoverable:
- Find your repository on NostrHub
- Click into repository
- Check Patches tab
- Your patches should appear ✅
Common Issues
Issue: "Repository announcement not found"
Cause: Announcement not on current relay Fix: Re-announce on current relay
Issue: Patches published but not visible
Cause: Patches on different relay than announcement Fix: Ensure both announcement and patches on same relay
Issue: Works in Shakespeare but not NostrHub
Cause: Different relays Fix: Use same relay in both clients
Issue: Relay hints not working
Explanation: Relay hints are suggestions only - clients may ignore them Fix: Ensure announcement is on relay the client uses
Event Format Reference
Repository Announcement (Kind 30617)
{
"kind": 30617,
"content": "",
"tags": [
["d", "git.shakespeare.diy/portfoliux"],
["name", "Portfoliux"],
["description", "Portfolio website"],
["clone", "nostr://npub.../git.shakespeare.diy/portfoliux"],
["relays", "wss://relay.nostr.band"],
["r", "abc123...", "euc"]
]
}
Patch Event (Kind 1617)
{
"kind": 1617,
"content": "From abc... Mon Sep 17...\n<git format-patch content>",
"tags": [
["a", "30617:932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d:git.shakespeare.diy/portfoliux"],
["p", "932614571afcbad4d17a191ee281e39eebbb41b93fac8fd87829622aeb112f4d"],
["t", "root"],
["t", "root-revision"],
["subject", "Fix bug in component"],
["r", "abc123..."],
["commit", "def456..."],
["parent-commit", "ghi789..."]
]
}
Testing Relay Synchronization
To test if events are on a relay:
-
Using nostr.band explorer:
- Go to https://nostr.band
- Search for your event ID or repository coordinate
- Check which relays have the event
-
Using console in Shakespeare:
// Check repository announcement await nostr.query([{ kinds: [30617], authors: ["your-pubkey"], "#d": ["your-repo-id"], limit: 1 }]); // Check patches await nostr.query([{ kinds: [1617], "#a": ["30617:your-pubkey:your-repo-id"], limit: 10 }]);
Recommended Workflow
Simplified (Auto-Announce Enabled)
-
Configure relay (one time):
- Settings → Select relay (e.g.,
wss://relay.nostr.band) - This relay will be used for all Nostr git operations
- Settings → Select relay (e.g.,
-
Create patches (automatic announcement):
- Click "Create Patch"
- System automatically announces repository if needed
- Patch is published with proper references
- Check "Your Patches" section to verify
-
View in NostrHub:
- Ensure NostrHub uses same relay
- Browse to Repositories → Find your repository
- View patches in Patches tab
Manual (If Auto-Announce Fails)
-
First time setup:
- Switch to
wss://relay.nostr.band(widely used) - Click "Announce Repository" button
- Verify announcement succeeded
- Switch to
-
Creating patches:
- Ensure same relay as announcement
- Create patch
- Check console for successful repository lookup
- Verify patch appears in "Your Patches" section
-
Checking in NostrHub:
- Ensure NostrHub on same relay
- Browse to Repositories
- Find your repository
- View patches
Future Improvements Needed
- Multi-relay publishing: Publish to multiple relays automatically
- NIP-65 integration: Use user's relay list
- Relay fallback: Try multiple relays when querying
- Relay selection UI: Easy relay switching before operations
- Event verification: Confirm events were published successfully
- Cross-relay search: Query multiple relays for better discovery