accept all UserGraspList for better discovery

This commit is contained in:
DanConwayDev
2025-12-22 20:21:26 +00:00
parent 777509bb03
commit 5d3d96c7f0
5 changed files with 25 additions and 3 deletions
+5 -1
View File
@@ -134,7 +134,11 @@ This a useful feature of other git servers.
### Store all user grasp lists (for better grasp discovery)
do this. should we also accept (and weekly sync) 10002 and 0 for all authors of accepted events?
✅ **Implemented**: Kind 10317 (User Grasp List) events are now accepted and synced from all relays for better GRASP repository discovery.
**Future enhancement**: We aspire to also accept and weekly sync kind 10002 (user relay lists) and kind 0 (user metadata) events, but only for authors of accepted events. This would require an additional state-driven layer 2 filter (see Roadmap in GRASP-02 Proactive Sync documentation).
**Future enhancement**: should we periodically scan relays in UserGraspLists to check for announcements that list our relay?
## Technology Stack
+11 -1
View File
@@ -13,7 +13,7 @@ use nostr_relay_builder::prelude::*;
use crate::config::{Config, DatabaseBackend};
use crate::nostr::events::{
RepositoryAnnouncement, RepositoryState, KIND_PR, KIND_PR_UPDATE, KIND_REPOSITORY_ANNOUNCEMENT,
KIND_REPOSITORY_STATE,
KIND_REPOSITORY_STATE, KIND_USER_GRASP_LIST,
};
use crate::nostr::policy::{
AnnouncementPolicy, AnnouncementResult, PolicyContext, PrEventPolicy, ReferenceResult,
@@ -257,6 +257,16 @@ impl WritePolicy for Nip34WritePolicy {
KIND_REPOSITORY_ANNOUNCEMENT => self.handle_announcement(event).await,
KIND_REPOSITORY_STATE => self.handle_state(event).await,
KIND_PR | KIND_PR_UPDATE => self.handle_pr_event(event).await,
KIND_USER_GRASP_LIST => {
// Accept all kind 10317 (User Grasp List) events
// for better GRASP repository discovery
tracing::debug!(
event_id = %event.id.to_bech32().unwrap_or_else(|_| event.id.to_hex()),
author = %event.pubkey.to_hex(),
"Accepted kind 10317 user grasp list"
);
PolicyResult::Accept
}
_ => self.handle_related_event(event, "Event").await,
}
})
+3
View File
@@ -21,6 +21,9 @@ pub const KIND_PR: u16 = 1618;
/// NIP-34 Pull Request Update (kind 1619) - has `c` tag for commit
pub const KIND_PR_UPDATE: u16 = 1619;
/// User Grasp List (kind 10317) - user's personal list of GRASP repositories
pub const KIND_USER_GRASP_LIST: u16 = 10317;
/// Repository announcement details extracted from NIP-34 event
#[derive(Debug, Clone)]
pub struct RepositoryAnnouncement {
+3 -1
View File
@@ -13,14 +13,16 @@ use std::collections::HashSet;
use nostr_sdk::prelude::*;
/// Layer 1: Announcements filter (kinds 30617 + 30618)
/// Layer 1: Announcements filter (kinds 30617 + 30618 + 10317)
///
/// Subscribed ONCE on connect - NOT included in consolidation rebuilds.
/// Note: 30618 is ONLY synced from remote relays, not self-subscribed.
/// Note: 10317 (User Grasp List) is synced for better GRASP discovery.
pub fn build_announcement_filter(since: Option<Timestamp>) -> Filter {
let filter = Filter::new().kinds([
Kind::Custom(30617), // Repository announcements
Kind::Custom(30618), // Maintainer lists
Kind::Custom(10317), // User Grasp List
]);
match since {
+3
View File
@@ -285,6 +285,7 @@ impl SelfSubscriber {
// Subscribe to announcement and root event kinds
// Per v4 spec: 30617, 1617, 1618, 1621 (NOT 30618)
// Plus kind 10317 (User Grasp List) for GRASP discovery
// Check if we have a last_connected time for reconnect filtering
let filter = if let Some(last) = self.last_connected {
// Quick reconnect - use since filter (15 min buffer)
@@ -299,6 +300,7 @@ impl SelfSubscriber {
Kind::Custom(1617), // Patches
Kind::Custom(1621), // Issues
Kind::Custom(1618), // Pull Requests
Kind::Custom(10317), // User Grasp List
])
.since(since)
} else {
@@ -308,6 +310,7 @@ impl SelfSubscriber {
Kind::Custom(1617), // Patches
Kind::Custom(1621), // Issues
Kind::Custom(1618), // Pull Requests
Kind::Custom(10317), // User Grasp List
])
};