upleb.uk

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

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/audit.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-11-05 13:32:50 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-11-05 13:32:50 +0000
commit5f137994850773114d8a4f8ba70f34aaf2eb1992 (patch)
treeaec84ac0536412896826e47de563213c26276988 /grasp-audit/src/audit.rs
parent64a86de9fc5ded51a1b5405223fc5dce16839fef (diff)
tag test events with audit-grasp-test-event
Diffstat (limited to 'grasp-audit/src/audit.rs')
-rw-r--r--grasp-audit/src/audit.rs40
1 files changed, 39 insertions, 1 deletions
diff --git a/grasp-audit/src/audit.rs b/grasp-audit/src/audit.rs
index fad4bf2..105fa00 100644
--- a/grasp-audit/src/audit.rs
+++ b/grasp-audit/src/audit.rs
@@ -61,7 +61,45 @@ impl AuditConfig {
61 } 61 }
62 } 62 }
63 63
64 /// Get audit tags for an event 64 /// Get audit tags that are automatically added to all events
65 ///
66 /// These tags are automatically added to all events created via [`AuditEventBuilder`].
67 /// They provide isolation, cleanup scheduling, and easy discovery of audit events.
68 ///
69 /// # Tag Format
70 ///
71 /// All tags use the `"t"` (hashtag) format for maximum relay compatibility:
72 ///
73 /// 1. `["t", "grasp-audit-test-event"]` - Identifies all audit-related events
74 /// 2. `["t", "audit-{run_id}"]` - Unique identifier for this audit run
75 /// - CI mode: `audit-ci-{uuid}`
76 /// - Production mode: `audit-prod-audit-{timestamp}`
77 /// 3. `["t", "audit-cleanup-after-{unix_timestamp}"]` - Cleanup timestamp
78 /// - CI mode: Current time + 3600 seconds (1 hour)
79 /// - Production mode: Current time + 300 seconds (5 minutes)
80 ///
81 /// # Purpose
82 ///
83 /// - **Isolation**: Each test run has a unique ID for event filtering in CI mode
84 /// - **Cleanup**: Events marked for cleanup after timestamp (enables direct DB cleanup)
85 /// - **Discovery**: Easy to query all audit events via hashtag
86 /// - **No deletion trails**: Avoids NIP-09 deletion events by using direct cleanup
87 ///
88 /// # Example
89 ///
90 /// ```rust
91 /// use grasp_audit::AuditConfig;
92 ///
93 /// let config = AuditConfig::ci();
94 /// let tags = config.audit_tags();
95 ///
96 /// // Tags will look like:
97 /// // [
98 /// // ["t", "grasp-audit-test-event"],
99 /// // ["t", "audit-ci-a1b2c3d4-e5f6-7890-abcd-ef1234567890"],
100 /// // ["t", "audit-cleanup-after-1730822334"]
101 /// // ]
102 /// ```
65 pub fn audit_tags(&self) -> Vec<Tag> { 103 pub fn audit_tags(&self) -> Vec<Tag> {
66 use nostr_sdk::prelude::{Alphabet, SingleLetterTag}; 104 use nostr_sdk::prelude::{Alphabet, SingleLetterTag};
67 105