Repository navigation
Commit cd02b69
refactor(relay): extract NIP-29 membership authorization (block#7285)
## Why
NIP-29 membership authorization for kinds 9000, 9001, and 9022 was
embedded in a large async handler, requiring Postgres and Redis to test
and repeating the last-owner rule across five call sites. This addresses
[TheSentinel454#24](TheSentinel454#24)
without adding the broader state/repository abstraction suggested there
because HTTP and WebSocket writes already share ingestion.
## What
- Extract pure, typed membership authorization decisions while leaving
database reads and mutations in `validate_admin_event`.
- Preserve existing client-visible errors and independent database
last-owner safeguards.
- Collapse five last-owner policy restatements into one predicate and
share the identical self-departure policy.
- Include the relay decision modules in `just test-unit`, so these tests
execute in CI.
## Risk Assessment
Medium-low. This touches production relay authorization, but
intentionally preserves wire behavior and database defense in depth;
exhaustive decision tables and relay-backed tests cover the affected
paths.
## Simplification
This removes repeated policy from the orchestration path and makes the
rule set directly testable without introducing a repository trait or
second transport path.
## Verification
Verified at `15255a090797f85874921120003c645962fefaed`:
- `just test-unit` — all 10 package summaries passed. An initial run hit
two unrelated timing-sensitive `buzz-acp` failures; the complete retry
passed 905/905 in that package.
- `cargo fmt --all -- --check`
- `cargo clippy --workspace --all-targets -- -D warnings`
- `just file-size-check` — 10/10 policy tests passed.
- `just security-review-check` — 13/13 tests passed.
- Push preflight — `push-head-scope`, `branch-skew`, `file-size-check`,
`rust-tests`, and `desktop-tauri-checks` passed.
- Blox Postgres relay lane — 84/84 at the byte-identical source patch;
full live `e2e_relay` behavior matched the clean base (45 pass and the
same pre-existing kind:9002 failure on each).
Generated with Claude Code
---------
Signed-off-by: tornquist <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Codex <[email protected]>1 parent 01bacb8 commit cd02b69
8 files changed
Lines changed: 916 additions & 134 deletions
File tree
- .github/workflows
- crates
- buzz-relay/src/handlers
- buzz-test-client/tests
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
| 572 | + | |
572 | 573 | | |
573 | 574 | | |
574 | 575 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
432 | 445 | | |
433 | | - | |
| 446 | + | |
434 | 447 | | |
435 | 448 | | |
436 | 449 | | |
| |||
0 commit comments