upleb.uk

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

summaryrefslogtreecommitdiff
path: root/docs/archive/2025-11-03-test-visual-summary.txt
blob: cc452613a7972601407d195cb263068d71d9350d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
╔══════════════════════════════════════════════════════════════════════════════╗
║                    GRASP COMPLIANCE TEST TOOL PROPOSAL                       ║
║                              Visual Summary                                  ║
╚══════════════════════════════════════════════════════════════════════════════╝

REQUIREMENT TO TEST
═══════════════════
"MUST serve a NIP-01 compliant nostr relay at / that accepts git repository 
announcements and their corresponding repo state announcements."


THE BIG QUESTION
════════════════
Should we comprehensively test NIP-01, or just smoke test it?

┌─────────────────────────────────────────────────────────────────────────────┐
│ COMPREHENSIVE APPROACH                  │  OUR APPROACH (RECOMMENDED)       │
├─────────────────────────────────────────┼───────────────────────────────────┤
│ • 50+ NIP-01 tests                      │  • 6 NIP-01 smoke tests           │
│ • 12 GRASP tests                        │  • 12 GRASP tests                 │
│ • Total: 62+ tests                      │  • Total: 18 tests                │
│ • Time: 3-4 weeks                       │  • Time: 1 week                   │
│ • Mostly redundant with rust-nostr      │  • Focused on GRASP logic         │
│ • High maintenance burden               │  • Low maintenance burden         │
└─────────────────────────────────────────┴───────────────────────────────────┘

RECOMMENDATION: Our approach (18 tests, 1 week)
REASON: rust-nostr already has 1000+ tests for NIP-01


TEST BREAKDOWN
══════════════

┌───────────────────────────────────────────────────────────────────────┐
│                       NIP-01 SMOKE TESTS (6)                          │
├───────────────────────────────────────────────────────────────────────┤
│                                                                       │
│  1. websocket_connection         → Can connect to /                  │
│  2. send_receive_event           → Can send EVENT, get OK            │
│  3. create_subscription          → Can send REQ, get EOSE            │
│  4. close_subscription           → Can close subscriptions           │
│  5. reject_invalid_event         → Rejects bad signatures            │
│  6. reject_invalid_event_id      → Rejects wrong IDs                 │
│                                                                       │
│  PURPOSE: Verify basic relay works (not GRASP-specific)              │
│  TIME: 1-2 days                                                      │
└───────────────────────────────────────────────────────────────────────┘

┌───────────────────────────────────────────────────────────────────────┐
│                    GRASP-01 SPECIFIC TESTS (12)                       │
├───────────────────────────────────────────────────────────────────────┤
│                                                                       │
│  ANNOUNCEMENT ACCEPTANCE                                             │
│  ────────────────────────                                            │
│  7.  accepts_repository_announcement                                 │
│  8.  accepts_repository_state                                        │
│                                                                       │
│  POLICY ENFORCEMENT                                                  │
│  ──────────────────                                                  │
│  9.  rejects_announcement_without_clone_tag                          │
│  10. rejects_announcement_without_relay_tag                          │
│  11. accepts_announcement_with_multiple_clones                       │
│                                                                       │
│  RELATED EVENTS                                                      │
│  ──────────────                                                      │
│  12. accepts_events_tagging_announcement                             │
│  13. accepts_events_tagged_by_announcement                           │
│  14. rejects_events_tagging_rejected_announcement                    │
│                                                                       │
│  QUERIES & STATE                                                     │
│  ───────────────                                                     │
│  15. query_announcements_by_identifier                               │
│  16. query_state_events                                              │
│  17. state_replaces_previous                                         │
│                                                                       │
│  RELIABILITY                                                         │
│  ───────────                                                         │
│  18. concurrent_event_submission                                     │
│                                                                       │
│  PURPOSE: Verify GRASP protocol requirements                         │
│  TIME: 3-4 days                                                      │
└───────────────────────────────────────────────────────────────────────┘


WHAT WE LEVERAGE FROM RUST-NOSTR
═════════════════════════════════

┌──────────────────────────────────┐
│  rust-nostr ALREADY TESTS:       │
├──────────────────────────────────┤
│  ✅ Event validation             │
│  ✅ Signature verification        │
│  ✅ Event ID calculation          │
│  ✅ WebSocket handling            │
│  ✅ Subscription management       │
│  ✅ Filter matching               │
│                                  │
│  1000+ existing tests            │
└──────────────────────────────────┘
         │
         │ We use their library
         │
         ▼
┌──────────────────────────────────┐
│  WE TEST:                        │
├──────────────────────────────────┤
│  🎯 GRASP policy enforcement     │
│  🎯 Repo announcement logic      │
│  🎯 Integration with Git service │
│                                  │
│  18 focused tests                │
└──────────────────────────────────┘


PROJECT STRUCTURE
═════════════════

grasp-compliance-tests/          ← Standalone, reusable crate
├── src/
│   ├── lib.rs                   ← Public API
│   ├── client.rs                ← HTTP/WebSocket/Git client
│   ├── assertions.rs            ← Spec-based assertions
│   ├── fixtures.rs              ← Event/repo builders
│   └── specs/
│       ├── nip01_smoke.rs       ← 6 smoke tests
│       └── grasp_01.rs          ← 12 GRASP tests
├── fixtures/
│   ├── repos/                   ← Test git repos
│   ├── events/                  ← Event JSON
│   └── keys/                    ← Test keypairs
└── examples/
    └── test_server.rs           ← Test any GRASP server


USAGE EXAMPLE
═════════════

use grasp_compliance_tests::*;

#[tokio::main]
async fn main() {
    // Test ANY GRASP implementation
    let client = GraspTestClient::new("http://localhost:8080");
    
    // Run smoke tests
    let smoke = test_nip01_smoke(&client).await;
    smoke.print_report();
    
    // Run GRASP tests
    let grasp = test_grasp_01_relay(&client).await;
    grasp.print_report();
}


EXAMPLE OUTPUT
══════════════

GRASP-01: Relay Requirements
════════════════════════════════════════════════════════════

✓ accepts_repository_announcement (GRASP-01:9-10)
  Requirement: MUST accept NIP-34 repository announcements
  Duration: 45ms

✓ accepts_repository_state (GRASP-01:9-10)
  Requirement: MUST accept NIP-34 repository state events
  Duration: 32ms

✗ rejects_announcement_without_clone_tag (GRASP-01:12-13)
  Requirement: MUST reject announcements without clone tag
  Error: Event was accepted but should have been rejected
  Expected: OK response with ok=false
  Got: OK response with ok=true
  Duration: 28ms

Results: 11/12 passed (91.7%)


TIMELINE
════════

Week 1: Test Tool Foundation
├── Day 1-2: Set up crate structure
├── Day 3:   Implement test client
├── Day 4:   Implement 6 smoke tests
└── Day 5:   Create fixtures & builders

Week 2: GRASP Tests
├── Day 1-2: Announcement tests (7-11)
├── Day 3:   Related event tests (12-14)
├── Day 4:   Query tests (15-17)
└── Day 5:   Concurrent test (18) + polish

Week 3: Integration
├── Day 1-2: Create ngit-grasp skeleton
├── Day 3-4: Wire up nostr-relay-builder
└── Day 5:   First test run

Week 4: Iteration
├── Day 1-3: Fix failing tests
├── Day 4:   Documentation
└── Day 5:   Polish

TOTAL: 4 weeks to prove the concept


BENEFITS
════════

✅ Focused Testing
   • 18 tests vs. 62+ redundant tests
   • Test GRASP logic, not generic Nostr
   • Fast execution (seconds, not minutes)

✅ Reusable Tool
   • Any GRASP implementation can use it
   • Works with Go, Rust, Python, JavaScript
   • Publish as standalone crate

✅ Clear Failures
   • Cite exact spec requirements
   • Show expected vs. actual
   • Actionable error messages

✅ Maintainable
   • Tests mirror spec structure
   • Easy to add GRASP-02, GRASP-05
   • Update when spec updates

✅ Proof of Concept
   • Validates architecture
   • Shows rust-nostr integration works
   • Demonstrates inline authorization


DECISIONS NEEDED
════════════════

1. SCOPE
   ☐ Agree with smoke tests approach?
   ☐ 18 tests sufficient for first requirement?

2. APPROACH
   ☐ A: Test-first (write tests, then implement)
   ☐ B: Parallel (tests and implementation together)
   ☐ C: Implementation-first (code first, tests later)
   
   RECOMMENDED: A (test-first)

3. STRUCTURE
   ☐ Separate crate from day one?
   ☐ Start integrated, extract later?
   
   RECOMMENDED: Separate from day one

4. FIXTURES
   ☐ Deterministic test keys?
   ☐ Random test keys?
   ☐ Configurable (both)?
   
   RECOMMENDED: Deterministic (reproducible)


NEXT STEPS
══════════

1. ✅ Review this proposal
2. ✅ Answer decision questions
3. ✅ Create test tool skeleton
4. ✅ Implement smoke tests
5. ✅ Implement GRASP tests
6. ✅ Create minimal ngit-grasp
7. ✅ Iterate until green
8. ✅ Document and polish


FILES CREATED
═════════════

• COMPLIANCE_TEST_PROPOSAL.md    → Detailed proposal with code
• REPORT_COMPLIANCE_TESTING.md   → Executive summary
• TEST_BREAKDOWN.md               → Test-by-test breakdown
• TEST_VISUAL_SUMMARY.txt         → This file


READY TO PROCEED?
═════════════════

Please review and advise on:
1. Scope (smoke tests vs. comprehensive)
2. Approach (test-first, parallel, or implementation-first)
3. Any changes to the 18 proposed tests
4. Priority of specific tests

Once confirmed, implementation begins immediately.

STATUS: ⏸️  Awaiting your decision