From cad58fccae7ed84bb033e56de0f1323b714a854d Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 17 Feb 2026 11:43:40 +0000 Subject: docs: clarify why fetch_repository_data excludes purgatory Add comments explaining that PR event processing (both incoming and purgatory) should only use database announcements, not purgatory ones. This is intentional because: - Incoming PR events should only be accepted for validated announcements - Purgatory PR events should only be released when announcement is promoted - This prevents accepting PR events for announcements that fail validation Differs from state event processing which uses fetch_repository_data_with_purgatory because state events check authorization without releasing from purgatory. --- src/git/sync.rs | 3 +++ src/nostr/policy/pr_event.rs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/git/sync.rs b/src/git/sync.rs index a0b7c47..4b35023 100644 --- a/src/git/sync.rs +++ b/src/git/sync.rs @@ -1171,6 +1171,9 @@ async fn process_purgatory_pr_events( ); // Fetch repository data for syncing + // NOTE: Only fetch from database, NOT purgatory. PR events should only be + // released from purgatory when the announcement has been promoted (validated). + // This ensures we don't accept PR events for announcements that fail validation. let db_repo_data = match fetch_repository_data(database, identifier).await { Ok(data) => data, Err(e) => { diff --git a/src/nostr/policy/pr_event.rs b/src/nostr/policy/pr_event.rs index 00e09c3..072e445 100644 --- a/src/nostr/policy/pr_event.rs +++ b/src/nostr/policy/pr_event.rs @@ -127,6 +127,10 @@ impl PrEventPolicy { .ok_or_else(|| anyhow::anyhow!("No identifier in PR event"))?; // Fetch repository data + // NOTE: Only fetch from database, NOT purgatory. Incoming PR events should + // only be accepted for announcements that have been promoted (validated). + // If the announcement is still in purgatory, the PR event should also go + // to purgatory and wait for the announcement to be promoted. let db_repo_data = fetch_repository_data(&self.ctx.database, &identifier).await?; // Extract owner pubkey from source repo path @@ -203,6 +207,10 @@ impl PrEventPolicy { let identifier = parts[2]; // 2. Fetch repo data + // NOTE: Only fetch from database, NOT purgatory. Incoming PR events should + // only be accepted for announcements that have been promoted (validated). + // If the announcement is still in purgatory, the PR event should also go + // to purgatory and wait for the announcement to be promoted. let db_repo_data = fetch_repository_data(&self.ctx.database, identifier).await?; // 3. Extract list of maintainers from "a 30617::" tags -- cgit v1.2.3