From dcaaa0c44c46f963929ab0baa91f63759ec702dc Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 12 Feb 2026 12:57:44 +0000 Subject: refactor(grasp-audit): split ValidRepo into Sent/Served, add tolerant purgatory - Rename ValidRepo to ValidRepoSent (announcement sent, may be in purgatory) - Add ValidRepoServed (announcement queryable after git data pushed) - Add send_event_and_note_purgatory() for tolerant purgatory detection - Update fixtures to use tolerant method instead of strict assertion - Update event_acceptance_policy tests to use ValidRepoServed This enables tests to pass regardless of purgatory implementation status while still having explicit purgatory tests that verify the behavior. --- grasp-audit/src/specs/grasp01/cors.rs | 2 +- .../src/specs/grasp01/event_acceptance_policy.rs | 120 ++++++++++++--------- grasp-audit/src/specs/grasp01/git_clone.rs | 6 +- grasp-audit/src/specs/grasp01/git_filter.rs | 6 +- grasp-audit/src/specs/grasp01/nip01_smoke.rs | 4 +- .../src/specs/grasp01/push_authorization.rs | 16 +-- .../src/specs/grasp01/repository_creation.rs | 6 +- 7 files changed, 92 insertions(+), 68 deletions(-) (limited to 'grasp-audit/src/specs') diff --git a/grasp-audit/src/specs/grasp01/cors.rs b/grasp-audit/src/specs/grasp01/cors.rs index eba9e42..e5d9a27 100644 --- a/grasp-audit/src/specs/grasp01/cors.rs +++ b/grasp-audit/src/specs/grasp01/cors.rs @@ -246,7 +246,7 @@ impl CorsTests { let ctx = TestContext::new(client); // Create repository announcement to get a real repo path - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( diff --git a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs index 8259283..3375c4d 100644 --- a/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs +++ b/grasp-audit/src/specs/grasp01/event_acceptance_policy.rs @@ -157,12 +157,15 @@ impl EventAcceptancePolicyTests { let ctx = TestContext::new(client); // Request repository fixture - behavior depends on mode - let event = ctx.get_fixture(FixtureKind::ValidRepo).await.map_err(|e| { - format!( - "Test setup failed: could not get valid repository fixture: {}", - e - ) - })?; + let event = ctx + .get_fixture(FixtureKind::ValidRepoServed) + .await + .map_err(|e| { + format!( + "Test setup failed: could not get valid repository fixture: {}", + e + ) + })?; // Get relay URL for validation let relay_url = client @@ -602,12 +605,15 @@ impl EventAcceptancePolicyTests { let ctx = TestContext::new(client); // NEW: Get repository fixture (mode-aware) - let repo = ctx.get_fixture(FixtureKind::ValidRepo).await.map_err(|e| { - format!( - "Test setup failed: could not get valid repository fixture: {}", - e - ) - })?; + let repo = ctx + .get_fixture(FixtureKind::ValidRepoServed) + .await + .map_err(|e| { + format!( + "Test setup failed: could not get valid repository fixture: {}", + e + ) + })?; // 2. Create issue that references the repo let issue = Self::create_issue_for_repo(client, &repo, "Test Issue 1")?; @@ -637,12 +643,15 @@ impl EventAcceptancePolicyTests { let ctx = TestContext::new(client); // Get repository fixture (mode-aware) - let repo = ctx.get_fixture(FixtureKind::ValidRepo).await.map_err(|e| { - format!( - "Test setup failed: could not get valid repository fixture: {}", - e - ) - })?; + let repo = ctx + .get_fixture(FixtureKind::ValidRepoServed) + .await + .map_err(|e| { + format!( + "Test setup failed: could not get valid repository fixture: {}", + e + ) + })?; // Extract repo_id and create `A` tag manually let repo_id = @@ -690,12 +699,15 @@ impl EventAcceptancePolicyTests { let ctx = TestContext::new(client); // Get repository fixture (mode-aware) - let repo = ctx.get_fixture(FixtureKind::ValidRepo).await.map_err(|e| { - format!( - "Test setup failed: could not get valid repository fixture: {}", - e - ) - })?; + let repo = ctx + .get_fixture(FixtureKind::ValidRepoServed) + .await + .map_err(|e| { + format!( + "Test setup failed: could not get valid repository fixture: {}", + e + ) + })?; // Extract repo_id and create `q` tag let repo_id = @@ -825,12 +837,15 @@ impl EventAcceptancePolicyTests { let ctx = TestContext::new(client); // Get repository fixture (mode-aware) - let repo = ctx.get_fixture(FixtureKind::ValidRepo).await.map_err(|e| { - format!( - "Test setup failed: could not get valid repository fixture: {}", - e - ) - })?; + let repo = ctx + .get_fixture(FixtureKind::ValidRepoServed) + .await + .map_err(|e| { + format!( + "Test setup failed: could not get valid repository fixture: {}", + e + ) + })?; // Create Kind 1 A that quotes the repo (makes it accepted) let repo_id = Self::extract_d_tag(&repo).ok_or("Failed to extract repo_id")?; @@ -881,12 +896,15 @@ impl EventAcceptancePolicyTests { let ctx = TestContext::new(client); // Get repository fixture (mode-aware) - let repo = ctx.get_fixture(FixtureKind::ValidRepo).await.map_err(|e| { - format!( - "Test setup failed: could not get valid repository fixture: {}", - e - ) - })?; + let repo = ctx + .get_fixture(FixtureKind::ValidRepoServed) + .await + .map_err(|e| { + format!( + "Test setup failed: could not get valid repository fixture: {}", + e + ) + })?; // Verify repo is queryable (ensures it's fully indexed before we reference it) let repo_id = Self::extract_d_tag(&repo).ok_or("Failed to extract repo_id")?; @@ -1034,12 +1052,15 @@ impl EventAcceptancePolicyTests { let ctx = TestContext::new(client); // Get repository fixture (mode-aware) - let repo = ctx.get_fixture(FixtureKind::ValidRepo).await.map_err(|e| { - format!( - "Test setup failed: could not get valid repository fixture: {}", - e - ) - })?; + let repo = ctx + .get_fixture(FixtureKind::ValidRepoServed) + .await + .map_err(|e| { + format!( + "Test setup failed: could not get valid repository fixture: {}", + e + ) + })?; // Create Kind 1 A locally but DON'T send it yet let kind1_a = client @@ -1148,12 +1169,15 @@ impl EventAcceptancePolicyTests { let ctx = TestContext::new(client); // Get accepted repo A fixture (mode-aware) - let _repo_a = ctx.get_fixture(FixtureKind::ValidRepo).await.map_err(|e| { - format!( - "Test setup failed: could not get valid repository fixture: {}", - e - ) - })?; + let _repo_a = ctx + .get_fixture(FixtureKind::ValidRepoServed) + .await + .map_err(|e| { + format!( + "Test setup failed: could not get valid repository fixture: {}", + e + ) + })?; // Create Repo B but DON'T send it (unaccepted) let repo_b = Self::create_test_repo(client, "unaccepted-repo-b").await?; diff --git a/grasp-audit/src/specs/grasp01/git_clone.rs b/grasp-audit/src/specs/grasp01/git_clone.rs index fda472b..0c223f4 100644 --- a/grasp-audit/src/specs/grasp01/git_clone.rs +++ b/grasp-audit/src/specs/grasp01/git_clone.rs @@ -49,7 +49,7 @@ impl GitCloneTests { let ctx = TestContext::new(client); // Create repository announcement - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( @@ -171,7 +171,7 @@ impl GitCloneTests { let ctx = TestContext::new(client); // Create repository announcement - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( @@ -274,7 +274,7 @@ impl GitCloneTests { let ctx = TestContext::new(client); // Create repository announcement - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( diff --git a/grasp-audit/src/specs/grasp01/git_filter.rs b/grasp-audit/src/specs/grasp01/git_filter.rs index 7f203a2..31d86aa 100644 --- a/grasp-audit/src/specs/grasp01/git_filter.rs +++ b/grasp-audit/src/specs/grasp01/git_filter.rs @@ -62,7 +62,7 @@ impl GitFilterTests { let ctx = TestContext::new(client); // Create repository announcement - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( @@ -185,7 +185,7 @@ impl GitFilterTests { let ctx = TestContext::new(client); // Create repository announcement - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( @@ -296,7 +296,7 @@ impl GitFilterTests { let ctx = TestContext::new(client); // Create repository announcement - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( diff --git a/grasp-audit/src/specs/grasp01/nip01_smoke.rs b/grasp-audit/src/specs/grasp01/nip01_smoke.rs index 5976252..8cb4166 100644 --- a/grasp-audit/src/specs/grasp01/nip01_smoke.rs +++ b/grasp-audit/src/specs/grasp01/nip01_smoke.rs @@ -69,7 +69,7 @@ impl Nip01SmokeTests { // Step 1: GENERATE - Create TestContext and get ValidRepo fixture let ctx = TestContext::new(client); let event = ctx - .get_fixture(FixtureKind::ValidRepo) + .get_fixture(FixtureKind::ValidRepoSent) .await .map_err(|e| format!("Failed to create ValidRepo fixture: {}", e))?; @@ -135,7 +135,7 @@ impl Nip01SmokeTests { // Step 1: GENERATE - Create TestContext and get ValidRepo fixture let ctx = TestContext::new(client); let _event = ctx - .get_fixture(FixtureKind::ValidRepo) + .get_fixture(FixtureKind::ValidRepoSent) .await .map_err(|e| format!("Failed to create ValidRepo fixture: {}", e))?; diff --git a/grasp-audit/src/specs/grasp01/push_authorization.rs b/grasp-audit/src/specs/grasp01/push_authorization.rs index be354a0..78ef471 100644 --- a/grasp-audit/src/specs/grasp01/push_authorization.rs +++ b/grasp-audit/src/specs/grasp01/push_authorization.rs @@ -208,7 +208,7 @@ async fn setup_pr_test_repo( ) -> Result<(PathBuf, String, String, String), String> { // Get fixtures let repo_event = ctx - .get_fixture(FixtureKind::ValidRepo) + .get_fixture(FixtureKind::ValidRepoSent) .await .map_err(|e| format!("Failed to get repo announcement: {}", e))?; @@ -407,7 +407,7 @@ impl PushAuthorizationTests { let ctx = TestContext::new(client); // Create repository (no state event) - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( @@ -956,7 +956,7 @@ impl PushAuthorizationTests { // ============================================================ let ctx = TestContext::new(client); - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( @@ -1110,7 +1110,7 @@ impl PushAuthorizationTests { let pr_event_id = pr_event.id.to_hex(); // Get repo info for cloning (fresh clone for verification) - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new(test_name, SpecRef::GitAcceptRefsNostrEventId, desc) @@ -1198,7 +1198,7 @@ impl PushAuthorizationTests { let pr_event_id = pr_event.id.to_hex(); // Get repo info for cloning (fresh clone for this test) - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new(test_name, SpecRef::GitAcceptRefsNostrEventId, desc) @@ -1289,7 +1289,7 @@ impl PushAuthorizationTests { let pr_event_id = pr_event.id.to_hex(); // Get repo info for cloning (fresh clone for this test) - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new(test_name, SpecRef::GitAcceptRefsNostrEventId, desc) @@ -1425,7 +1425,7 @@ impl PushAuthorizationTests { // ============================================================ // Step 2: Extract repo_id and owner npub from ValidRepo (cached by fixture) // ============================================================ - let valid_repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let valid_repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(e) => e, Err(e) => { return TestResult::new(test_name, SpecRef::GitSetHeadOnReceive, desc) @@ -1528,7 +1528,7 @@ impl PushAuthorizationTests { // ============================================================ // Step 2: Extract repo_id and owner npub from ValidRepo (cached by fixture) // ============================================================ - let valid_repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let valid_repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(e) => e, Err(e) => { return TestResult::new(test_name, SpecRef::GitSetHeadOnReceive, desc) diff --git a/grasp-audit/src/specs/grasp01/repository_creation.rs b/grasp-audit/src/specs/grasp01/repository_creation.rs index a702afe..5730f1c 100644 --- a/grasp-audit/src/specs/grasp01/repository_creation.rs +++ b/grasp-audit/src/specs/grasp01/repository_creation.rs @@ -51,7 +51,7 @@ impl RepositoryCreationTests { let ctx = TestContext::new(client); // Use TestContext to create and send repository announcement - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( @@ -131,7 +131,7 @@ impl RepositoryCreationTests { let ctx = TestContext::new(client); // Create a repository announcement - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( @@ -210,7 +210,7 @@ impl RepositoryCreationTests { let ctx = TestContext::new(client); - let repo = match ctx.get_fixture(FixtureKind::ValidRepo).await { + let repo = match ctx.get_fixture(FixtureKind::ValidRepoSent).await { Ok(r) => r, Err(e) => { return TestResult::new( -- cgit v1.2.3